edge test cash discount
This commit is contained in:
@@ -461,7 +461,7 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
|
||||
if (trans.getTradeSettlement() != null) {
|
||||
for (final IZUGFeRDTradeSettlement payment : trans.getTradeSettlement()) {
|
||||
if ((payment != null) && (payment instanceof IZUGFeRDTradeSettlementDebit)) {
|
||||
// xml += payment.getPaymentXML();
|
||||
//not in order-x xml += payment.getPaymentXML();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.mustangproject.XMLTools;
|
||||
|
||||
public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
|
||||
protected byte[] zugferdData;
|
||||
protected byte[] zugferdData;
|
||||
protected IExportableTransaction trans;
|
||||
protected TransactionCalculator calc;
|
||||
private String paymentTermsDescription;
|
||||
@@ -130,10 +130,10 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
}
|
||||
xml += " <ram:Name>" + XMLTools.encodeXML(party.getName()) + "</ram:Name>\n";
|
||||
|
||||
if (party.getLegalOrganisation()!=null) {
|
||||
xml += "<ram:SpecifiedLegalOrganization> ";
|
||||
xml += " <ram:ID schemeID=\""+XMLTools.encodeXML(party.getLegalOrganisation().getSchemeID())+"\">"+XMLTools.encodeXML(party.getLegalOrganisation().getID())+"</ram:ID>";
|
||||
xml += "</ram:SpecifiedLegalOrganization>";
|
||||
if (party.getLegalOrganisation() != null) {
|
||||
xml += "<ram:SpecifiedLegalOrganization> ";
|
||||
xml += " <ram:ID schemeID=\"" + XMLTools.encodeXML(party.getLegalOrganisation().getSchemeID()) + "\">" + XMLTools.encodeXML(party.getLegalOrganisation().getID()) + "</ram:ID>";
|
||||
xml += "</ram:SpecifiedLegalOrganization>";
|
||||
}
|
||||
|
||||
if ((party.getContact() != null) && (isSender || profile == Profiles.getByName("Extended") || profile == Profiles.getByName("XRechnung"))) {
|
||||
@@ -488,9 +488,9 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
|
||||
if (trans.getSpecifiedProcuringProjectID() != null) {
|
||||
xml = xml + " <ram:SpecifiedProcuringProject>\n"
|
||||
+ " <ram:ID>"
|
||||
+ XMLTools.encodeXML(trans.getSpecifiedProcuringProjectID()) + "</ram:ID>\n";
|
||||
if(trans.getSpecifiedProcuringProjectName()!= null) {
|
||||
+ " <ram:ID>"
|
||||
+ XMLTools.encodeXML(trans.getSpecifiedProcuringProjectID()) + "</ram:ID>\n";
|
||||
if (trans.getSpecifiedProcuringProjectName() != null) {
|
||||
xml += " <ram:Name >" + XMLTools.encodeXML(trans.getSpecifiedProcuringProjectName()) + "</ram:Name>\n";
|
||||
}
|
||||
xml += " </ram:SpecifiedProcuringProject>\n";
|
||||
@@ -507,7 +507,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
+ " <ram:OccurrenceDateTime>";
|
||||
|
||||
if (trans.getDeliveryDate() != null) {
|
||||
xml += DATE.udtFormat(trans.getDeliveryDate());
|
||||
xml += DATE.udtFormat(trans.getDeliveryDate());
|
||||
} else {
|
||||
throw new IllegalStateException("No delivery date provided");
|
||||
}
|
||||
@@ -669,10 +669,10 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
xml = xml + " <ram:InvoiceReferencedDocument>\n"
|
||||
+ " <ram:IssuerAssignedID>"
|
||||
+ XMLTools.encodeXML(trans.getInvoiceReferencedDocumentID()) + "</ram:IssuerAssignedID>\n";
|
||||
if(trans.getInvoiceReferencedIssueDate()!= null){
|
||||
xml += "<ram:FormattedIssueDateTime>"
|
||||
+ DATE.qdtFormat(trans.getInvoiceReferencedIssueDate())
|
||||
+ "</ram:FormattedIssueDateTime>\n";
|
||||
if (trans.getInvoiceReferencedIssueDate() != null) {
|
||||
xml += "<ram:FormattedIssueDateTime>"
|
||||
+ DATE.qdtFormat(trans.getInvoiceReferencedIssueDate())
|
||||
+ "</ram:FormattedIssueDateTime>\n";
|
||||
}
|
||||
xml += " </ram:InvoiceReferencedDocument>\n";
|
||||
}
|
||||
@@ -706,7 +706,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
}
|
||||
|
||||
private String buildPaymentTermsXml() {
|
||||
|
||||
final IZUGFeRDPaymentTerms paymentTerms = trans.getPaymentTerms();
|
||||
if (paymentTerms == null) {
|
||||
return "";
|
||||
@@ -714,18 +713,27 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
String paymentTermsXml = "<ram:SpecifiedTradePaymentTerms>";
|
||||
|
||||
final IZUGFeRDPaymentDiscountTerms discountTerms = paymentTerms.getDiscountTerms();
|
||||
final Date dueDate = paymentTerms.getDueDate();
|
||||
Date dueDate = paymentTerms.getDueDate();
|
||||
if (dueDate != null && discountTerms != null && discountTerms.getBaseDate() != null) {
|
||||
throw new IllegalStateException(
|
||||
"if paymentTerms.dueDate is specified, paymentTerms.discountTerms.baseDate has not to be specified");
|
||||
}
|
||||
paymentTermsXml += "<ram:Description>" + paymentTerms.getDescription() + "</ram:Description>";
|
||||
|
||||
if (dueDate != null) {
|
||||
paymentTermsXml += "<ram:DueDateDateTime>";
|
||||
paymentTermsXml += DATE.udtFormat(dueDate) ;
|
||||
paymentTermsXml += DATE.udtFormat(dueDate);
|
||||
paymentTermsXml += "</ram:DueDateDateTime>";
|
||||
}
|
||||
|
||||
if (trans.getTradeSettlement() != null) {
|
||||
for (final IZUGFeRDTradeSettlement payment : trans.getTradeSettlement()) {
|
||||
if ((payment != null) && (payment instanceof IZUGFeRDTradeSettlementDebit)) {
|
||||
paymentTermsXml += payment.getPaymentXML();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (discountTerms != null) {
|
||||
paymentTermsXml += "<ram:ApplicableTradePaymentDiscountTerms>";
|
||||
final String currency = trans.getCurrency();
|
||||
@@ -737,7 +745,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
if (discountTerms.getBaseDate() != null) {
|
||||
final Date baseDate = discountTerms.getBaseDate();
|
||||
paymentTermsXml += "<ram:BasisDateTime>";
|
||||
paymentTermsXml += DATE.udtFormat(baseDate);
|
||||
paymentTermsXml += DATE.udtFormat(baseDate);
|
||||
paymentTermsXml += "</ram:BasisDateTime>";
|
||||
|
||||
paymentTermsXml += "<ram:BasisPeriodMeasure unitCode=\"" + discountTerms.getBasePeriodUnitCode() + "\">"
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@@ -172,7 +173,7 @@ public class ZF2EdgeTest extends MustangReaderTestCase implements IExportableTra
|
||||
public IZUGFeRDExportableTradeParty getRecipient() {
|
||||
return new RecipientTradeParty();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IZUGFeRDExportableTradeParty getDeliveryAddress() {
|
||||
return new RecipientTradeParty();
|
||||
@@ -194,7 +195,7 @@ public class ZF2EdgeTest extends MustangReaderTestCase implements IExportableTra
|
||||
EdgeProduct designProduct = new EdgeProduct("", "Künstlerische Gestaltung (Stunde): Einer Beispielrechnung",
|
||||
"HUR");
|
||||
EdgeProduct balloonProduct = new EdgeProduct("", "Bestellerweiterung für E&F Umbau", "C62");// test for issue
|
||||
// 103
|
||||
// 103
|
||||
EdgeProduct airProduct = new EdgeProduct("", "Heiße Luft pro Liter", "LTR");
|
||||
|
||||
Item design=new Item(new BigDecimal("160"), new BigDecimal("1"), designProduct);
|
||||
@@ -211,6 +212,31 @@ public class ZF2EdgeTest extends MustangReaderTestCase implements IExportableTra
|
||||
return "Zahlbar ohne Abzug bis zum " + germanDateFormat.format(getDueDate());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IZUGFeRDPaymentTerms getPaymentTerms() {
|
||||
PaymentDiscountTerms paymentDiscountTerms =
|
||||
new PaymentDiscountTerms(
|
||||
new BigDecimal(2), // skonto prozent
|
||||
null, // kein basedate
|
||||
14, // anzahl tage
|
||||
"DAYS");
|
||||
|
||||
Date due = null;
|
||||
try {
|
||||
due = new SimpleDateFormat("yyyyMMdd").parse("20220228");
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
return
|
||||
new PaymentTerms(
|
||||
"14 Tage 2% Skonto, 30 Tage rein netto",
|
||||
due,// fälligkeitsdatum
|
||||
paymentDiscountTerms //PaymentDiscountTerms
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IZUGFeRDAllowanceCharge[] getZFAllowances() {
|
||||
return null;
|
||||
@@ -264,8 +290,8 @@ public class ZF2EdgeTest extends MustangReaderTestCase implements IExportableTra
|
||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
|
||||
|
||||
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application")
|
||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
|
||||
.load(SOURCE_PDF)) {
|
||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).setProfile(Profiles.getByName("Extended")).ignorePDFAErrors()
|
||||
.load(SOURCE_PDF)) {
|
||||
ze.setTransaction(this);
|
||||
String theXML = new String(ze.getProvider().getXML(), StandardCharsets.UTF_8);
|
||||
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
||||
@@ -276,14 +302,15 @@ public class ZF2EdgeTest extends MustangReaderTestCase implements IExportableTra
|
||||
|
||||
// now check the contents (like MustangReaderTest)
|
||||
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF);
|
||||
|
||||
assertTrue(zi.getUTF8().contains("<ram:TypeCode>59</ram:TypeCode>"));
|
||||
assertTrue(zi.getUTF8().contains("<ram:ShipToTradeParty>"));
|
||||
assertTrue(zi.getUTF8().contains("<ram:IBANID>DE540815</ram:IBANID>"));
|
||||
assertTrue(zi.getUTF8().contains("<ram:DirectDebitMandateID>DE99XX12345</ram:DirectDebitMandateID>"));
|
||||
assertFalse(zi.getUTF8().contains("<ram:DueDateDateTime>"));
|
||||
assertFalse(zi.getUTF8().contains("EUR"));
|
||||
assertTrue(zi.getUTF8().contains("USD"));//currency should be USD, test for #150
|
||||
String resultXML=zi.getUTF8();
|
||||
assertTrue(resultXML.contains("<ram:TypeCode>59</ram:TypeCode>"));
|
||||
assertTrue(resultXML.contains("<ram:ShipToTradeParty>"));
|
||||
assertTrue(resultXML.contains("<ram:IBANID>DE540815</ram:IBANID>"));
|
||||
assertTrue(resultXML.contains("<ram:ApplicableTradePaymentDiscountTerms"));
|
||||
assertTrue(resultXML.contains("<ram:DirectDebitMandateID>DE99XX12345</ram:DirectDebitMandateID>"));
|
||||
assertTrue(resultXML.contains("<ram:DueDateDateTime>"));
|
||||
assertFalse(resultXML.contains("EUR"));
|
||||
assertTrue(resultXML.contains("USD"));//currency should be USD, test for #150
|
||||
|
||||
// Reading ZUGFeRD
|
||||
assertEquals("496.00", zi.getAmount());
|
||||
@@ -311,9 +338,9 @@ public class ZF2EdgeTest extends MustangReaderTestCase implements IExportableTra
|
||||
try (InputStream SOURCE_PDF = this.getClass()
|
||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505PDFA3.pdf");
|
||||
|
||||
IZUGFeRDExporter ze = new ZUGFeRDExporterFromA3().setProducer("My Application")
|
||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).disableFacturX()
|
||||
.load(SOURCE_PDF)) {
|
||||
IZUGFeRDExporter ze = new ZUGFeRDExporterFromA3().setProducer("My Application")
|
||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).disableFacturX()
|
||||
.load(SOURCE_PDF)) {
|
||||
ze.setTransaction(this);
|
||||
String theXML = new String(ze.getProvider().getXML(), StandardCharsets.UTF_8);
|
||||
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
||||
@@ -324,4 +351,67 @@ public class ZF2EdgeTest extends MustangReaderTestCase implements IExportableTra
|
||||
|
||||
}
|
||||
|
||||
private class PaymentDiscountTerms implements IZUGFeRDPaymentDiscountTerms {
|
||||
|
||||
protected BigDecimal percent;
|
||||
protected Date baseDate;
|
||||
protected int periodMeasure;
|
||||
protected String periodCode;
|
||||
|
||||
public PaymentDiscountTerms(BigDecimal percent, Date baseDate, int periodMeasure, String periodCode) {
|
||||
this.percent = percent;
|
||||
this.baseDate = baseDate;
|
||||
this.periodMeasure = periodMeasure;
|
||||
this.periodCode = periodCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getCalculationPercentage() {
|
||||
return percent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getBaseDate() {
|
||||
return baseDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBasePeriodMeasure() {
|
||||
return periodMeasure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBasePeriodUnitCode() {
|
||||
return periodCode;
|
||||
}
|
||||
}
|
||||
private class PaymentTerms implements IZUGFeRDPaymentTerms {
|
||||
|
||||
protected String description;
|
||||
protected Date duedate;
|
||||
protected IZUGFeRDPaymentDiscountTerms disco;
|
||||
|
||||
public PaymentTerms(String description, Date duedate, IZUGFeRDPaymentDiscountTerms disco) {
|
||||
this.description = description;
|
||||
this.duedate = duedate;
|
||||
this.disco = disco;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getDueDate() {
|
||||
return duedate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IZUGFeRDPaymentDiscountTerms getDiscountTerms() {
|
||||
return disco;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -371,6 +371,7 @@ public class ZF2PushTest extends TestCase {
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
|
||||
ze.setTransaction(new Invoice().setCurrency("CHF").addNote("document level 1/2").addNote("document level 2/2").setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date())
|
||||
.setDetailedDeliveryPeriod(new SimpleDateFormat("yyyyMMdd").parse(occurrenceFrom), new SimpleDateFormat("yyyyMMdd").parse(occurrenceTo))
|
||||
.setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID(taxID).setID("0009845"))
|
||||
@@ -396,6 +397,7 @@ public class ZF2PushTest extends TestCase {
|
||||
// now check the contents (like MustangReaderTest)
|
||||
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PUSHEDGE);
|
||||
|
||||
assertFalse(zi.getUTF8().contains("<ram:IBANID>")); // maybe add a direct debit mandate to the class in the future then this would fail
|
||||
assertTrue(zi.getUTF8().contains("Hinterhaus"));
|
||||
assertTrue(zi.getUTF8().contains("0009845"));
|
||||
assertTrue(zi.getUTF8().contains("0008734"));
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<!-- be able to generate XSLT from XRechnung Schematron: uncomment this and "mvn generate-resources" if you have 20min to spare-->
|
||||
<!-- be able to generate XSLT from XRechnung Schematron: uncomment this and "mvn generate-resources" if you have 20min to spare
|
||||
<plugin>
|
||||
<groupId>com.helger.maven</groupId>
|
||||
<artifactId>ph-schematron-maven-plugin</artifactId>
|
||||
@@ -139,6 +139,7 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
-->
|
||||
|
||||
<!-- allow getImplementationVersion for the pom.xml -->
|
||||
<plugin>
|
||||
|
||||
Reference in New Issue
Block a user