Merge branch 'master' of github.com:ZUGFeRD/mustangproject
This commit is contained in:
@@ -191,10 +191,10 @@ public class Item implements IZUGFeRDExportableItem {
|
||||
izac.setTotalAmount(new BigDecimal(amountString));
|
||||
}
|
||||
if(percentString!=null) {
|
||||
izac.setPercent(new BigDecimal(percentString));
|
||||
izac.setPercent(new BigDecimal(percentString));
|
||||
}
|
||||
if(reason!=null) {
|
||||
izac.setReason(reason);
|
||||
izac.setReason(reason);
|
||||
}
|
||||
|
||||
if (isChargeString.equalsIgnoreCase("false")) {
|
||||
@@ -213,6 +213,12 @@ public class Item implements IZUGFeRDExportableItem {
|
||||
}
|
||||
|
||||
icnm.getAllNodes("AdditionalReferencedDocument").map(ReferencedDocument::fromNode).forEach(this::addAdditionalReference);
|
||||
|
||||
icnm.getAsNodeMap("BillingSpecifiedPeriod").ifPresent(periodNode -> {
|
||||
Date start = periodNode.getAsNodeMap("StartDateTime").flatMap(dateTimeNode -> dateTimeNode.getNode("DateTimeString")).map(dts -> XMLTools.tryDate(dts)).orElse(null);
|
||||
Date end = periodNode.getAsNodeMap("EndDateTime").flatMap(dateTimeNode -> dateTimeNode.getNode("DateTimeString")).map(dts -> XMLTools.tryDate(dts)).orElse(null);
|
||||
setDetailedDeliveryPeriod(start, end);
|
||||
});
|
||||
});
|
||||
|
||||
itemMap.getAsNodeMap("AssociatedDocumentLineDocument").ifPresent(adld -> {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class Product implements IZUGFeRDExportableProduct {
|
||||
nodeMap.getAsString("Description").ifPresent(this::setDescription);
|
||||
|
||||
|
||||
nodeMap.getAsNodeMap("ApplicableProductCharacteristic").ifPresent(apcNodes -> {
|
||||
nodeMap.getAllNodes("ApplicableProductCharacteristic").map(NodeMap::new).forEach(apcNodes -> { // ApplicableProductCharacteristic is 0 .. unbounded
|
||||
String key = apcNodes.getAsStringOrNull("Description");
|
||||
String value = apcNodes.getAsStringOrNull("Value");
|
||||
if (key != null && value != null) {
|
||||
@@ -80,7 +80,6 @@ public class Product implements IZUGFeRDExportableProduct {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//UBL
|
||||
nodeMap.getAsNodeMap("AdditionalItemProperty").ifPresent(aipNodes -> {
|
||||
String name = aipNodes.getAsStringOrNull("Name");
|
||||
|
||||
@@ -40,6 +40,7 @@ import java.nio.file.Paths;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -125,8 +126,8 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
|
||||
// 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());
|
||||
@@ -305,10 +306,10 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
|
||||
|
||||
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) {
|
||||
@@ -327,9 +328,9 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
|
||||
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);
|
||||
|
||||
assertEquals("Z", invoice.getZFItems()[0].getProduct().getTaxCategoryCode());
|
||||
@@ -483,15 +484,15 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
|
||||
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);
|
||||
@@ -528,23 +529,34 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
|
||||
|
||||
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());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItemsBillingSpecifiedPeriod() throws FileNotFoundException, XPathExpressionException, ParseException {
|
||||
File inputFile = getResourceAsFile("factur-x_invoicingPeriod.xml");
|
||||
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(new FileInputStream(inputFile));
|
||||
|
||||
CalculatedInvoice invoice = new CalculatedInvoice();
|
||||
zii.extractInto(invoice);
|
||||
assertEquals(3, invoice.getZFItems().length);
|
||||
assertEquals(new Date(2022-1900, 8-1, 29), invoice.getZFItems()[0].getDetailedDeliveryPeriodFrom());
|
||||
assertEquals(new Date(2022-1900, 8-1, 31), invoice.getZFItems()[0].getDetailedDeliveryPeriodTo());
|
||||
}
|
||||
|
||||
public void testImportPositionIncludedNotes() throws FileNotFoundException, XPathExpressionException, ParseException {
|
||||
File inputFile = getResourceAsFile("ZTESTZUGFERD_1_INVDSS_012015738820PDF-1.pdf");
|
||||
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(new FileInputStream(inputFile));
|
||||
|
||||
Reference in New Issue
Block a user