starting with document level charges/allowances via invoice class
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.mustangproject;
|
||||
|
||||
import org.mustangproject.ZUGFeRD.IExportableTransaction;
|
||||
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.mustangproject;
|
||||
|
||||
import org.mustangproject.ZUGFeRD.IExportableTransaction;
|
||||
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
|
||||
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem;
|
||||
|
||||
@@ -64,6 +65,17 @@ public class Charge implements IZUGFeRDAllowanceCharge {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getTotalAmount(IExportableTransaction currentTrans) {
|
||||
// if (totalAmount!=null) {
|
||||
return totalAmount;
|
||||
// } else //if (percent!=null) {
|
||||
// to be implemented return currentItem.get().multiply(getPercent().divide(new BigDecimal(100)));
|
||||
//} else {
|
||||
// throw new RuntimeException("Either totalAmount or percent must be set");
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
public BigDecimal getPercent() {
|
||||
return percent;
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.math.BigDecimal;
|
||||
public interface IZUGFeRDAllowanceCharge {
|
||||
|
||||
BigDecimal getTotalAmount(IZUGFeRDExportableItem currentItem);
|
||||
BigDecimal getTotalAmount(IExportableTransaction trans);
|
||||
|
||||
String getReason();
|
||||
|
||||
|
||||
@@ -484,14 +484,31 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
xml = xml + buildPaymentTermsXml();
|
||||
}
|
||||
|
||||
xml = xml + " <ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n"
|
||||
|
||||
String chargeTotalLine="";
|
||||
|
||||
IZUGFeRDAllowanceCharge[] allowances= trans.getZFAllowances();
|
||||
BigDecimal allowanceTotal=new BigDecimal(0);
|
||||
if ((allowances!=null) && (allowances.length>0)) {
|
||||
for (IZUGFeRDAllowanceCharge currentAllowance:allowances) {
|
||||
allowanceTotal=allowanceTotal.add(currentAllowance.getTotalAmount(trans));
|
||||
}
|
||||
}
|
||||
String allowanceTotalLine="<ram:AllowanceTotalAmount currencyID=\"+trans.getCurrency()+\">"+currencyFormat(allowanceTotal)+"</ram:AllowanceTotalAmount>";
|
||||
|
||||
IZUGFeRDAllowanceCharge[] charges= trans.getZFCharges();
|
||||
BigDecimal chargesTotal=new BigDecimal(0);
|
||||
if ((charges!=null) && (charges.length>0)) {
|
||||
for (IZUGFeRDAllowanceCharge currentCharge:charges) {
|
||||
chargesTotal=chargesTotal.add(currentCharge.getTotalAmount(trans));
|
||||
}
|
||||
}
|
||||
String chargesTotalLine="<ram:ChargeTotalAmount currencyID=\""+trans.getCurrency()+"\">"+currencyFormat(chargesTotal)+"</ram:ChargeTotalAmount>";
|
||||
|
||||
xml = xml + " <ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n"
|
||||
+ " <ram:LineTotalAmount>" + currencyFormat(getTotal()) + "</ram:LineTotalAmount>\n" //$NON-NLS-2$
|
||||
// currencyID=\"EUR\"
|
||||
+ " <ram:ChargeTotalAmount>0.00</ram:ChargeTotalAmount>\n"
|
||||
+ " <ram:AllowanceTotalAmount>0.00</ram:AllowanceTotalAmount>\n" //
|
||||
// currencyID=\"EUR\"
|
||||
// + " <ChargeTotalAmount currencyID=\"EUR\">5.80</ChargeTotalAmount>\n"
|
||||
// + " <AllowanceTotalAmount currencyID=\"EUR\">14.73</AllowanceTotalAmount>\n"
|
||||
+ chargesTotalLine
|
||||
+ allowanceTotalLine
|
||||
+ " <ram:TaxBasisTotalAmount>" + currencyFormat(getTotal()) + "</ram:TaxBasisTotalAmount>\n" //$NON-NLS-2$
|
||||
// //
|
||||
// currencyID=\"EUR\"
|
||||
|
||||
@@ -31,6 +31,11 @@ public class IZUGFeRDAllowanceChargeImpl implements IZUGFeRDAllowanceCharge {
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getTotalAmount(IExportableTransaction currentTransaction) {
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReason() {
|
||||
return reason;
|
||||
|
||||
@@ -207,7 +207,7 @@ public class ZF2PushTest extends TestCase {
|
||||
assertFalse(zi.getUTF8().contains("EUR"));
|
||||
|
||||
// Reading ZUGFeRD
|
||||
assertEquals("10.71", zi.getAmount());
|
||||
assertEquals("11.07", zi.getAmount());
|
||||
assertEquals(zi.getHolder(), orgname);
|
||||
assertEquals(zi.getForeignReference(), number);
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user