- be able to extract data into existing invoice objects

This commit is contained in:
jstaerk
2023-05-06 11:39:49 +02:00
parent 0652ccdb9e
commit 4bde4516ea
2 changed files with 30 additions and 19 deletions

View File

@@ -1,3 +1,8 @@
- #317 (support conversion towards peppol #282)
- #313
- https://github.com/ZUGFeRD/mustangproject/pull/315 invoiceimporter constructor for InputStream
- be able to extract data into existing invoice objects
2.7.0
=======
2023-04-17

View File

@@ -57,12 +57,7 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
}
}
/***
* This will parse a XML into a invoice object
*
* @return the parsed invoice object
*/
public Invoice extractInvoice() throws XPathExpressionException, ParseException {
public Invoice extractInto(Invoice zpp) throws XPathExpressionException, ParseException {
String number = "";
/*
@@ -72,7 +67,6 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
*/
XPathFactory xpathFact = XPathFactory.newInstance();
XPath xpath = xpathFact.newXPath();
Invoice zpp = null;
XPathExpression xpr = xpath.compile("//*[local-name()=\"SellerTradeParty\"]");
NodeList SellerNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
@@ -184,7 +178,7 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
}
}
zpp = new Invoice().setDueDate(dueDate).setDeliveryDate(deliveryDate).setIssueDate(issueDate)
zpp.setDueDate(dueDate).setDeliveryDate(deliveryDate).setIssueDate(issueDate)
.setSender(new TradeParty(SellerNodes)).setRecipient(new TradeParty(BuyerNodes)).setNumber(number);
//.addItem(new Item(new Product("Testprodukt","","C62",BigDecimal.ZERO),amount,new BigDecimal(1.0)))
zpp.setOwnOrganisationName(extractString("//*[local-name()=\"SellerTradeParty\"]/*[local-name()=\"Name\"]"));
@@ -195,7 +189,7 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
if (totalNodes.getLength() > 0) {
buyerReference = totalNodes.item(0).getTextContent();
}
if (buyerReference!=null) {
if (buyerReference != null) {
zpp.setReferenceNumber(buyerReference);
}
@@ -454,6 +448,18 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
}
/***
* This will parse a XML into a invoice object
*
* @return the parsed invoice object
*/
public Invoice extractInvoice() throws XPathExpressionException, ParseException {
Invoice i=new Invoice();
return extractInto(i);
}
public void doRecalculateItemPricesFromLineTotals() {
recalcPrice = true;
}