diff --git a/library/src/main/java/org/mustangproject/LegalOrganisation.java b/library/src/main/java/org/mustangproject/LegalOrganisation.java
index 9ed0aa62..320d7412 100644
--- a/library/src/main/java/org/mustangproject/LegalOrganisation.java
+++ b/library/src/main/java/org/mustangproject/LegalOrganisation.java
@@ -2,6 +2,8 @@ package org.mustangproject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.mustangproject.ZUGFeRD.*;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/***
* A organisation, i.e. usually a company
@@ -9,35 +11,68 @@ import org.mustangproject.ZUGFeRD.*;
@JsonIgnoreProperties(ignoreUnknown = true)
public class LegalOrganisation implements IZUGFeRDLegalOrganisation {
- protected String ID = null;
- protected String SchemeID = null;
+ protected SchemedID schemedID = null;
+ protected String tradingBusinessName = null;
public LegalOrganisation() {
}
public LegalOrganisation(String ID, String scheme) {
- this.ID=ID;
- this.SchemeID=scheme;
+ this.schemedID = new SchemedID(ID, scheme);
+ }
+
+ public LegalOrganisation(SchemedID schemedID, String tradingBusinessName) {
+ this.schemedID = schemedID;
+ this.tradingBusinessName=tradingBusinessName;
+ }
+
+ /***
+ * XML parsing constructor
+ * @param nodes the nodelist returned e.g. from xpath
+ */
+ public LegalOrganisation(NodeList nodes) {
+ if (nodes.getLength() > 0) {
+ /*
+ will parse sth like
+
+ 4711
+ Test GmbH & Co.KG
+
+ */
+ for (int nodeIndex = 0; nodeIndex < nodes.getLength(); nodeIndex++) {
+ Node currentItemNode = nodes.item(nodeIndex);
+ if (currentItemNode.getLocalName() != null) {
+ if (currentItemNode.getLocalName().equals("GlobalID")) {
+ if (currentItemNode.getAttributes().getNamedItem("schemeID") != null) {
+ SchemedID gid = new SchemedID().setScheme(currentItemNode.getAttributes().getNamedItem("schemeID").getNodeValue()).setId(currentItemNode.getTextContent());
+ this.setSchemedID(gid);
+ }
+ }
+ if (currentItemNode.getLocalName().equals("TradingBusinessName")) {
+ setTradingBusinessName(currentItemNode.getFirstChild().getNodeValue());
+ }
+ }
+ }
+ }
}
@Override
- public String getID() {
- return ID;
+ public SchemedID getSchemedID() {
+ return this.schemedID;
}
@Override
- public String getSchemeID() {
- return SchemeID;
+ public String getTradingBusinessName() {
+ return this.tradingBusinessName;
}
- public LegalOrganisation setID(String id) {
- this.ID=id;
+ public LegalOrganisation setSchemedID(SchemedID schemedID) {
+ this.schemedID = schemedID;
return this;
}
- public LegalOrganisation setSchemeID(String scheme) {
- SchemeID=scheme;
+ public LegalOrganisation setTradingBusinessName(String tradingBusinessName) {
+ this.tradingBusinessName = tradingBusinessName;
return this;
}
-
}
diff --git a/library/src/main/java/org/mustangproject/TradeParty.java b/library/src/main/java/org/mustangproject/TradeParty.java
index 2580fbef..40922376 100644
--- a/library/src/main/java/org/mustangproject/TradeParty.java
+++ b/library/src/main/java/org/mustangproject/TradeParty.java
@@ -308,6 +308,10 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
addGlobalID(gid);
}
}
+ if (itemChilds.item(itemChildIndex).getLocalName().equals("SpecifiedLegalOrganization")) {
+ NodeList organization = itemChilds.item(itemChildIndex).getChildNodes();
+ setLegalOrganisation(new LegalOrganisation(organization));
+ }
if (itemChilds.item(itemChildIndex).getLocalName().equals("DefinedTradeContact")) {
NodeList contact = itemChilds.item(itemChildIndex).getChildNodes();
setContact(new Contact(contact));
diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDLegalOrganisation.java b/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDLegalOrganisation.java
index 9de017cf..09bf14fc 100644
--- a/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDLegalOrganisation.java
+++ b/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDLegalOrganisation.java
@@ -18,17 +18,19 @@
*********************************************************************** */
package org.mustangproject.ZUGFeRD;
-public interface IZUGFeRDLegalOrganisation {
+import org.mustangproject.SchemedID;
- /***
- *
- * @return the ID of the legal organisation
- */
- public String getID();
+public interface IZUGFeRDLegalOrganisation {
/**
*
- * @return the scheme attribute of the legal organization=the type of the identification, e.g. 0002=Siren
+ * @return the scheme attribute of the legal organization=the type of the identification, e.g. 0002=Siren, and its value
*/
- public String getSchemeID();
+ public SchemedID getSchemedID();
+
+ /***
+ *
+ * @return the TradingBusinessName of the legal organisation
+ */
+ public String getTradingBusinessName();
}
diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java
index 8577e5a0..64bfb738 100644
--- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java
+++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java
@@ -139,13 +139,18 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
}
xml += "" + XMLTools.encodeXML(party.getName()) + "";
- if (party.getLegalOrganisation() != null) {
+ if (party.getLegalOrganisation() != null && (profile == Profiles.getByName("EN16931") || profile == Profiles.getByName("Extended") || profile == Profiles.getByName("XRechnung"))) {
xml += " ";
- xml += "" + XMLTools.encodeXML(party.getLegalOrganisation().getID()) + "";
+ if (party.getLegalOrganisation().getSchemedID() != null) {
+ xml += "" + XMLTools.encodeXML(party.getLegalOrganisation().getSchemedID().getID()) + "";
+ }
+ if (party.getLegalOrganisation().getTradingBusinessName() != null) {
+ xml += "" + XMLTools.encodeXML(party.getLegalOrganisation().getTradingBusinessName()) + "";
+ }
xml += "";
}
- if ((party.getContact() != null) && (isSender || profile == Profiles.getByName("Extended") || profile == Profiles.getByName("XRechnung"))) {
+ if ((party.getContact() != null) && (isSender || profile == Profiles.getByName("EN16931") || profile == Profiles.getByName("Extended") || profile == Profiles.getByName("XRechnung"))) {
xml += "";
if (party.getContact().getName() != null) {
xml += "" + XMLTools.encodeXML(party.getContact().getName())
diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ProfilesMinimumBasicWLTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ProfilesMinimumBasicWLTest.java
index 016dd9f2..af75615f 100644
--- a/library/src/test/java/org/mustangproject/ZUGFeRD/ProfilesMinimumBasicWLTest.java
+++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ProfilesMinimumBasicWLTest.java
@@ -36,7 +36,8 @@ import java.util.Date;
*/
public class ProfilesMinimumBasicWLTest extends TestCase {
- final String TARGET_PDF_FX_MINIMUM = "./target/testout-Minimum.pdf";
+ final String TARGET_PDF_FX_MINIMUM_INV = "./target/testout-Minimum-INV.pdf";
+ final String TARGET_PDF_FX_MINIMUM_CN = "./target/testout-Minimum-CN.pdf";
public void testMinimumCreditNote() {
String ownNumber = "NUMFACTURE";
@@ -67,7 +68,7 @@ public class ProfilesMinimumBasicWLTest extends TestCase {
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), new BigDecimal(123), new BigDecimal(1)))
.setCreditNote();
ze.setTransaction(i);
- ze.export(TARGET_PDF_FX_MINIMUM);
+ ze.export(TARGET_PDF_FX_MINIMUM_CN);
// check for pdf-a schema extension
// assertFalse(pdfContent.indexOf("EN 16931") == -1);
@@ -79,7 +80,7 @@ public class ProfilesMinimumBasicWLTest extends TestCase {
}
// now check the contents (like MustangReaderTest)
- ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF_FX_MINIMUM);
+ ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF_FX_MINIMUM_CN);
// Reading ZUGFeRD
assertEquals("146.37",zi.getAmount());
@@ -121,7 +122,7 @@ public class ProfilesMinimumBasicWLTest extends TestCase {
.setNumber(ownNumber).setTotalPrepaidAmount(new BigDecimal("1"))
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), new BigDecimal(123), new BigDecimal(1)));
ze.setTransaction(i);
- ze.export(TARGET_PDF_FX_MINIMUM);
+ ze.export(TARGET_PDF_FX_MINIMUM_INV);
// check for pdf-a schema extension
// assertFalse(pdfContent.indexOf("EN 16931") == -1);
@@ -133,7 +134,7 @@ public class ProfilesMinimumBasicWLTest extends TestCase {
}
// now check the contents (like MustangReaderTest)
- ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF_FX_MINIMUM);
+ ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF_FX_MINIMUM_INV);
// Reading ZUGFeRD
assertEquals("145.37",zi.getAmount());
diff --git a/validator/src/test/java/org/mustangproject/validator/LibraryTest.java b/validator/src/test/java/org/mustangproject/validator/LibraryTest.java
index 2e1b1a17..03b7c782 100644
--- a/validator/src/test/java/org/mustangproject/validator/LibraryTest.java
+++ b/validator/src/test/java/org/mustangproject/validator/LibraryTest.java
@@ -244,8 +244,31 @@ public class LibraryTest extends ResourceCase {
.isEqualTo(0);
}
- public void testMinimumProfileValidity() {
- File tempFile = new File("../library/target/testout-Minimum.pdf");
+ public void testMinimumProfileValidityInvoice() {
+ File tempFile = new File("../library/target/testout-Minimum-INV.pdf");
+ ZUGFeRDValidator zfv = new ZUGFeRDValidator();
+
+ String res = zfv.validate(tempFile.getAbsolutePath());
+
+ assertThat(res).valueByXPath("count(//error)")
+ .asInt()
+ .isEqualTo(0);
+ assertThat(res).valueByXPath("/validation/summary/@status")
+ .asString()
+ .isEqualTo("valid");// expect to be valid because XR notices are, well, only notices
+ assertThat(res).valueByXPath("/validation/xml/summary/@status")
+ .asString()
+ .isEqualTo("valid");
+ /** end of errors due to version mismatch*/
+
+
+ assertThat(res).valueByXPath("count(//notice)")
+ .asInt()
+ .isEqualTo(0);
+ }
+
+ public void testMinimumProfileValidityCreditNote() {
+ File tempFile = new File("../library/target/testout-Minimum-CN.pdf");
ZUGFeRDValidator zfv = new ZUGFeRDValidator();
String res = zfv.validate(tempFile.getAbsolutePath());