Item: add BillingSpecifiedPeriod

parses SpecifiedLineTradeSettlement->BillingSpecifiedPeriod to
detailedDeliveryPeriod
also fix parser for multiple ApplicableProductCharacteristics
This commit is contained in:
ean
2025-01-16 13:08:16 +01:00
parent 4a410bcd14
commit 1fb4b94718
3 changed files with 19 additions and 2 deletions

View File

@@ -206,6 +206,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 -> {

View File

@@ -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");

View File

@@ -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;
@@ -492,6 +493,17 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
}
@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));