Skip to content

Add unit tests for XRechnung payment terms formatting #723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jswzr
Copy link

@jswzr jswzr commented Apr 19, 2025

This PR adds the unit tests discussed in Issue #721, specifically covering the following scenarios:

  • Ensures only one SpecifiedTradePaymentTerms element is present in XRechnung documents, as required by the specification.

  • Verifies that multiple payment conditions (e.g. Skonto terms) are correctly structured within the Description element using the required line-based format.

  • Confirms that each structured payment condition ends with a proper line break (\n), ensuring compatibility with XRechnung validators.

These tests help ensure conformance with the XRechnung CIUS and improve validation reliability for structured payment term formatting.

@stephanstapel
Copy link
Owner

Hi @jswzr ,

thanks for your pull request. Can you review

public void TestPaymentTermsMultiCardinalityXRechnungStructured()

do you think this is still necessary?

Concerning newline, please use this constant:

public const string XmlNewLine = "
";

Finally, could you add to your proposed tests reading of the raw file and checking if tab and newline (as mentioned above) is written correctly?

@jswzr
Copy link
Author

jswzr commented Apr 20, 2025

Thanks again for the feedback!

To me, it absolutely makes sense to test multiple payment terms – they’re all written into a single field with a custom structure.

Using XmlConstants.XmlNewLine definitely makes sense – I’ll update the tests accordingly.

Regarding the last point:
Currently, GetTradePaymentTerms() returns the structured lines including line breaks via the Description property.
Would you prefer I manually open and read the generated file (e.g., using XmlDocument) and directly check the PaymentTerms section to ensure the correct use of newlines in the raw XML?

Just want to be sure I understand your expectations for this test.

@stephanstapel
Copy link
Owner

stephanstapel commented Apr 20, 2025

Hi again,
great, thanks!
concerning the last point: in addition to reading the xml as xml (using either the library o XmlDocument), it would be great to convert the stream into a string and see if indention and line breaks are as they are supposed to be. I'd like to make sure that future changes don't break the required textual representation.

Like this;

StreamReader reader = new StreamReader( stream );
string content = reader.ReadToEnd();

you can find a similar test here:

public void TestSingleSkontoForCorrectIndention()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants