Skip to content

Commit

Permalink
corrected tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jstaerk committed Jan 20, 2025
1 parent deea7c0 commit f5a4cb3
Showing 1 changed file with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ public void testInvoiceImportUBL() {
// Reading ZUGFeRD
assertEquals("Bei Spiel GmbH", invoice.getOwnOrganisationName());
assertEquals(3, invoice.getZFItems().length);
assertEquals(invoice.getZFItems()[0].getNotesWithSubjectCode().get(0).getContent(),"Something");
assertEquals(invoice.getZFItems()[0].getNotesWithSubjectCode().size(),1);
assertEquals(invoice.getZFItems()[0].getNotesWithSubjectCode().get(0).getContent(), "Something");
assertEquals(invoice.getZFItems()[0].getNotesWithSubjectCode().size(), 1);
assertEquals("400", invoice.getZFItems()[1].getQuantity().toString());
assertEquals("Zahlbar ohne Abzug bis zum 30.05.2017", invoice.getPaymentTermDescription());
assertEquals("AB321", invoice.getReferenceNumber());
Expand Down Expand Up @@ -245,7 +245,7 @@ public void testItemAllowancesChargesImport() {
}
assertFalse(hasExceptions);
TransactionCalculator tc = new TransactionCalculator(invoice);
assertEquals(new BigDecimal("18.33"), tc.getGrandTotal());
assertEquals(new BigDecimal("19.52"), tc.getGrandTotal());
}

public void testBasisQuantityImport() {
Expand All @@ -264,6 +264,7 @@ public void testBasisQuantityImport() {
assertEquals(new BigDecimal("337.60"), tc.getGrandTotal());
}


public void testAllowancesChargesImport() {

ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter("./target/testout-ZF2PushChargesAllowances.pdf");
Expand All @@ -286,10 +287,10 @@ public void testXRImport() {

ZUGFeRDImporter zii = new ZUGFeRDImporter();

int version=-1;
int version = -1;
try {
zii.fromXML(new String(Files.readAllBytes(Paths.get("./target/testout-XR-Edge.xml")), StandardCharsets.UTF_8));
version=zii.getVersion();
version = zii.getVersion();
} catch (IOException e) {
hasExceptions = true;
} catch (Exception e) {
Expand All @@ -305,13 +306,12 @@ public void testXRImport() {
assertFalse(hasExceptions);



TransactionCalculator tc = new TransactionCalculator(invoice);
assertEquals(new BigDecimal("1.00"), tc.getGrandTotal());

assertEquals(version,2);
assertEquals(version, 2);
assertTrue(new BigDecimal("1").compareTo(invoice.getZFItems()[0].getQuantity()) == 0);
LineCalculator lc=new LineCalculator(invoice.getZFItems()[0]);
LineCalculator lc = new LineCalculator(invoice.getZFItems()[0]);
assertTrue(new BigDecimal("1").compareTo(lc.getItemTotalNetAmount()) == 0);

assertTrue(invoice.getTradeSettlement().length == 1);
Expand Down Expand Up @@ -357,7 +357,7 @@ public void testImportDebit() {
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(new FileInputStream(CIIinputFile));
Invoice i = zii.extractInvoice();

assertEquals("DE21860000000086001055", i.getSender().getBankDetails().get(0).getIBAN());
assertEquals("DE21860000000086001055", i.getRecipient().getBankDetails().get(0).getIBAN());
ObjectMapper mapper = new ObjectMapper();

String jsonArray = mapper.writeValueAsString(i);
Expand Down Expand Up @@ -430,15 +430,15 @@ public void testImportPrepaid() throws XPathExpressionException, ParseException
CalculatedInvoice invoice = new CalculatedInvoice();
importer.extractInto(invoice);

boolean isBD=invoice.getTotalPrepaidAmount() instanceof BigDecimal;
boolean isBD = invoice.getTotalPrepaidAmount() instanceof BigDecimal;
assertTrue(isBD);
BigDecimal expectedPrepaid=new BigDecimal(50);
BigDecimal expectedLineTotal=new BigDecimal("180.76");
BigDecimal expectedDue=new BigDecimal("147.65");
BigDecimal expectedPrepaid = new BigDecimal(50);
BigDecimal expectedLineTotal = new BigDecimal("180.76");
BigDecimal expectedDue = new BigDecimal("147.65");
if (isBD) {
BigDecimal amread=invoice.getTotalPrepaidAmount();
BigDecimal importedLineTotal=invoice.getLineTotalAmount();
BigDecimal importedDuePayable=invoice.getDuePayable();
BigDecimal amread = invoice.getTotalPrepaidAmount();
BigDecimal importedLineTotal = invoice.getLineTotalAmount();
BigDecimal importedDuePayable = invoice.getDuePayable();
assertTrue(amread.compareTo(expectedPrepaid) == 0);
assertTrue(importedLineTotal.compareTo(expectedLineTotal) == 0);
assertTrue(importedDuePayable.compareTo(expectedDue) == 0);
Expand Down Expand Up @@ -475,19 +475,19 @@ public void testIBANparsing() throws XPathExpressionException, ParseException, F

ZUGFeRDInvoiceImporter importer = new ZUGFeRDInvoiceImporter(new FileInputStream(inputFile));
Invoice invoice = importer.extractInvoice();
assertEquals(1,invoice.getRecipient().getBankDetails().size());
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());
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());
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());
assertEquals("DE88200800000970375700", invoice.getSender().getBankDetails().get(0).getIBAN());
assertEquals(0, invoice.getRecipient().getBankDetails().size());

}

Expand Down

0 comments on commit f5a4cb3

Please sign in to comment.