edge test cash discount
This commit is contained in:
@@ -461,7 +461,7 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
|
|||||||
if (trans.getTradeSettlement() != null) {
|
if (trans.getTradeSettlement() != null) {
|
||||||
for (final IZUGFeRDTradeSettlement payment : trans.getTradeSettlement()) {
|
for (final IZUGFeRDTradeSettlement payment : trans.getTradeSettlement()) {
|
||||||
if ((payment != null) && (payment instanceof IZUGFeRDTradeSettlementDebit)) {
|
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() {
|
private String buildPaymentTermsXml() {
|
||||||
|
|
||||||
final IZUGFeRDPaymentTerms paymentTerms = trans.getPaymentTerms();
|
final IZUGFeRDPaymentTerms paymentTerms = trans.getPaymentTerms();
|
||||||
if (paymentTerms == null) {
|
if (paymentTerms == null) {
|
||||||
return "";
|
return "";
|
||||||
@@ -714,18 +713,27 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
String paymentTermsXml = "<ram:SpecifiedTradePaymentTerms>";
|
String paymentTermsXml = "<ram:SpecifiedTradePaymentTerms>";
|
||||||
|
|
||||||
final IZUGFeRDPaymentDiscountTerms discountTerms = paymentTerms.getDiscountTerms();
|
final IZUGFeRDPaymentDiscountTerms discountTerms = paymentTerms.getDiscountTerms();
|
||||||
final Date dueDate = paymentTerms.getDueDate();
|
Date dueDate = paymentTerms.getDueDate();
|
||||||
if (dueDate != null && discountTerms != null && discountTerms.getBaseDate() != null) {
|
if (dueDate != null && discountTerms != null && discountTerms.getBaseDate() != null) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"if paymentTerms.dueDate is specified, paymentTerms.discountTerms.baseDate has not to be specified");
|
"if paymentTerms.dueDate is specified, paymentTerms.discountTerms.baseDate has not to be specified");
|
||||||
}
|
}
|
||||||
paymentTermsXml += "<ram:Description>" + paymentTerms.getDescription() + "</ram:Description>";
|
paymentTermsXml += "<ram:Description>" + paymentTerms.getDescription() + "</ram:Description>";
|
||||||
|
|
||||||
if (dueDate != null) {
|
if (dueDate != null) {
|
||||||
paymentTermsXml += "<ram:DueDateDateTime>";
|
paymentTermsXml += "<ram:DueDateDateTime>";
|
||||||
paymentTermsXml += DATE.udtFormat(dueDate);
|
paymentTermsXml += DATE.udtFormat(dueDate);
|
||||||
paymentTermsXml += "</ram:DueDateDateTime>";
|
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) {
|
if (discountTerms != null) {
|
||||||
paymentTermsXml += "<ram:ApplicableTradePaymentDiscountTerms>";
|
paymentTermsXml += "<ram:ApplicableTradePaymentDiscountTerms>";
|
||||||
final String currency = trans.getCurrency();
|
final String currency = trans.getCurrency();
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -211,6 +212,31 @@ public class ZF2EdgeTest extends MustangReaderTestCase implements IExportableTra
|
|||||||
return "Zahlbar ohne Abzug bis zum " + germanDateFormat.format(getDueDate());
|
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
|
@Override
|
||||||
public IZUGFeRDAllowanceCharge[] getZFAllowances() {
|
public IZUGFeRDAllowanceCharge[] getZFAllowances() {
|
||||||
return null;
|
return null;
|
||||||
@@ -264,7 +290,7 @@ public class ZF2EdgeTest extends MustangReaderTestCase implements IExportableTra
|
|||||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
|
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
|
||||||
|
|
||||||
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application")
|
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)) {
|
.load(SOURCE_PDF)) {
|
||||||
ze.setTransaction(this);
|
ze.setTransaction(this);
|
||||||
String theXML = new String(ze.getProvider().getXML(), StandardCharsets.UTF_8);
|
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)
|
// now check the contents (like MustangReaderTest)
|
||||||
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF);
|
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF);
|
||||||
|
String resultXML=zi.getUTF8();
|
||||||
assertTrue(zi.getUTF8().contains("<ram:TypeCode>59</ram:TypeCode>"));
|
assertTrue(resultXML.contains("<ram:TypeCode>59</ram:TypeCode>"));
|
||||||
assertTrue(zi.getUTF8().contains("<ram:ShipToTradeParty>"));
|
assertTrue(resultXML.contains("<ram:ShipToTradeParty>"));
|
||||||
assertTrue(zi.getUTF8().contains("<ram:IBANID>DE540815</ram:IBANID>"));
|
assertTrue(resultXML.contains("<ram:IBANID>DE540815</ram:IBANID>"));
|
||||||
assertTrue(zi.getUTF8().contains("<ram:DirectDebitMandateID>DE99XX12345</ram:DirectDebitMandateID>"));
|
assertTrue(resultXML.contains("<ram:ApplicableTradePaymentDiscountTerms"));
|
||||||
assertFalse(zi.getUTF8().contains("<ram:DueDateDateTime>"));
|
assertTrue(resultXML.contains("<ram:DirectDebitMandateID>DE99XX12345</ram:DirectDebitMandateID>"));
|
||||||
assertFalse(zi.getUTF8().contains("EUR"));
|
assertTrue(resultXML.contains("<ram:DueDateDateTime>"));
|
||||||
assertTrue(zi.getUTF8().contains("USD"));//currency should be USD, test for #150
|
assertFalse(resultXML.contains("EUR"));
|
||||||
|
assertTrue(resultXML.contains("USD"));//currency should be USD, test for #150
|
||||||
|
|
||||||
// Reading ZUGFeRD
|
// Reading ZUGFeRD
|
||||||
assertEquals("496.00", zi.getAmount());
|
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");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
try {
|
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())
|
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))
|
.setDetailedDeliveryPeriod(new SimpleDateFormat("yyyyMMdd").parse(occurrenceFrom), new SimpleDateFormat("yyyyMMdd").parse(occurrenceTo))
|
||||||
.setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID(taxID).setID("0009845"))
|
.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)
|
// now check the contents (like MustangReaderTest)
|
||||||
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PUSHEDGE);
|
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("Hinterhaus"));
|
||||||
assertTrue(zi.getUTF8().contains("0009845"));
|
assertTrue(zi.getUTF8().contains("0009845"));
|
||||||
assertTrue(zi.getUTF8().contains("0008734"));
|
assertTrue(zi.getUTF8().contains("0008734"));
|
||||||
|
|||||||
@@ -122,7 +122,7 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
<plugins>
|
<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>
|
<plugin>
|
||||||
<groupId>com.helger.maven</groupId>
|
<groupId>com.helger.maven</groupId>
|
||||||
<artifactId>ph-schematron-maven-plugin</artifactId>
|
<artifactId>ph-schematron-maven-plugin</artifactId>
|
||||||
@@ -139,6 +139,7 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
-->
|
||||||
|
|
||||||
<!-- allow getImplementationVersion for the pom.xml -->
|
<!-- allow getImplementationVersion for the pom.xml -->
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|||||||
Reference in New Issue
Block a user