From fd63a79cedf93ba8f6d91e7cf9861a58782f514d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20Sta=CC=88rk?= Date: Thu, 10 Sep 2020 09:04:25 +0200 Subject: [PATCH] Introduce InvoiceCorrection class and TradeParty --- History.md | 2 +- .../main/java/org/mustangproject/Invoice.java | 52 +++---- .../org/mustangproject/InvoiceCorrection.java | 31 +++++ .../java/org/mustangproject/TradeParty.java | 73 ++++++++++ .../ZUGFeRD/IExportableTransaction.java | 8 +- .../ZUGFeRD/IZUGFeRDExportableContact.java | 18 --- .../ZUGFeRD/IZUGFeRDExportableTradeParty.java | 130 ++++++++++++++++++ .../ZUGFeRD/ZUGFeRD1PullProvider.java | 26 ++-- .../ZUGFeRD/ZUGFeRD2PullProvider.java | 26 ++-- .../ZUGFeRD/ZUGFeRDInvoiceImporter.java | 7 +- .../ZUGFeRD/BackwardCompatibilityTest.java | 5 +- .../ZUGFeRD/IExportableTransactionImpl.java | 6 +- .../ZUGFeRD/MustangReaderTestCase.java | 2 +- .../ZUGFeRD/MustangReaderWriterEdgeTest.java | 5 +- .../ZUGFeRD/MustangReaderWriterTest.java | 4 +- .../org/mustangproject/ZUGFeRD/XRTest.java | 7 +- .../mustangproject/ZUGFeRD/ZF2EdgeTest.java | 8 +- .../mustangproject/ZUGFeRD/ZF2PushTest.java | 51 ++++++- .../org/mustangproject/ZUGFeRD/ZF2Test.java | 4 +- validator/pom.xml | 2 +- 20 files changed, 353 insertions(+), 114 deletions(-) create mode 100644 library/src/main/java/org/mustangproject/InvoiceCorrection.java create mode 100644 library/src/main/java/org/mustangproject/TradeParty.java create mode 100644 library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTradeParty.java diff --git a/History.md b/History.md index ffd3d011..4b7d42b6 100644 --- a/History.md +++ b/History.md @@ -29,7 +29,7 @@ switch - validate as library doc - unify loggers - release notes - +- new tradeparty class, switch recipient, shipping address from contact to tradeparty ### 2.0 still todo - verapdf as prevalidation? diff --git a/library/src/main/java/org/mustangproject/Invoice.java b/library/src/main/java/org/mustangproject/Invoice.java index 87720bc1..f879aad6 100644 --- a/library/src/main/java/org/mustangproject/Invoice.java +++ b/library/src/main/java/org/mustangproject/Invoice.java @@ -28,10 +28,10 @@ import java.util.Date; 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, ownTaxID = null, ownVATID = null, ownForeignOrganisationID = null, ownOrganisationName = null, ownStreet = null, ownZIP = null, ownLocation = null, ownCountry = null, currency = null, paymentTermDescription = null; + 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, ownTaxID = null, ownVATID = null, ownForeignOrganisationID = null, ownOrganisationName = null, currency = null, paymentTermDescription = null; protected Date issueDate = null, dueDate = null, deliveryDate = null; protected BigDecimal totalPrepaidAmount = null; - protected IZUGFeRDExportableContact ownContact = null, recipient = null, deliveryAddress = null; + protected TradeParty sender=null, recipient = null, deliveryAddress = null; protected ArrayList ZFItems = null; protected String contractReferencedDocument = null; @@ -223,41 +223,25 @@ public class Invoice implements IExportableTransaction { @Override public String getOwnStreet() { - return ownStreet; + return sender.getStreet(); } - public Invoice setOwnStreet(String ownStreet) { - this.ownStreet = ownStreet; - return this; - } @Override public String getOwnZIP() { - return ownZIP; + return sender.getZIP(); } - public Invoice setOwnZIP(String ownZIP) { - this.ownZIP = ownZIP; - return this; - } public String getOwnLocation() { - return ownLocation; + return sender.getLocation(); } - public Invoice setOwnLocation(String getOwnLocation) { - this.ownLocation = getOwnLocation; - return this; - } public String getOwnCountry() { - return ownCountry; + return sender.getCountry(); } - public Invoice setOwnCountry(String getOwnCountry) { - this.ownCountry = getOwnCountry; - return this; - } @Override public String getCurrency() { @@ -320,25 +304,29 @@ public class Invoice implements IExportableTransaction { } @Override - public IZUGFeRDExportableContact getOwnContact() { - return ownContact; + public IZUGFeRDExportableTradeParty getSender() { + return sender; } - public Invoice setOwnContact(IZUGFeRDExportableContact ownContact) { - this.ownContact = ownContact; + public Invoice setOwnContact(Contact ownContact) { + this.sender.setContact(ownContact); return this; } - @Override - public IZUGFeRDExportableContact getRecipient() { + public IZUGFeRDExportableTradeParty getRecipient() { return recipient; } - public Invoice setRecipient(IZUGFeRDExportableContact recipient) { + public Invoice setRecipient(TradeParty recipient) { this.recipient = recipient; return this; } + public Invoice setSender(TradeParty sender) { + this.sender = sender; + return this; + } + @Override public IZUGFeRDAllowanceCharge[] getZFAllowances() { if (Allowances.isEmpty()) { @@ -386,11 +374,11 @@ public class Invoice implements IExportableTransaction { } @Override - public IZUGFeRDExportableContact getDeliveryAddress() { + public TradeParty getDeliveryAddress() { return deliveryAddress; } - public Invoice setDeliveryAddress(IZUGFeRDExportableContact deliveryAddress) { + public Invoice setDeliveryAddress(TradeParty deliveryAddress) { this.deliveryAddress = deliveryAddress; return this; } @@ -413,7 +401,7 @@ public class Invoice implements IExportableTransaction { * @return */ public boolean isValid() { - return (dueDate != null) && (ownZIP != null) && (ownStreet != null) && (ownLocation != null) && (ownCountry != null) && (ownTaxID != null) && (ownVATID != null) && (recipient != null); + return (dueDate != null) && (sender != null) && (ownTaxID != null) && (ownVATID != null) && (recipient != null); //contact // this.phone = phone; // this.email = email; diff --git a/library/src/main/java/org/mustangproject/InvoiceCorrection.java b/library/src/main/java/org/mustangproject/InvoiceCorrection.java new file mode 100644 index 00000000..3a39fa4f --- /dev/null +++ b/library/src/main/java/org/mustangproject/InvoiceCorrection.java @@ -0,0 +1,31 @@ +/** + * ********************************************************************* + *

+ * Copyright 2018 Jochen Staerk + *

+ * Use is subject to license terms. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0. + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + *

+ * See the License for the specific language governing permissions and + * limitations under the License. + *

+ * ********************************************************************** + */ +package org.mustangproject; + +import org.mustangproject.ZUGFeRD.*; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; + +public class InvoiceCorrection extends Invoice { + +} diff --git a/library/src/main/java/org/mustangproject/TradeParty.java b/library/src/main/java/org/mustangproject/TradeParty.java new file mode 100644 index 00000000..625dc08f --- /dev/null +++ b/library/src/main/java/org/mustangproject/TradeParty.java @@ -0,0 +1,73 @@ +package org.mustangproject; + +import org.mustangproject.ZUGFeRD.IZUGFeRDExportableContact; +import org.mustangproject.ZUGFeRD.IZUGFeRDExportableTradeParty; + +public class TradeParty implements IZUGFeRDExportableTradeParty { + + protected String name,zip,street,location,country; + protected Contact contact=null; + + public TradeParty(String name, String street, String zip, String location, String country) { + this.name = name; + this.street = street; + this.zip = zip; + this.location = location; + this.country = country; + + } + + public TradeParty setContact(Contact c) { + this.contact = c; + return this; + } + + public String getName() { + return name; + } + + public TradeParty setName(String name) { + this.name = name; + return this; + } + + + public String getZIP() { + return zip; + } + + public TradeParty setZIP(String zip) { + this.zip = zip; + return this; + } + + @Override + public String getStreet() { + return street; + } + + public TradeParty setStreet(String street) { + this.street = street; + return this; + } + + @Override + public String getLocation() { + return location; + } + + public TradeParty setLocation(String location) { + this.location = location; + return this; + } + + @Override + public String getCountry() { + return country; + } + + public TradeParty setCountry(String country) { + this.country = country; + return this; + } +} diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/IExportableTransaction.java b/library/src/main/java/org/mustangproject/ZUGFeRD/IExportableTransaction.java index 0d23f191..76bb7e01 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/IExportableTransaction.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/IExportableTransaction.java @@ -101,11 +101,11 @@ public interface IExportableTransaction { /** - * who processed the order + * the sender of the invoice * * @return the contact person at the supplier side */ - default IZUGFeRDExportableContact getOwnContact() { + default IZUGFeRDExportableTradeParty getSender() { return null; } @@ -137,7 +137,7 @@ public interface IExportableTransaction { * * @return the recipient of the invoice */ - IZUGFeRDExportableContact getRecipient(); + IZUGFeRDExportableTradeParty getRecipient(); /** @@ -390,7 +390,7 @@ public interface IExportableTransaction { * @return */ - default IZUGFeRDExportableContact getDeliveryAddress() { + default IZUGFeRDExportableTradeParty getDeliveryAddress() { return null; } diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableContact.java b/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableContact.java index f5312ff8..58ffa8e3 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableContact.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableContact.java @@ -38,24 +38,6 @@ public interface IZUGFeRDExportableContact { return null; } - /** - * customer global identification assigned by the seller - * - * @return customer identification - */ - default String getGlobalID() { - return null; - } - - /** - * customer global identification scheme - * - * @return customer identification - */ - default String getGlobalIDScheme() { - return null; - } - /** * First and last name of the recipient diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTradeParty.java b/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTradeParty.java new file mode 100644 index 00000000..e5d7ba7b --- /dev/null +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTradeParty.java @@ -0,0 +1,130 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + *********************************************************************** */ +package org.mustangproject.ZUGFeRD; + +/** + * Mustangproject's ZUGFeRD implementation neccessary interface for ZUGFeRD exporter Licensed under the APLv2 + * + * @author jstaerk + * @version 1.2.0 + * dated 2014-05-10 + */ + + +public interface IZUGFeRDExportableTradeParty { + + /** + * customer identification assigned by the seller + * + * @return customer identification + */ + default String getID() { + return null; + } + + /** + * customer global identification assigned by the seller + * + * @return customer identification + */ + default String getGlobalID() { + return null; + } + + /** + * customer global identification scheme + * + * @return customer identification + */ + default String getGlobalIDScheme() { + return null; + } + + + default IZUGFeRDExportableContact getContact() { + return null; + } + + /** + * First and last name of the recipient + * + * @return First and last name of the recipient + */ + default String getName() { + return null; + } + /** + * Postal code of the recipient + * + * @return Postal code of the recipient + */ + default String getZIP() { + return null; + } + + + /** + * VAT ID (Umsatzsteueridentifikationsnummer) of the contact + * + * @return VAT ID (Umsatzsteueridentifikationsnummer) of the contact + */ + default String getVATID() { + return null; + } + + + /** + * two-letter country code of the contact + * + * @return two-letter iso country code of the contact + */ + default String getCountry() { + return null; + } + + + /** + * Returns the city of the contact + * + * @return Returns the city of the recipient + */ + default String getLocation() { + return null; + } + + + /** + * Returns the street address (street+number) of the contact + * + * @return street address (street+number) of the contact + */ + default String getStreet() { + return null; + } + + /** + * returns additional address information which is display in xml tag "LineTwo" + * + * @return additional address information + */ + default String getAdditionalAddress() { + return null; + } + +} diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD1PullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD1PullProvider.java index 86295745..c46195f1 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD1PullProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD1PullProvider.java @@ -157,7 +157,7 @@ public class ZUGFeRD1PullProvider implements IXMLProvider, IProfileProvider { return "urn:ferd:CrossIndustryDocument:invoice:1p0:comfort"; } - protected String getContactAsXML(IZUGFeRDExportableContact contact) { + protected String getTradePartyAsXML(IZUGFeRDExportableTradeParty contact) { String xml = " " + XMLTools.encodeXML(contact.getName()) + "\n" //$NON-NLS-2$ // + " \n" // + " xxx\n" @@ -167,7 +167,7 @@ public class ZUGFeRD1PullProvider implements IXMLProvider, IProfileProvider { + "\n" + " " + XMLTools.encodeXML(contact.getStreet()) + "\n"; - if (trans.getRecipient().getAdditionalAddress() != null) { + if (contact.getAdditionalAddress() != null) { xml += " " + XMLTools.encodeXML(contact.getAdditionalAddress()) + "\n"; } @@ -270,25 +270,25 @@ public class ZUGFeRD1PullProvider implements IXMLProvider, IProfileProvider { xml = xml + " " + XMLTools.encodeXML(trans.getOwnForeignOrganisationID()) + "\n"; } - if ((trans.getOwnContact()!=null)&&(trans.getOwnContact().getGlobalID()!=null)&&(trans.getOwnContact().getGlobalIDScheme()!=null)) { - xml = xml + " " - + XMLTools.encodeXML(trans.getOwnContact().getGlobalID()) + "\n"; + if ((trans.getSender()!=null)&&(trans.getSender().getGlobalID()!=null)&&(trans.getSender().getGlobalIDScheme()!=null)) { + xml = xml + " " + + XMLTools.encodeXML(trans.getSender().getGlobalID()) + "\n"; } xml = xml + " " + XMLTools.encodeXML(trans.getOwnOrganisationName()) + "\n"; //$NON-NLS-2$ - if (trans.getOwnContact() != null) { - xml = xml + "\n" + " " + XMLTools.encodeXML(trans.getOwnContact().getName()) + if (trans.getSender().getContact() != null) { + xml = xml + "\n" + " " + XMLTools.encodeXML(trans.getSender().getContact().getName()) + "\n"; - if (trans.getOwnContact().getPhone() != null) { + if (trans.getSender().getContact().getPhone() != null) { xml = xml + " \n" + " " - + XMLTools.encodeXML(trans.getOwnContact().getPhone()) + "\n" + + XMLTools.encodeXML(trans.getSender().getContact().getPhone()) + "\n" + " \n"; } - if (trans.getOwnContact().getEMail() != null) { + if (trans.getSender().getContact().getEMail() != null) { xml = xml + " \n" + " " - + XMLTools.encodeXML(trans.getOwnContact().getEMail()) + "\n" + + XMLTools.encodeXML(trans.getSender().getContact().getEMail()) + "\n" + " \n"; } xml = xml + " "; @@ -310,7 +310,7 @@ public class ZUGFeRD1PullProvider implements IXMLProvider, IProfileProvider { // + " GE2020211\n" // + " 4000001987658\n" - xml+=getContactAsXML(trans.getRecipient()); + xml+= getTradePartyAsXML(trans.getRecipient()); if ((trans.getOwnVATID()!=null)&&(trans.getOwnOrganisationName()!=null)) { xml = xml + " \n" + " " + XMLTools.encodeXML(trans.getOwnVATID()) + "\n" @@ -329,7 +329,7 @@ public class ZUGFeRD1PullProvider implements IXMLProvider, IProfileProvider { + " \n" ; if (this.trans.getDeliveryAddress()!=null) { xml += ""+ - getContactAsXML(this.trans.getDeliveryAddress())+ + getTradePartyAsXML(this.trans.getDeliveryAddress())+ ""; } diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java index be0e25d1..9c252217 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java @@ -157,7 +157,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { return "urn:cen.eu:en16931:2017"; } - protected String getContactAsXML(IZUGFeRDExportableContact contact) { + protected String getTradePartyAsXML(IZUGFeRDExportableTradeParty contact) { String xml = " " + XMLTools.encodeXML(contact.getName()) + "\n" //$NON-NLS-2$ // + " \n" // + " xxx\n" @@ -167,7 +167,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { + "\n" + " " + XMLTools.encodeXML(contact.getStreet()) + "\n"; - if (trans.getRecipient().getAdditionalAddress() != null) { + if (contact.getAdditionalAddress() != null) { xml += " " + XMLTools.encodeXML(contact.getAdditionalAddress()) + "\n"; } @@ -347,9 +347,9 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { xml = xml + " " + XMLTools.encodeXML(trans.getOwnForeignOrganisationID()) + "\n"; } - if ((trans.getOwnContact()!=null)&&(trans.getOwnContact().getGlobalID()!=null)&&(trans.getOwnContact().getGlobalIDScheme()!=null)) { - xml = xml + " " - + XMLTools.encodeXML(trans.getOwnContact().getGlobalID()) + "\n"; + if ((trans.getSender()!=null)&&(trans.getSender().getGlobalID()!=null)&&(trans.getSender().getGlobalIDScheme()!=null)) { + xml = xml + " " + + XMLTools.encodeXML(trans.getSender().getGlobalID()) + "\n"; } xml = xml + " " + XMLTools.encodeXML(trans.getOwnOrganisationName()) + "\n"; //$NON-NLS-2$ @@ -361,19 +361,19 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { + " "; } - if (trans.getOwnContact() != null) { - xml = xml + "\n" + " " + XMLTools.encodeXML(trans.getOwnContact().getName()) + if (trans.getSender().getContact() != null) { + xml = xml + "\n" + " " + XMLTools.encodeXML(trans.getSender().getContact().getName()) + "\n"; - if (trans.getOwnContact().getPhone() != null) { + if (trans.getSender().getContact().getPhone() != null) { xml = xml + " \n" + " " - + XMLTools.encodeXML(trans.getOwnContact().getPhone()) + "\n" + + XMLTools.encodeXML(trans.getSender().getContact().getPhone()) + "\n" + " \n"; } - if (trans.getOwnContact().getEMail() != null) { + if (trans.getSender().getContact().getEMail() != null) { xml = xml + " \n" + " " - + XMLTools.encodeXML(trans.getOwnContact().getEMail()) + "\n" + + XMLTools.encodeXML(trans.getSender().getContact().getEMail()) + "\n" + " \n"; } xml = xml + " "; @@ -396,7 +396,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { // + " GE2020211\n" // + " 4000001987658\n" - xml+=getContactAsXML(trans.getRecipient()); + xml+=getTradePartyAsXML(trans.getRecipient()); xml += " \n"; if (trans.getBuyerOrderReferencedDocumentID()!=null) { @@ -409,7 +409,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { + " \n" ; if (this.trans.getDeliveryAddress()!=null) { xml += ""+ - getContactAsXML(this.trans.getDeliveryAddress())+ + getTradePartyAsXML(this.trans.getDeliveryAddress())+ ""; } diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java index 506845b0..a4ae4fed 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java @@ -1,9 +1,6 @@ package org.mustangproject.ZUGFeRD; -import org.mustangproject.Contact; -import org.mustangproject.Invoice; -import org.mustangproject.Item; -import org.mustangproject.Product; +import org.mustangproject.*; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -18,7 +15,7 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter { public Invoice extractInvoice() { String number="AB123"; - Invoice zpp=new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).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); + Invoice zpp=new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty("company","teststr","55232","teststadt","DE")).setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number); //.addItem(new Item(new Product("Testprodukt","","C62",new BigDecimal(0)),amount,new BigDecimal(1.0))) zpp.setOwnOrganisationName(extractString("//SellerTradeParty/Name")); diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/BackwardCompatibilityTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/BackwardCompatibilityTest.java index af5e9cab..026d79c9 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/BackwardCompatibilityTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/BackwardCompatibilityTest.java @@ -27,6 +27,7 @@ import java.util.Date; import java.util.GregorianCalendar; import junit.framework.TestCase; +import org.mustangproject.TradeParty; /*** * This is a test to confirm the minimum steps to implement a interface are still sufficient @@ -304,8 +305,8 @@ public class BackwardCompatibilityTest extends TestCase implements IExportableTr @Override - public IZUGFeRDExportableContact getRecipient() { - return new Contact(); + public IZUGFeRDExportableTradeParty getRecipient() { + return new TradeParty("name","street","zip","city","DE"); } diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/IExportableTransactionImpl.java b/library/src/test/java/org/mustangproject/ZUGFeRD/IExportableTransactionImpl.java index 92d6a183..5a7d2de8 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/IExportableTransactionImpl.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/IExportableTransactionImpl.java @@ -30,7 +30,7 @@ public class IExportableTransactionImpl implements IExportableTransaction { private IZUGFeRDAllowanceCharge[] zFCharges; private IZUGFeRDAllowanceCharge[] zFLogisticsServiceCharges; private IZUGFeRDExportableItem[] zFItems; - private IZUGFeRDExportableContact recipient; + private IZUGFeRDExportableTradeParty recipient; private IZUGFeRDTradeSettlementPayment[] settlementPayments; private String ownTaxID; private String ownVATID; @@ -85,7 +85,7 @@ public class IExportableTransactionImpl implements IExportableTransaction { } @Override - public IZUGFeRDExportableContact getRecipient() { + public IZUGFeRDExportableTradeParty getRecipient() { return recipient; } @@ -190,7 +190,7 @@ public class IExportableTransactionImpl implements IExportableTransaction { return this; } - public IExportableTransactionImpl setRecipient(IZUGFeRDExportableContact recipient) { + public IExportableTransactionImpl setRecipient(IZUGFeRDExportableTradeParty recipient) { this.recipient = recipient; return this; } diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderTestCase.java b/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderTestCase.java index a24f5a2d..df54834b 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderTestCase.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderTestCase.java @@ -54,7 +54,7 @@ public abstract class MustangReaderTestCase extends TestCase implements IExporta } } - protected class RecipientContact implements IZUGFeRDExportableContact { + protected class RecipientTradeParty implements IZUGFeRDExportableTradeParty { @Override public String getCountry() { diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java index cafb8f73..81816e5f 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java @@ -23,7 +23,6 @@ import junit.framework.TestSuite; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; @@ -98,8 +97,8 @@ public class MustangReaderWriterEdgeTest extends MustangReaderTestCase { } @Override - public IZUGFeRDExportableContact getRecipient() { - return new RecipientContact(); + public IZUGFeRDExportableTradeParty getRecipient() { + return new RecipientTradeParty(); } @Override diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java index 575e2d41..7a2c93df 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java @@ -100,8 +100,8 @@ public class MustangReaderWriterTest extends MustangReaderTestCase { } @Override - public IZUGFeRDExportableContact getRecipient() { - return new RecipientContact(); + public IZUGFeRDExportableTradeParty getRecipient() { + return new RecipientTradeParty(); } @Override diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java index 2955f27b..a6c4990e 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java @@ -22,10 +22,7 @@ package org.mustangproject.ZUGFeRD; import junit.framework.TestCase; -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; import org.mustangproject.ZUGFeRD.ZUGFeRD2PullProvider; @@ -49,7 +46,7 @@ public class XRTest extends TestCase { String amountStr = "1.00"; BigDecimal amount = new BigDecimal(amountStr); - Invoice i = 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))); + Invoice i = new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname,"teststr","55232","teststadt","DE")).setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0))); ZUGFeRD2PullProvider zf2p = new ZUGFeRD2PullProvider(); zf2p.generateXML(i); diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2EdgeTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2EdgeTest.java index 67a201b1..92b8daa9 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2EdgeTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2EdgeTest.java @@ -173,13 +173,13 @@ public class ZF2EdgeTest extends MustangReaderTestCase implements IExportableTra } @Override - public IZUGFeRDExportableContact getRecipient() { - return new RecipientContact(); + public IZUGFeRDExportableTradeParty getRecipient() { + return new RecipientTradeParty(); } @Override - public IZUGFeRDExportableContact getDeliveryAddress() { - return new RecipientContact(); + public IZUGFeRDExportableTradeParty getDeliveryAddress() { + return new RecipientTradeParty(); } @Override diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java index 6d247848..8b755f5a 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java @@ -51,7 +51,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()).setContractReferencedDocument("0815").setOwnOrganisationName(orgname).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("DE19990815").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.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setContractReferencedDocument("0815").setSender(new TradeParty(orgname,"teststr", "55232","teststadt","DE")).setOwnTaxID("4711").setOwnVATID("DE19990815").setRecipient(new TradeParty("Franz Müller","teststr.12", "55232", "Entenhausen", "DE")).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)))); String theXML = new String(ze.getProvider().getXML()); assertTrue(theXML.contains("4.0.0 org.mustangproject validator - Library to validate Factur-X/ZUGFeRD 1.0 and 2.1 as well as XRechnung e-invoices. + Library to validate e-invoices (ZUGFeRD, Factur-X and Xrechnung) jar 1.9.0-alpha2-SNAPSHOT