- a correction should reference the original invoice via invoiceReferencedDocument, not buyerOrderReferencedDocument

This commit is contained in:
jstaerk
2021-01-26 15:29:29 +01:00
parent 66b495f9a8
commit cf3ba8376b
3 changed files with 39 additions and 12 deletions

View File

@@ -33,7 +33,7 @@ import java.util.Date;
*/ */
public class Invoice implements IExportableTransaction { public class Invoice implements IExportableTransaction {
protected String documentName = null, documentCode = null, number = null, ownOrganisationFullPlaintextInfo = null, referenceNumber = null, shipToOrganisationID = null, shipToOrganisationName = null, shipToStreet = null, shipToZIP = null, shipToLocation = null, shipToCountry = null, buyerOrderReferencedDocumentID = null, buyerOrderReferencedDocumentIssueDateTime = null, ownForeignOrganisationID = null, ownOrganisationName = null, currency = null, paymentTermDescription = null; protected String documentName = null, documentCode = null, number = null, ownOrganisationFullPlaintextInfo = null, referenceNumber = null, shipToOrganisationID = null, shipToOrganisationName = null, shipToStreet = null, shipToZIP = null, shipToLocation = null, shipToCountry = null, buyerOrderReferencedDocumentID = null, invoiceReferencedDocumentID = null, buyerOrderReferencedDocumentIssueDateTime = null, ownForeignOrganisationID = null, ownOrganisationName = null, currency = null, paymentTermDescription = null;
protected Date issueDate = null, dueDate = null, deliveryDate = null; protected Date issueDate = null, dueDate = null, deliveryDate = null;
protected BigDecimal totalPrepaidAmount = null; protected BigDecimal totalPrepaidAmount = null;
protected TradeParty sender = null, recipient = null, deliveryAddress = null; protected TradeParty sender = null, recipient = null, deliveryAddress = null;
@@ -118,7 +118,7 @@ public class Invoice implements IExportableTransaction {
* @return this object (fluent setter) * @return this object (fluent setter)
*/ */
public Invoice setCorrection(String number) { public Invoice setCorrection(String number) {
setBuyerOrderReferencedDocumentID(number); setInvoiceReferencedDocumentID(number);
documentCode = DocumentCodeTypeConstants.CORRECTEDINVOICE; documentCode = DocumentCodeTypeConstants.CORRECTEDINVOICE;
return this; return this;
} }
@@ -223,7 +223,7 @@ public class Invoice implements IExportableTransaction {
return this; return this;
} }
/*** /***
* usually the order number or in case of a correction the original invoice number * usually the order number
* @param buyerOrderReferencedDocumentID string with number * @param buyerOrderReferencedDocumentID string with number
* @return fluent setter * @return fluent setter
*/ */
@@ -232,6 +232,20 @@ public class Invoice implements IExportableTransaction {
return this; return this;
} }
/***
* usually in case of a correction the original invoice number
* @param invoiceReferencedDocumentID string with number
* @return fluent setter
*/
public Invoice setInvoiceReferencedDocumentID(String invoiceReferencedDocumentID) {
this.invoiceReferencedDocumentID = invoiceReferencedDocumentID;
return this;
}
@Override
public String getInvoiceReferencedDocumentID() {
return invoiceReferencedDocumentID;
}
@Override @Override
public String getBuyerOrderReferencedDocumentIssueDateTime() { public String getBuyerOrderReferencedDocumentIssueDateTime() {
return buyerOrderReferencedDocumentIssueDateTime; return buyerOrderReferencedDocumentIssueDateTime;

View File

@@ -415,6 +415,14 @@ public interface IExportableTransaction {
return null; return null;
} }
/**
* get the ID of the prceding invoice, which is e.g. to be corrected if this is a correction
*
* @return the ID of the document
*/
default String getInvoiceReferencedDocumentID() {
return null;
}
/** /**
* get the issue timestamp of the BuyerOrderReferencedDocument, which sits in the ApplicableSupplyChainTradeAgreement * get the issue timestamp of the BuyerOrderReferencedDocument, which sits in the ApplicableSupplyChainTradeAgreement

View File

@@ -610,23 +610,28 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
final String chargesTotalLine = "<ram:ChargeTotalAmount>" + currencyFormat(calc.getChargesForPercent(null)) + "</ram:ChargeTotalAmount>"; final String chargesTotalLine = "<ram:ChargeTotalAmount>" + currencyFormat(calc.getChargesForPercent(null)) + "</ram:ChargeTotalAmount>";
xml = xml + " <ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n" xml = xml + " <ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n"
+ " <ram:LineTotalAmount>" + currencyFormat(calc.getTotal()) + "</ram:LineTotalAmount>\n" //$NON-NLS-2$ + " <ram:LineTotalAmount>" + currencyFormat(calc.getTotal()) + "</ram:LineTotalAmount>\n"
+ chargesTotalLine + chargesTotalLine
+ allowanceTotalLine + allowanceTotalLine
+ " <ram:TaxBasisTotalAmount>" + currencyFormat(calc.getTaxBasis()) + "</ram:TaxBasisTotalAmount>\n" //$NON-NLS-2$ + " <ram:TaxBasisTotalAmount>" + currencyFormat(calc.getTaxBasis()) + "</ram:TaxBasisTotalAmount>\n"
// // // //
// currencyID=\"EUR\" // currencyID=\"EUR\"
+ " <ram:TaxTotalAmount currencyID=\"" + trans.getCurrency() + "\">" + " <ram:TaxTotalAmount currencyID=\"" + trans.getCurrency() + "\">"
+ currencyFormat(calc.getGrandTotal().subtract(calc.getTaxBasis()))+ "</ram:TaxTotalAmount>\n" + currencyFormat(calc.getGrandTotal().subtract(calc.getTaxBasis())) + "</ram:TaxTotalAmount>\n"
+ " <ram:GrandTotalAmount>" + currencyFormat(calc.getGrandTotal()) + "</ram:GrandTotalAmount>\n" //$NON-NLS-2$ + " <ram:GrandTotalAmount>" + currencyFormat(calc.getGrandTotal()) + "</ram:GrandTotalAmount>\n"
// // // //
// currencyID=\"EUR\" // currencyID=\"EUR\"
+ " <ram:TotalPrepaidAmount>" + currencyFormat(calc.getTotalPrepaid()) + "</ram:TotalPrepaidAmount>\n" + " <ram:TotalPrepaidAmount>" + currencyFormat(calc.getTotalPrepaid()) + "</ram:TotalPrepaidAmount>\n"
+ " <ram:DuePayableAmount>" + currencyFormat(calc.getGrandTotal().subtract(calc.getTotalPrepaid())) + "</ram:DuePayableAmount>\n" //$NON-NLS-2$ + " <ram:DuePayableAmount>" + currencyFormat(calc.getGrandTotal().subtract(calc.getTotalPrepaid())) + "</ram:DuePayableAmount>\n"
// // + " </ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n";
// currencyID=\"EUR\" if (trans.getInvoiceReferencedDocumentID() != null) {
+ " </ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n" xml = xml + " <ram:InvoiceReferencedDocument>\n"
+ " </ram:ApplicableHeaderTradeSettlement>\n"; + " <ram:IssuerAssignedID>"
+ XMLTools.encodeXML(trans.getInvoiceReferencedDocumentID()) + "</ram:IssuerAssignedID>\n"
+ " </ram:InvoiceReferencedDocument>\n";
}
xml = xml + " </ram:ApplicableHeaderTradeSettlement>\n";
// + " <IncludedSupplyChainTradeLineItem>\n" // + " <IncludedSupplyChainTradeLineItem>\n"
// + " <AssociatedDocumentLineDocument>\n" // + " <AssociatedDocumentLineDocument>\n"
// + " <IncludedNote>\n" // + " <IncludedNote>\n"