Skip to content

Commit

Permalink
closes #530
Browse files Browse the repository at this point in the history
  • Loading branch information
jstaerk committed Oct 26, 2024
1 parent 3675894 commit 1496262
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 3 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- 518 corrently validate more XRechnung versions
- make document charges and allowances serializable
- 523
- 530


2.14.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -818,7 +818,6 @@ public void generateXML(IExportableTransaction trans) {
}
}


if ((trans.getPaymentTerms() == null) && (getProfile() != Profiles.getByName("Minimum")) && ((paymentTermsDescription != null) || (trans.getTradeSettlement() != null) || (hasDueDate))) {
xml += "<ram:SpecifiedTradePaymentTerms>";

Expand All @@ -834,7 +833,7 @@ public void generateXML(IExportableTransaction trans) {
}
}

if (hasDueDate && (trans.getDueDate() != null)) {
if (trans.getDueDate() != null) {
xml += "<ram:DueDateDateTime>" // $NON-NLS-2$
+ DATE.udtFormat(trans.getDueDate())
+ "</ram:DueDateDateTime>";// 20130704
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("<udt:DateTimeString format=\"102\">20241026</udt:DateTimeString>"));

}



}

0 comments on commit 1496262

Please sign in to comment.