Merge branch 'ZUGFeRD:master' into master

This commit is contained in:
Kemal Taskin
2024-12-11 13:10:39 +01:00
committed by GitHub
3 changed files with 57 additions and 2 deletions

View File

@@ -31,8 +31,8 @@ import org.w3c.dom.Node;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class ClassCode {
private final String listID;
private final String code;
private String listID;
private String code;
private String listVersionID;
/**
@@ -58,6 +58,13 @@ public class ClassCode {
this(listID, code, null);
}
/***
* bean constructor
*/
public ClassCode() {
}
/***
* Set the version for the scheme returned by {@link #getListID()}
* @param listVersionID the scheme version

View File

@@ -2,6 +2,7 @@ package org.mustangproject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonSetter;
import org.mustangproject.ZUGFeRD.IDesignatedProductClassification;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableProduct;
import org.mustangproject.util.NodeMap;
@@ -32,6 +33,7 @@ public class Product implements IZUGFeRDExportableProduct {
protected SchemedID globalId = null;
protected String countryOfOrigin = null;
protected HashMap<String, String> attributes = new HashMap<>();
protected List<IDesignatedProductClassification> classifications = new ArrayList<>();
/***
@@ -365,6 +367,23 @@ public class Product implements IZUGFeRDExportableProduct {
return this;
}
/**
* Provide Jackson a hint as to use DesignatedProductClassification for the
* IDesignatedProductClassification product classifications
*
* @param classifications the new set of classifications
* @return fluent setter
*/
@JsonSetter("classifications")
public Product setClassificationsClass(DesignatedProductClassification[] classifications) {
this.classifications.clear();
if (classifications != null) {
this.classifications.addAll(Arrays.asList(classifications));
}
return this;
}
/**
* Add a {@link IDesignatedProductClassification} classification
*

View File

@@ -21,6 +21,7 @@
*/
package org.mustangproject.ZUGFeRD;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import junit.framework.TestCase;
@@ -165,6 +166,34 @@ public class DeSerializationTest extends ResourceCase {
}
public void testFull300Roundtrip() {
File inputCII = getResourceAsFile("not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel.cii.xml");
Invoice i=new Invoice();
String exText=null;
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter();
zii.doIgnoreCalculationErrors();
try {
zii.fromXML(new String(Files.readAllBytes(inputCII.toPath()), StandardCharsets.UTF_8));
ObjectMapper mapper = new ObjectMapper();
zii.extractInto(i);
String json = mapper.writeValueAsString(i);
Invoice newInvoiceFromJSON = mapper.readValue(json, Invoice.class);
assertEquals("Test_EeISI_100",i.getNumber());
assertEquals(newInvoiceFromJSON.getNumber(),i.getNumber());
} catch (IOException e) {
exText=e.getMessage();
} catch (XPathExpressionException e) {
exText=e.getMessage();
} catch (ParseException e) {
exText=e.getMessage();
}
assertNull(exText);
}
public void testIssuerAssignedIDRoundtrip() {
String occurrenceFrom = "20201001";