allow some more JSONing

This commit is contained in:
jstaerk
2024-11-28 14:11:14 +01:00
parent 53a0fe8fc2
commit 8932646b59
17 changed files with 603 additions and 69 deletions

View File

@@ -1,15 +1,15 @@
2.15.1 2.15.1
======= =======
- #566 - #566 Failed to parse PDF - Could not reproduce the invoice
- have a bean contructor for direct debit
-? lineTotalAmount is null
? be able to access ID in error message ? be able to access ID in error message
- closes #579 - closes #579 prepaidamount is only read in UBL
- #581 - #581 parse lineTotalAmount
- #576 - #576 read lineid, #578 set lineid
- #578
- log error ids - log error ids
- #503 import more ubl - #503 import more ubl
- allow jackson to run over more classes, e.g., DirectDebit, bean contructor for direct debit
- allow json includedNotes
- support importing duePayableAmount
2.15.0 2.15.0
======= =======

View File

@@ -1,12 +1,14 @@
package org.mustangproject; package org.mustangproject;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.math.BigDecimal; import java.math.BigDecimal;
/*** /***
* (absolute) allowances on item and document level * (absolute) allowances on item and document level
*/ */
@JsonIgnoreProperties(ignoreUnknown = true)
public class Allowance extends Charge { public class Allowance extends Charge {
/*** /***

View File

@@ -7,6 +7,7 @@ import org.mustangproject.ZUGFeRD.IZUGFeRDTradeSettlementPayment;
/** /**
* provides e.g. the IBAN to transfer money to :-) * provides e.g. the IBAN to transfer money to :-)
*/ */
@JsonIgnoreProperties(ignoreUnknown = true)
public class BankDetails implements IZUGFeRDTradeSettlementPayment { public class BankDetails implements IZUGFeRDTradeSettlementPayment {
/** /**
* the bank account number * the bank account number

View File

@@ -2,6 +2,7 @@
package org.mustangproject; package org.mustangproject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.mustangproject.ZUGFeRD.TransactionCalculator; import org.mustangproject.ZUGFeRD.TransactionCalculator;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -9,8 +10,10 @@ import org.slf4j.LoggerFactory;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
@JsonIgnoreProperties(ignoreUnknown = true)
public class CalculatedInvoice extends Invoice implements Serializable { public class CalculatedInvoice extends Invoice implements Serializable {
protected BigDecimal duePayable=null;
protected BigDecimal grandTotal=null; protected BigDecimal grandTotal=null;
protected BigDecimal lineTotalAmount=null; protected BigDecimal lineTotalAmount=null;
@@ -18,6 +21,7 @@ public class CalculatedInvoice extends Invoice implements Serializable {
TransactionCalculator tc=new TransactionCalculator(this); TransactionCalculator tc=new TransactionCalculator(this);
grandTotal=tc.getGrandTotal(); grandTotal=tc.getGrandTotal();
lineTotalAmount=tc.getValue(); lineTotalAmount=tc.getValue();
duePayable=tc.getDuePayable();
} }
public BigDecimal getGrandTotal() { public BigDecimal getGrandTotal() {
if (grandTotal==null) { if (grandTotal==null) {
@@ -29,6 +33,18 @@ public class CalculatedInvoice extends Invoice implements Serializable {
grandTotal=grand; grandTotal=grand;
return this; return this;
} }
public BigDecimal getDuePayable() {
if (duePayable==null) {
calculate();
}
return duePayable;
}
public CalculatedInvoice setDuePayable(BigDecimal due) {
duePayable=due;
return this;
}
public BigDecimal getLineTotalAmount() { public BigDecimal getLineTotalAmount() {
if (lineTotalAmount==null) { if (lineTotalAmount==null) {
calculate(); calculate();

View File

@@ -1,5 +1,6 @@
package org.mustangproject; package org.mustangproject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.mustangproject.ZUGFeRD.IZUGFeRDCashDiscount; import org.mustangproject.ZUGFeRD.IZUGFeRDCashDiscount;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -7,6 +8,7 @@ import java.math.BigDecimal;
/*** /***
* A class to represent discounts for early payments ("Skonto") * A class to represent discounts for early payments ("Skonto")
*/ */
@JsonIgnoreProperties(ignoreUnknown = true)
public class CashDiscount implements IZUGFeRDCashDiscount { public class CashDiscount implements IZUGFeRDCashDiscount {
/*** /***
@@ -31,6 +33,31 @@ public class CashDiscount implements IZUGFeRDCashDiscount {
this.days = days; this.days = days;
} }
/***
* bean contructor
*/
public CashDiscount() {
}
public BigDecimal getPercent() {
return percent;
}
public CashDiscount setPercent(BigDecimal percent) {
this.percent = percent;
return this;
}
public Integer getDays() {
return days;
}
public CashDiscount setDays(Integer days) {
this.days = days;
return this;
}
/*** /***
* @return this particular cash discount as cross industry invoice XML * @return this particular cash discount as cross industry invoice XML
*/ */

View File

@@ -1,6 +1,7 @@
package org.mustangproject; package org.mustangproject;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.mustangproject.ZUGFeRD.IAbsoluteValueProvider; import org.mustangproject.ZUGFeRD.IAbsoluteValueProvider;
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge; import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
@@ -9,6 +10,7 @@ import java.math.BigDecimal;
/*** /***
* Absolute and relative charges for document and item level * Absolute and relative charges for document and item level
*/ */
@JsonIgnoreProperties(ignoreUnknown = true)
public class Charge implements IZUGFeRDAllowanceCharge { public class Charge implements IZUGFeRDAllowanceCharge {
/** /**

View File

@@ -20,12 +20,14 @@
*/ */
package org.mustangproject; package org.mustangproject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.w3c.dom.NamedNodeMap; import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
/** /**
* A schemed classification for products. The scheme can be anything defined in UNTDID 7143. * A schemed classification for products. The scheme can be anything defined in UNTDID 7143.
*/ */
@JsonIgnoreProperties(ignoreUnknown = true)
public class ClassCode { public class ClassCode {
private final String listID; private final String listID;
private final String code; private final String code;

View File

@@ -20,12 +20,14 @@
*/ */
package org.mustangproject; package org.mustangproject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.mustangproject.ZUGFeRD.IDesignatedProductClassification; import org.mustangproject.ZUGFeRD.IDesignatedProductClassification;
/** /**
* An implementation of {@link IDesignatedProductClassification} for describing a {@link org.mustangproject.Product} * An implementation of {@link IDesignatedProductClassification} for describing a {@link org.mustangproject.Product}
* *
*/ */
@JsonIgnoreProperties(ignoreUnknown = true)
public class DesignatedProductClassification implements IDesignatedProductClassification { public class DesignatedProductClassification implements IDesignatedProductClassification {
private final ClassCode classCode; private final ClassCode classCode;
private String className; private String className;

View File

@@ -1,10 +1,12 @@
package org.mustangproject; package org.mustangproject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.mustangproject.ZUGFeRD.IZUGFeRDTradeSettlementDebit; import org.mustangproject.ZUGFeRD.IZUGFeRDTradeSettlementDebit;
/** /**
* provides e.g. the IBAN to transfer money to :-) * provides e.g. the IBAN to transfer money to :-)
*/ */
@JsonIgnoreProperties(ignoreUnknown = true)
public class DirectDebit implements IZUGFeRDTradeSettlementDebit { public class DirectDebit implements IZUGFeRDTradeSettlementDebit {
/** /**
* Debited account identifier (BT-91) * Debited account identifier (BT-91)

View File

@@ -1,5 +1,8 @@
package org.mustangproject; package org.mustangproject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public class FileAttachment { public class FileAttachment {
protected String filename; protected String filename;

View File

@@ -1,75 +1,98 @@
package org.mustangproject; package org.mustangproject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
/** /**
* A grouping of business terms to indicate accounting-relevant free texts including a qualification of these. * A grouping of business terms to indicate accounting-relevant free texts including a qualification of these.
*/ */
@JsonIgnoreProperties(ignoreUnknown = true)
public class IncludedNote { public class IncludedNote {
private String content; private String content;
private SubjectCode subjectCode;
private static final String INCLUDE_START = "<ram:IncludedNote>"; private SubjectCode subjectCode;
private static final String INCLUDE_END = "</ram:IncludedNote>";
private static final String CONTENT_START = "<ram:Content>";
private static final String CONTENT_END = "</ram:Content>";
private static final String SUBJECT_CODE_START = "<ram:SubjectCode>";
private static final String SUBJECT_CODE_END = "</ram:SubjectCode>";
private IncludedNote(String content, SubjectCode subjectCode) { private static final String INCLUDE_START = "<ram:IncludedNote>";
this.content = content; private static final String INCLUDE_END = "</ram:IncludedNote>";
this.subjectCode = subjectCode; private static final String CONTENT_START = "<ram:Content>";
} private static final String CONTENT_END = "</ram:Content>";
private static final String SUBJECT_CODE_START = "<ram:SubjectCode>";
private static final String SUBJECT_CODE_END = "</ram:SubjectCode>";
private IncludedNote(String content, SubjectCode subjectCode) {
this.content = content;
this.subjectCode = subjectCode;
}
/** /**
* bean constructor * bean constructor
*/ */
public IncludedNote() { public IncludedNote() {
} }
public static IncludedNote generalNote(String content) { public static IncludedNote generalNote(String content) {
return new IncludedNote(content, SubjectCode.AAI); return new IncludedNote(content, SubjectCode.AAI);
} }
public static IncludedNote regulatoryNote(String content) {
return new IncludedNote(content, SubjectCode.REG);
}
public static IncludedNote legalNote(String content) {
return new IncludedNote(content, SubjectCode.ABL);
}
public static IncludedNote customsNote(String content) {
return new IncludedNote(content, SubjectCode.CUS);
}
public static IncludedNote sellerNote(String content) {
return new IncludedNote(content, SubjectCode.SUR);
}
public static IncludedNote taxNote(String content) {
return new IncludedNote(content, SubjectCode.TXD);
}
public static IncludedNote introductionNote(String content) {
return new IncludedNote(content, SubjectCode.ACY);
}
public static IncludedNote discountBonusNote(String content) {
return new IncludedNote(content, SubjectCode.AAK);
}
public static IncludedNote unspecifiedNote(String content) { public static IncludedNote regulatoryNote(String content) {
return new IncludedNote(content, null); return new IncludedNote(content, SubjectCode.REG);
} }
public String getContent() { public static IncludedNote legalNote(String content) {
return content; return new IncludedNote(content, SubjectCode.ABL);
} }
public static IncludedNote customsNote(String content) {
return new IncludedNote(content, SubjectCode.CUS);
}
public static IncludedNote sellerNote(String content) {
return new IncludedNote(content, SubjectCode.SUR);
}
public static IncludedNote taxNote(String content) {
return new IncludedNote(content, SubjectCode.TXD);
}
public static IncludedNote introductionNote(String content) {
return new IncludedNote(content, SubjectCode.ACY);
}
public static IncludedNote discountBonusNote(String content) {
return new IncludedNote(content, SubjectCode.AAK);
}
public static IncludedNote unspecifiedNote(String content) {
return new IncludedNote(content, null);
}
public String getContent() {
return content;
}
public SubjectCode getSubjectCode() {
return subjectCode;
}
public IncludedNote setSubjectCode(SubjectCode subjectCode) {
this.subjectCode = subjectCode;
return this;
}
public IncludedNote setContent(String content) {
this.content = content;
return this;
}
public String toCiiXml() {
String result = INCLUDE_START + CONTENT_START +
XMLTools.encodeXML(getContent()) + CONTENT_END;
if (getSubjectCode() != null) {
result += SUBJECT_CODE_START + getSubjectCode() + SUBJECT_CODE_END;
}
return result + INCLUDE_END;
}
public SubjectCode getSubjectCode() {
return subjectCode;
}
public String toCiiXml(){
String result = INCLUDE_START + CONTENT_START +
XMLTools.encodeXML(getContent() )+ CONTENT_END;
if (getSubjectCode() != null) {
result += SUBJECT_CODE_START + getSubjectCode() + SUBJECT_CODE_END;
}
return result + INCLUDE_END;
}
} }

View File

@@ -413,6 +413,11 @@ public class Invoice implements IExportableTransaction {
return includedNotes; return includedNotes;
} }
public Invoice setNotesWithSubjectCode(List<IncludedNote> theList) {
includedNotes=theList;
return this;
}
@Override @Override
public String getCurrency() { public String getCurrency() {
return currency; return currency;

View File

@@ -1,9 +1,11 @@
package org.mustangproject; package org.mustangproject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.mustangproject.ZUGFeRD.IReferencedDocument; import org.mustangproject.ZUGFeRD.IReferencedDocument;
import org.mustangproject.util.NodeMap; import org.mustangproject.util.NodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReferencedDocument implements IReferencedDocument { public class ReferencedDocument implements IReferencedDocument {
String issuerAssignedID; String issuerAssignedID;

View File

@@ -1,5 +1,9 @@
package org.mustangproject; package org.mustangproject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public class SchemedID { public class SchemedID {
protected String scheme; protected String scheme;
protected String id; protected String id;

View File

@@ -415,6 +415,14 @@ public class ZUGFeRDInvoiceImporter {
} }
} }
xpr = xpath.compile("//*[local-name()=\"SpecifiedTradeSettlementHeaderMonetarySummation\"]/*[local-name()=\"DuePayableAmount\"]|//*[local-name()=\"LegalMonetaryTotal\"]/*[local-name()=\"PayableAmount\"]");
NodeList lineDueNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
if (lineDueNodes.getLength() > 0) {
if (zpp instanceof CalculatedInvoice) {
((CalculatedInvoice) zpp).setDuePayable(new BigDecimal(XMLTools.trimOrNull(lineDueNodes.item(0))));
}
}
Date issueDate = null; Date issueDate = null;
Date dueDate = null; Date dueDate = null;
Date deliveryDate = null; Date deliveryDate = null;

View File

@@ -24,21 +24,25 @@ package org.mustangproject.ZUGFeRD;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import org.mustangproject.*; import org.mustangproject.*;
import org.mustangproject.ZUGFeRD.model.EventTimeCodeTypeConstants;
import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathExpressionException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class DeSerializationTest extends ResourceCase { public class DeSerializationTest extends ResourceCase {
public void testJackson() throws JsonProcessingException { public void testJackson() throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
@@ -68,7 +72,7 @@ public class DeSerializationTest extends ResourceCase {
hasExceptions = true; hasExceptions = true;
} }
CalculatedInvoice ci=new CalculatedInvoice(); CalculatedInvoice ci = new CalculatedInvoice();
try { try {
zii.extractInto(ci); zii.extractInto(ci);
} catch (XPathExpressionException e) { } catch (XPathExpressionException e) {
@@ -154,14 +158,57 @@ public class DeSerializationTest extends ResourceCase {
" }\n" + " }\n" +
" ]\n" + " ]\n" +
"}", Invoice.class); "}", Invoice.class);
TransactionCalculator tc=new TransactionCalculator(fromJSON); TransactionCalculator tc = new TransactionCalculator(fromJSON);
assertEquals(tc.getGrandTotal(),new BigDecimal("234.43")); assertEquals(tc.getGrandTotal(), new BigDecimal("234.43"));
assertEquals(fromJSON.getNumber(), fromJSON.getNumber()); assertEquals(fromJSON.getNumber(), fromJSON.getNumber());
assertEquals(fromJSON.getZFItems().length, fromJSON.getZFItems().length); assertEquals(fromJSON.getZFItems().length, fromJSON.getZFItems().length);
} }
public void testIssuerAssignedIDRoundtrip() {
String occurrenceFrom = "20201001";
String occurrenceTo = "20201005";
String contractID = "376zreurzu0983";
String orgID = "0009845";
String orgname = "Test company";
String number = "123";
String priceStr = "1.00";
String taxID = "9990815";
BigDecimal price = new BigDecimal(priceStr);
Invoice newInvoiceFromJSON = null;
boolean hasExceptions = false;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
SchemedID gtin = new SchemedID("0160", "2001015001325");
SchemedID gln = new SchemedID("0088", "4304171000002");
Invoice i = new Invoice().setCurrency("CHF").addNote("document level 1/2").addNote("document level 2/2").setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date())
.setSellerOrderReferencedDocumentID("9384").setBuyerOrderReferencedDocumentID("28934")
.setDetailedDeliveryPeriod(new SimpleDateFormat("yyyyMMdd").parse(occurrenceFrom), new SimpleDateFormat("yyyyMMdd").parse(occurrenceTo))
.setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID(taxID).setEmail("sender@test.org").setID(orgID).addVATID("DE0815"))
.setDeliveryAddress(new TradeParty("just the other side of the street", "teststr.12a", "55232", "Entenhausen", "DE").addVATID("DE47110"))
.setContractReferencedDocument(contractID)
.setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").addGlobalID(gln).setEmail("recipient@test.org").addVATID("DE4711")
.setContact(new Contact("Franz Müller", "01779999999", "franz@mueller.de", "teststr. 12", "55232", "Entenhausen", "DE").setFax("++49555123456")).setAdditionalAddress("Hinterhaus 3"))
.addItem(new Item(new Product("Testprodukt", "", "H87", new BigDecimal(16)).addGlobalID(gtin).setSellerAssignedID("4711"), price, new BigDecimal(1.0)).setId("a123").addReferencedLineID("xxx").addNote("item level 1/1").addAllowance(new Allowance(new BigDecimal(0.02)).setReason("item discount").setTaxPercent(new BigDecimal(16))).setDetailedDeliveryPeriod(sdf.parse("2020-01-13"), sdf.parse("2020-01-15")))
.addCharge(new Charge(new BigDecimal(0.5)).setReason("quick delivery charge").setTaxPercent(new BigDecimal(16)))
.addAllowance(new Allowance(new BigDecimal(0.2)).setReason("discount").setTaxPercent(new BigDecimal(16)))
.addCashDiscount(new CashDiscount(new BigDecimal(2), 14))
.setDeliveryDate(sdf.parse("2020-11-02")).setNumber(number).setVATDueDateTypeCode(EventTimeCodeTypeConstants.PAYMENT_DATE);
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(i);
newInvoiceFromJSON = mapper.readValue(json, Invoice.class);
} catch (ParseException e) {
hasExceptions = true;
} catch (JsonProcessingException e) {
hasExceptions = true;
}
assertEquals(newInvoiceFromJSON.getBuyerOrderReferencedDocumentID(), "28934");
assertFalse(hasExceptions);
}
public void testDueDateRoundtrip() throws JsonProcessingException { public void testDueDateRoundtrip() throws JsonProcessingException {
@@ -219,4 +266,389 @@ public class DeSerializationTest extends ResourceCase {
} }
public void testDirectDebit() throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
// [{"stringValue":"a","intValue":1,"booleanValue":true},
// {"stringValue":"bc","intValue":3,"booleanValue":false}]
boolean exceptions = false;
String theXML = "";
try {
Invoice fromJSON = mapper.readValue("\n" +
"\t{\n" +
"\t\t\"documentCode\": \"380\",\n" +
"\t\t\"number\": \"F20220031\",\n" +
"\t\t\"referenceNumber\": \"SERVEXEC\",\n" +
"\t\t\"buyerOrderReferencedDocumentID\": \"PO201925478\",\n" +
"\t\t\"ownOrganisationName\": \"LE FOURNISSEUR\",\n" +
"\t\t\"currency\": \"EUR\",\n" +
"\t\t\"issueDate\": \"2022-01-30T23:00:00.000+00:00\",\n" +
"\t\t\"dueDate\": \"2022-03-01T23:00:00.000+00:00\",\n" +
"\t\t\"deliveryDate\": \"2022-01-27T23:00:00.000+00:00\",\n" +
"\t\t\"sender\": {\n" +
"\t\t\"name\": \"LE FOURNISSEUR\",\n" +
"\t\t\t\"zip\": \"75018\",\n" +
"\t\t\t\"street\": \"35 rue d'ici\",\n" +
"\t\t\t\"location\": \"PARIS\",\n" +
"\t\t\t\"country\": \"FR\",\n" +
"\t\t\t\"vatID\": \"FR11123456782\",\n" +
"\t\t\t\"additionalAddress\": \"Seller line 2\",\n" +
"\t\t\t\"additionalAddressExtension\": \"Seller line 3\",\n" +
"\t\t\t\"bankDetails\": [\n" +
"\t\t{\n" +
"\t\t\t\"accountName\": null,\n" +
"\t\t\t\"iban\": \"FR20 1254 2547 2569 8542 5874 698\",\n" +
"\t\t\t\"bic\": \"BIC_MONCOMPTE\"\n" +
"\t\t}\n" +
" ],\n" +
"\t\t\"debitDetails\": [\n" +
"\t\t{\n" +
"\t\t\t\"mandate\": \"MANDATE PT\",\n" +
"\t\t\t\"iban\": \"FR20 1254 2547 2569 8542 5874 698\"\n" +
"\t\t}\n" +
" ],\n" +
"\t\t\"contact\": {\n" +
"\t\t\t\"name\": \"M. CONTACT\",\n" +
"\t\t\t\t\"phone\": \"01 02 03 54 87\",\n" +
"\t\t\t\t\"email\": \"seller@seller.com\",\n" +
"\t\t\t\t\"zip\": null,\n" +
"\t\t\t\t\"street\": null,\n" +
"\t\t\t\t\"location\": null,\n" +
"\t\t\t\t\"country\": null,\n" +
"\t\t\t\t\"fax\": null,\n" +
"\t\t\t\t\"vatid\": null,\n" +
"\t\t\t\t\"id\": null,\n" +
"\t\t\t\t\"additionalAddress\": null\n" +
"\t\t},\n" +
"\t\t\"email\": \"moi@seller.com\",\n" +
"\t\t\t\"vatid\": \"FR11123456782\",\n" +
"\t\t\t\"id\": \"123\",\n" +
"\t\t\t\"legalOrganisation\": {\n" +
"\t\t\t\"schemedID\": null,\n" +
"\t\t\t\t\"tradingBusinessName\": \"SELLER TRADE NAME\"\n" +
"\t\t},\n" +
"\t\t\"globalID\": \"587451236587\",\n" +
"\t\t\t\"globalIDScheme\": \"0088\"\n" +
"\t},\n" +
"\t\t\"recipient\": {\n" +
"\t\t\"name\": \"LE CLIENT\",\n" +
"\t\t\t\"zip\": \"06000\",\n" +
"\t\t\t\"street\": \"MON ADRESSE LIGNE 1\",\n" +
"\t\t\t\"location\": \"MA VILLE\",\n" +
"\t\t\t\"country\": \"FR\",\n" +
"\t\t\t\"vatID\": \"FR 05 987 654 321\",\n" +
"\t\t\t\"additionalAddress\": \"Buyer line 2\",\n" +
"\t\t\t\"additionalAddressExtension\": \"Buyer line 3\",\n" +
"\t\t\t\"contact\": {\n" +
"\t\t\t\"name\": \"Buyer contact name\",\n" +
"\t\t\t\t\"phone\": \"01 01 25 45 87\",\n" +
"\t\t\t\t\"email\": \"buyer@buyer.com\",\n" +
"\t\t\t\t\"zip\": null,\n" +
"\t\t\t\t\"street\": null,\n" +
"\t\t\t\t\"location\": null,\n" +
"\t\t\t\t\"country\": null,\n" +
"\t\t\t\t\"fax\": null,\n" +
"\t\t\t\t\"vatid\": null,\n" +
"\t\t\t\t\"id\": null,\n" +
"\t\t\t\t\"additionalAddress\": null\n" +
"\t\t},\n" +
"\t\t\"email\": \"me@buyer.com\",\n" +
"\t\t\t\"vatid\": \"FR 05 987 654 321\",\n" +
"\t\t\t\"legalOrganisation\": {\n" +
"\t\t\t\"schemedID\": null,\n" +
"\t\t\t\t\"tradingBusinessName\": null\n" +
"\t\t},\n" +
"\t\t\"globalID\": \"3654789851\",\n" +
"\t\t\t\"globalIDScheme\": \"0088\"\n" +
"\t},\n" +
"\t\t\"deliveryAddress\": {\n" +
"\t\t\"name\": \"DEL Name\",\n" +
"\t\t\t\"zip\": \"06000\",\n" +
"\t\t\t\"street\": \"DEL ADRESSE LIGNE 1\",\n" +
"\t\t\t\"location\": \"NICE\",\n" +
"\t\t\t\"country\": \"FR\",\n" +
"\t\t\t\"additionalAddress\": \"DEL line 2\",\n" +
"\t\t\t\"id\": \"PRIVATE_ID_DEL\"\n" +
"\t},\n" +
"\t\t\"payee\": {\n" +
"\t\t\"name\": \"PAYEE NAME\",\n" +
"\t\t\t\"legalOrganisation\": {\n" +
"\t\t\t\"schemedID\": null,\n" +
"\t\t\t\t\"tradingBusinessName\": null\n" +
"\t\t},\n" +
"\t\t\"globalID\": \"587451236586\",\n" +
"\t\t\t\"globalIDScheme\": \"0088\"\n" +
"\t},\n" +
"\t\t\"sellerOrderReferencedDocumentID\": \"SALES REF 2547\",\n" +
"\t\t\"despatchAdviceReferencedDocumentID\": \"DESPADV002\",\n" +
"\t\t\"grandTotal\": 107.82,\n" +
"\t\t\"detailedDeliveryPeriodFrom\": \"2021-12-31T23:00:00.000+00:00\",\n" +
"\t\t\"detailedDeliveryPeriodTo\": \"2022-12-30T23:00:00.000+00:00\",\n" +
"\t\t\"notesWithSubjectCode\": [\n" +
"\t\t{\n" +
"\t\t\t\"content\": \"FOURNISSEUR F SARL au capital de 50 000 EUR\",\n" +
"\t\t\t\"subjectCode\": \"REG\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"content\": \"RCS MAVILLE 123 456 782\",\n" +
"\t\t\t\"subjectCode\": \"ABL\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"content\": \"35 ma rue a moi, code postal Ville Pays contact@masociete.fr - www.masociete.fr N° TVA : FR32 123 456 789\",\n" +
"\t\t\t\"subjectCode\": \"AAI\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"content\": \"Tout retard de paiement engendre une pénalité exigible à compter de la date d'échéance, calculée sur la base de trois fois le taux d'intérêt légal.\",\n" +
"\t\t\t\"subjectCode\": null\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"content\": \"Indemnité forfaitaire pour frais de recouvrement en cas de retard de paiement : 40 €.\",\n" +
"\t\t\t\"subjectCode\": null\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"content\": \"Les réglements reçus avant la date d'échéance ne donneront pas lieu à escompte.\",\n" +
"\t\t\t\"subjectCode\": null\n" +
"\t\t}\n" +
" ],\n" +
"\t\t\"zfallowances\": [\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1,\n" +
"\t\t\t\"taxPercent\": null,\n" +
"\t\t\t\"reason\": \"REMISE VOLUME\",\n" +
"\t\t\t\"reasonCode\": \"71\",\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1,\n" +
"\t\t\t\"taxPercent\": null,\n" +
"\t\t\t\"reason\": \"REMISE VOLUME\",\n" +
"\t\t\t\"reasonCode\": \"71\",\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1,\n" +
"\t\t\t\"taxPercent\": null,\n" +
"\t\t\t\"reason\": \"REMISE VOLUME\",\n" +
"\t\t\t\"reasonCode\": \"71\",\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1,\n" +
"\t\t\t\"taxPercent\": null,\n" +
"\t\t\t\"reason\": null,\n" +
"\t\t\t\"reasonCode\": \"100\",\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 2,\n" +
"\t\t\t\"taxPercent\": null,\n" +
"\t\t\t\"reason\": \"REMISE VOLUME\",\n" +
"\t\t\t\"reasonCode\": \"71\",\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1,\n" +
"\t\t\t\"taxPercent\": null,\n" +
"\t\t\t\"reason\": \"REMISE VOLUME\",\n" +
"\t\t\t\"reasonCode\": \"71\",\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1,\n" +
"\t\t\t\"taxPercent\": null,\n" +
"\t\t\t\"reason\": \"REMISE VOLUME\",\n" +
"\t\t\t\"reasonCode\": \"71\",\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1,\n" +
"\t\t\t\"taxPercent\": null,\n" +
"\t\t\t\"reason\": null,\n" +
"\t\t\t\"reasonCode\": \"100\",\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1.4,\n" +
"\t\t\t\"taxPercent\": 20,\n" +
"\t\t\t\"reason\": \"REMISE COMMERCIALE\",\n" +
"\t\t\t\"reasonCode\": \"100\",\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1.2,\n" +
"\t\t\t\"taxPercent\": 10,\n" +
"\t\t\t\"reason\": \"REMISE COMMERCIALE\",\n" +
"\t\t\t\"reasonCode\": \"100\",\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t}\n" +
" ],\n" +
"\t\t\"zfcharges\": [\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1,\n" +
"\t\t\t\"taxPercent\": null,\n" +
"\t\t\t\"reason\": \"FRAIS PALETTE\",\n" +
"\t\t\t\"reasonCode\": null,\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1,\n" +
"\t\t\t\"taxPercent\": null,\n" +
"\t\t\t\"reason\": \"FRAIS PALETTE\",\n" +
"\t\t\t\"reasonCode\": null,\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1,\n" +
"\t\t\t\"taxPercent\": null,\n" +
"\t\t\t\"reason\": \"FRAIS PALETTE\",\n" +
"\t\t\t\"reasonCode\": null,\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1,\n" +
"\t\t\t\"taxPercent\": null,\n" +
"\t\t\t\"reason\": \"FRAIS PALETTE\",\n" +
"\t\t\t\"reasonCode\": null,\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1,\n" +
"\t\t\t\"taxPercent\": null,\n" +
"\t\t\t\"reason\": null,\n" +
"\t\t\t\"reasonCode\": \"ADL\",\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1,\n" +
"\t\t\t\"taxPercent\": null,\n" +
"\t\t\t\"reason\": \"FRAIS PALETTE\",\n" +
"\t\t\t\"reasonCode\": null,\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 1,\n" +
"\t\t\t\"taxPercent\": null,\n" +
"\t\t\t\"reason\": \"FRAIS PALETTE\",\n" +
"\t\t\t\"reasonCode\": null,\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 2.8,\n" +
"\t\t\t\"taxPercent\": 20,\n" +
"\t\t\t\"reason\": \"FRAIS DEPLACEMENT\",\n" +
"\t\t\t\"reasonCode\": \"FC\",\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"percent\": null,\n" +
"\t\t\t\"totalAmount\": 0.6,\n" +
"\t\t\t\"taxPercent\": 10,\n" +
"\t\t\t\"reason\": \"FRAIS DEPLACEMENT\",\n" +
"\t\t\t\"reasonCode\": \"ADR\",\n" +
"\t\t\t\"categoryCode\": \"S\"\n" +
"\t\t}\n" +
" ],\n" +
"\t\t\"tradeSettlement\": [\n" +
"\t\t{\n" +
"\t\t\t\"accountName\": null,\n" +
"\t\t\t\"iban\": \"FR20 1254 2547 2569 8542 5874 698\",\n" +
"\t\t\t\"bic\": \"BIC_MONCOMPTE\"\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"mandate\": \"MANDATE PT\",\n" +
"\t\t\t\"iban\": \"FR20 1254 2547 2569 8542 5874 698\"\n" +
"\t\t}\n" +
" ],\n" +
"\t\t\"zfitems\": [\n" +
"\t\t{\n" +
"\t\t\t\"price\": 60,\n" +
"\t\t\t\"quantity\": 1,\n" +
"\t\t\t\"basisQuantity\": 1,\n" +
"\t\t\t\"product\": {\n" +
"\t\t\t\"unit\": \"C62\",\n" +
"\t\t\t\t\"name\": \"REMBOURSEMENT AFFRANCHISSEMENT\",\n" +
"\t\t\t\t\"description\": \"Description\",\n" +
"\t\t\t\t\"taxCategoryCode\": \"Z\",\n" +
"\t\t\t\t\"vatpercent\": 0,\n" +
"\t\t\t\t\"reverseCharge\": false,\n" +
"\t\t\t\t\"intraCommunitySupply\": false,\n" +
"\t\t\t\t\"globalID\": \"598785412598745\",\n" +
"\t\t\t\t\"globalIDScheme\": \"0160\"\n" +
"\t\t},\n" +
"\t\t\t\"buyerOrderReferencedDocumentLineID\": \"1\",\n" +
"\t\t\t\"value\": 60\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"price\": 30,\n" +
"\t\t\t\"quantity\": 3,\n" +
"\t\t\t\"basisQuantity\": 3,\n" +
"\t\t\t\"product\": {\n" +
"\t\t\t\"unit\": \"C62\",\n" +
"\t\t\t\t\"name\": \"FOURNITURES DIVERSES\",\n" +
"\t\t\t\t\"description\": \"Description\",\n" +
"\t\t\t\t\"taxCategoryCode\": \"S\",\n" +
"\t\t\t\t\"vatpercent\": 20,\n" +
"\t\t\t\t\"reverseCharge\": false,\n" +
"\t\t\t\t\"intraCommunitySupply\": false\n" +
"\t\t},\n" +
"\t\t\t\"buyerOrderReferencedDocumentLineID\": \"3\",\n" +
"\t\t\t\"value\": 30\n" +
"\t\t},\n" +
"\t\t{\n" +
"\t\t\t\"price\": 12,\n" +
"\t\t\t\"quantity\": 1,\n" +
"\t\t\t\"basisQuantity\": 1,\n" +
"\t\t\t\"product\": {\n" +
"\t\t\t\"unit\": \"C62\",\n" +
"\t\t\t\t\"name\": \"APPEL\",\n" +
"\t\t\t\t\"description\": \"Description\",\n" +
"\t\t\t\t\"taxCategoryCode\": \"S\",\n" +
"\t\t\t\t\"vatpercent\": 10,\n" +
"\t\t\t\t\"reverseCharge\": false,\n" +
"\t\t\t\t\"intraCommunitySupply\": false\n" +
"\t\t},\n" +
"\t\t\t\"buyerOrderReferencedDocumentLineID\": \"2\",\n" +
"\t\t\t\"value\": 12\n" +
"\t\t}\n" +
" ],\n" +
"\t\t\"ownStreet\": \"35 rue d'ici\",\n" +
"\t\t\"ownCountry\": \"FR\",\n" +
"\t\t\"ownZIP\": \"75018\",\n" +
"\t\t\"ownLocation\": \"PARIS\",\n" +
"\t\t\"ownVATID\": \"FR11123456782\",\n" +
"\t\t\"valid\": false\n" +
"\t}\n", Invoice.class);
ZUGFeRD2PullProvider zf2p = new ZUGFeRD2PullProvider();
zf2p.setProfile(Profiles.getByName("XRechnung"));
zf2p.generateXML(fromJSON);
theXML = new String(zf2p.getXML());
} catch (Exception e) {
exceptions = true;
}
assertTrue(theXML.contains("pour frais de recouvrement en cas de retard de paiement"));
assertFalse(exceptions);
}
} }

View File

@@ -461,11 +461,14 @@ this would test if for all elements/attributes
assertTrue(isBD); assertTrue(isBD);
BigDecimal expectedPrepaid=new BigDecimal(50); BigDecimal expectedPrepaid=new BigDecimal(50);
BigDecimal expectedLineTotal=new BigDecimal("180.76"); BigDecimal expectedLineTotal=new BigDecimal("180.76");
BigDecimal expectedDue=new BigDecimal("147.65");
if (isBD) { if (isBD) {
BigDecimal amread=invoice.getTotalPrepaidAmount(); BigDecimal amread=invoice.getTotalPrepaidAmount();
BigDecimal amline=invoice.getLineTotalAmount(); BigDecimal importedLineTotal=invoice.getLineTotalAmount();
BigDecimal importedDuePayable=invoice.getDuePayable();
assertTrue(amread.compareTo(expectedPrepaid) == 0); assertTrue(amread.compareTo(expectedPrepaid) == 0);
assertTrue(amline.compareTo(expectedLineTotal) == 0); assertTrue(importedLineTotal.compareTo(expectedLineTotal) == 0);
assertTrue(importedDuePayable.compareTo(expectedDue) == 0);
} }
} }