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) {
|
||||||
|
if (totalAmount!=null) {
|
||||||
return totalAmount;
|
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();
|
||||||
|
|
||||||
|
|||||||
@@ -9,18 +9,24 @@ public class LineCalc {
|
|||||||
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) {
|
public void addAllowance(BigDecimal b) {
|
||||||
allowance=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 {
|
||||||
@@ -297,17 +298,16 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|||||||
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())
|
|
||||||
+ "\">" + quantityFormat(currentItem.getBasisQuantity()) +"</ram:BasisQuantity>\n";
|
|
||||||
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()) {
|
||||||
if (allowance.isCharge()) {
|
allowanceChargeStr = "<ram:AppliedTradeAllowanceCharge><ram:ChargeIndicator><udt:Indicator>false</udt:Indicator></ram:ChargeIndicator><ram:ActualAmount>" + priceFormat(allowance.getTotalAmount(currentItem)) + "</ram:ActualAmount></ram:AppliedTradeAllowanceCharge>";
|
||||||
throw new RuntimeException("Item level charges are not yet implemented");
|
|
||||||
} else {
|
|
||||||
allowanceStr= "<ram:AppliedTradeAllowanceCharge><ram:ChargeIndicator><udt:Indicator>false</udt:Indicator></ram:ChargeIndicator><ram:ActualAmount>"+priceFormat(allowance.getTotalAmount())+"</ram:ActualAmount></ram:AppliedTradeAllowanceCharge>";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (currentItem.getItemCharges() != null && currentItem.getItemCharges().length > 0) {
|
||||||
|
for (IZUGFeRDAllowanceCharge charge : currentItem.getItemCharges()) {
|
||||||
|
allowanceChargeStr += "<ram:AppliedTradeAllowanceCharge><ram:ChargeIndicator><udt:Indicator>true</udt:Indicator></ram:ChargeIndicator><ram:ActualAmount>" + priceFormat(charge.getTotalAmount(currentItem)) + "</ram:ActualAmount></ram:AppliedTradeAllowanceCharge>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xml = xml + " <ram:Name>" + XMLTools.encodeXML(currentItem.getProduct().getName()) + "</ram:Name>\n" //$NON-NLS-2$
|
xml = xml + " <ram:Name>" + XMLTools.encodeXML(currentItem.getProduct().getName()) + "</ram:Name>\n" //$NON-NLS-2$
|
||||||
@@ -319,7 +319,9 @@ 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 +
|
||||||
|
"<ram:BasisQuantity unitCode=\"" + XMLTools.encodeXML(currentItem.getProduct().getUnit())
|
||||||
|
+ "\">" + quantityFormat(currentItem.getBasisQuantity()) + "</ram:BasisQuantity>\n"
|
||||||
// + " <AppliedTradeAllowanceCharge>\n"
|
// + " <AppliedTradeAllowanceCharge>\n"
|
||||||
// + " <ChargeIndicator>false</ChargeIndicator>\n"
|
// + " <ChargeIndicator>false</ChargeIndicator>\n"
|
||||||
// + " <ActualAmount currencyID=\"EUR\">0.6667</ActualAmount>\n"
|
// + " <ActualAmount currencyID=\"EUR\">0.6667</ActualAmount>\n"
|
||||||
@@ -416,6 +418,9 @@ 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";
|
||||||
|
|
||||||
|
|||||||
@@ -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