Merge branch 'ZUGFeRD:master' into master
This commit is contained in:
@@ -3,13 +3,13 @@
|
||||
<parent>
|
||||
<groupId>org.mustangproject</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>2.15.3-SNAPSHOT</version>
|
||||
<version>2.16.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.mustangproject</groupId>
|
||||
<artifactId>library</artifactId>
|
||||
<version>2.15.3-SNAPSHOT</version>
|
||||
<version>2.16.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>Library to write, read and validate e-invoices (Factur-X, ZUGFeRD, Order-X, XRechnung/CII)</name>
|
||||
<description>FOSS Java library to read, write and validate european electronic invoices and orders in the UN/CEFACT
|
||||
|
||||
@@ -309,7 +309,7 @@ public class ZUGFeRDInvoiceImporter {
|
||||
List<IncludedNote> includedNotes = new ArrayList<>();
|
||||
|
||||
//UBL...
|
||||
XPathExpression UBLNotesEx = xpath.compile("/*[local-name()=\"Invoice\"]/*[local-name()=\"Note\"]");
|
||||
XPathExpression UBLNotesEx = xpath.compile("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"Note\"]");
|
||||
NodeList UBLNotesNd = (NodeList) UBLNotesEx.evaluate(getDocument(), XPathConstants.NODESET);
|
||||
if ((UBLNotesNd != null) && (UBLNotesNd.getLength() > 0)) {
|
||||
for (int nodeIndex = 0; nodeIndex < UBLNotesNd.getLength(); nodeIndex++) {
|
||||
@@ -556,15 +556,16 @@ public class ZUGFeRDInvoiceImporter {
|
||||
}
|
||||
zpp.addNotes(includedNotes);
|
||||
String rootNode = extractString("local-name(/*)");
|
||||
if (rootNode.equals("Invoice")) {
|
||||
if (rootNode.equals("Invoice")||rootNode.equals("CreditNote")) {
|
||||
// UBL...
|
||||
number = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"ID\"]").trim();
|
||||
typeCode = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"InvoiceTypeCode\"]").trim();
|
||||
String issueDateStr = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"IssueDate\"]").trim();
|
||||
// //*[local-name()="Invoice" or local-name()="CreditNote"]
|
||||
number = extractString("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"ID\"]").trim();
|
||||
typeCode = extractString("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"InvoiceTypeCode\"]").trim();
|
||||
String issueDateStr = extractString("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"IssueDate\"]").trim();
|
||||
if (issueDateStr.length()>0) {
|
||||
issueDate = new SimpleDateFormat("yyyy-MM-dd").parse(issueDateStr);
|
||||
}
|
||||
String dueDt = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"DueDate\"]").trim();
|
||||
String dueDt = extractString("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"DueDate\"]").trim();
|
||||
if (dueDt.length() > 0) {
|
||||
dueDate = new SimpleDateFormat("yyyy-MM-dd").parse(dueDt);
|
||||
}
|
||||
@@ -812,9 +813,11 @@ public class ZUGFeRDInvoiceImporter {
|
||||
d.setPaymentMeansInformation(paymentMeansInformation);
|
||||
}
|
||||
zpp.getSender().addDebitDetails(d);
|
||||
bankDetails.forEach(bankDetail -> zpp.getRecipient().addBankDetails(bankDetail));
|
||||
} else {
|
||||
bankDetails.forEach(bankDetail -> zpp.getSender().addBankDetails(bankDetail));
|
||||
}
|
||||
|
||||
bankDetails.forEach(bankDetail -> zpp.getSender().addBankDetails(bankDetail));
|
||||
|
||||
if (payeeNodes.getLength() > 0) {
|
||||
zpp.setPayee(new TradeParty(payeeNodes));
|
||||
|
||||
@@ -375,7 +375,7 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
|
||||
|
||||
}
|
||||
|
||||
public void testImportMinimum() {
|
||||
public void testImportMinimum() {
|
||||
File CIIinputFile = getResourceAsFile("cii/facturFrMinimum.xml");
|
||||
try {
|
||||
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(new FileInputStream(CIIinputFile));
|
||||
@@ -394,6 +394,28 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void testImportUBLCreditnote() { // Confirm some basics also work with UBL credit notes
|
||||
File CIIinputFile = getResourceAsFile("ubl/UBL-CreditNote-2.1-Example.ubl.xml");
|
||||
try {
|
||||
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(new FileInputStream(CIIinputFile));
|
||||
|
||||
|
||||
CalculatedInvoice i = new CalculatedInvoice();
|
||||
zii.extractInto(i);
|
||||
assertEquals("TOSL108", i.getNumber());
|
||||
assertEquals("729", i.getGrandTotal().toString());
|
||||
|
||||
} catch (IOException e) {
|
||||
fail("IOException not expected");
|
||||
} catch (XPathExpressionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -445,6 +467,30 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIBANparsing() throws XPathExpressionException, ParseException, FileNotFoundException {
|
||||
|
||||
File inputFile = getResourceAsFile("cii/minimalDebit.xml");
|
||||
|
||||
ZUGFeRDInvoiceImporter importer = new ZUGFeRDInvoiceImporter(new FileInputStream(inputFile));
|
||||
Invoice invoice = importer.extractInvoice();
|
||||
assertEquals(1,invoice.getRecipient().getBankDetails().size());
|
||||
// IBAN belongs to recipient in invoice with sepa debit
|
||||
assertEquals("DE21860000000086001055",invoice.getRecipient().getBankDetails().get(0).getIBAN());
|
||||
assertEquals(0,invoice.getSender().getBankDetails().size());
|
||||
|
||||
inputFile = getResourceAsFile("factur-x.xml");
|
||||
|
||||
importer = new ZUGFeRDInvoiceImporter(new FileInputStream(inputFile));
|
||||
invoice = importer.extractInvoice();
|
||||
assertEquals(1,invoice.getSender().getBankDetails().size());
|
||||
// IBAN belongs to sender in normal invoice
|
||||
assertEquals("DE88200800000970375700",invoice.getSender().getBankDetails().get(0).getIBAN());
|
||||
assertEquals(0,invoice.getRecipient().getBankDetails().size());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImportPositionIncludedNotes() throws FileNotFoundException, XPathExpressionException, ParseException {
|
||||
File inputFile = getResourceAsFile("ZTESTZUGFERD_1_INVDSS_012015738820PDF-1.pdf");
|
||||
|
||||
Reference in New Issue
Block a user