attempt for new tests(which compile but do not yet even fail)

This commit is contained in:
jstaerk
2020-09-03 21:16:07 +02:00
parent 70d110ef6d
commit d8824a15e5
6 changed files with 138 additions and 40 deletions

View File

@@ -0,0 +1,12 @@
package org.mustangproject;
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
import java.math.BigDecimal;
public class Allowance extends Charge {
public Allowance(BigDecimal totalAmount, BigDecimal taxPercent, String categoryCode, String reason) {
super(totalAmount, taxPercent, categoryCode, reason);
}
}

View File

@@ -0,0 +1,60 @@
package org.mustangproject;
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableContact;
import java.math.BigDecimal;
public class Charge implements IZUGFeRDAllowanceCharge {
protected String reason;
protected BigDecimal totalAmount;
protected BigDecimal taxPercent;
protected String categoryCode;
public Charge(BigDecimal totalAmount, BigDecimal taxPercent, String categoryCode, String reason) {
this.totalAmount=totalAmount;
this.taxPercent=taxPercent;
this.categoryCode=categoryCode;
this.reason=reason;
}
@Override
public String getReason() {
return reason;
}
public Charge setReason(String reason) {
this.reason = reason;
return this;
}
@Override
public BigDecimal getTotalAmount() {
return totalAmount;
}
public Charge setTotalAmount(BigDecimal totalAmount) {
this.totalAmount = totalAmount;
return this;
}
@Override
public BigDecimal getTaxPercent() {
return taxPercent;
}
public Charge setTaxPercent(BigDecimal taxPercent) {
this.taxPercent = taxPercent;
return this;
}
@Override
public String getCategoryCode() {
return categoryCode;
}
public Charge setCategoryCode(String categoryCode) {
this.categoryCode = categoryCode;
return this;
}
}

View File

@@ -34,7 +34,8 @@ public class Invoice implements IExportableTransaction {
protected IZUGFeRDExportableContact ownContact = null, recipient = null, deliveryAddress = null;
protected ArrayList<IZUGFeRDExportableItem> ZFItems = null;
protected IZUGFeRDAllowanceCharge[] ZFAllowances = null, ZFCharges = null, ZFLogisticsServiceCharges = null;
protected ArrayList<IZUGFeRDAllowanceCharge> Allowances = new ArrayList<IZUGFeRDAllowanceCharge>(),
Charges = new ArrayList<IZUGFeRDAllowanceCharge>(), LogisticsServiceCharges = new ArrayList<IZUGFeRDAllowanceCharge>();
protected IZUGFeRDTradeSettlement[] getTradeSettlement = null;
protected IZUGFeRDPaymentTerms paymentTerms = null;
@@ -334,33 +335,30 @@ public class Invoice implements IExportableTransaction {
@Override
public IZUGFeRDAllowanceCharge[] getZFAllowances() {
return ZFAllowances;
if (Allowances.isEmpty()) {
return null;
} else
return Allowances.toArray(new IZUGFeRDAllowanceCharge[0]);
}
public Invoice setZFAllowances(IZUGFeRDAllowanceCharge[] ZFAllowances) {
this.ZFAllowances = ZFAllowances;
return this;
}
@Override
public IZUGFeRDAllowanceCharge[] getZFCharges() {
return ZFCharges;
if (Charges.isEmpty()) {
return null;
} else
return Charges.toArray(new IZUGFeRDAllowanceCharge[0]);
}
public Invoice setZFCharges(IZUGFeRDAllowanceCharge[] ZFCharges) {
this.ZFCharges = ZFCharges;
return this;
}
@Override
public IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges() {
return ZFLogisticsServiceCharges;
if (LogisticsServiceCharges.isEmpty()) {
return null;
} else
return LogisticsServiceCharges.toArray(new IZUGFeRDAllowanceCharge[0]);
}
public Invoice setZFLogisticsServiceCharges(IZUGFeRDAllowanceCharge[] ZFLogisticsServiceCharges) {
this.ZFLogisticsServiceCharges = ZFLogisticsServiceCharges;
return this;
}
public IZUGFeRDTradeSettlement[] getGetTradeSettlement() {
return getTradeSettlement;
@@ -413,4 +411,12 @@ public class Invoice implements IExportableTransaction {
// this.country = country;
}
public Invoice addCharge(IZUGFeRDAllowanceCharge izac) {
Charges.add(izac);
return this;
}
public Invoice addAllowance(IZUGFeRDAllowanceCharge izac) {
Allowances.add(izac);
return this;
}
}

View File

@@ -4,11 +4,14 @@ import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem;
import java.math.BigDecimal;
import java.util.ArrayList;
public class Item implements IZUGFeRDExportableItem {
protected BigDecimal price, quantity, tax, grossPrice, lineTotalAmount;
protected String id;
protected Product product;
protected ArrayList<IZUGFeRDAllowanceCharge> Allowances = new ArrayList<IZUGFeRDAllowanceCharge>(),
Charges = new ArrayList<IZUGFeRDAllowanceCharge>();
public Item(Product product, BigDecimal price, BigDecimal quantity) {
this.price = price;
@@ -81,16 +84,32 @@ public class Item implements IZUGFeRDExportableItem {
@Override
public IZUGFeRDAllowanceCharge[] getItemAllowances() {
return null;
if (Allowances.isEmpty()) {
return null;
} else
return Allowances.toArray(new IZUGFeRDAllowanceCharge[0]);
}
@Override
public IZUGFeRDAllowanceCharge[] getItemCharges() {
return null;
if (Charges.isEmpty()) {
return null;
} else
return Charges.toArray(new IZUGFeRDAllowanceCharge[0]);
}
public Item setProduct(Product product) {
this.product = product;
return this;
}
public Item addCharge(IZUGFeRDAllowanceCharge izac) {
Charges.add(izac);
return this;
}
public Item addAllowance(IZUGFeRDAllowanceCharge izac) {
Allowances.add(izac);
return this;
}
}

View File

@@ -208,6 +208,9 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
ensurePDFisUpgraded = false;
}
public void attachFile(String filename, byte[] data, String mimetype, String relation) {
//throw new RuntimeException("Not implemented");
}
/***
* Perform the final export to a now ZUGFeRD-enriched PDF file