Introduce InvoiceCorrection class and TradeParty

This commit is contained in:
Jochen Stärk
2020-09-10 09:04:25 +02:00
parent bbf8c97501
commit fd63a79ced
20 changed files with 353 additions and 114 deletions

View File

@@ -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<IZUGFeRDExportableItem> 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;

View File

@@ -0,0 +1,31 @@
/**
* *********************************************************************
* <p>
* Copyright 2018 Jochen Staerk
* <p>
* Use is subject to license terms.
* <p>
* 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.
* <p>
* 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.
* <p>
* See the License for the specific language governing permissions and
* limitations under the License.
* <p>
* **********************************************************************
*/
package org.mustangproject;
import org.mustangproject.ZUGFeRD.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
public class InvoiceCorrection extends Invoice {
}

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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;
}
}

View File

@@ -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 = " <ram:Name>" + XMLTools.encodeXML(contact.getName()) + "</ram:Name>\n" //$NON-NLS-2$
// + " <DefinedTradeContact>\n"
// + " <PersonName>xxx</PersonName>\n"
@@ -167,7 +167,7 @@ public class ZUGFeRD1PullProvider implements IXMLProvider, IProfileProvider {
+ "</ram:PostcodeCode>\n"
+ " <ram:LineOne>" + XMLTools.encodeXML(contact.getStreet())
+ "</ram:LineOne>\n";
if (trans.getRecipient().getAdditionalAddress() != null) {
if (contact.getAdditionalAddress() != null) {
xml += " <ram:LineTwo>" + XMLTools.encodeXML(contact.getAdditionalAddress())
+ "</ram:LineTwo>\n";
}
@@ -270,25 +270,25 @@ public class ZUGFeRD1PullProvider implements IXMLProvider, IProfileProvider {
xml = xml + " <ram:ID>" + XMLTools.encodeXML(trans.getOwnForeignOrganisationID()) + "</ram:ID>\n";
}
if ((trans.getOwnContact()!=null)&&(trans.getOwnContact().getGlobalID()!=null)&&(trans.getOwnContact().getGlobalIDScheme()!=null)) {
xml = xml + " <ram:GlobalID schemeID=\"" + XMLTools.encodeXML(trans.getOwnContact().getGlobalIDScheme()) + "\">"
+ XMLTools.encodeXML(trans.getOwnContact().getGlobalID()) + "</ram:GlobalID>\n";
if ((trans.getSender()!=null)&&(trans.getSender().getGlobalID()!=null)&&(trans.getSender().getGlobalIDScheme()!=null)) {
xml = xml + " <ram:GlobalID schemeID=\"" + XMLTools.encodeXML(trans.getSender().getGlobalIDScheme()) + "\">"
+ XMLTools.encodeXML(trans.getSender().getGlobalID()) + "</ram:GlobalID>\n";
}
xml = xml + " <ram:Name>" + XMLTools.encodeXML(trans.getOwnOrganisationName()) + "</ram:Name>\n"; //$NON-NLS-2$
if (trans.getOwnContact() != null) {
xml = xml + "<ram:DefinedTradeContact>\n" + " <ram:PersonName>" + XMLTools.encodeXML(trans.getOwnContact().getName())
if (trans.getSender().getContact() != null) {
xml = xml + "<ram:DefinedTradeContact>\n" + " <ram:PersonName>" + XMLTools.encodeXML(trans.getSender().getContact().getName())
+ "</ram:PersonName>\n";
if (trans.getOwnContact().getPhone() != null) {
if (trans.getSender().getContact().getPhone() != null) {
xml = xml + " <ram:TelephoneUniversalCommunication>\n" + " <ram:CompleteNumber>"
+ XMLTools.encodeXML(trans.getOwnContact().getPhone()) + "</ram:CompleteNumber>\n"
+ XMLTools.encodeXML(trans.getSender().getContact().getPhone()) + "</ram:CompleteNumber>\n"
+ " </ram:TelephoneUniversalCommunication>\n";
}
if (trans.getOwnContact().getEMail() != null) {
if (trans.getSender().getContact().getEMail() != null) {
xml = xml + " <ram:EmailURIUniversalCommunication>\n" + " <ram:URIID>"
+ XMLTools.encodeXML(trans.getOwnContact().getEMail()) + "</ram:URIID>\n"
+ XMLTools.encodeXML(trans.getSender().getContact().getEMail()) + "</ram:URIID>\n"
+ " </ram:EmailURIUniversalCommunication>\n";
}
xml = xml + " </ram:DefinedTradeContact>";
@@ -310,7 +310,7 @@ public class ZUGFeRD1PullProvider implements IXMLProvider, IProfileProvider {
// + " <ID>GE2020211</ID>\n"
// + " <GlobalID schemeID=\"0088\">4000001987658</GlobalID>\n"
xml+=getContactAsXML(trans.getRecipient());
xml+= getTradePartyAsXML(trans.getRecipient());
if ((trans.getOwnVATID()!=null)&&(trans.getOwnOrganisationName()!=null)) {
xml = xml + " <ram:SpecifiedTaxRegistration>\n" + " <ram:ID schemeID=\"VA\">"
+ XMLTools.encodeXML(trans.getOwnVATID()) + "</ram:ID>\n"
@@ -329,7 +329,7 @@ public class ZUGFeRD1PullProvider implements IXMLProvider, IProfileProvider {
+ " <ram:ApplicableSupplyChainTradeDelivery>\n" ;
if (this.trans.getDeliveryAddress()!=null) {
xml += "<ram:ShipToTradeParty>"+
getContactAsXML(this.trans.getDeliveryAddress())+
getTradePartyAsXML(this.trans.getDeliveryAddress())+
"</ram:ShipToTradeParty>";
}

View File

@@ -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 = " <ram:Name>" + XMLTools.encodeXML(contact.getName()) + "</ram:Name>\n" //$NON-NLS-2$
// + " <DefinedTradeContact>\n"
// + " <PersonName>xxx</PersonName>\n"
@@ -167,7 +167,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
+ "</ram:PostcodeCode>\n"
+ " <ram:LineOne>" + XMLTools.encodeXML(contact.getStreet())
+ "</ram:LineOne>\n";
if (trans.getRecipient().getAdditionalAddress() != null) {
if (contact.getAdditionalAddress() != null) {
xml += " <ram:LineTwo>" + XMLTools.encodeXML(contact.getAdditionalAddress())
+ "</ram:LineTwo>\n";
}
@@ -347,9 +347,9 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
xml = xml + " <ram:ID>" + XMLTools.encodeXML(trans.getOwnForeignOrganisationID()) + "</ram:ID>\n";
}
if ((trans.getOwnContact()!=null)&&(trans.getOwnContact().getGlobalID()!=null)&&(trans.getOwnContact().getGlobalIDScheme()!=null)) {
xml = xml + " <ram:GlobalID schemeID=\"" + XMLTools.encodeXML(trans.getOwnContact().getGlobalIDScheme()) + "\">"
+ XMLTools.encodeXML(trans.getOwnContact().getGlobalID()) + "</ram:GlobalID>\n";
if ((trans.getSender()!=null)&&(trans.getSender().getGlobalID()!=null)&&(trans.getSender().getGlobalIDScheme()!=null)) {
xml = xml + " <ram:GlobalID schemeID=\"" + XMLTools.encodeXML(trans.getSender().getGlobalIDScheme()) + "\">"
+ XMLTools.encodeXML(trans.getSender().getGlobalID()) + "</ram:GlobalID>\n";
}
xml = xml + " <ram:Name>" + XMLTools.encodeXML(trans.getOwnOrganisationName()) + "</ram:Name>\n"; //$NON-NLS-2$
@@ -361,19 +361,19 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
+ " </ram:SpecifiedLegalOrganization>";
}
if (trans.getOwnContact() != null) {
xml = xml + "<ram:DefinedTradeContact>\n" + " <ram:PersonName>" + XMLTools.encodeXML(trans.getOwnContact().getName())
if (trans.getSender().getContact() != null) {
xml = xml + "<ram:DefinedTradeContact>\n" + " <ram:PersonName>" + XMLTools.encodeXML(trans.getSender().getContact().getName())
+ "</ram:PersonName>\n";
if (trans.getOwnContact().getPhone() != null) {
if (trans.getSender().getContact().getPhone() != null) {
xml = xml + " <ram:TelephoneUniversalCommunication>\n" + " <ram:CompleteNumber>"
+ XMLTools.encodeXML(trans.getOwnContact().getPhone()) + "</ram:CompleteNumber>\n"
+ XMLTools.encodeXML(trans.getSender().getContact().getPhone()) + "</ram:CompleteNumber>\n"
+ " </ram:TelephoneUniversalCommunication>\n";
}
if (trans.getOwnContact().getEMail() != null) {
if (trans.getSender().getContact().getEMail() != null) {
xml = xml + " <ram:EmailURIUniversalCommunication>\n" + " <ram:URIID>"
+ XMLTools.encodeXML(trans.getOwnContact().getEMail()) + "</ram:URIID>\n"
+ XMLTools.encodeXML(trans.getSender().getContact().getEMail()) + "</ram:URIID>\n"
+ " </ram:EmailURIUniversalCommunication>\n";
}
xml = xml + " </ram:DefinedTradeContact>";
@@ -396,7 +396,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
// + " <ID>GE2020211</ID>\n"
// + " <GlobalID schemeID=\"0088\">4000001987658</GlobalID>\n"
xml+=getContactAsXML(trans.getRecipient());
xml+=getTradePartyAsXML(trans.getRecipient());
xml += " </ram:BuyerTradeParty>\n";
if (trans.getBuyerOrderReferencedDocumentID()!=null) {
@@ -409,7 +409,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
+ " <ram:ApplicableHeaderTradeDelivery>\n" ;
if (this.trans.getDeliveryAddress()!=null) {
xml += "<ram:ShipToTradeParty>"+
getContactAsXML(this.trans.getDeliveryAddress())+
getTradePartyAsXML(this.trans.getDeliveryAddress())+
"</ram:ShipToTradeParty>";
}

View File

@@ -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"));