The Invoice.java class currently lacks a field for storing the "Invoiced Object Identifier" (BT-18), which is required at the entire-invoice level in XRechnung. This identifier is essential for referencing objects related to the entire invoice, similar to the way Item.java stores "Invoice Line Object Identifier" (BT-128).
In the current setup:
Item.java includes field (referencedDocuments) to store ReferencedDocument objects, allowing it to handle "Invoice Line Object Identifier" (BT-128).
However, Invoice.java has no corresponding field to hold ReferencedDocument instances for BT-18 at the invoice level.
Suggested Solution:
To align with XRechnung requirements, add an ArrayList field in Invoice.java to store BT-18 references. This new field would ensure consistency across classes, allowing Invoice.java to manage invoice-wide object identifiers similarly to how Item.java handles line-specific identifiers.
public class Invoice {
// New field for storing Invoiced Object Identifier (BT-18)
protected ArrayList<ReferencedDocument> invoiceReferencedDocuments = null;
// Getter for BT-18
public ArrayList<ReferencedDocument> getInvoiceReferencedDocuments() {
return invoiceReferencedDocuments;
}
// Setter for BT-18
public void setInvoiceReferencedDocuments(ArrayList<ReferencedDocument> invoiceReferencedDocuments) {
this.invoiceReferencedDocuments = invoiceReferencedDocuments;
}
// Method to add a single ReferencedDocument for BT-18
public void addInvoiceReferencedDocument(ReferencedDocument doc) {
if (invoiceReferencedDocuments == null) {
invoiceReferencedDocuments = new ArrayList<>();
}
invoiceReferencedDocuments.add(doc);
}
}
Suggested XML Output Update:
With the proposed changes, Invoice.java should generate XML for ./rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:AdditionalReferencedDocument
as follows:
The Invoice.java class currently lacks a field for storing the "Invoiced Object Identifier" (BT-18), which is required at the entire-invoice level in XRechnung. This identifier is essential for referencing objects related to the entire invoice, similar to the way Item.java stores "Invoice Line Object Identifier" (BT-128).
Mustang has the specification of mapping BT-18 to XML as follows: (https://github.com/ZUGFeRD/mustangproject/blob/master/library/src/main/resources/stylesheets/cii-xr.xsl)
<xsl:apply-templates mode="BT-18" select="./rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:AdditionalReferencedDocument/ram:IssuerAssignedID[following-sibling::ram:TypeCode='130']"/>
In the current setup: Item.java includes field (referencedDocuments) to store ReferencedDocument objects, allowing it to handle "Invoice Line Object Identifier" (BT-128).
However, Invoice.java has no corresponding field to hold ReferencedDocument instances for BT-18 at the invoice level.
Suggested Solution: To align with XRechnung requirements, add an ArrayList field in Invoice.java to store BT-18 references. This new field would ensure consistency across classes, allowing Invoice.java to manage invoice-wide object identifiers similarly to how Item.java handles line-specific identifiers.
Suggested XML Output Update: With the proposed changes, Invoice.java should generate XML for ./rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:AdditionalReferencedDocument as follows: