From 1baaf0513ed7789a04e0489a20dcbf76218ac60b Mon Sep 17 00:00:00 2001 From: Bharti Date: Mon, 25 Nov 2024 17:53:35 +0100 Subject: [PATCH] UBL updates --- .../main/java/org/mustangproject/Product.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/org/mustangproject/Product.java b/library/src/main/java/org/mustangproject/Product.java index 1263d593..352d3368 100644 --- a/library/src/main/java/org/mustangproject/Product.java +++ b/library/src/main/java/org/mustangproject/Product.java @@ -6,6 +6,7 @@ import org.mustangproject.ZUGFeRD.IDesignatedProductClassification; import org.mustangproject.ZUGFeRD.IZUGFeRDExportableProduct; import org.mustangproject.util.NodeMap; import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import java.math.BigDecimal; import java.util.ArrayList; @@ -21,7 +22,7 @@ import java.util.Map; @JsonInclude(JsonInclude.Include.NON_EMPTY) public class Product implements IZUGFeRDExportableProduct { - protected String unit, name, sellerAssignedID, buyerAssignedID; + protected String unit, name, sellerAssignedID, buyerAssignedID,ID; protected String description=""; protected String taxExemptionReason=null; protected String taxCategoryCode=null; @@ -59,11 +60,15 @@ public class Product implements IZUGFeRDExportableProduct { } }); + + + nodeMap.getAsString("SellerAssignedID").ifPresent(this::setSellerAssignedID); nodeMap.getAsString("BuyerAssignedID").ifPresent(this::setBuyerAssignedID); nodeMap.getAsString("Name").ifPresent(this::setName); nodeMap.getAsString("Description").ifPresent(this::setDescription); + nodeMap.getAsNodeMap("ApplicableProductCharacteristic").ifPresent(apcNodes -> { String key = apcNodes.getAsStringOrNull("Description"); String value = apcNodes.getAsStringOrNull("Value"); @@ -75,6 +80,18 @@ public class Product implements IZUGFeRDExportableProduct { } }); + //UBL + nodeMap.getAsNodeMap("AdditionalItemProperty").ifPresent(aipNodes -> { + String key = aipNodes.getAsStringOrNull("Name"); + String value = aipNodes.getAsStringOrNull("Value"); + if (key != null && value != null) { + if (attributes == null) { + attributes = new HashMap<>(); + } + attributes.put(key, value); + } + }); + nodeMap.getAsNodeMap("DesignatedProductClassification").ifPresent(dpcNodes -> { String className = dpcNodes.getAsStringOrNull("ClassName"); dpcNodes.getNode("ClassCode").map(ClassCode::fromNode).ifPresent(classCode ->