From b0e3cc00e2b2df41464fb8e4094acdb430291735 Mon Sep 17 00:00:00 2001 From: Arne Bosien Date: Thu, 12 Dec 2024 19:52:06 +0100 Subject: [PATCH 1/2] ... --- .../ZUGFeRD/ZUGFeRDInvoiceImporter.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java index ffcfaac19..4c174795b 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java @@ -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; @@ -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++) { @@ -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); From a38986f89e244823c7f401d95ad916166a298297 Mon Sep 17 00:00:00 2001 From: Arne Bosien Date: Thu, 12 Dec 2024 20:04:43 +0100 Subject: [PATCH 2/2] ... --- .../ZUGFeRD/ZF2ZInvoiceImporterTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java index b6fac219e..2825e404b 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java @@ -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"); + } }