add a usnit test for https://github.com/ZUGFeRD/mustangproject/pull/292
This commit is contained in:
@@ -44,9 +44,6 @@ public class Invoice implements IExportableTransaction {
|
||||
|
||||
protected String documentName = null, documentCode = null, number = null, ownOrganisationFullPlaintextInfo = null, referenceNumber = null, shipToOrganisationID = null, shipToOrganisationName = null, shipToStreet = null, shipToZIP = null, shipToLocation = null, shipToCountry = null, buyerOrderReferencedDocumentID = null, invoiceReferencedDocumentID = null, buyerOrderReferencedDocumentIssueDateTime = null, ownForeignOrganisationID = null, ownOrganisationName = null, currency = null, paymentTermDescription = null;
|
||||
protected Date issueDate = null, dueDate = null, deliveryDate = null;
|
||||
protected BigDecimal totalPrepaidAmount = null;
|
||||
protected BigDecimal grandTotalAmount = null;
|
||||
protected BigDecimal duePayableAmount = null;
|
||||
protected TradeParty sender = null, recipient = null, deliveryAddress = null;
|
||||
@JsonDeserialize(contentAs=Item.class)
|
||||
protected ArrayList<IZUGFeRDExportableItem> ZFItems = null;
|
||||
@@ -431,34 +428,6 @@ public class Invoice implements IExportableTransaction {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getTotalPrepaidAmount() {
|
||||
return totalPrepaidAmount;
|
||||
}
|
||||
|
||||
public Invoice setTotalPrepaidAmount(BigDecimal totalPrepaidAmount) {
|
||||
this.totalPrepaidAmount = totalPrepaidAmount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getGrandTotalAmount() {
|
||||
return grandTotalAmount;
|
||||
}
|
||||
|
||||
public Invoice setGrandTotalAmount(BigDecimal grandTotalAmount) {
|
||||
this.grandTotalAmount = grandTotalAmount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getDuePayableAmount() {
|
||||
return duePayableAmount;
|
||||
}
|
||||
|
||||
public Invoice setDuePayableAmount(BigDecimal duePayableAmount) {
|
||||
this.duePayableAmount = duePayableAmount;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IZUGFeRDExportableTradeParty getSender() {
|
||||
return sender;
|
||||
|
||||
@@ -73,7 +73,7 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
||||
|
||||
xpr = xpath.compile("//*[local-name()=\"BuyerTradeParty\"]");
|
||||
NodeList BuyerNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||
xpr = xpath.compile("//*[local-name()=\"ExchangedDocument\"]");
|
||||
xpr = xpath.compile("//*[local-name()=\"ExchangedDocument\"]|//*[local-name()=\"HeaderExchangedDocument\"]");
|
||||
NodeList ExchangedDocumentNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||
|
||||
xpr = xpath.compile("//*[local-name()=\"GrandTotalAmount\"]");
|
||||
@@ -147,7 +147,7 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
||||
}
|
||||
}
|
||||
|
||||
xpr = xpath.compile("//*[local-name()=\"ApplicableHeaderTradeSettlement\"]");
|
||||
xpr = xpath.compile("//*[local-name()=\"ApplicableHeaderTradeSettlement\"]|//*[local-name()=\"ApplicableSupplyChainTradeSettlement\"]");
|
||||
NodeList headerTradeSettlementNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||
|
||||
for (int i = 0; i < headerTradeSettlementNodes.getLength(); i++) {
|
||||
@@ -419,9 +419,6 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
||||
|
||||
TransactionCalculator tc = new TransactionCalculator(zpp);
|
||||
String expectedStringTotalGross = tc.getGrandTotal().toPlainString();
|
||||
zpp.setGrandTotalAmount(tc.getGrandTotal());
|
||||
zpp.setTotalPrepaidAmount(tc.getTotalPrepaid());
|
||||
zpp.setDuePayableAmount(tc.getGrandTotal().add(tc.getTotalPrepaid().negate()));
|
||||
EStandard whichType;
|
||||
try {
|
||||
whichType = getStandard();
|
||||
|
||||
@@ -95,6 +95,53 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
|
||||
|
||||
|
||||
}
|
||||
public void testZF1Import() {
|
||||
|
||||
ZUGFeRDInvoiceImporter zii=new ZUGFeRDInvoiceImporter("./target/testout-MustangGnuaccountingBeispielRE-20171118_506zf1.pdf");
|
||||
|
||||
boolean hasExceptions=false;
|
||||
Invoice invoice=null;
|
||||
try {
|
||||
invoice=zii.extractInvoice();
|
||||
} catch (XPathExpressionException | ParseException e) {
|
||||
hasExceptions=true;
|
||||
}
|
||||
assertFalse(hasExceptions);
|
||||
// Reading ZUGFeRD
|
||||
assertEquals("Bei Spiel GmbH", invoice.getOwnOrganisationName());
|
||||
assertEquals(3, invoice.getZFItems().length);
|
||||
assertEquals("400.0000", invoice.getZFItems()[1].getQuantity().toString());
|
||||
|
||||
assertEquals("160.0000", invoice.getZFItems()[0].getPrice().toString());
|
||||
assertEquals("Hot air „heiße Luft“ (litres)", invoice.getZFItems()[2].getProduct().getName());
|
||||
assertEquals("LTR", invoice.getZFItems()[2].getProduct().getUnit());
|
||||
assertEquals("7.00", invoice.getZFItems()[0].getProduct().getVATPercent().toString());
|
||||
assertEquals("RE-20190610/507", invoice.getNumber());
|
||||
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
||||
assertEquals("2019-06-10",sdf.format(invoice.getIssueDate()));
|
||||
assertEquals("2019-07-01",sdf.format(invoice.getDueDate()));
|
||||
|
||||
assertEquals("street", invoice.getRecipient().getStreet());
|
||||
assertEquals("zip", invoice.getRecipient().getZIP());
|
||||
assertEquals("DE", invoice.getRecipient().getCountry());
|
||||
assertEquals("city", invoice.getRecipient().getLocation());
|
||||
|
||||
assertEquals("street", invoice.getSender().getStreet());
|
||||
assertEquals("zip", invoice.getSender().getZIP());
|
||||
assertEquals("DE", invoice.getSender().getCountry());
|
||||
assertEquals("city", invoice.getSender().getLocation());
|
||||
|
||||
TransactionCalculator tc=new TransactionCalculator(invoice);
|
||||
assertEquals(new BigDecimal("571.04"),tc.getGrandTotal());
|
||||
|
||||
|
||||
// name street location zip country, contact name phone email, total amount
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void testItemAllowancesChargesImport() {
|
||||
|
||||
ZUGFeRDInvoiceImporter zii=new ZUGFeRDInvoiceImporter("./target/testout-ZF2PushItemChargesAllowances.pdf");
|
||||
|
||||
Reference in New Issue
Block a user