Merge branch 'master' into code-quality-enhancements
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
2.18.1
|
||||||
|
=======
|
||||||
|
- #893 Tradeparty globalID is not read from JSON
|
||||||
|
|
||||||
2.18.0
|
2.18.0
|
||||||
=======
|
=======
|
||||||
2025-07-14
|
2025-07-14
|
||||||
|
|||||||
@@ -541,6 +541,32 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* for jackson, primarily, use addGlobalID(SchemedID) instead
|
||||||
|
* @param ID the id part without scheme
|
||||||
|
* @return fluent setter
|
||||||
|
*/
|
||||||
|
public TradeParty setGlobalID(String ID) {
|
||||||
|
if (globalId==null) {
|
||||||
|
globalId=new SchemedID();
|
||||||
|
}
|
||||||
|
globalId.setId(ID);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* for jackson, primarily, use addGlobalID(SchemedID) instead
|
||||||
|
* @param scheme the scheme part without id
|
||||||
|
* @return fluent setter
|
||||||
|
*/
|
||||||
|
public TradeParty setGlobalIDScheme(String scheme) {
|
||||||
|
if (globalId==null) {
|
||||||
|
globalId=new SchemedID();
|
||||||
|
}
|
||||||
|
globalId.setScheme(scheme);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public TradeParty addGlobalID(SchemedID schemedID) {
|
public TradeParty addGlobalID(SchemedID schemedID) {
|
||||||
globalId = schemedID;
|
globalId = schemedID;
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -126,8 +126,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
if (Arrays.equals(pad, pdfSignature)) { // we have a pdf
|
if (Arrays.equals(pad, pdfSignature)) { // we have a pdf
|
||||||
|
|
||||||
|
|
||||||
try {
|
try(PDDocument doc = Loader.loadPDF(IOUtils.toByteArray(pdfStream))) {
|
||||||
PDDocument doc = Loader.loadPDF(IOUtils.toByteArray(pdfStream));
|
|
||||||
// PDDocumentInformation info = doc.getDocumentInformation();
|
// PDDocumentInformation info = doc.getDocumentInformation();
|
||||||
final PDDocumentNameDictionary names = new PDDocumentNameDictionary(doc.getDocumentCatalog());
|
final PDDocumentNameDictionary names = new PDDocumentNameDictionary(doc.getDocumentCatalog());
|
||||||
//start
|
//start
|
||||||
|
|||||||
@@ -414,10 +414,12 @@ public class DeSerializationTest extends ResourceCase {
|
|||||||
String number = "123";
|
String number = "123";
|
||||||
String priceStr = "1.00";
|
String priceStr = "1.00";
|
||||||
String taxID = "9990815";
|
String taxID = "9990815";
|
||||||
|
|
||||||
BigDecimal price = new BigDecimal(priceStr);
|
BigDecimal price = new BigDecimal(priceStr);
|
||||||
Invoice newInvoiceFromJSON = null;
|
Invoice newInvoiceFromJSON = null;
|
||||||
boolean hasExceptions = false;
|
boolean hasExceptions = false;
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
String json = "";
|
||||||
try {
|
try {
|
||||||
SchemedID gtin = new SchemedID("0160", "2001015001325");
|
SchemedID gtin = new SchemedID("0160", "2001015001325");
|
||||||
SchemedID gln = new SchemedID("0088", "4304171000002");
|
SchemedID gln = new SchemedID("0088", "4304171000002");
|
||||||
@@ -435,7 +437,7 @@ public class DeSerializationTest extends ResourceCase {
|
|||||||
.addCashDiscount(new CashDiscount(new BigDecimal(2), 14))
|
.addCashDiscount(new CashDiscount(new BigDecimal(2), 14))
|
||||||
.setDeliveryDate(sdf.parse("2020-11-02")).setNumber(number).setVATDueDateTypeCode(EventTimeCodeTypeConstants.PAYMENT_DATE);
|
.setDeliveryDate(sdf.parse("2020-11-02")).setNumber(number).setVATDueDateTypeCode(EventTimeCodeTypeConstants.PAYMENT_DATE);
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String json = mapper.writeValueAsString(i);
|
json = mapper.writeValueAsString(i);
|
||||||
newInvoiceFromJSON = mapper.readValue(json, Invoice.class);
|
newInvoiceFromJSON = mapper.readValue(json, Invoice.class);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
hasExceptions = true;
|
hasExceptions = true;
|
||||||
@@ -447,6 +449,23 @@ public class DeSerializationTest extends ResourceCase {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public void testFromJSON() throws JsonProcessingException {
|
||||||
|
String globalID = "4000001123452";
|
||||||
|
String globalIDScheme = "0088";
|
||||||
|
String itemDeliveryFrom="2022-01-28T23:00:00.000+00:00";
|
||||||
|
String itemDeliveryTo="2022-01-30T23:00:00.000+00:00";
|
||||||
|
|
||||||
|
String json="{\"number\":\"123\",\"buyerOrderReferencedDocumentID\":\"28934\",\"currency\":\"CHF\",\"issueDate\":1752744199178,\"dueDate\":1752744199178,\"deliveryDate\":1604271600000,\"sender\":{\"name\":\"Test company\",\"zip\":\"55232\",\"street\":\"teststr\",\"location\":\"teststadt\",\"country\":\"DE\",\"taxID\":\"9990815\",\"vatID\":\"DE0815\",\"id\":\"0009845\",\"globalID\":\""+globalID+"\",\"globalIDScheme\":\""+globalIDScheme+"\",\"email\":\"sender@test.org\",\"vatid\":\"DE0815\"},\"recipient\":{\"name\":\"Franz Müller\",\"zip\":\"55232\",\"street\":\"teststr.12\",\"location\":\"Entenhausen\",\"country\":\"DE\",\"vatID\":\"DE4711\",\"additionalAddress\":\"Hinterhaus 3\",\"contact\":{\"name\":\"Franz Müller\",\"phone\":\"01779999999\",\"email\":\"franz@mueller.de\",\"zip\":\"55232\",\"street\":\"teststr. 12\",\"location\":\"Entenhausen\",\"country\":\"DE\",\"fax\":\"++49555123456\"},\"globalID\":\"4304171000002\",\"globalIDScheme\":\"0088\",\"email\":\"recipient@test.org\",\"vatid\":\"DE4711\"},\"deliveryAddress\":{\"name\":\"just the other side of the street\",\"zip\":\"55232\",\"street\":\"teststr.12a\",\"location\":\"Entenhausen\",\"country\":\"DE\",\"vatID\":\"DE47110\",\"vatid\":\"DE47110\"},\"cashDiscounts\":[{\"percent\":2,\"days\":14}],\"notes\":[\"document level 1/2\",\"document level 2/2\"],\"sellerOrderReferencedDocumentID\":\"9384\",\"contractReferencedDocument\":\"376zreurzu0983\",\"valid\":true,\"vatdueDateTypeCode\":\"72\",\"zfitems\":[{\"price\":1.00,\"quantity\":1,\"basisQuantity\":1,\"detailedDeliveryPeriodFrom\":\""+itemDeliveryFrom+"\",\"detailedDeliveryPeriodTo\":\""+itemDeliveryTo+"\",\"id\":\"a123\",\"buyerOrderReferencedDocumentLineID\":\"xxx\",\"product\":{\"unit\":\"H87\",\"name\":\"Testprodukt\",\"sellerAssignedID\":\"4711\",\"taxCategoryCode\":\"S\",\"globalID\":\"2001015001325\",\"globalIDScheme\":\"0160\",\"intraCommunitySupply\":false,\"reverseCharge\":false,\"vatpercent\":16},\"notes\":[\"item level 1/1\"],\"notesWithSubjectCode\":[{\"content\":\"item level 1/1\"}],\"itemAllowances\":[{\"totalAmount\":0.0200000000000000004163336342344337026588618755340576171875,\"taxPercent\":16,\"reason\":\"item discount\",\"categoryCode\":\"S\"}],\"value\":1.00}],\"ownVATID\":\"DE0815\",\"detailedDeliveryPeriodFrom\":1601503200000,\"detailedDeliveryPeriodTo\":1601848800000,\"ownTaxID\":\"9990815\",\"ownZIP\":\"55232\",\"ownLocation\":\"teststadt\",\"zfallowances\":[{\"totalAmount\":0.200000000000000011102230246251565404236316680908203125,\"taxPercent\":16,\"reason\":\"discount\",\"categoryCode\":\"S\"}],\"ownStreet\":\"teststr\",\"zfcharges\":[{\"totalAmount\":0.5,\"taxPercent\":16,\"reason\":\"quick delivery charge\",\"categoryCode\":\"S\"}],\"ownCountry\":\"DE\"}";
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
Invoice fromJSON = mapper.readValue(json, Invoice.class);
|
||||||
|
assertEquals(globalID, fromJSON.getSender().getGlobalID());
|
||||||
|
assertEquals(globalIDScheme, fromJSON.getSender().getGlobalIDScheme());
|
||||||
|
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
assertEquals("2022-01-29", sdf.format(fromJSON.getZFItems()[0].getDetailedDeliveryPeriodFrom()));
|
||||||
|
assertEquals("2022-01-31", sdf.format(fromJSON.getZFItems()[0].getDetailedDeliveryPeriodTo()));
|
||||||
|
assertEquals("sender@test.org", fromJSON.getSender().getEmail());
|
||||||
|
}
|
||||||
|
|
||||||
public void testDueDateRoundtrip() throws JsonProcessingException {
|
public void testDueDateRoundtrip() throws JsonProcessingException {
|
||||||
|
|
||||||
|
|||||||
@@ -225,13 +225,7 @@ public class XMLValidator extends Validator {
|
|||||||
isExtended = context.getProfile().contains("extended");
|
isExtended = context.getProfile().contains("extended");
|
||||||
validateSchema(zfXML.getBytes(StandardCharsets.UTF_8), "OX_10/comfort/SCRDMCCBDACIOMessageStructure_100pD20B.xsd", 99, EPart.ox);
|
validateSchema(zfXML.getBytes(StandardCharsets.UTF_8), "OX_10/comfort/SCRDMCCBDACIOMessageStructure_100pD20B.xsd", 99, EPart.ox);
|
||||||
xsltFilename = "/xslt/OX_10/comfort/SCRDMCCBDACIOMessageStructure_100pD20B_COMFORT.xslt";
|
xsltFilename = "/xslt/OX_10/comfort/SCRDMCCBDACIOMessageStructure_100pD20B_COMFORT.xslt";
|
||||||
|
|
||||||
} else if (root.getLocalName().equalsIgnoreCase("SCRDMCCBDACIOMessageStructure")) {
|
|
||||||
context.setGeneration("1");
|
|
||||||
isOrderX = true;
|
|
||||||
validateSchema(zfXML.getBytes(StandardCharsets.UTF_8), "OX_10/comfort/SCRDMCCBDACIOMessageStructure_100pD20B.xsd", 99, EPart.ox);
|
|
||||||
xsltFilename = "/xslt/OX_10/comfort/SCRDMCCBDACIOMessageStructure_100pD20B_COMFORT.xslt";
|
|
||||||
|
|
||||||
} else if (root.getLocalName().equalsIgnoreCase("CrossIndustryInvoice")) { // ZUGFeRD 2.0 or Factur-X
|
} else if (root.getLocalName().equalsIgnoreCase("CrossIndustryInvoice")) { // ZUGFeRD 2.0 or Factur-X
|
||||||
context.setGeneration("2");
|
context.setGeneration("2");
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ public class ResourceCase extends TestCase {
|
|||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceCase.class.getCanonicalName()); // log output is
|
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceCase.class.getCanonicalName()); // log output is
|
||||||
|
|
||||||
public static File getResourceAsFile(String resourcePath) {
|
public static File getResourceAsFile(String resourcePath) {
|
||||||
try {
|
try(InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream(resourcePath)) {
|
||||||
InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream(resourcePath);
|
|
||||||
if (in == null) {
|
if (in == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -42,8 +41,7 @@ public class ResourceCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] getResourceAsByteArray(String resourcePath) {
|
public static byte[] getResourceAsByteArray(String resourcePath) {
|
||||||
try {
|
try(InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream(resourcePath)) {
|
||||||
InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream(resourcePath);
|
|
||||||
if (in == null) {
|
if (in == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user