diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java index 0d5ecc2c..6d044371 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java @@ -486,7 +486,8 @@ public class ZUGFeRDInvoiceImporter { NodeList paymentMeansChilds = headerTradeSettlementChilds.item(settlementChildIndex).getChildNodes(); String IBAN = null, BIC = null; for (int paymentMeansChildIndex = 0; paymentMeansChildIndex < paymentMeansChilds.getLength(); paymentMeansChildIndex++) { - if ((paymentMeansChilds.item(paymentMeansChildIndex).getLocalName() != null) && (paymentMeansChilds.item(paymentMeansChildIndex).getLocalName().equals("PayeePartyCreditorFinancialAccount"))) { + + if ((paymentMeansChilds.item(paymentMeansChildIndex).getLocalName() != null) && (paymentMeansChilds.item(paymentMeansChildIndex).getLocalName().equals("PayeePartyCreditorFinancialAccount") || paymentMeansChilds.item(paymentMeansChildIndex).getLocalName().equals("PayerPartyDebtorFinancialAccount"))) { NodeList accountChilds = paymentMeansChilds.item(paymentMeansChildIndex).getChildNodes(); for (int accountChildIndex = 0; accountChildIndex < accountChilds.getLength(); accountChildIndex++) { if ((accountChilds.item(accountChildIndex).getLocalName() != null) && (accountChilds.item(accountChildIndex).getLocalName().equals("IBANID"))) {//CII diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java index b79ce8c8..a62fe21b 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java @@ -324,6 +324,26 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase { } + + public void testImportDebit() { + File CIIinputFile = getResourceAsFile("cii/minimalDebit.xml"); + try { + ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(new FileInputStream(CIIinputFile)); + Invoice i=zii.extractInvoice(); + + assertEquals("DE21860000000086001055", i.getSender().getBankDetails().get(0).getIBAN()); + + } catch (IOException e) { + fail("IOException not expected"); + } catch (XPathExpressionException e) { + throw new RuntimeException(e); + } catch (ParseException e) { + throw new RuntimeException(e); + } + + + } + /* public void testEEISI_300_cii_Import() { boolean hasExceptions = false; diff --git a/library/src/test/resources/cii/minimalDebit.xml b/library/src/test/resources/cii/minimalDebit.xml new file mode 100644 index 00000000..f714e0c9 --- /dev/null +++ b/library/src/test/resources/cii/minimalDebit.xml @@ -0,0 +1,143 @@ + + + + + + urn:cen.eu:en16931:2017 + + + + 471102 + 380 + + 20180304 + + + + + + 1 + + + Trennblätter A4 + + + + 9.9000 + 1.0000 + + + + 20.0000 + + + + VAT + S + 19.00 + + + 198.00 + + + + + + 2 + + + Joghurt Banane + + + + 5.5000 + 1.0000 + + + + 50.0000 + + + + VAT + S + 7.00 + + + 275.00 + + + + + + Lieferant GmbH + + 80333 + Lieferantenstraße 20 + München + DE + + + DE123456789 + + + 201/113/40209 + + + + Kunden AG Mitte + + 69876 + Kundenstraße 15 + Frankfurt + DE + + + + + + + 20180304 + + + + + DE98ZZZ09999999999 + EUR + + 59 + + DE21860000000086001055 + + + 19.25 + VAT + 275.00 + S + 7.00 + + + 37.62 + VAT + 198.00 + S + 19.00 + + + Der Betrag in Höhe von EUR 529,87 wird am 20.03.2018 von Ihrem Konto per SEPA-Lastschrift eingezogen. + + REF A-123 + + + 473.00 + 0.00 + 0.00 + 473.00 + 56.87 + 529.87 + 0.00 + 529.87 + + + + \ No newline at end of file