support document level charges/allowances in invoiceimporter

This commit is contained in:
jstaerk
2020-11-10 12:03:38 +01:00
parent b065a1beb1
commit 5b8d1c9c54
5 changed files with 117 additions and 10 deletions

View File

@@ -41,11 +41,10 @@ import java.util.GregorianCalendar;
* used for this import, testout-ZF2New.pdf
*/
public class ZF2ZInvoiceImporterTest extends TestCase {
final String TARGET_PDF = "./target/testout-ZF2new.pdf";
public void testInvoiceImport() {
ZUGFeRDInvoiceImporter zii=new ZUGFeRDInvoiceImporter(TARGET_PDF);
ZUGFeRDInvoiceImporter zii=new ZUGFeRDInvoiceImporter("./target/testout-ZF2new.pdf");
boolean hasExceptions=false;
Invoice invoice=null;
@@ -82,7 +81,44 @@ public class ZF2ZInvoiceImporterTest extends TestCase {
assertEquals("Stadthausen", invoice.getSender().getLocation());
TransactionCalculator tc=new TransactionCalculator(invoice);
assertEquals(new BigDecimal("571.040000"),tc.getTotalGross());
assertEquals(new BigDecimal("571.04"),tc.getTotalGross());
// name street location zip country, contact name phone email, total amount
}
public void testItemAllowancesChargesImport() {
ZUGFeRDInvoiceImporter zii=new ZUGFeRDInvoiceImporter("./target/testout-ZF2PushItemChargesAllowances.pdf");
boolean hasExceptions=false;
Invoice invoice=null;
try {
invoice=zii.extractInvoice();
} catch (XPathExpressionException | ParseException e) {
hasExceptions=true;
}
assertFalse(hasExceptions);
TransactionCalculator tc=new TransactionCalculator(invoice);
assertEquals(new BigDecimal("18.33"),tc.getTotalGross());
}
public void testAllowancesChargesImport() {
ZUGFeRDInvoiceImporter zii=new ZUGFeRDInvoiceImporter("./target/testout-ZF2PushChargesAllowances.pdf");
boolean hasExceptions=false;
Invoice invoice=null;
try {
invoice=zii.extractInvoice();
} catch (XPathExpressionException | ParseException e) {
hasExceptions=true;
}
assertFalse(hasExceptions);
TransactionCalculator tc=new TransactionCalculator(invoice);
assertEquals(new BigDecimal("11.07"),tc.getTotalGross());
// name street location zip country, contact name phone email, total amount
@@ -91,4 +127,5 @@ public class ZF2ZInvoiceImporterTest extends TestCase {
}
}