changes for new feature

This commit is contained in:
jstaerk
2025-06-05 14:04:37 +02:00
parent c69867c55e
commit c0c9ad1405
4 changed files with 83 additions and 3 deletions

View File

@@ -32,6 +32,8 @@ public class Product implements IZUGFeRDExportableProduct {
protected boolean isIntraCommunitySupply = false; protected boolean isIntraCommunitySupply = false;
protected SchemedID globalId = null; protected SchemedID globalId = null;
protected String countryOfOrigin = null; protected String countryOfOrigin = null;
protected ArrayList<Charge> charges=new ArrayList<>();
protected ArrayList<Allowance> allowances=new ArrayList<>();
protected HashMap<String, String> attributes = new HashMap<>(); protected HashMap<String, String> attributes = new HashMap<>();
protected List<IDesignatedProductClassification> classifications = new ArrayList<>(); protected List<IDesignatedProductClassification> classifications = new ArrayList<>();
@@ -393,4 +395,42 @@ public class Product implements IZUGFeRDExportableProduct {
this.classifications.add(classification); this.classifications.add(classification);
return this; return this;
} }
public Product addCharge(Charge e) {
charges.add(e);
return this;
}
public Product addAllowance(Allowance a) {
allowances.add(a);
return this;
}
/***
* returns the AppliedTradeAllowanceCharges of this product which are actually Charges
* @return array of or null, if none
*/
@Override
public Charge[] getCharges() {
if (charges.size()==0) {
return null;
}
Charge[] chargeArr = new Charge[charges.size()];
return charges.toArray(chargeArr);
}
@Override
/***
* returns the AppliedTradeAllowanceCharges of this product which are actually Allowances
* @return array of or null, if none
*/
public Allowance[] getAllowances() {
if (allowances.size()==0) {
return null;
}
Allowance[] allowanceArr = new Allowance[allowances.size()];
return allowances.toArray(allowanceArr);
}
} }

View File

@@ -43,7 +43,11 @@ public interface IZUGFeRDExportableItem extends IAbsoluteValueProvider{
* item level discounts * item level discounts
* @return array of the discounts on a single item * @return array of the discounts on a single item
*/ */
@Deprecated
default IZUGFeRDAllowanceCharge[] getItemAllowances() { default IZUGFeRDAllowanceCharge[] getItemAllowances() {
if (getProduct()!=null) {
return getProduct().getAllowances();
}
return null; return null;
} }
@@ -51,10 +55,27 @@ public interface IZUGFeRDExportableItem extends IAbsoluteValueProvider{
* item level price additions * item level price additions
* @return array of the additional charges on the item * @return array of the additional charges on the item
*/ */
@Deprecated
default IZUGFeRDAllowanceCharge[] getItemCharges() { default IZUGFeRDAllowanceCharge[] getItemCharges() {
if (getProduct()!=null) {
return getProduct().getCharges();
}
return null; return null;
} }
@Deprecated
default IZUGFeRDAllowanceCharge[] getAllowances() {
return null;
}
/**
* item level price additions
* @return array of the additional charges on the item
*/
@Deprecated
default IZUGFeRDAllowanceCharge[] getCharges() {
return null;
}
/*** /***
* BT 132 (issue https://github.com/ZUGFeRD/mustangproject/issues/247) * BT 132 (issue https://github.com/ZUGFeRD/mustangproject/issues/247)
@@ -147,9 +168,9 @@ public interface IZUGFeRDExportableItem extends IAbsoluteValueProvider{
} }
/*** /***
* specify allowances amount for the line item total * get all (allowances and charges) SpecifiedTradeAllowanceCharges
* *
* @return the sum of allowances for this item * @return the real item lecel SpecifiedTradeAllowanceCharges
*/ */
default IZUGFeRDAllowanceCharge[] getItemTotalAllowances() { default IZUGFeRDAllowanceCharge[] getItemTotalAllowances() {
return null; return null;

View File

@@ -166,6 +166,25 @@ public interface IZUGFeRDExportableProduct {
return null; return null;
} }
/**
* product level discounts (AppliedTradeAllowanceCharge, will change net price)
* @return array of the discounts on a single product
*/
default IZUGFeRDAllowanceCharge[] getAllowances() {
return null;
}
/**
* product level charges (AppliedTradeAllowanceCharge, will change net price)
* @return array of the additional charges on the product
*/
default IZUGFeRDAllowanceCharge[] getCharges() {
return null;
}
/** /**
* Detailed information about the product * Detailed information about the product
* *

View File

@@ -628,7 +628,7 @@ public class ZF2PushTest extends TestCase {
.setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID("4711").addVATID("DE0815")) .setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID("4711").addVATID("DE0815"))
.setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE")) .setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE"))
.setNumber(number) .setNumber(number)
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), new BigDecimal(500.0), qty).addAllowance(new Allowance(new BigDecimal(300)).setTaxPercent(new BigDecimal(19)))) .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)).addAllowance(new Allowance(BigDecimal.ONE)), new BigDecimal(500.0), qty).addAllowance(new Allowance(new BigDecimal(300)).setTaxPercent(new BigDecimal(19))))
.addAllowance(new Allowance(new BigDecimal(600)).setTaxPercent(new BigDecimal(19))) .addAllowance(new Allowance(new BigDecimal(600)).setTaxPercent(new BigDecimal(19)))
); );
String theXML = new String(ze.getProvider().getXML()); String theXML = new String(ze.getProvider().getXML());