UBL updates

This commit is contained in:
Bharti
2024-11-25 17:53:35 +01:00
parent 5bd04e0bbc
commit 1baaf0513e

View File

@@ -6,6 +6,7 @@ import org.mustangproject.ZUGFeRD.IDesignatedProductClassification;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableProduct; import org.mustangproject.ZUGFeRD.IZUGFeRDExportableProduct;
import org.mustangproject.util.NodeMap; import org.mustangproject.util.NodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
@@ -21,7 +22,7 @@ import java.util.Map;
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Product implements IZUGFeRDExportableProduct { public class Product implements IZUGFeRDExportableProduct {
protected String unit, name, sellerAssignedID, buyerAssignedID; protected String unit, name, sellerAssignedID, buyerAssignedID,ID;
protected String description=""; protected String description="";
protected String taxExemptionReason=null; protected String taxExemptionReason=null;
protected String taxCategoryCode=null; protected String taxCategoryCode=null;
@@ -59,11 +60,15 @@ public class Product implements IZUGFeRDExportableProduct {
} }
}); });
nodeMap.getAsString("SellerAssignedID").ifPresent(this::setSellerAssignedID); nodeMap.getAsString("SellerAssignedID").ifPresent(this::setSellerAssignedID);
nodeMap.getAsString("BuyerAssignedID").ifPresent(this::setBuyerAssignedID); nodeMap.getAsString("BuyerAssignedID").ifPresent(this::setBuyerAssignedID);
nodeMap.getAsString("Name").ifPresent(this::setName); nodeMap.getAsString("Name").ifPresent(this::setName);
nodeMap.getAsString("Description").ifPresent(this::setDescription); nodeMap.getAsString("Description").ifPresent(this::setDescription);
nodeMap.getAsNodeMap("ApplicableProductCharacteristic").ifPresent(apcNodes -> { nodeMap.getAsNodeMap("ApplicableProductCharacteristic").ifPresent(apcNodes -> {
String key = apcNodes.getAsStringOrNull("Description"); String key = apcNodes.getAsStringOrNull("Description");
String value = apcNodes.getAsStringOrNull("Value"); 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 -> { nodeMap.getAsNodeMap("DesignatedProductClassification").ifPresent(dpcNodes -> {
String className = dpcNodes.getAsStringOrNull("ClassName"); String className = dpcNodes.getAsStringOrNull("ClassName");
dpcNodes.getNode("ClassCode").map(ClassCode::fromNode).ifPresent(classCode -> dpcNodes.getNode("ClassCode").map(ClassCode::fromNode).ifPresent(classCode ->