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

fix: parse paymentTermDescription #611

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ public Invoice extractInto(Invoice zpp) throws XPathExpressionException, ParseEx

Date issueDate = null;
Date dueDate = null;
String paymentTermDescription = null;
Date deliveryDate = null;
String despatchAdviceReferencedDocument = null;

Expand Down Expand Up @@ -663,6 +664,12 @@ public Invoice extractInto(Invoice zpp) throws XPathExpressionException, ParseEx
&& (headerTradeSettlementChilds.item(settlementChildIndex).getLocalName().equals("SpecifiedTradePaymentTerms"))) {
NodeList paymentTermChilds = headerTradeSettlementChilds.item(settlementChildIndex).getChildNodes();
for (int paymentTermChildIndex = 0; paymentTermChildIndex < paymentTermChilds.getLength(); paymentTermChildIndex++) {
if ("Description".equals(paymentTermChilds.item(paymentTermChildIndex).getLocalName())) {
var description = paymentTermChilds.item(paymentTermChildIndex).getTextContent();
if (description != null && !description.isEmpty()) {
paymentTermDescription = description;
}
}
if ((paymentTermChilds.item(paymentTermChildIndex).getLocalName() != null) && (paymentTermChilds.item(paymentTermChildIndex).getLocalName().equals("DueDateDateTime"))) {
NodeList dueDateChilds = paymentTermChilds.item(paymentTermChildIndex).getChildNodes();
for (int dueDateChildIndex = 0; dueDateChildIndex < dueDateChilds.getLength(); dueDateChildIndex++) {
Expand Down Expand Up @@ -780,7 +787,14 @@ public Invoice extractInto(Invoice zpp) throws XPathExpressionException, ParseEx

}

zpp.setIssueDate(issueDate).setDueDate(dueDate).setDeliveryDate(deliveryDate).setSender(new TradeParty(SellerNodes)).setRecipient(new TradeParty(BuyerNodes)).setNumber(number).setDocumentCode(typeCode);
zpp.setIssueDate(issueDate)
.setDueDate(dueDate)
.setPaymentTermDescription(paymentTermDescription)
.setDeliveryDate(deliveryDate)
.setSender(new TradeParty(SellerNodes))
.setRecipient(new TradeParty(BuyerNodes))
.setNumber(number)
.setDocumentCode(typeCode);

if ((directDebitMandateID != null) && (IBAN != null)) {
DirectDebit d = new DirectDebit(IBAN, directDebitMandateID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,4 +465,17 @@ public void testImportXRechnungPositionNote() throws FileNotFoundException, XPat
assertFalse(invoice.getZFItems()[0].getNotes() == null);
assertEquals(1, invoice.getZFItems()[0].getNotes().length);
}

@Test
public void testReadDescription() throws XPathExpressionException, ParseException {
// given
var inputStream = this.getClass().getResourceAsStream("/cii/minimalDebit.xml");

// when
var zii = new ZUGFeRDInvoiceImporter(inputStream);
var invoice = zii.extractInvoice();

// then
assertThat(invoice.getPaymentTermDescription()).startsWith("Der Betrag in Höhe von");
}
}