Issue #458 Allow multiple PaymentTerms for in Invoice
This commit is contained in:
@@ -28,6 +28,7 @@ import org.mustangproject.ZUGFeRD.*;
|
|||||||
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
|
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
@@ -56,7 +57,7 @@ public class Invoice implements IExportableTransaction {
|
|||||||
|
|
||||||
protected ArrayList<IZUGFeRDAllowanceCharge> Allowances = new ArrayList<>(),
|
protected ArrayList<IZUGFeRDAllowanceCharge> Allowances = new ArrayList<>(),
|
||||||
Charges = new ArrayList<>(), LogisticsServiceCharges = new ArrayList<>();
|
Charges = new ArrayList<>(), LogisticsServiceCharges = new ArrayList<>();
|
||||||
protected IZUGFeRDPaymentTerms paymentTerms = null;
|
protected IZUGFeRDPaymentTerms[] paymentTerms = null;
|
||||||
|
|
||||||
protected String invoiceReferencedDocumentID = null;
|
protected String invoiceReferencedDocumentID = null;
|
||||||
protected Date invoiceReferencedIssueDate;
|
protected Date invoiceReferencedIssueDate;
|
||||||
@@ -641,15 +642,22 @@ public class Invoice implements IExportableTransaction {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IZUGFeRDPaymentTerms getPaymentTerms() {
|
public IZUGFeRDPaymentTerms[] getPaymentTerms() {
|
||||||
return paymentTerms;
|
return paymentTerms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Invoice setPaymentTerms(IZUGFeRDPaymentTerms paymentTerms) {
|
@JsonProperty
|
||||||
|
public Invoice setPaymentTerms(IZUGFeRDPaymentTerms[] paymentTerms) {
|
||||||
this.paymentTerms = paymentTerms;
|
this.paymentTerms = paymentTerms;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Invoice setPaymentTerms(IZUGFeRDPaymentTerms paymentTerms) {
|
||||||
|
this.paymentTerms = new IZUGFeRDPaymentTerms[] { paymentTerms };
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TradeParty getDeliveryAddress() {
|
public TradeParty getDeliveryAddress() {
|
||||||
return deliveryAddress;
|
return deliveryAddress;
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ public interface IExportableTransaction {
|
|||||||
*
|
*
|
||||||
* @return the IZUGFeRDPaymentTerms of the invoice
|
* @return the IZUGFeRDPaymentTerms of the invoice
|
||||||
*/
|
*/
|
||||||
default IZUGFeRDPaymentTerms getPaymentTerms() {
|
default IZUGFeRDPaymentTerms[] getPaymentTerms() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -505,15 +505,21 @@ public class OXPullProvider extends ZUGFeRD2PullProvider {
|
|||||||
|
|
||||||
private String buildPaymentTermsXml() {
|
private String buildPaymentTermsXml() {
|
||||||
|
|
||||||
final IZUGFeRDPaymentTerms paymentTerms = trans.getPaymentTerms();
|
final IZUGFeRDPaymentTerms[] paymentTerms = trans.getPaymentTerms();
|
||||||
if (paymentTerms == null) {
|
|
||||||
|
String paymentTermsXml = "";
|
||||||
|
if (paymentTerms == null || paymentTerms.length == 0) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
String paymentTermsXml = "<ram:SpecifiedTradePaymentTerms>";
|
|
||||||
|
|
||||||
final IZUGFeRDPaymentDiscountTerms discountTerms = paymentTerms.getDiscountTerms();
|
for (IZUGFeRDPaymentTerms pt : paymentTerms)
|
||||||
paymentTermsXml += "<ram:Description>" + paymentTerms.getDescription() + "</ram:Description>";
|
{
|
||||||
if (discountTerms != null) {
|
paymentTermsXml += "<ram:SpecifiedTradePaymentTerms>";
|
||||||
|
|
||||||
|
final IZUGFeRDPaymentDiscountTerms discountTerms = pt.getDiscountTerms();
|
||||||
|
paymentTermsXml += "<ram:Description>" + pt.getDescription() + "</ram:Description>";
|
||||||
|
if (discountTerms != null)
|
||||||
|
{
|
||||||
paymentTermsXml += "<ram:ApplicableTradePaymentDiscountTerms>";
|
paymentTermsXml += "<ram:ApplicableTradePaymentDiscountTerms>";
|
||||||
final String currency = trans.getCurrency();
|
final String currency = trans.getCurrency();
|
||||||
final String basisAmount = currencyFormat(calc.getGrandTotal());
|
final String basisAmount = currencyFormat(calc.getGrandTotal());
|
||||||
@@ -521,7 +527,8 @@ public class OXPullProvider extends ZUGFeRD2PullProvider {
|
|||||||
paymentTermsXml += "<ram:CalculationPercent>" + discountTerms.getCalculationPercentage().toString()
|
paymentTermsXml += "<ram:CalculationPercent>" + discountTerms.getCalculationPercentage().toString()
|
||||||
+ "</ram:CalculationPercent>";
|
+ "</ram:CalculationPercent>";
|
||||||
|
|
||||||
if (discountTerms.getBaseDate() != null) {
|
if (discountTerms.getBaseDate() != null)
|
||||||
|
{
|
||||||
final Date baseDate = discountTerms.getBaseDate();
|
final Date baseDate = discountTerms.getBaseDate();
|
||||||
paymentTermsXml += "<ram:BasisDateTime>";
|
paymentTermsXml += "<ram:BasisDateTime>";
|
||||||
paymentTermsXml += DATE.udtFormat(baseDate);
|
paymentTermsXml += DATE.udtFormat(baseDate);
|
||||||
@@ -535,6 +542,7 @@ public class OXPullProvider extends ZUGFeRD2PullProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
paymentTermsXml += "</ram:SpecifiedTradePaymentTerms>";
|
paymentTermsXml += "</ram:SpecifiedTradePaymentTerms>";
|
||||||
|
}
|
||||||
return paymentTermsXml;
|
return paymentTermsXml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -433,23 +433,34 @@ public class ZUGFeRD1PullProvider extends ZUGFeRD2PullProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String buildPaymentTermsXml() {
|
private String buildPaymentTermsXml() {
|
||||||
String paymentTermsXml = "<ram:SpecifiedTradePaymentTerms>";
|
final IZUGFeRDPaymentTerms[] paymentTerms = trans.getPaymentTerms();
|
||||||
|
|
||||||
final IZUGFeRDPaymentTerms paymentTerms = trans.getPaymentTerms();
|
String paymentTermsXml = "";
|
||||||
final IZUGFeRDPaymentDiscountTerms discountTerms = paymentTerms.getDiscountTerms();
|
if (paymentTerms == null || paymentTerms.length == 0) {
|
||||||
final Date dueDate = paymentTerms.getDueDate();
|
return paymentTermsXml;
|
||||||
if (dueDate != null && discountTerms != null && discountTerms.getBaseDate() != null) {
|
}
|
||||||
|
|
||||||
|
for (IZUGFeRDPaymentTerms pt : paymentTerms)
|
||||||
|
{
|
||||||
|
paymentTermsXml += "<ram:SpecifiedTradePaymentTerms>";
|
||||||
|
|
||||||
|
final IZUGFeRDPaymentDiscountTerms discountTerms = pt.getDiscountTerms();
|
||||||
|
final Date dueDate = pt.getDueDate();
|
||||||
|
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>" + pt.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 (discountTerms != null) {
|
if (discountTerms != null)
|
||||||
|
{
|
||||||
paymentTermsXml += "<ram:ApplicableTradePaymentDiscountTerms>";
|
paymentTermsXml += "<ram:ApplicableTradePaymentDiscountTerms>";
|
||||||
final String currency = trans.getCurrency();
|
final String currency = trans.getCurrency();
|
||||||
final String basisAmount = currencyFormat(calc.getGrandTotal());
|
final String basisAmount = currencyFormat(calc.getGrandTotal());
|
||||||
@@ -457,7 +468,8 @@ public class ZUGFeRD1PullProvider extends ZUGFeRD2PullProvider {
|
|||||||
paymentTermsXml += "<ram:CalculationPercent>" + discountTerms.getCalculationPercentage().toString()
|
paymentTermsXml += "<ram:CalculationPercent>" + discountTerms.getCalculationPercentage().toString()
|
||||||
+ "</ram:CalculationPercent>";
|
+ "</ram:CalculationPercent>";
|
||||||
|
|
||||||
if (discountTerms.getBaseDate() != null) {
|
if (discountTerms.getBaseDate() != null)
|
||||||
|
{
|
||||||
final Date baseDate = discountTerms.getBaseDate();
|
final Date baseDate = discountTerms.getBaseDate();
|
||||||
paymentTermsXml += "<ram:BasisDateTime>";
|
paymentTermsXml += "<ram:BasisDateTime>";
|
||||||
paymentTermsXml += DATE.udtFormat(baseDate);
|
paymentTermsXml += DATE.udtFormat(baseDate);
|
||||||
@@ -471,6 +483,7 @@ public class ZUGFeRD1PullProvider extends ZUGFeRD2PullProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
paymentTermsXml += "</ram:SpecifiedTradePaymentTerms>";
|
paymentTermsXml += "</ram:SpecifiedTradePaymentTerms>";
|
||||||
|
}
|
||||||
return paymentTermsXml;
|
return paymentTermsXml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -963,35 +963,47 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String buildPaymentTermsXml() {
|
private String buildPaymentTermsXml() {
|
||||||
final IZUGFeRDPaymentTerms paymentTerms = trans.getPaymentTerms();
|
final IZUGFeRDPaymentTerms[] paymentTerms = trans.getPaymentTerms();
|
||||||
if (paymentTerms == null) {
|
|
||||||
|
String paymentTermsXml = "";
|
||||||
|
if (paymentTerms == null || paymentTerms.length == 0) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
String paymentTermsXml = "<ram:SpecifiedTradePaymentTerms>";
|
|
||||||
|
|
||||||
final IZUGFeRDPaymentDiscountTerms discountTerms = paymentTerms.getDiscountTerms();
|
for (IZUGFeRDPaymentTerms pt : paymentTerms)
|
||||||
final Date dueDate = paymentTerms.getDueDate();
|
{
|
||||||
if (dueDate != null && discountTerms != null && discountTerms.getBaseDate() != null) {
|
|
||||||
|
paymentTermsXml += "<ram:SpecifiedTradePaymentTerms>";
|
||||||
|
|
||||||
|
final IZUGFeRDPaymentDiscountTerms discountTerms = pt.getDiscountTerms();
|
||||||
|
final Date dueDate = pt.getDueDate();
|
||||||
|
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>" + pt.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) {
|
if (trans.getTradeSettlement() != null)
|
||||||
for (final IZUGFeRDTradeSettlement payment : trans.getTradeSettlement()) {
|
{
|
||||||
if ((payment != null) && (payment instanceof IZUGFeRDTradeSettlementDebit)) {
|
for (final IZUGFeRDTradeSettlement payment : trans.getTradeSettlement())
|
||||||
|
{
|
||||||
|
if ((payment != null) && (payment instanceof IZUGFeRDTradeSettlementDebit))
|
||||||
|
{
|
||||||
paymentTermsXml += payment.getPaymentXML();
|
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();
|
||||||
final String basisAmount = currencyFormat(calc.getGrandTotal());
|
final String basisAmount = currencyFormat(calc.getGrandTotal());
|
||||||
@@ -999,7 +1011,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
paymentTermsXml += "<ram:CalculationPercent>" + discountTerms.getCalculationPercentage().toString()
|
paymentTermsXml += "<ram:CalculationPercent>" + discountTerms.getCalculationPercentage().toString()
|
||||||
+ "</ram:CalculationPercent>";
|
+ "</ram:CalculationPercent>";
|
||||||
|
|
||||||
if (discountTerms.getBaseDate() != null) {
|
if (discountTerms.getBaseDate() != null)
|
||||||
|
{
|
||||||
final Date baseDate = discountTerms.getBaseDate();
|
final Date baseDate = discountTerms.getBaseDate();
|
||||||
paymentTermsXml += "<ram:BasisDateTime>";
|
paymentTermsXml += "<ram:BasisDateTime>";
|
||||||
paymentTermsXml += DATE.udtFormat(baseDate);
|
paymentTermsXml += DATE.udtFormat(baseDate);
|
||||||
@@ -1013,6 +1026,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
paymentTermsXml += "</ram:SpecifiedTradePaymentTerms>";
|
paymentTermsXml += "</ram:SpecifiedTradePaymentTerms>";
|
||||||
|
}
|
||||||
return paymentTermsXml;
|
return paymentTermsXml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ public class ZF2EdgeTest extends MustangReaderTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IZUGFeRDPaymentTerms getPaymentTerms() {
|
public IZUGFeRDPaymentTerms[] getPaymentTerms() {
|
||||||
PaymentDiscountTerms paymentDiscountTerms =
|
PaymentDiscountTerms paymentDiscountTerms =
|
||||||
new PaymentDiscountTerms(
|
new PaymentDiscountTerms(
|
||||||
new BigDecimal(2), // skonto prozent
|
new BigDecimal(2), // skonto prozent
|
||||||
@@ -240,13 +240,13 @@ public class ZF2EdgeTest extends MustangReaderTestCase {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
return
|
return new IZUGFeRDPaymentTerms[]{
|
||||||
new PaymentTerms(
|
new PaymentTerms(
|
||||||
"14 Tage 2% Skonto, 30 Tage rein netto",
|
"14 Tage 2% Skonto, 30 Tage rein netto",
|
||||||
due,// fälligkeitsdatum
|
due,// fälligkeitsdatum
|
||||||
paymentDiscountTerms //PaymentDiscountTerms
|
paymentDiscountTerms //PaymentDiscountTerms
|
||||||
);
|
)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ public class ZF2Test extends MustangReaderTestCase {
|
|||||||
try {
|
try {
|
||||||
assertEquals(zi.getVersion(), 2);
|
assertEquals(zi.getVersion(), 2);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TCalODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user