From 14962621ed7433cfa96406c1490e6d933f5f58ef Mon Sep 17 00:00:00 2001 From: jstaerk Date: Sat, 26 Oct 2024 14:30:39 +0200 Subject: [PATCH] closes #530 --- History.md | 1 + .../ZUGFeRD/ZUGFeRD2PullProvider.java | 5 +- .../ZUGFeRD/DeSerializationTest.java | 56 +++++++++++++++++++ 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 93461378..77915c86 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,7 @@ - 518 corrently validate more XRechnung versions - make document charges and allowances serializable - 523 +- 530 2.14.2 diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java index 72718b58..03ed3099 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java @@ -334,7 +334,7 @@ public void generateXML(IExportableTransaction trans) { this.trans = trans; this.calc = new TransactionCalculator(trans); - boolean hasDueDate = false; + boolean hasDueDate = trans.getDueDate()!=null; final SimpleDateFormat germanDateFormat = new SimpleDateFormat("dd.MM.yyyy"); String exemptionReason = ""; @@ -818,7 +818,6 @@ public void generateXML(IExportableTransaction trans) { } } - if ((trans.getPaymentTerms() == null) && (getProfile() != Profiles.getByName("Minimum")) && ((paymentTermsDescription != null) || (trans.getTradeSettlement() != null) || (hasDueDate))) { xml += ""; @@ -834,7 +833,7 @@ public void generateXML(IExportableTransaction trans) { } } - if (hasDueDate && (trans.getDueDate() != null)) { + if (trans.getDueDate() != null) { xml += "" // $NON-NLS-2$ + DATE.udtFormat(trans.getDueDate()) + "";// 20130704 diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/DeSerializationTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/DeSerializationTest.java index 5b06d2b7..85b8534c 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/DeSerializationTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/DeSerializationTest.java @@ -130,5 +130,61 @@ public void testAllowanceRead() throws JsonProcessingException { + public void testDueDateRoundtrip() throws JsonProcessingException { + + ObjectMapper mapper = new ObjectMapper(); + + // [{"stringValue":"a","intValue":1,"booleanValue":true}, + // {"stringValue":"bc","intValue":3,"booleanValue":false}] + + Invoice fromJSON = mapper.readValue("{\n" + + " \"number\": \"RE - 228\",\n" + + " \"currency\": \"EUR\",\n" + + " \"issueDate\": \"2024-10-24\",\n" + + " \"dueDate\": \"2024-10-26\",\n" + + " \"deliveryDate\": \"2024-10-25\",\n" + + " \"sender\": {\n" + + " \"name\": \"Amazing Company\",\n" + + " \"zip\": \"10000\",\n" + + " \"street\": \"Straße der Kosmonauten 20\",\n" + + " \"location\": \"Berlin\",\n" + + " \"country\": \"DE\",\n" + + " \"taxID\": \"201/113/40209\",\n" + + " \"vatID\": \"DE123456789\",\n" + + " \"globalID\": \"4000001123452\",\n" + + " \"globalIDScheme\": \"0088\"\n" + + " },\n" + + " \"recipient\": {\n" + + " \"name\": \"Amazing Company\",\n" + + " \"zip\": \"1000\",\n" + + " \"street\": \"Straße der Kosmonauten 10\",\n" + + " \"location\": \"Berlin\",\n" + + " \"taxID\": \"201/113/40209\",\n" + + " \"vatID\": \"DE123456789\",\n" + + " \"country\": \"DE\"\n" + + " },\n" + + " \"zfitems\": [\n" + + " {\n" + + " \"price\": 99.9,\n" + + " \"quantity\": 10,\n" + + " \"product\": {\n" + + " \"unit\": \"H87\",\n" + + " \"name\": \"Amazing Archives\",\n" + + " \"description\": \"123\",\n" + + " \"vatpercent\": \"19\",\n" + + " \"taxCategoryCode\": \"3\"\n" + + " }\n" + + " }\n" + + " ]\n" + + "}\n", Invoice.class); + ZUGFeRD2PullProvider zf2p = new ZUGFeRD2PullProvider(); + zf2p.setProfile(Profiles.getByName("XRechnung")); + zf2p.generateXML(fromJSON); + String theXML = new String(zf2p.getXML()); + assertTrue(theXML.contains("20241026")); + + } + + }