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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 += "</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();
|
||||
|
||||
@@ -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;
|
||||
@@ -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,7 +290,7 @@ 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()
|
||||
.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);
|
||||
@@ -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());
|
||||
@@ -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