From 6970279764960d06bbecb060ba06da480bd2ed7d Mon Sep 17 00:00:00 2001 From: Sebastian Sieber Date: Tue, 18 Apr 2023 14:53:59 +0200 Subject: [PATCH] Add URIUniversalCommunication to TradeParty --- .../java/org/mustangproject/TradeParty.java | 27 +++++++++++++++++++ .../ZUGFeRD/IZUGFeRDExportableTradeParty.java | 20 +++++++++++++- .../ZUGFeRD/ZUGFeRD2PullProvider.java | 11 +++++--- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/library/src/main/java/org/mustangproject/TradeParty.java b/library/src/main/java/org/mustangproject/TradeParty.java index f92455f7..025d9668 100644 --- a/library/src/main/java/org/mustangproject/TradeParty.java +++ b/library/src/main/java/org/mustangproject/TradeParty.java @@ -31,6 +31,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty { protected Contact contact = null; protected LegalOrganisation legalOrg = null; protected SchemedID globalId=null; + protected SchemedID uriUniversalCommunicationId=null; /** * Default constructor. @@ -192,6 +193,27 @@ public class TradeParty implements IZUGFeRDExportableTradeParty { } + + @Override + public String getUriUniversalCommunicationID() { + if (uriUniversalCommunicationId!=null) { + return uriUniversalCommunicationId.getID(); + } + return null; + } + + + + @Override + public String getUriUniversalCommunicationIDScheme() { + if (uriUniversalCommunicationId!=null) { + return uriUniversalCommunicationId.getScheme(); + } + return null; + + } + + /** * if it's a customer, this can e.g. be the customer ID @@ -219,6 +241,11 @@ public class TradeParty implements IZUGFeRDExportableTradeParty { globalId=schemedID; return this; } + + public TradeParty addUriUniversalCommunicationID(SchemedID schemedID) { + uriUniversalCommunicationId=schemedID; + return this; + } /*** * required (for senders, if payment is not debit): the BIC and IBAN diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTradeParty.java b/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTradeParty.java index e76a429e..b9bf67d4 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTradeParty.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTradeParty.java @@ -49,7 +49,8 @@ public interface IZUGFeRDExportableTradeParty { return null; } - /*** + + /*** * gets the official representation * @return the interface with the attributes of the legal organisation */ @@ -66,6 +67,23 @@ public interface IZUGFeRDExportableTradeParty { } + /** + * URIUniversalCommunication scheme (see EAS code list of the ZUGFeRD documentation) + * + */ + default String getUriUniversalCommunicationIDScheme() { + return null; + } + /** + * The URIID of URIUniversalCommunicationID + * It is used by some countries, i.e. Luxembourg + * + */ + default String getUriUniversalCommunicationID() { + return null; + } + + default IZUGFeRDExportableContact getContact() { return null; } diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java index 7992ef08..912e35e1 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java @@ -157,14 +157,11 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { + ""; } if (party.getContact().getEMail() != null) { - xml += "" + XMLTools.encodeXML(party.getContact().getEMail()) + "" + ""; } - xml += ""; - } xml += ""; @@ -188,11 +185,17 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { xml += "" + XMLTools.encodeXML(party.getLocation()) + ""; } - ; + //country IS mandatory xml += "" + XMLTools.encodeXML(party.getCountry()) + "" + ""; + if (party.getUriUniversalCommunicationID() != null && party.getUriUniversalCommunicationIDScheme()!=null) { + xml += "" + + "" + + XMLTools.encodeXML(party.getUriUniversalCommunicationID()) + + ""; + } if ((party.getVATID() != null) && (!isShipToTradeParty)) { xml += ""