some charges/allowance changes
This commit is contained in:
16
library/src/main/java/org/mustangproject/Allowance.java
Normal file
16
library/src/main/java/org/mustangproject/Allowance.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package org.mustangproject;
|
||||
|
||||
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class Allowance extends Charge implements IZUGFeRDAllowanceCharge {
|
||||
|
||||
public Allowance() {
|
||||
|
||||
}
|
||||
public Allowance(BigDecimal totalAmount, BigDecimal taxPercent, String reason, String categoryCode) {
|
||||
super(totalAmount, taxPercent, reason, categoryCode);
|
||||
|
||||
}
|
||||
}
|
||||
74
library/src/main/java/org/mustangproject/Charge.java
Normal file
74
library/src/main/java/org/mustangproject/Charge.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package org.mustangproject;
|
||||
|
||||
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
|
||||
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableProduct;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class Charge implements IZUGFeRDAllowanceCharge {
|
||||
|
||||
protected BigDecimal percent;
|
||||
protected BigDecimal totalAmount;
|
||||
protected BigDecimal taxPercent;
|
||||
protected String reason;
|
||||
protected String categoryCode;
|
||||
|
||||
public Charge() {
|
||||
|
||||
}
|
||||
|
||||
public Charge(BigDecimal totalAmount, BigDecimal taxPercent, String reason, String categoryCode) {
|
||||
this.totalAmount = totalAmount;
|
||||
this.taxPercent = taxPercent;
|
||||
this.reason = reason;
|
||||
this.categoryCode = categoryCode;
|
||||
}
|
||||
|
||||
|
||||
public Charge setTotalAmount(BigDecimal totalAmount) {
|
||||
this.totalAmount = totalAmount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Charge setPercent(BigDecimal percent) {
|
||||
this.percent = percent;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Charge setTaxPercent(BigDecimal taxPercent) {
|
||||
this.taxPercent = taxPercent;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Charge setReason(String reason) {
|
||||
this.reason = reason;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Charge setCategoryCode(String categoryCode) {
|
||||
this.categoryCode = categoryCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BigDecimal getTotalAmount() {
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getTaxPercent() {
|
||||
return taxPercent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategoryCode() {
|
||||
return categoryCode;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -402,6 +402,22 @@ public class Invoice implements IExportableTransaction {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Invoice addCharge(IZUGFeRDAllowanceCharge charge) {
|
||||
//@todo
|
||||
return this;
|
||||
}
|
||||
|
||||
public Invoice addAllowance(IZUGFeRDAllowanceCharge allowance) {
|
||||
//@todo
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* checks if all required items are set in order to be able to export it
|
||||
* @return
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return (dueDate != null) && (ownZIP != null) && (ownStreet != null) && (ownLocation != null) && (ownCountry != null) && (ownTaxID != null) && (ownVATID != null) && (recipient != null);
|
||||
//contact
|
||||
|
||||
@@ -25,6 +25,16 @@ public class Item implements IZUGFeRDExportableItem {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item addCharge(IZUGFeRDAllowanceCharge charge) {
|
||||
//@todo
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item addAllowance(IZUGFeRDAllowanceCharge allowance) {
|
||||
//@todo
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getGrossPrice() {
|
||||
return grossPrice;
|
||||
}
|
||||
|
||||
@@ -24,10 +24,7 @@ import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import org.mustangproject.Contact;
|
||||
import org.mustangproject.Invoice;
|
||||
import org.mustangproject.Item;
|
||||
import org.mustangproject.Product;
|
||||
import org.mustangproject.*;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.runners.MethodSorters;
|
||||
|
||||
@@ -78,7 +75,7 @@ public class ZF2PushTest extends TestCase {
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
|
||||
public void testAttachmentsExport() {
|
||||
|
||||
String orgname = "Test company";
|
||||
@@ -92,9 +89,7 @@ public class ZF2PushTest extends TestCase {
|
||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
|
||||
.load(SOURCE_PDF)) {
|
||||
|
||||
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setOwnOrganisationName(orgname).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new Contact("Franz Müller", "0177123456", "fmueller@test.com", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)))
|
||||
.set
|
||||
);
|
||||
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setOwnOrganisationName(orgname).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new Contact("Franz Müller", "0177123456", "fmueller@test.com", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0))));
|
||||
ze.attachFile("one.pdf");
|
||||
ze.attachFile("two.pdf");
|
||||
String theXML = new String(ze.getProvider().getXML());
|
||||
@@ -136,9 +131,9 @@ public class ZF2PushTest extends TestCase {
|
||||
.load(SOURCE_PDF)) {
|
||||
|
||||
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setOwnOrganisationName(orgname).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new Contact("Franz Müller", "0177123456", "fmueller@test.com", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number)
|
||||
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)).addCharge(new BigDecimal(0.1)))
|
||||
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)).addAllowance(new BigDecimal(0.07)))
|
||||
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)).addAllowance(new BigDecimal(0.07)).addCharge(new BigDecimal(0.1)))
|
||||
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)).addCharge(new Charge(new BigDecimal(0.1),new BigDecimal(0), "", "K")))
|
||||
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)).addAllowance(new Allowance(new BigDecimal(0.07),new BigDecimal(0), "", "K")))
|
||||
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)).addAllowance(new Allowance(new BigDecimal(0.07),new BigDecimal(0), "", "K")))
|
||||
|
||||
);
|
||||
String theXML = new String(ze.getProvider().getXML());
|
||||
@@ -166,7 +161,7 @@ public class ZF2PushTest extends TestCase {
|
||||
|
||||
}
|
||||
|
||||
public void testItemChargesAllowancesExport() {
|
||||
public void testChargesAllowancesExport() {
|
||||
|
||||
String orgname = "Test company";
|
||||
String number = "123";
|
||||
@@ -183,10 +178,8 @@ public class ZF2PushTest extends TestCase {
|
||||
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)))
|
||||
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)))
|
||||
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)))
|
||||
.addCharge(new BigDecimal(0.5))
|
||||
.addAllowance(new BigDecimal(0.7))
|
||||
|
||||
);
|
||||
.addCharge(new Charge(new BigDecimal(0.1),new BigDecimal(0), "", "K"))
|
||||
.addAllowance(new Allowance(new BigDecimal(0.07),new BigDecimal(0), "", "K")));
|
||||
String theXML = new String(ze.getProvider().getXML());
|
||||
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
||||
ze.export(TARGET_PDF);
|
||||
@@ -212,7 +205,7 @@ public class ZF2PushTest extends TestCase {
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
public void testCorrectionExport() {
|
||||
|
||||
String orgname = "Test company";
|
||||
|
||||
Reference in New Issue
Block a user