support included notes
This commit is contained in:
@@ -38,6 +38,8 @@ switch
|
||||
- new tradeparty class, Contact getOwnContact superseded by TradeParty getSender
|
||||
- new invoicecorrection class
|
||||
- order-x xml read support
|
||||
- support included notes on document and item level
|
||||
- occurence periods setOccurrencePeriod(Date start, Date end)
|
||||
- automated tests zuv/verapdf validate created library test files
|
||||
- trans.getTradeSettlementPayment() removed in favor of trans.getTradeSettlement()
|
||||
- commandline option for no notices
|
||||
|
||||
@@ -27,6 +27,10 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
/***
|
||||
* An invoice, with fluent setters
|
||||
* @see IExportableTransaction if you want to implement an interface instead
|
||||
*/
|
||||
public class Invoice implements IExportableTransaction {
|
||||
|
||||
protected String documentName = null, documentCode = null, number = null, ownOrganisationFullPlaintextInfo = null, referenceNumber = null, shipToOrganisationID = null, shipToOrganisationName = null, shipToStreet = null, shipToZIP = null, shipToLocation = null, shipToCountry = null, buyerOrderReferencedDocumentID = null, buyerOrderReferencedDocumentIssueDateTime = null, ownForeignOrganisationID = null, ownOrganisationName = null, currency = null, paymentTermDescription = null;
|
||||
@@ -34,6 +38,7 @@ public class Invoice implements IExportableTransaction {
|
||||
protected BigDecimal totalPrepaidAmount = null;
|
||||
protected TradeParty sender=null, recipient = null, deliveryAddress = null;
|
||||
protected ArrayList<IZUGFeRDExportableItem> ZFItems = null;
|
||||
protected ArrayList<String> notes = null;
|
||||
protected String contractReferencedDocument = null;
|
||||
|
||||
protected Date occurrenceDateFrom = null;
|
||||
@@ -266,6 +271,14 @@ public class Invoice implements IExportableTransaction {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String[] getNotes() {
|
||||
if (notes==null) {
|
||||
return null;
|
||||
}
|
||||
return notes.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrency() {
|
||||
return currency;
|
||||
@@ -492,4 +505,13 @@ public class Invoice implements IExportableTransaction {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Invoice addNote(String text) {
|
||||
if (notes==null) {
|
||||
notes=new ArrayList<String>();
|
||||
}
|
||||
notes.add(text);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ public class Item implements IZUGFeRDExportableItem {
|
||||
protected BigDecimal price, quantity, tax, grossPrice, lineTotalAmount;
|
||||
protected String id;
|
||||
protected Product product;
|
||||
protected ArrayList<String> notes = null;
|
||||
protected ArrayList<IZUGFeRDAllowanceCharge> Allowances = new ArrayList<IZUGFeRDAllowanceCharge>(),
|
||||
Charges = new ArrayList<IZUGFeRDAllowanceCharge>();
|
||||
|
||||
@@ -98,6 +99,16 @@ public class Item implements IZUGFeRDExportableItem {
|
||||
return Charges.toArray(new IZUGFeRDAllowanceCharge[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String[] getNotes() {
|
||||
if (notes==null) {
|
||||
return null;
|
||||
}
|
||||
return notes.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public Item setProduct(Product product) {
|
||||
this.product = product;
|
||||
return this;
|
||||
@@ -108,8 +119,19 @@ public class Item implements IZUGFeRDExportableItem {
|
||||
Charges.add(izac);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item addAllowance(IZUGFeRDAllowanceCharge izac) {
|
||||
Allowances.add(izac);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item addNote(String text) {
|
||||
if (notes==null) {
|
||||
notes=new ArrayList<String>();
|
||||
}
|
||||
notes.add(text);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,11 @@ import java.util.Date;
|
||||
import org.mustangproject.FileAttachment;
|
||||
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
|
||||
|
||||
/***
|
||||
* the interface of an transaction, e.g. an invoice, you want to create xml (potentially to be added to a PDF)
|
||||
* for
|
||||
* @see Invoice if you want to use an object rather than an interface
|
||||
*/
|
||||
public interface IExportableTransaction {
|
||||
|
||||
/**
|
||||
@@ -426,13 +431,26 @@ public interface IExportableTransaction {
|
||||
return null;
|
||||
}
|
||||
|
||||
/***
|
||||
* specify delivery date
|
||||
* @return the delivery date
|
||||
*/
|
||||
default Date getOccurrenceDate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/***
|
||||
* specify delivery period
|
||||
* @return the beginning of the delivery period
|
||||
*/
|
||||
default Date getOccurrencePeriodFrom() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/***
|
||||
* specify delivery period
|
||||
* @return the end of the delivery period
|
||||
*/
|
||||
default Date getOccurrencePeriodTo() {
|
||||
return null;
|
||||
}
|
||||
@@ -446,4 +464,13 @@ public interface IExportableTransaction {
|
||||
default FileAttachment[] getAdditionalReferencedDocuments() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* additional text description
|
||||
* @return an array of strings of document wide "includedNotes" (descriptive text values)
|
||||
*/
|
||||
default String[] getNotes() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,16 @@ public interface IZUGFeRDExportableItem extends IAbsoluteValueProvider{
|
||||
|
||||
IZUGFeRDExportableProduct getProduct();
|
||||
|
||||
/**
|
||||
* item level discounts
|
||||
* @return array of the discounts on a single item
|
||||
*/
|
||||
IZUGFeRDAllowanceCharge[] getItemAllowances();
|
||||
|
||||
/**
|
||||
* item level price additions
|
||||
* @return array of the additional charges on the item
|
||||
*/
|
||||
IZUGFeRDAllowanceCharge[] getItemCharges();
|
||||
|
||||
|
||||
@@ -70,8 +78,20 @@ public interface IZUGFeRDExportableItem extends IAbsoluteValueProvider{
|
||||
return TaxCategoryCodeTypeConstants.STANDARDRATE;
|
||||
}
|
||||
|
||||
/***
|
||||
* the ID of an additionally referenced document for this item
|
||||
* @return the id as string
|
||||
*/
|
||||
default String getAdditionalReferencedDocumentID() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/***
|
||||
* descriptive texts
|
||||
* @return an array of strings of item specific "includedNotes", text values
|
||||
*/
|
||||
default String[] getNotes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -236,6 +236,13 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
if (trans.getDocumentCode() != null) {
|
||||
typecode = trans.getDocumentCode();
|
||||
}
|
||||
String notes="";
|
||||
if (trans.getNotes()!=null) {
|
||||
for (String currentNote:trans.getNotes()) {
|
||||
notes=notes+"<ram:IncludedNote><ram:Content>" + XMLTools.encodeXML(currentNote) + "</ram:Content></ram:IncludedNote>";
|
||||
|
||||
}
|
||||
}
|
||||
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
|
||||
+ "<rsm:CrossIndustryInvoice xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:rsm=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100\""
|
||||
@@ -259,9 +266,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
+ " <ram:TypeCode>" + typecode + "</ram:TypeCode>\n"
|
||||
+ " <ram:IssueDateTime><udt:DateTimeString format=\"102\">"
|
||||
+ zugferdDateFormat.format(trans.getIssueDate()) + "</udt:DateTimeString></ram:IssueDateTime>\n" // date
|
||||
// format
|
||||
// was
|
||||
// 20130605
|
||||
+ notes
|
||||
+ subjectNote
|
||||
+ rebateAgreement
|
||||
+ senderReg
|
||||
@@ -275,12 +280,20 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
if (currentItem.getProduct().getTaxExemptionReason() != null) {
|
||||
exemptionReason = "<ram:ExemptionReason>" + XMLTools.encodeXML(currentItem.getProduct().getTaxExemptionReason()) + "</ram:ExemptionReason>";
|
||||
}
|
||||
notes="";
|
||||
if (currentItem.getNotes()!=null) {
|
||||
for (String currentNote:currentItem.getNotes()) {
|
||||
notes=notes+"<ram:IncludedNote><ram:Content>" + XMLTools.encodeXML(currentNote) + "</ram:Content></ram:IncludedNote>";
|
||||
|
||||
}
|
||||
}
|
||||
LineCalculator lc = new LineCalculator(currentItem);
|
||||
xml = xml + " <ram:IncludedSupplyChainTradeLineItem>\n" +
|
||||
" <ram:AssociatedDocumentLineDocument>\n"
|
||||
+ " <ram:LineID>" + lineID + "</ram:LineID>\n" //$NON-NLS-2$
|
||||
+ notes
|
||||
+ " </ram:AssociatedDocumentLineDocument>\n"
|
||||
|
||||
+ " <ram:SpecifiedTradeProduct>\n";
|
||||
// + " <GlobalID schemeID=\"0160\">4012345001235</GlobalID>\n"
|
||||
if (currentItem.getProduct().getSellerAssignedID() != null) {
|
||||
|
||||
@@ -44,6 +44,7 @@ public class ZF2PushTest extends TestCase {
|
||||
final String TARGET_CHARGESALLOWANCESPDF = "./target/testout-ZF2PushChargesAllowances.pdf";
|
||||
final String TARGET_RELATIVECHARGESALLOWANCESPDF = "./target/testout-ZF2PushRelativeChargesAllowances.pdf";
|
||||
final String TARGET_ATTACHMENTSPDF = "./target/testout-ZF2PushAttachments.pdf";
|
||||
final String TARGET_PUSHEDGE = "./target/testout-ZF2PushEdge.pdf";
|
||||
|
||||
public void testPushExport() {
|
||||
|
||||
@@ -241,6 +242,38 @@ public class ZF2PushTest extends TestCase {
|
||||
|
||||
}
|
||||
|
||||
public void testPushEdge() {
|
||||
|
||||
String orgname = "Test company";
|
||||
String number = "123";
|
||||
String priceStr = "1.00";
|
||||
String taxID = "9990815";
|
||||
BigDecimal price = new BigDecimal(priceStr);
|
||||
try (InputStream SOURCE_PDF = this.getClass()
|
||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
|
||||
|
||||
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application")
|
||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
|
||||
.load(SOURCE_PDF)) {
|
||||
|
||||
ze.setTransaction(new Invoice().addNote("document level 1/2").addNote("document level 2/2").setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID(taxID)).setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").addVATID("DE4711").setContact(new Contact("Franz Müller", "01779999999", "franz@mueller.de", "teststr. 12", "55232", "Entenhausen", "DE"))).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, new BigDecimal(1.0)).addNote("item level 1/1"))
|
||||
|
||||
);
|
||||
String theXML = new String(ze.getProvider().getXML());
|
||||
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
||||
ze.export(TARGET_PUSHEDGE);
|
||||
} catch (IOException e) {
|
||||
fail("IOException should not be raised in testEdgeExport");
|
||||
}
|
||||
|
||||
// now check the contents (like MustangReaderTest)
|
||||
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PUSHEDGE);
|
||||
|
||||
assertTrue(zi.getUTF8().contains("item level 1/1"));
|
||||
assertTrue(zi.getUTF8().contains("document level 2/2"));
|
||||
|
||||
}
|
||||
|
||||
public void testAllowancesExport() {
|
||||
|
||||
String orgname = "Test company";
|
||||
|
||||
Reference in New Issue
Block a user