Skip to content
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

Duplicate InvoiceReferencedDocument elements in corrected XRechnung (TypeCode 384) with invoice.setCorrection() #748

Open
thomasweitzel opened this issue Feb 18, 2025 · 1 comment

Comments

@thomasweitzel
Copy link

thomasweitzel commented Feb 18, 2025

When generating XML files with the Mustangproject v2.16.2 and using setCorrection on the invoice, I get an invalid XML.

A Java fragment:

Invoice invoice = new Invoice();
/*using some setters except `setCorrection` */
invoice.setCorrection("test-123");

Excerpt from the generated XML file (the element InvoiceReferencedDocument appears twice with the same contents):

<ram:InvoiceReferencedDocument>
    <ram:IssuerAssignedID>test-123</ram:IssuerAssignedID>
</ram:InvoiceReferencedDocument>
<ram:InvoiceReferencedDocument>
    <ram:IssuerAssignedID>test-123</ram:IssuerAssignedID>
</ram:InvoiceReferencedDocument>

The XML is generated like this:

ZUGFeRD2PullProvider zf2p = new ZUGFeRD2PullProvider();
zf2p.setProfile(Profiles.getByName("XRechnung", 3));
zf2p.generateXML(invoice);
String theXML = new String(zf2p.getXML());

I'm using Java-22, but the problem is present with Java-21 (LTS), too.

@thomasweitzel
Copy link
Author

Upon further investigation: the problem was caused by commit 5d741586 (2024-12-24 14:29 by cs), that added a line to Invoice.setCorrection: addInvoiceReferencedDocument ...

public Invoice setCorrection(String number) {
    setInvoiceReferencedDocumentID(number);
    addInvoiceReferencedDocument(new ReferencedDocument(number)); // <--
    documentCode = DocumentCodeTypeConstants.CORRECTEDINVOICE;
    return this;
}

When I remove this line, the XML is valid again.

There was much more added with this change, which probably had a good reason, but that I don't understand ;-)

@christoph-sommer

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

No branches or pull requests

1 participant