closes #678
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
- #678
|
||||||
|
|
||||||
2.16.0
|
2.16.0
|
||||||
=======
|
=======
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
List<IncludedNote> includedNotes = new ArrayList<>();
|
List<IncludedNote> includedNotes = new ArrayList<>();
|
||||||
|
|
||||||
//UBL...
|
//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);
|
NodeList UBLNotesNd = (NodeList) UBLNotesEx.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
if ((UBLNotesNd != null) && (UBLNotesNd.getLength() > 0)) {
|
if ((UBLNotesNd != null) && (UBLNotesNd.getLength() > 0)) {
|
||||||
for (int nodeIndex = 0; nodeIndex < UBLNotesNd.getLength(); nodeIndex++) {
|
for (int nodeIndex = 0; nodeIndex < UBLNotesNd.getLength(); nodeIndex++) {
|
||||||
@@ -556,15 +556,16 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
}
|
}
|
||||||
zpp.addNotes(includedNotes);
|
zpp.addNotes(includedNotes);
|
||||||
String rootNode = extractString("local-name(/*)");
|
String rootNode = extractString("local-name(/*)");
|
||||||
if (rootNode.equals("Invoice")) {
|
if (rootNode.equals("Invoice")||rootNode.equals("CreditNote")) {
|
||||||
// UBL...
|
// UBL...
|
||||||
number = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"ID\"]").trim();
|
// //*[local-name()="Invoice" or local-name()="CreditNote"]
|
||||||
typeCode = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"InvoiceTypeCode\"]").trim();
|
number = extractString("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"ID\"]").trim();
|
||||||
String issueDateStr = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"IssueDate\"]").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) {
|
if (issueDateStr.length()>0) {
|
||||||
issueDate = new SimpleDateFormat("yyyy-MM-dd").parse(issueDateStr);
|
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) {
|
if (dueDt.length() > 0) {
|
||||||
dueDate = new SimpleDateFormat("yyyy-MM-dd").parse(dueDt);
|
dueDate = new SimpleDateFormat("yyyy-MM-dd").parse(dueDt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testImportMinimum() {
|
public void testImportMinimum() {
|
||||||
File CIIinputFile = getResourceAsFile("cii/facturFrMinimum.xml");
|
File CIIinputFile = getResourceAsFile("cii/facturFrMinimum.xml");
|
||||||
try {
|
try {
|
||||||
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(new FileInputStream(CIIinputFile));
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user