import contacts and tradeparty vat and tax number
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package org.mustangproject;
|
package org.mustangproject;
|
||||||
|
|
||||||
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableContact;
|
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableContact;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* a named contact person in an organisation
|
* a named contact person in an organisation
|
||||||
@@ -46,6 +48,58 @@ public class Contact implements IZUGFeRDExportableContact {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* XML parsing constructor
|
||||||
|
* @param nodes the nodelist returned e.g. from xpath
|
||||||
|
*
|
||||||
|
* e.g. sth like
|
||||||
|
* <ram:DefinedTradeContact>
|
||||||
|
* <ram:PersonName>Name</ram:PersonName>
|
||||||
|
* <ram:TelephoneUniversalCommunication>
|
||||||
|
* <ram:CompleteNumber>069 100-0</ram:CompleteNumber>
|
||||||
|
* </ram:TelephoneUniversalCommunication>
|
||||||
|
* <ram:EmailURIUniversalCommunication>
|
||||||
|
* <ram:URIID>test@example.com</ram:URIID>
|
||||||
|
* </ram:EmailURIUniversalCommunication>
|
||||||
|
* </ram:DefinedTradeContact>
|
||||||
|
*/
|
||||||
|
public Contact(NodeList nodes) {
|
||||||
|
if (nodes.getLength() > 0) {
|
||||||
|
|
||||||
|
for (int nodeIndex = 0; nodeIndex < nodes.getLength(); nodeIndex++) {
|
||||||
|
//nodes.item(i).getTextContent())) {
|
||||||
|
Node currentItemNode = nodes.item(nodeIndex);
|
||||||
|
if (currentItemNode.getLocalName() != null) {
|
||||||
|
|
||||||
|
if (currentItemNode.getLocalName().equals("PersonName")) {
|
||||||
|
setName(currentItemNode.getFirstChild().getNodeValue());
|
||||||
|
}
|
||||||
|
if (currentItemNode.getLocalName().equals("TelephoneUniversalCommunication")) {
|
||||||
|
NodeList tel = currentItemNode.getChildNodes();
|
||||||
|
for (int telChildIndex = 0; telChildIndex < tel.getLength(); telChildIndex++) {
|
||||||
|
if (tel.item(telChildIndex).getLocalName() != null) {
|
||||||
|
if (tel.item(telChildIndex).getLocalName().equals("CompleteNumber")) {
|
||||||
|
setPhone(tel.item(telChildIndex).getTextContent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (currentItemNode.getLocalName().equals("EmailURIUniversalCommunication")) {
|
||||||
|
NodeList email = currentItemNode.getChildNodes();
|
||||||
|
for (int emailChildIndex = 0; emailChildIndex < email.getLength(); emailChildIndex++) {
|
||||||
|
if (email.item(emailChildIndex).getLocalName() != null) {
|
||||||
|
if (email.item(emailChildIndex).getLocalName().equals("URIID")) {
|
||||||
|
setEMail(email.item(emailChildIndex).getTextContent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
@@ -53,6 +107,7 @@ public class Contact implements IZUGFeRDExportableContact {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* the first and last name of the contact
|
* the first and last name of the contact
|
||||||
|
*
|
||||||
* @param name first and last name
|
* @param name first and last name
|
||||||
* @return fluent setter
|
* @return fluent setter
|
||||||
*/
|
*/
|
||||||
@@ -126,6 +181,7 @@ public class Contact implements IZUGFeRDExportableContact {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* street and number, if the address is different to the organisation
|
* street and number, if the address is different to the organisation
|
||||||
|
*
|
||||||
* @param street street and number of the contact
|
* @param street street and number of the contact
|
||||||
* @return fluent setter
|
* @return fluent setter
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -78,35 +78,64 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
|||||||
Node currentItemNode = nodes.item(nodeIndex);
|
Node currentItemNode = nodes.item(nodeIndex);
|
||||||
NodeList itemChilds = currentItemNode.getChildNodes();
|
NodeList itemChilds = currentItemNode.getChildNodes();
|
||||||
for (int itemChildIndex = 0; itemChildIndex < itemChilds.getLength(); itemChildIndex++) {
|
for (int itemChildIndex = 0; itemChildIndex < itemChilds.getLength(); itemChildIndex++) {
|
||||||
if (itemChilds.item(itemChildIndex).getNodeName().equals("ram:Name")) {
|
if (itemChilds.item(itemChildIndex).getLocalName() != null) {
|
||||||
|
|
||||||
|
if (itemChilds.item(itemChildIndex).getLocalName().equals("Name")) {
|
||||||
setName(itemChilds.item(itemChildIndex).getTextContent());
|
setName(itemChilds.item(itemChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
if (itemChilds.item(itemChildIndex).getNodeName().equals("ram:PostalTradeAddress")) {
|
if (itemChilds.item(itemChildIndex).getLocalName().equals("DefinedTradeContact")) {
|
||||||
|
NodeList contact = itemChilds.item(itemChildIndex).getChildNodes();
|
||||||
|
setContact(new Contact(contact));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemChilds.item(itemChildIndex).getLocalName().equals("PostalTradeAddress")) {
|
||||||
NodeList postal = itemChilds.item(itemChildIndex).getChildNodes();
|
NodeList postal = itemChilds.item(itemChildIndex).getChildNodes();
|
||||||
for (int postalChildIndex = 0; postalChildIndex < postal.getLength(); postalChildIndex++) {
|
for (int postalChildIndex = 0; postalChildIndex < postal.getLength(); postalChildIndex++) {
|
||||||
if (postal.item(postalChildIndex).getNodeName().equals("ram:LineOne")) {
|
if (postal.item(postalChildIndex).getLocalName() != null) {
|
||||||
|
if (postal.item(postalChildIndex).getLocalName().equals("LineOne")) {
|
||||||
setStreet(postal.item(postalChildIndex).getTextContent());
|
setStreet(postal.item(postalChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
if (postal.item(postalChildIndex).getNodeName().equals("ram:LineTwo")) {
|
if (postal.item(postalChildIndex).getLocalName().equals("LineTwo")) {
|
||||||
setAdditionalAddress(postal.item(postalChildIndex).getTextContent());
|
setAdditionalAddress(postal.item(postalChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
if (postal.item(postalChildIndex).getNodeName().equals("ram:CityName")) {
|
if (postal.item(postalChildIndex).getLocalName().equals("CityName")) {
|
||||||
setLocation(postal.item(postalChildIndex).getTextContent());
|
setLocation(postal.item(postalChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
if (postal.item(postalChildIndex).getNodeName().equals("ram:PostcodeCode")) {
|
if (postal.item(postalChildIndex).getLocalName().equals("PostcodeCode")) {
|
||||||
setZIP(postal.item(postalChildIndex).getTextContent());
|
setZIP(postal.item(postalChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
if (postal.item(postalChildIndex).getNodeName().equals("ram:CountryID")) {
|
if (postal.item(postalChildIndex).getLocalName().equals("CountryID")) {
|
||||||
setCountry(postal.item(postalChildIndex).getTextContent());
|
setCountry(postal.item(postalChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemChilds.item(itemChildIndex).getLocalName().equals("SpecifiedTaxRegistration")) {
|
||||||
|
NodeList taxChilds = itemChilds.item(itemChildIndex).getChildNodes();
|
||||||
|
for (int taxChildIndex = 0; taxChildIndex < taxChilds.getLength(); taxChildIndex++) {
|
||||||
|
if (taxChilds.item(taxChildIndex).getLocalName() != null) {
|
||||||
|
if ((taxChilds.item(taxChildIndex).getLocalName().equals("ID"))) {
|
||||||
|
if (taxChilds.item(taxChildIndex).getAttributes().getNamedItem("schemeID")!=null) {
|
||||||
|
if (taxChilds.item(taxChildIndex).getAttributes().getNamedItem("schemeID").getNodeValue().equals("VA"))
|
||||||
|
{
|
||||||
|
setVATID(taxChilds.item(taxChildIndex).getFirstChild().getNodeValue());
|
||||||
|
}
|
||||||
|
if (taxChilds.item(taxChildIndex).getAttributes().getNamedItem("schemeID").getNodeValue().equals("FC"))
|
||||||
|
{
|
||||||
|
setTaxID(taxChilds.item(taxChildIndex).getFirstChild().getNodeValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -116,6 +145,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* if it's a customer, this can e.g. be the customer ID
|
* if it's a customer, this can e.g. be the customer ID
|
||||||
|
*
|
||||||
* @param ID customer/seller number
|
* @param ID customer/seller number
|
||||||
* @return fluent setter
|
* @return fluent setter
|
||||||
*/
|
*/
|
||||||
@@ -144,8 +174,10 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
|||||||
bankDetails.add(s);
|
bankDetails.add(s);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (optional)
|
* (optional)
|
||||||
|
*
|
||||||
* @param debitDetail
|
* @param debitDetail
|
||||||
* @return fluent setter
|
* @return fluent setter
|
||||||
*/
|
*/
|
||||||
@@ -183,11 +215,21 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
|||||||
return vatID;
|
return vatID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TradeParty setVATID(String VATid) {
|
||||||
|
this.vatID = VATid;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTaxID() {
|
public String getTaxID() {
|
||||||
return taxID;
|
return taxID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TradeParty setTaxID(String tax) {
|
||||||
|
this.taxID = tax;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,8 +130,11 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
xml += " <ram:Name>" + XMLTools.encodeXML(party.getName()) + "</ram:Name>\n";
|
xml += " <ram:Name>" + XMLTools.encodeXML(party.getName()) + "</ram:Name>\n";
|
||||||
|
|
||||||
if ((party.getContact() != null) && (isSender || profile == Profiles.getByName("Extended") || profile == Profiles.getByName("XRechnung"))) {
|
if ((party.getContact() != null) && (isSender || profile == Profiles.getByName("Extended") || profile == Profiles.getByName("XRechnung"))) {
|
||||||
xml = xml + "<ram:DefinedTradeContact>\n" + " <ram:PersonName>" + XMLTools.encodeXML(party.getContact().getName())
|
xml = xml + "<ram:DefinedTradeContact>\n";
|
||||||
|
if (party.getContact().getPhone() != null) {
|
||||||
|
xml = xml + "<ram:PersonName>" + XMLTools.encodeXML(party.getContact().getName())
|
||||||
+ "</ram:PersonName>\n";
|
+ "</ram:PersonName>\n";
|
||||||
|
}
|
||||||
if (party.getContact().getPhone() != null) {
|
if (party.getContact().getPhone() != null) {
|
||||||
|
|
||||||
xml = xml + " <ram:TelephoneUniversalCommunication>\n" + " <ram:CompleteNumber>"
|
xml = xml + " <ram:TelephoneUniversalCommunication>\n" + " <ram:CompleteNumber>"
|
||||||
|
|||||||
Reference in New Issue
Block a user