starting with document level charges/allowances via invoice class
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package org.mustangproject;
|
package org.mustangproject;
|
||||||
|
|
||||||
|
import org.mustangproject.ZUGFeRD.IExportableTransaction;
|
||||||
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
|
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.mustangproject;
|
package org.mustangproject;
|
||||||
|
|
||||||
|
import org.mustangproject.ZUGFeRD.IExportableTransaction;
|
||||||
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
|
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
|
||||||
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem;
|
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() {
|
public BigDecimal getPercent() {
|
||||||
return percent;
|
return percent;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import java.math.BigDecimal;
|
|||||||
public interface IZUGFeRDAllowanceCharge {
|
public interface IZUGFeRDAllowanceCharge {
|
||||||
|
|
||||||
BigDecimal getTotalAmount(IZUGFeRDExportableItem currentItem);
|
BigDecimal getTotalAmount(IZUGFeRDExportableItem currentItem);
|
||||||
|
BigDecimal getTotalAmount(IExportableTransaction trans);
|
||||||
|
|
||||||
String getReason();
|
String getReason();
|
||||||
|
|
||||||
|
|||||||
@@ -484,14 +484,31 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
xml = xml + buildPaymentTermsXml();
|
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$
|
+ " <ram:LineTotalAmount>" + currencyFormat(getTotal()) + "</ram:LineTotalAmount>\n" //$NON-NLS-2$
|
||||||
// currencyID=\"EUR\"
|
+ chargesTotalLine
|
||||||
+ " <ram:ChargeTotalAmount>0.00</ram:ChargeTotalAmount>\n"
|
+ allowanceTotalLine
|
||||||
+ " <ram:AllowanceTotalAmount>0.00</ram:AllowanceTotalAmount>\n" //
|
|
||||||
// currencyID=\"EUR\"
|
|
||||||
// + " <ChargeTotalAmount currencyID=\"EUR\">5.80</ChargeTotalAmount>\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\"
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ public class IZUGFeRDAllowanceChargeImpl implements IZUGFeRDAllowanceCharge {
|
|||||||
return totalAmount;
|
return totalAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal getTotalAmount(IExportableTransaction currentTransaction) {
|
||||||
|
return totalAmount;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getReason() {
|
public String getReason() {
|
||||||
return reason;
|
return reason;
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ public class ZF2PushTest extends TestCase {
|
|||||||
assertFalse(zi.getUTF8().contains("EUR"));
|
assertFalse(zi.getUTF8().contains("EUR"));
|
||||||
|
|
||||||
// Reading ZUGFeRD
|
// Reading ZUGFeRD
|
||||||
assertEquals("10.71", zi.getAmount());
|
assertEquals("11.07", zi.getAmount());
|
||||||
assertEquals(zi.getHolder(), orgname);
|
assertEquals(zi.getHolder(), orgname);
|
||||||
assertEquals(zi.getForeignReference(), number);
|
assertEquals(zi.getForeignReference(), number);
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user