allow relative =percentual item allowances/charges
This commit is contained in:
@@ -9,8 +9,8 @@ public class Allowance extends Charge implements IZUGFeRDAllowanceCharge {
|
|||||||
public Allowance() {
|
public Allowance() {
|
||||||
|
|
||||||
}
|
}
|
||||||
public Allowance(BigDecimal totalAmount, BigDecimal taxPercent, String reason, String categoryCode) {
|
public Allowance(BigDecimal totalAmount) {
|
||||||
super(totalAmount, taxPercent, reason, categoryCode);
|
super(totalAmount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.mustangproject;
|
package org.mustangproject;
|
||||||
|
|
||||||
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
|
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
|
||||||
|
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
@@ -16,11 +17,12 @@ public class Charge implements IZUGFeRDAllowanceCharge {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Charge(BigDecimal totalAmount, BigDecimal taxPercent, String reason, String categoryCode) {
|
/***
|
||||||
|
* creates a item level or invoice level charge
|
||||||
|
* @param totalAmount (the absolute amount)
|
||||||
|
*/
|
||||||
|
public Charge(BigDecimal totalAmount) {
|
||||||
this.totalAmount = totalAmount;
|
this.totalAmount = totalAmount;
|
||||||
this.taxPercent = taxPercent;
|
|
||||||
this.reason = reason;
|
|
||||||
this.categoryCode = categoryCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -52,11 +54,21 @@ public class Charge implements IZUGFeRDAllowanceCharge {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal getTotalAmount() {
|
public BigDecimal getTotalAmount(IZUGFeRDExportableItem currentItem) {
|
||||||
return totalAmount;
|
if (totalAmount!=null) {
|
||||||
|
return totalAmount;
|
||||||
|
} else if (percent!=null) {
|
||||||
|
return currentItem.getPrice().multiply(getPercent().divide(new BigDecimal(100)));
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("Either totalAmount or percent must be set");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public BigDecimal getPercent() {
|
||||||
|
return percent;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal getTaxPercent() {
|
public BigDecimal getTaxPercent() {
|
||||||
return taxPercent;
|
return taxPercent;
|
||||||
|
|||||||
@@ -6,6 +6,12 @@ public class Contact implements IZUGFeRDExportableContact {
|
|||||||
|
|
||||||
protected String name,phone,email,zip,street,location,country;
|
protected String name,phone,email,zip,street,location,country;
|
||||||
|
|
||||||
|
public Contact(String name, String phone, String email) {
|
||||||
|
this.name = name;
|
||||||
|
this.phone = phone;
|
||||||
|
this.email = email;
|
||||||
|
|
||||||
|
}
|
||||||
public Contact(String name, String phone, String email, String street, String zip, String location, String country) {
|
public Contact(String name, String phone, String email, String street, String zip, String location, String country) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.phone = phone;
|
this.phone = phone;
|
||||||
|
|||||||
@@ -196,6 +196,11 @@ public class Invoice implements IExportableTransaction {
|
|||||||
return getSender().getTaxID();
|
return getSender().getTaxID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
/***
|
||||||
|
* @deprecated use TradeParty::addTaxID instead
|
||||||
|
*/
|
||||||
public Invoice setOwnTaxID(String ownTaxID) {
|
public Invoice setOwnTaxID(String ownTaxID) {
|
||||||
sender.addTaxID(ownTaxID);
|
sender.addTaxID(ownTaxID);
|
||||||
return this;
|
return this;
|
||||||
@@ -206,6 +211,10 @@ public class Invoice implements IExportableTransaction {
|
|||||||
return getSender().getVATID();
|
return getSender().getVATID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
/***
|
||||||
|
* @deprecated use TradeParty::addVATID instead
|
||||||
|
*/
|
||||||
public Invoice setOwnVATID(String ownVATID) {
|
public Invoice setOwnVATID(String ownVATID) {
|
||||||
sender.addVATID(ownVATID);
|
sender.addVATID(ownVATID);
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import java.math.BigDecimal;
|
|||||||
*/
|
*/
|
||||||
public interface IZUGFeRDAllowanceCharge {
|
public interface IZUGFeRDAllowanceCharge {
|
||||||
|
|
||||||
BigDecimal getTotalAmount();
|
BigDecimal getTotalAmount(IZUGFeRDExportableItem currentItem);
|
||||||
|
|
||||||
String getReason();
|
String getReason();
|
||||||
|
|
||||||
|
|||||||
@@ -8,19 +8,25 @@ public class LineCalc {
|
|||||||
private BigDecimal priceGross;
|
private BigDecimal priceGross;
|
||||||
private BigDecimal itemTotalNetAmount;
|
private BigDecimal itemTotalNetAmount;
|
||||||
private BigDecimal itemTotalVATAmount;
|
private BigDecimal itemTotalVATAmount;
|
||||||
private BigDecimal allowance=new BigDecimal(0);
|
private BigDecimal allowance = new BigDecimal(0);
|
||||||
|
private BigDecimal charge = new BigDecimal(0);
|
||||||
|
|
||||||
public LineCalc(IZUGFeRDExportableItem currentItem) {
|
public LineCalc(IZUGFeRDExportableItem currentItem) {
|
||||||
|
|
||||||
if (currentItem.getItemAllowances()!=null && currentItem.getItemAllowances().length>0) {
|
if (currentItem.getItemAllowances() != null && currentItem.getItemAllowances().length > 0) {
|
||||||
for (IZUGFeRDAllowanceCharge allowance:currentItem.getItemAllowances()) {
|
for (IZUGFeRDAllowanceCharge allowance : currentItem.getItemAllowances()) {
|
||||||
addAllowance(allowance.getTotalAmount());
|
addAllowance(allowance.getTotalAmount(currentItem));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (currentItem.getItemCharges() != null && currentItem.getItemCharges().length > 0) {
|
||||||
|
for (IZUGFeRDAllowanceCharge charge : currentItem.getItemCharges()) {
|
||||||
|
addCharge(charge.getTotalAmount(currentItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BigDecimal multiplicator = currentItem.getProduct().getVATPercent().divide(new BigDecimal(100))
|
BigDecimal multiplicator = currentItem.getProduct().getVATPercent().divide(new BigDecimal(100))
|
||||||
.add(new BigDecimal(1));
|
.add(new BigDecimal(1));
|
||||||
priceGross = currentItem.getPrice(); // see https://github.com/ZUGFeRD/mustangproject/issues/159
|
priceGross = currentItem.getPrice(); // see https://github.com/ZUGFeRD/mustangproject/issues/159
|
||||||
price = priceGross.subtract(allowance);
|
price = priceGross.subtract(allowance).add(charge);
|
||||||
totalGross = currentItem.getQuantity().multiply(getPrice()).divide(currentItem.getBasisQuantity())
|
totalGross = currentItem.getQuantity().multiply(getPrice()).divide(currentItem.getBasisQuantity())
|
||||||
.multiply(multiplicator);
|
.multiply(multiplicator);
|
||||||
itemTotalNetAmount = currentItem.getQuantity().multiply(getPrice()).divide(currentItem.getBasisQuantity())
|
itemTotalNetAmount = currentItem.getQuantity().multiply(getPrice()).divide(currentItem.getBasisQuantity())
|
||||||
@@ -49,9 +55,13 @@ public class LineCalc {
|
|||||||
public BigDecimal getPriceGross() {
|
public BigDecimal getPriceGross() {
|
||||||
return priceGross;
|
return priceGross;
|
||||||
}
|
}
|
||||||
public void addAllowance(BigDecimal b) {
|
|
||||||
allowance=b;
|
|
||||||
|
|
||||||
|
public void addAllowance(BigDecimal b) {
|
||||||
|
allowance = allowance.add(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCharge(BigDecimal b) {
|
||||||
|
charge = charge.add(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,23 @@
|
|||||||
/** **********************************************************************
|
/**
|
||||||
*
|
* *********************************************************************
|
||||||
|
* <p>
|
||||||
* Copyright 2018 Jochen Staerk
|
* Copyright 2018 Jochen Staerk
|
||||||
*
|
* <p>
|
||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
*
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
* use this file except in compliance with the License. You may obtain a copy
|
||||||
* of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
* of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
*
|
* <p>
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
*
|
* <p>
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
* <p>
|
||||||
*********************************************************************** */
|
* **********************************************************************
|
||||||
|
*/
|
||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -33,7 +35,6 @@ import org.dom4j.DocumentException;
|
|||||||
import org.dom4j.DocumentHelper;
|
import org.dom4j.DocumentHelper;
|
||||||
import org.dom4j.io.OutputFormat;
|
import org.dom4j.io.OutputFormat;
|
||||||
import org.dom4j.io.XMLWriter;
|
import org.dom4j.io.XMLWriter;
|
||||||
import org.mustangproject.Charge;
|
|
||||||
import org.mustangproject.XMLTools;
|
import org.mustangproject.XMLTools;
|
||||||
|
|
||||||
public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
||||||
@@ -160,7 +161,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
|
|
||||||
protected String getTradePartyAsXML(IZUGFeRDExportableTradeParty contact) {
|
protected String getTradePartyAsXML(IZUGFeRDExportableTradeParty contact) {
|
||||||
String xml = "";
|
String xml = "";
|
||||||
// According EN16931 either GlobalID or seller assigned ID might be present for BuyerTradeParty
|
// According EN16931 either GlobalID or seller assigned ID might be present for BuyerTradeParty
|
||||||
// and ShipToTradeParty, but not both. Prefer seller assigned ID for now.
|
// and ShipToTradeParty, but not both. Prefer seller assigned ID for now.
|
||||||
if (contact.getID()!=null) {
|
if (contact.getID()!=null) {
|
||||||
xml += " <ram:ID>" + XMLTools.encodeXML(contact.getID()) + "</ram:ID>\n";
|
xml += " <ram:ID>" + XMLTools.encodeXML(contact.getID()) + "</ram:ID>\n";
|
||||||
@@ -201,19 +202,19 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
public void generateXML(IExportableTransaction trans) {
|
public void generateXML(IExportableTransaction trans) {
|
||||||
this.trans = trans;
|
this.trans = trans;
|
||||||
|
|
||||||
boolean hasDueDate=false;
|
boolean hasDueDate = false;
|
||||||
String taxCategoryCode="";
|
String taxCategoryCode = "";
|
||||||
SimpleDateFormat germanDateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
SimpleDateFormat germanDateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
||||||
|
|
||||||
String exemptionReason="";
|
String exemptionReason = "";
|
||||||
|
|
||||||
if (trans.getPaymentTermDescription()!=null) {
|
if (trans.getPaymentTermDescription() != null) {
|
||||||
paymentTermsDescription=trans.getPaymentTermDescription();
|
paymentTermsDescription = trans.getPaymentTermDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paymentTermsDescription==null) {
|
if (paymentTermsDescription == null) {
|
||||||
paymentTermsDescription= "Zahlbar ohne Abzug bis " + germanDateFormat.format(trans.getDueDate());
|
paymentTermsDescription = "Zahlbar ohne Abzug bis " + germanDateFormat.format(trans.getDueDate());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String senderReg = "";
|
String senderReg = "";
|
||||||
@@ -232,15 +233,15 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String subjectNote = "";
|
String subjectNote = "";
|
||||||
if (trans.getSubjectNote()!=null) {
|
if (trans.getSubjectNote() != null) {
|
||||||
subjectNote = "<ram:IncludedNote>\n" + " <ram:Content>"
|
subjectNote = "<ram:IncludedNote>\n" + " <ram:Content>"
|
||||||
+ XMLTools.encodeXML(trans.getSubjectNote())+ "</ram:Content>\n"
|
+ XMLTools.encodeXML(trans.getSubjectNote()) + "</ram:Content>\n"
|
||||||
+ "</ram:IncludedNote>\n";
|
+ "</ram:IncludedNote>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
String typecode="380";
|
String typecode = "380";
|
||||||
if (trans.getDocumentCode()!=null) {
|
if (trans.getDocumentCode() != null) {
|
||||||
typecode=trans.getDocumentCode();
|
typecode = trans.getDocumentCode();
|
||||||
}
|
}
|
||||||
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||||
|
|
||||||
@@ -265,9 +266,9 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
+ " <ram:TypeCode>" + typecode + "</ram:TypeCode>\n"
|
+ " <ram:TypeCode>" + typecode + "</ram:TypeCode>\n"
|
||||||
+ " <ram:IssueDateTime><udt:DateTimeString format=\"102\">"
|
+ " <ram:IssueDateTime><udt:DateTimeString format=\"102\">"
|
||||||
+ zugferdDateFormat.format(trans.getIssueDate()) + "</udt:DateTimeString></ram:IssueDateTime>\n" // date
|
+ zugferdDateFormat.format(trans.getIssueDate()) + "</udt:DateTimeString></ram:IssueDateTime>\n" // date
|
||||||
// format
|
// format
|
||||||
// was
|
// was
|
||||||
// 20130605
|
// 20130605
|
||||||
+ subjectNote
|
+ subjectNote
|
||||||
+ rebateAgreement
|
+ rebateAgreement
|
||||||
+ senderReg
|
+ senderReg
|
||||||
@@ -277,36 +278,35 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
int lineID = 0;
|
int lineID = 0;
|
||||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
||||||
lineID++;
|
lineID++;
|
||||||
taxCategoryCode=currentItem.getProduct().getTaxCategoryCode();
|
taxCategoryCode = currentItem.getProduct().getTaxCategoryCode();
|
||||||
if (currentItem.getProduct().getTaxExemptionReason() != null) {
|
if (currentItem.getProduct().getTaxExemptionReason() != null) {
|
||||||
exemptionReason="<ram:ExemptionReason>" + XMLTools.encodeXML(currentItem.getProduct().getTaxExemptionReason()) + "</ram:ExemptionReason>";
|
exemptionReason = "<ram:ExemptionReason>" + XMLTools.encodeXML(currentItem.getProduct().getTaxExemptionReason()) + "</ram:ExemptionReason>";
|
||||||
}
|
}
|
||||||
|
|
||||||
LineCalc lc = new LineCalc(currentItem);
|
LineCalc lc = new LineCalc(currentItem);
|
||||||
xml = xml + " <ram:IncludedSupplyChainTradeLineItem>\n" +
|
xml = xml + " <ram:IncludedSupplyChainTradeLineItem>\n" +
|
||||||
" <ram:AssociatedDocumentLineDocument>\n"
|
" <ram:AssociatedDocumentLineDocument>\n"
|
||||||
+ " <ram:LineID>" + lineID + "</ram:LineID>\n" //$NON-NLS-2$
|
+ " <ram:LineID>" + lineID + "</ram:LineID>\n" //$NON-NLS-2$
|
||||||
+ " </ram:AssociatedDocumentLineDocument>\n"
|
+ " </ram:AssociatedDocumentLineDocument>\n"
|
||||||
+ " <ram:SpecifiedTradeProduct>\n";
|
+ " <ram:SpecifiedTradeProduct>\n";
|
||||||
// + " <GlobalID schemeID=\"0160\">4012345001235</GlobalID>\n"
|
// + " <GlobalID schemeID=\"0160\">4012345001235</GlobalID>\n"
|
||||||
if (currentItem.getProduct().getSellerAssignedID() != null) {
|
if (currentItem.getProduct().getSellerAssignedID() != null) {
|
||||||
xml = xml + " <ram:SellerAssignedID>"
|
xml = xml + " <ram:SellerAssignedID>"
|
||||||
+ XMLTools.encodeXML(currentItem.getProduct().getSellerAssignedID()) + "</ram:SellerAssignedID>\n";
|
+ XMLTools.encodeXML(currentItem.getProduct().getSellerAssignedID()) + "</ram:SellerAssignedID>\n";
|
||||||
}
|
}
|
||||||
if (currentItem.getProduct().getBuyerAssignedID() != null) {
|
if (currentItem.getProduct().getBuyerAssignedID() != null) {
|
||||||
xml = xml + " <ram:BuyerAssignedID>"
|
xml = xml + " <ram:BuyerAssignedID>"
|
||||||
+ XMLTools.encodeXML(currentItem.getProduct().getBuyerAssignedID()) + "</ram:BuyerAssignedID>\n";
|
+ XMLTools.encodeXML(currentItem.getProduct().getBuyerAssignedID()) + "</ram:BuyerAssignedID>\n";
|
||||||
}
|
}
|
||||||
|
String allowanceChargeStr = "";
|
||||||
String allowanceStr=" <ram:BasisQuantity unitCode=\"" + XMLTools.encodeXML(currentItem.getProduct().getUnit())
|
if (currentItem.getItemAllowances() != null && currentItem.getItemAllowances().length > 0) {
|
||||||
+ "\">" + quantityFormat(currentItem.getBasisQuantity()) +"</ram:BasisQuantity>\n";
|
for (IZUGFeRDAllowanceCharge allowance : currentItem.getItemAllowances()) {
|
||||||
if (currentItem.getItemAllowances()!=null && currentItem.getItemAllowances().length>0) {
|
allowanceChargeStr = "<ram:AppliedTradeAllowanceCharge><ram:ChargeIndicator><udt:Indicator>false</udt:Indicator></ram:ChargeIndicator><ram:ActualAmount>" + priceFormat(allowance.getTotalAmount(currentItem)) + "</ram:ActualAmount></ram:AppliedTradeAllowanceCharge>";
|
||||||
for (IZUGFeRDAllowanceCharge allowance:currentItem.getItemAllowances()) {
|
}
|
||||||
if (allowance.isCharge()) {
|
}
|
||||||
throw new RuntimeException("Item level charges are not yet implemented");
|
if (currentItem.getItemCharges() != null && currentItem.getItemCharges().length > 0) {
|
||||||
} else {
|
for (IZUGFeRDAllowanceCharge charge : currentItem.getItemCharges()) {
|
||||||
allowanceStr= "<ram:AppliedTradeAllowanceCharge><ram:ChargeIndicator><udt:Indicator>false</udt:Indicator></ram:ChargeIndicator><ram:ActualAmount>"+priceFormat(allowance.getTotalAmount())+"</ram:ActualAmount></ram:AppliedTradeAllowanceCharge>";
|
allowanceChargeStr += "<ram:AppliedTradeAllowanceCharge><ram:ChargeIndicator><udt:Indicator>true</udt:Indicator></ram:ChargeIndicator><ram:ActualAmount>" + priceFormat(charge.getTotalAmount(currentItem)) + "</ram:ActualAmount></ram:AppliedTradeAllowanceCharge>";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,18 +319,20 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
+ " <ram:GrossPriceProductTradePrice>\n"
|
+ " <ram:GrossPriceProductTradePrice>\n"
|
||||||
+ " <ram:ChargeAmount>" + priceFormat(lc.getPriceGross())
|
+ " <ram:ChargeAmount>" + priceFormat(lc.getPriceGross())
|
||||||
+ "</ram:ChargeAmount>\n" //currencyID=\"EUR\"
|
+ "</ram:ChargeAmount>\n" //currencyID=\"EUR\"
|
||||||
+ allowanceStr
|
+ allowanceChargeStr +
|
||||||
// + " <AppliedTradeAllowanceCharge>\n"
|
"<ram:BasisQuantity unitCode=\"" + XMLTools.encodeXML(currentItem.getProduct().getUnit())
|
||||||
// + " <ChargeIndicator>false</ChargeIndicator>\n"
|
+ "\">" + quantityFormat(currentItem.getBasisQuantity()) + "</ram:BasisQuantity>\n"
|
||||||
// + " <ActualAmount currencyID=\"EUR\">0.6667</ActualAmount>\n"
|
// + " <AppliedTradeAllowanceCharge>\n"
|
||||||
// + " <Reason>Rabatt</Reason>\n"
|
// + " <ChargeIndicator>false</ChargeIndicator>\n"
|
||||||
// + " </AppliedTradeAllowanceCharge>\n"
|
// + " <ActualAmount currencyID=\"EUR\">0.6667</ActualAmount>\n"
|
||||||
+ " </ram:GrossPriceProductTradePrice>\n"
|
// + " <Reason>Rabatt</Reason>\n"
|
||||||
|
// + " </AppliedTradeAllowanceCharge>\n"
|
||||||
|
+" </ram:GrossPriceProductTradePrice>\n"
|
||||||
+ " <ram:NetPriceProductTradePrice>\n"
|
+ " <ram:NetPriceProductTradePrice>\n"
|
||||||
+ " <ram:ChargeAmount>" + priceFormat(lc.getPrice())
|
+ " <ram:ChargeAmount>" + priceFormat(lc.getPrice())
|
||||||
+ "</ram:ChargeAmount>\n" // currencyID=\"EUR\"
|
+ "</ram:ChargeAmount>\n" // currencyID=\"EUR\"
|
||||||
+ " <ram:BasisQuantity unitCode=\"" + XMLTools.encodeXML(currentItem.getProduct().getUnit())
|
+ " <ram:BasisQuantity unitCode=\"" + XMLTools.encodeXML(currentItem.getProduct().getUnit())
|
||||||
+ "\">" + quantityFormat(currentItem.getBasisQuantity()) +"</ram:BasisQuantity>\n"
|
+ "\">" + quantityFormat(currentItem.getBasisQuantity()) + "</ram:BasisQuantity>\n"
|
||||||
+ " </ram:NetPriceProductTradePrice>\n"
|
+ " </ram:NetPriceProductTradePrice>\n"
|
||||||
+ " </ram:SpecifiedLineTradeAgreement>\n"
|
+ " </ram:SpecifiedLineTradeAgreement>\n"
|
||||||
|
|
||||||
@@ -342,8 +344,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
+ " <ram:ApplicableTradeTax>\n"
|
+ " <ram:ApplicableTradeTax>\n"
|
||||||
+ " <ram:TypeCode>VAT</ram:TypeCode>\n"
|
+ " <ram:TypeCode>VAT</ram:TypeCode>\n"
|
||||||
+ exemptionReason
|
+ exemptionReason
|
||||||
+ " <ram:CategoryCode>"+currentItem.getProduct().getTaxCategoryCode()+"</ram:CategoryCode>\n"
|
+ " <ram:CategoryCode>" + currentItem.getProduct().getTaxCategoryCode() + "</ram:CategoryCode>\n"
|
||||||
|
|
||||||
+ " <ram:RateApplicablePercent>"
|
+ " <ram:RateApplicablePercent>"
|
||||||
+ vatFormat(currentItem.getProduct().getVATPercent()) + "</ram:RateApplicablePercent>\n"
|
+ vatFormat(currentItem.getProduct().getVATPercent()) + "</ram:RateApplicablePercent>\n"
|
||||||
+ " </ram:ApplicableTradeTax>\n"
|
+ " </ram:ApplicableTradeTax>\n"
|
||||||
@@ -351,11 +353,11 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
+ " <ram:LineTotalAmount>" + currencyFormat(lc.getItemTotalNetAmount())
|
+ " <ram:LineTotalAmount>" + currencyFormat(lc.getItemTotalNetAmount())
|
||||||
+ "</ram:LineTotalAmount>\n" // currencyID=\"EUR\"
|
+ "</ram:LineTotalAmount>\n" // currencyID=\"EUR\"
|
||||||
+ " </ram:SpecifiedTradeSettlementLineMonetarySummation>\n";
|
+ " </ram:SpecifiedTradeSettlementLineMonetarySummation>\n";
|
||||||
if (currentItem.getAdditionalReferencedDocumentID()!=null) {
|
if (currentItem.getAdditionalReferencedDocumentID() != null) {
|
||||||
xml=xml + " <ram:AdditionalReferencedDocument><ram:IssuerAssignedID>"+currentItem.getAdditionalReferencedDocumentID()+"</ram:IssuerAssignedID><ram:TypeCode>130</ram:TypeCode></ram:AdditionalReferencedDocument>\n";
|
xml = xml + " <ram:AdditionalReferencedDocument><ram:IssuerAssignedID>" + currentItem.getAdditionalReferencedDocumentID() + "</ram:IssuerAssignedID><ram:TypeCode>130</ram:TypeCode></ram:AdditionalReferencedDocument>\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
xml=xml + " </ram:SpecifiedLineTradeSettlement>\n"
|
xml = xml + " </ram:SpecifiedLineTradeSettlement>\n"
|
||||||
+ " </ram:IncludedSupplyChainTradeLineItem>\n";
|
+ " </ram:IncludedSupplyChainTradeLineItem>\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -366,18 +368,18 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
|
|
||||||
}
|
}
|
||||||
xml = xml + " <ram:SellerTradeParty>\n";
|
xml = xml + " <ram:SellerTradeParty>\n";
|
||||||
if (trans.getOwnForeignOrganisationID()!=null) {
|
if (trans.getOwnForeignOrganisationID() != null) {
|
||||||
xml = xml + " <ram:ID>" + XMLTools.encodeXML(trans.getOwnForeignOrganisationID()) + "</ram:ID>\n";
|
xml = xml + " <ram:ID>" + XMLTools.encodeXML(trans.getOwnForeignOrganisationID()) + "</ram:ID>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((trans.getSender()!=null)&&(trans.getSender().getGlobalID()!=null)&&(trans.getSender().getGlobalIDScheme()!=null)) {
|
if ((trans.getSender() != null) && (trans.getSender().getGlobalID() != null) && (trans.getSender().getGlobalIDScheme() != null)) {
|
||||||
xml = xml + " <ram:GlobalID schemeID=\"" + XMLTools.encodeXML(trans.getSender().getGlobalIDScheme()) + "\">"
|
xml = xml + " <ram:GlobalID schemeID=\"" + XMLTools.encodeXML(trans.getSender().getGlobalIDScheme()) + "\">"
|
||||||
+ XMLTools.encodeXML(trans.getSender().getGlobalID()) + "</ram:GlobalID>\n";
|
+ XMLTools.encodeXML(trans.getSender().getGlobalID()) + "</ram:GlobalID>\n";
|
||||||
}
|
}
|
||||||
xml = xml + " <ram:Name>" + XMLTools.encodeXML(trans.getSender().getName()) + "</ram:Name>\n"; //$NON-NLS-2$
|
xml = xml + " <ram:Name>" + XMLTools.encodeXML(trans.getSender().getName()) + "</ram:Name>\n"; //$NON-NLS-2$
|
||||||
|
|
||||||
if ((trans.getOwnVATID()!=null)&&(trans.getOwnOrganisationName()!=null)) {
|
if ((trans.getOwnVATID() != null) && (trans.getOwnOrganisationName() != null)) {
|
||||||
|
|
||||||
xml = xml + " <ram:SpecifiedLegalOrganization>\n" + " <ram:ID>"
|
xml = xml + " <ram:SpecifiedLegalOrganization>\n" + " <ram:ID>"
|
||||||
+ XMLTools.encodeXML(trans.getOwnVATID()) + "</ram:ID>\n" + " <ram:TradingBusinessName>"
|
+ XMLTools.encodeXML(trans.getOwnVATID()) + "</ram:ID>\n" + " <ram:TradingBusinessName>"
|
||||||
+ XMLTools.encodeXML(trans.getOwnOrganisationName()) + "</ram:TradingBusinessName>\n"
|
+ XMLTools.encodeXML(trans.getOwnOrganisationName()) + "</ram:TradingBusinessName>\n"
|
||||||
@@ -416,24 +418,27 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
+ " </ram:SpecifiedTaxRegistration>\n"
|
+ " </ram:SpecifiedTaxRegistration>\n"
|
||||||
+ " </ram:SellerTradeParty>\n"
|
+ " </ram:SellerTradeParty>\n"
|
||||||
+ " <ram:BuyerTradeParty>\n";
|
+ " <ram:BuyerTradeParty>\n";
|
||||||
|
// + " <ID>GE2020211</ID>\n"
|
||||||
|
// + " <GlobalID schemeID=\"0088\">4000001987658</GlobalID>\n"
|
||||||
|
|
||||||
xml+=getTradePartyAsXML(trans.getRecipient());
|
xml+=getTradePartyAsXML(trans.getRecipient());
|
||||||
xml += " </ram:BuyerTradeParty>\n";
|
xml += " </ram:BuyerTradeParty>\n";
|
||||||
|
|
||||||
if (trans.getBuyerOrderReferencedDocumentID()!=null) {
|
if (trans.getBuyerOrderReferencedDocumentID() != null) {
|
||||||
xml = xml + " <ram:BuyerOrderReferencedDocument>\n"
|
xml = xml + " <ram:BuyerOrderReferencedDocument>\n"
|
||||||
+ " <ram:IssuerAssignedID>"
|
+ " <ram:IssuerAssignedID>"
|
||||||
+ XMLTools.encodeXML(trans.getBuyerOrderReferencedDocumentID()) + "</ram:IssuerAssignedID>\n"
|
+ XMLTools.encodeXML(trans.getBuyerOrderReferencedDocumentID()) + "</ram:IssuerAssignedID>\n"
|
||||||
+ " </ram:BuyerOrderReferencedDocument>\n";
|
+ " </ram:BuyerOrderReferencedDocument>\n";
|
||||||
}
|
}
|
||||||
xml = xml + " </ram:ApplicableHeaderTradeAgreement>\n"
|
xml = xml + " </ram:ApplicableHeaderTradeAgreement>\n"
|
||||||
+ " <ram:ApplicableHeaderTradeDelivery>\n" ;
|
+ " <ram:ApplicableHeaderTradeDelivery>\n";
|
||||||
if (this.trans.getDeliveryAddress()!=null) {
|
if (this.trans.getDeliveryAddress() != null) {
|
||||||
xml += "<ram:ShipToTradeParty>"+
|
xml += "<ram:ShipToTradeParty>" +
|
||||||
getTradePartyAsXML(this.trans.getDeliveryAddress())+
|
getTradePartyAsXML(this.trans.getDeliveryAddress()) +
|
||||||
"</ram:ShipToTradeParty>";
|
"</ram:ShipToTradeParty>";
|
||||||
}
|
}
|
||||||
|
|
||||||
xml+= " <ram:ActualDeliverySupplyChainEvent>\n"
|
xml += " <ram:ActualDeliverySupplyChainEvent>\n"
|
||||||
+ " <ram:OccurrenceDateTime>";
|
+ " <ram:OccurrenceDateTime>";
|
||||||
|
|
||||||
if (trans.getDeliveryDate() != null) {
|
if (trans.getDeliveryDate() != null) {
|
||||||
@@ -454,21 +459,21 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
+ " <ram:PaymentReference>" + XMLTools.encodeXML(trans.getNumber()) + "</ram:PaymentReference>\n" //$NON-NLS-2$
|
+ " <ram:PaymentReference>" + XMLTools.encodeXML(trans.getNumber()) + "</ram:PaymentReference>\n" //$NON-NLS-2$
|
||||||
+ " <ram:InvoiceCurrencyCode>" + trans.getCurrency() + "</ram:InvoiceCurrencyCode>\n";
|
+ " <ram:InvoiceCurrencyCode>" + trans.getCurrency() + "</ram:InvoiceCurrencyCode>\n";
|
||||||
|
|
||||||
if (trans.getTradeSettlementPayment()!=null) {
|
if (trans.getTradeSettlementPayment() != null) {
|
||||||
for (IZUGFeRDTradeSettlementPayment payment : trans.getTradeSettlementPayment()) {
|
for (IZUGFeRDTradeSettlementPayment payment : trans.getTradeSettlementPayment()) {
|
||||||
if(payment!=null) {
|
if (payment != null) {
|
||||||
hasDueDate=true;
|
hasDueDate = true;
|
||||||
xml+=payment.getSettlementXML();
|
xml += payment.getSettlementXML();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (trans.getTradeSettlement()!=null) {
|
if (trans.getTradeSettlement() != null) {
|
||||||
for (IZUGFeRDTradeSettlement payment : trans.getTradeSettlement()) {
|
for (IZUGFeRDTradeSettlement payment : trans.getTradeSettlement()) {
|
||||||
if(payment!=null) {
|
if (payment != null) {
|
||||||
if (payment instanceof IZUGFeRDTradeSettlementPayment) {
|
if (payment instanceof IZUGFeRDTradeSettlementPayment) {
|
||||||
hasDueDate=true;
|
hasDueDate = true;
|
||||||
}
|
}
|
||||||
xml+=payment.getSettlementXML();
|
xml += payment.getSettlementXML();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -483,7 +488,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
+ " <ram:TypeCode>VAT</ram:TypeCode>\n"
|
+ " <ram:TypeCode>VAT</ram:TypeCode>\n"
|
||||||
+ exemptionReason
|
+ exemptionReason
|
||||||
+ " <ram:BasisAmount>" + currencyFormat(amount.getBasis()) + "</ram:BasisAmount>\n" // currencyID=\"EUR\"
|
+ " <ram:BasisAmount>" + currencyFormat(amount.getBasis()) + "</ram:BasisAmount>\n" // currencyID=\"EUR\"
|
||||||
+ " <ram:CategoryCode>"+taxCategoryCode+"</ram:CategoryCode>\n"
|
+ " <ram:CategoryCode>" + taxCategoryCode + "</ram:CategoryCode>\n"
|
||||||
+ " <ram:RateApplicablePercent>" + vatFormat(currentTaxPercent)
|
+ " <ram:RateApplicablePercent>" + vatFormat(currentTaxPercent)
|
||||||
+ "</ram:RateApplicablePercent>\n" + " </ram:ApplicableTradeTax>\n"; //$NON-NLS-2$
|
+ "</ram:RateApplicablePercent>\n" + " </ram:ApplicableTradeTax>\n"; //$NON-NLS-2$
|
||||||
|
|
||||||
@@ -502,7 +507,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasDueDate && (trans.getDueDate()!=null)) {
|
if (hasDueDate && (trans.getDueDate() != null)) {
|
||||||
xml = xml + " <ram:DueDateDateTime><udt:DateTimeString format=\"102\">" // $NON-NLS-2$
|
xml = xml + " <ram:DueDateDateTime><udt:DateTimeString format=\"102\">" // $NON-NLS-2$
|
||||||
+ zugferdDateFormat.format(trans.getDueDate())
|
+ zugferdDateFormat.format(trans.getDueDate())
|
||||||
+ "</udt:DateTimeString></ram:DueDateDateTime>\n";// 20130704
|
+ "</udt:DateTimeString></ram:DueDateDateTime>\n";// 20130704
|
||||||
@@ -515,24 +520,24 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
|
|
||||||
xml = xml + " <ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n"
|
xml = xml + " <ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n"
|
||||||
+ " <ram:LineTotalAmount>" + currencyFormat(getTotal()) + "</ram:LineTotalAmount>\n" //$NON-NLS-2$
|
+ " <ram:LineTotalAmount>" + currencyFormat(getTotal()) + "</ram:LineTotalAmount>\n" //$NON-NLS-2$
|
||||||
// currencyID=\"EUR\"
|
// currencyID=\"EUR\"
|
||||||
+ " <ram:ChargeTotalAmount>0.00</ram:ChargeTotalAmount>\n"
|
+ " <ram:ChargeTotalAmount>0.00</ram:ChargeTotalAmount>\n"
|
||||||
+ " <ram:AllowanceTotalAmount>0.00</ram:AllowanceTotalAmount>\n" //
|
+ " <ram:AllowanceTotalAmount>0.00</ram:AllowanceTotalAmount>\n" //
|
||||||
// currencyID=\"EUR\"
|
// currencyID=\"EUR\"
|
||||||
// + " <ChargeTotalAmount currencyID=\"EUR\">5.80</ChargeTotalAmount>\n"
|
// + " <ChargeTotalAmount currencyID=\"EUR\">5.80</ChargeTotalAmount>\n"
|
||||||
// + " <AllowanceTotalAmount currencyID=\"EUR\">14.73</AllowanceTotalAmount>\n"
|
// + " <AllowanceTotalAmount currencyID=\"EUR\">14.73</AllowanceTotalAmount>\n"
|
||||||
+ " <ram:TaxBasisTotalAmount>" + currencyFormat(getTotal()) + "</ram:TaxBasisTotalAmount>\n" //$NON-NLS-2$
|
+ " <ram:TaxBasisTotalAmount>" + currencyFormat(getTotal()) + "</ram:TaxBasisTotalAmount>\n" //$NON-NLS-2$
|
||||||
// //
|
// //
|
||||||
// currencyID=\"EUR\"
|
// currencyID=\"EUR\"
|
||||||
+ " <ram:TaxTotalAmount currencyID=\"" + trans.getCurrency() + "\">"
|
+ " <ram:TaxTotalAmount currencyID=\"" + trans.getCurrency() + "\">"
|
||||||
+ currencyFormat(getTotalGross().subtract(getTotal())) + "</ram:TaxTotalAmount>\n"
|
+ currencyFormat(getTotalGross().subtract(getTotal())) + "</ram:TaxTotalAmount>\n"
|
||||||
+ " <ram:GrandTotalAmount>" + currencyFormat(getTotalGross()) + "</ram:GrandTotalAmount>\n" //$NON-NLS-2$
|
+ " <ram:GrandTotalAmount>" + currencyFormat(getTotalGross()) + "</ram:GrandTotalAmount>\n" //$NON-NLS-2$
|
||||||
// //
|
// //
|
||||||
// currencyID=\"EUR\"
|
// currencyID=\"EUR\"
|
||||||
+ " <ram:TotalPrepaidAmount>" + currencyFormat(getTotalPrepaid()) + "</ram:TotalPrepaidAmount>\n"
|
+ " <ram:TotalPrepaidAmount>" + currencyFormat(getTotalPrepaid()) + "</ram:TotalPrepaidAmount>\n"
|
||||||
+ " <ram:DuePayableAmount>" + currencyFormat(getTotalGross().subtract(getTotalPrepaid())) + "</ram:DuePayableAmount>\n" //$NON-NLS-2$
|
+ " <ram:DuePayableAmount>" + currencyFormat(getTotalGross().subtract(getTotalPrepaid())) + "</ram:DuePayableAmount>\n" //$NON-NLS-2$
|
||||||
// //
|
// //
|
||||||
// currencyID=\"EUR\"
|
// currencyID=\"EUR\"
|
||||||
+ " </ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n"
|
+ " </ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n"
|
||||||
+ " </ram:ApplicableHeaderTradeSettlement>\n";
|
+ " </ram:ApplicableHeaderTradeSettlement>\n";
|
||||||
// + " <IncludedSupplyChainTradeLineItem>\n"
|
// + " <IncludedSupplyChainTradeLineItem>\n"
|
||||||
@@ -594,7 +599,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
paymentTermsXml += "<ram:BasisDateTime>";
|
paymentTermsXml += "<ram:BasisDateTime>";
|
||||||
paymentTermsXml += "<udt:DateTimeString format=\"102\">" + zugferdDateFormat.format(baseDate) + "</udt:DateTimeString>";
|
paymentTermsXml += "<udt:DateTimeString format=\"102\">" + zugferdDateFormat.format(baseDate) + "</udt:DateTimeString>";
|
||||||
paymentTermsXml += "</ram:BasisDateTime>";
|
paymentTermsXml += "</ram:BasisDateTime>";
|
||||||
|
|
||||||
paymentTermsXml += "<ram:BasisPeriodMeasure unitCode=\"" + discountTerms.getBasePeriodUnitCode() + "\">"
|
paymentTermsXml += "<ram:BasisPeriodMeasure unitCode=\"" + discountTerms.getBasePeriodUnitCode() + "\">"
|
||||||
+ discountTerms.getBasePeriodMeasure() + "</ram:BasisPeriodMeasure>";
|
+ discountTerms.getBasePeriodMeasure() + "</ram:BasisPeriodMeasure>";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class IZUGFeRDAllowanceChargeImpl implements IZUGFeRDAllowanceCharge {
|
|||||||
boolean isCharge=true;
|
boolean isCharge=true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal getTotalAmount() {
|
public BigDecimal getTotalAmount(IZUGFeRDExportableItem currentItem) {
|
||||||
return totalAmount;
|
return totalAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import junit.framework.TestCase;
|
|||||||
public class ZF2PushTest extends TestCase {
|
public class ZF2PushTest extends TestCase {
|
||||||
final String TARGET_PDF = "./target/testout-ZF2Push.pdf";
|
final String TARGET_PDF = "./target/testout-ZF2Push.pdf";
|
||||||
final String TARGET_CORRECTIONPDF = "./target/testout-ZF2PushCorrection.pdf";
|
final String TARGET_CORRECTIONPDF = "./target/testout-ZF2PushCorrection.pdf";
|
||||||
|
final String TARGET_ITEMCHARGESALLOWANCESPDF = "./target/testout-ZF2PushItemChargesAllowances.pdf";
|
||||||
final String TARGET_CHARGESALLOWANCESPDF = "./target/testout-ZF2PushChargesAllowances.pdf";
|
final String TARGET_CHARGESALLOWANCESPDF = "./target/testout-ZF2PushChargesAllowances.pdf";
|
||||||
|
|
||||||
public void testPushExport() {
|
public void testPushExport() {
|
||||||
@@ -134,27 +135,32 @@ public class ZF2PushTest extends TestCase {
|
|||||||
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).ignorePDFAErrors()
|
||||||
.load(SOURCE_PDF)) {
|
.load(SOURCE_PDF)) {
|
||||||
|
|
||||||
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname,"teststr", "55232","teststadt","DE")).setOwnTaxID("4711").setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number)
|
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname,"teststr", "55232","teststadt","DE")).setOwnTaxID("4711").setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number)
|
||||||
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)).addAllowance(new Allowance(new BigDecimal(0.1),new BigDecimal(0), "","K")))
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)).addAllowance(new Allowance().setPercent(new BigDecimal(50)))));
|
||||||
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)))
|
|
||||||
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)))
|
/*
|
||||||
|
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname,"teststr", "55232","teststadt","DE")).setOwnTaxID("4711").setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number)
|
||||||
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)).addAllowance(new Allowance(new BigDecimal("0.1"))))
|
||||||
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)).addAllowance(new Allowance().setPercent(new BigDecimal(50))))
|
||||||
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(2.0)).addCharge(new Charge(new BigDecimal(1))))
|
||||||
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)).addCharge(new Charge(new BigDecimal(1))).addAllowance(new Allowance(new BigDecimal("1"))))
|
||||||
|
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
String theXML = new String(ze.getProvider().getXML());
|
String theXML = new String(ze.getProvider().getXML());
|
||||||
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
||||||
ze.export(TARGET_CHARGESALLOWANCESPDF);
|
ze.export(TARGET_ITEMCHARGESALLOWANCESPDF);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail("IOException should not be raised in testEdgeExport");
|
fail("IOException should not be raised in testEdgeExport");
|
||||||
}
|
}
|
||||||
|
|
||||||
// now check the contents (like MustangReaderTest)
|
// now check the contents (like MustangReaderTest)
|
||||||
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_CHARGESALLOWANCESPDF);
|
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_ITEMCHARGESALLOWANCESPDF);
|
||||||
|
|
||||||
assertTrue(zi.getUTF8().contains("EUR"));
|
assertTrue(zi.getUTF8().contains("EUR"));
|
||||||
|
|
||||||
// Reading ZUGFeRD
|
// Reading ZUGFeRD
|
||||||
assertEquals("10.59", zi.getAmount());
|
assertEquals("1.79", zi.getAmount());
|
||||||
assertEquals(zi.getHolder(), orgname);
|
assertEquals(zi.getHolder(), orgname);
|
||||||
assertEquals(zi.getForeignReference(), number);
|
assertEquals(zi.getForeignReference(), number);
|
||||||
try {
|
try {
|
||||||
@@ -183,19 +189,19 @@ public class ZF2PushTest extends TestCase {
|
|||||||
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)))
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)))
|
||||||
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)))
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)))
|
||||||
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)))
|
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)))
|
||||||
.addCharge(new Charge(new BigDecimal(0.5),new BigDecimal(0), "","K"))
|
.addCharge(new Charge(new BigDecimal(0.5)))
|
||||||
.addAllowance(new Allowance(new BigDecimal(0.2),new BigDecimal(0), "","K"))
|
.addAllowance(new Allowance(new BigDecimal(0.2)))
|
||||||
|
|
||||||
);
|
);
|
||||||
String theXML = new String(ze.getProvider().getXML());
|
String theXML = new String(ze.getProvider().getXML());
|
||||||
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
||||||
ze.export(TARGET_PDF);
|
ze.export(TARGET_CHARGESALLOWANCESPDF);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail("IOException should not be raised in testEdgeExport");
|
fail("IOException should not be raised in testEdgeExport");
|
||||||
}
|
}
|
||||||
|
|
||||||
// now check the contents (like MustangReaderTest)
|
// now check the contents (like MustangReaderTest)
|
||||||
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF);
|
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_CHARGESALLOWANCESPDF);
|
||||||
|
|
||||||
assertFalse(zi.getUTF8().contains("EUR"));
|
assertFalse(zi.getUTF8().contains("EUR"));
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,25 @@ public class LibraryTest extends ResourceCase {
|
|||||||
.isEqualTo("valid");
|
.isEqualTo("valid");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public void testLibraryPushItemAllowances() {
|
||||||
|
File tempFile = new File("../library/target/testout-ZF2PushItemChargesAllowances.pdf");
|
||||||
|
assertTrue(tempFile.exists());
|
||||||
|
ZUGFeRDValidator zfv = new ZUGFeRDValidator();
|
||||||
|
|
||||||
|
String res = zfv.validate(tempFile.getAbsolutePath());
|
||||||
|
|
||||||
|
|
||||||
|
assertThat(res).valueByXPath("/validation/pdf/summary/@status")
|
||||||
|
.isEqualTo("valid");
|
||||||
|
|
||||||
|
assertThat(res).valueByXPath("/validation/xml/summary/@status")
|
||||||
|
.isEqualTo("valid");
|
||||||
|
|
||||||
|
assertThat(res).valueByXPath("/validation/summary/@status")
|
||||||
|
.isEqualTo("valid");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void testLibraryPushAllowances() {
|
public void testLibraryPushAllowances() {
|
||||||
File tempFile = new File("../library/target/testout-ZF2PushChargesAllowances.pdf");
|
File tempFile = new File("../library/target/testout-ZF2PushChargesAllowances.pdf");
|
||||||
assertTrue(tempFile.exists());
|
assertTrue(tempFile.exists());
|
||||||
|
|||||||
Reference in New Issue
Block a user