add fax number to contact. Allow access to lineTwo(additionaladdress)

This commit is contained in:
Jochen Stärk
2020-10-27 10:18:28 +01:00
parent 558c88bfd6
commit 2bb906df3a
6 changed files with 48 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ import org.mustangproject.ZUGFeRD.IZUGFeRDExportableContact;
public class Contact implements IZUGFeRDExportableContact {
protected String name,phone,email,zip,street,location,country;
protected String fax=null;
public Contact(String name, String phone, String email) {
this.name = name;
@@ -43,6 +44,16 @@ public class Contact implements IZUGFeRDExportableContact {
return this;
}
@Override
public String getFax() {
return fax;
}
public Contact setFax(String fax) {
this.fax = fax;
return this;
}
public String getEMail() {
return email;
}

View File

@@ -6,13 +6,13 @@ import org.mustangproject.ZUGFeRD.IZUGFeRDTradeSettlement;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.xpath.XPathConstants;
import java.util.ArrayList;
public class TradeParty implements IZUGFeRDExportableTradeParty {
protected String name, zip, street, location, country;
protected String taxID = null, vatID = null;
protected String additionalAddress = null;
protected ArrayList<BankDetails> bankDetails = new ArrayList<BankDetails>();
protected Contact contact = null;
@@ -66,6 +66,9 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
if (postal.item(postalChildIndex).getNodeName().equals("ram:LineOne")) {
setStreet(postal.item(postalChildIndex).getTextContent());
}
if (postal.item(postalChildIndex).getNodeName().equals("ram:LineTwo")) {
setAdditionalAddress(postal.item(postalChildIndex).getTextContent());
}
if (postal.item(postalChildIndex).getNodeName().equals("ram:CityName")) {
setLocation(postal.item(postalChildIndex).getTextContent());
}
@@ -188,4 +191,15 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
}
return bankDetails.toArray(new IZUGFeRDTradeSettlement[0]);
}
@Override
public String getAdditionalAddress() {
return additionalAddress;
}
public TradeParty setAdditionalAddress(String additionalAddress) {
this.additionalAddress = additionalAddress;
return this;
}
}

View File

@@ -51,11 +51,15 @@ public interface IZUGFeRDExportableContact {
default String getPhone() {
return null;
}
default String getEMail() {
return null;
}
default String getFax() {
return null;
}
/**
* Postal code of the recipient

View File

@@ -235,12 +235,20 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IAbsoluteValueProvide
+ XMLTools.encodeXML(party.getContact().getPhone()) + "</ram:CompleteNumber>\n"
+ " </ram:TelephoneUniversalCommunication>\n";
}
if (party.getContact().getFax() != null) {
xml = xml + " <ram:FaxUniversalCommunication>\n" + " <ram:CompleteNumber>"
+ XMLTools.encodeXML(party.getContact().getFax()) + "</ram:CompleteNumber>\n"
+ " </ram:FaxUniversalCommunication>\n";
}
if (party.getContact().getEMail() != null) {
xml = xml + " <ram:EmailURIUniversalCommunication>\n" + " <ram:URIID>"
+ XMLTools.encodeXML(party.getContact().getEMail()) + "</ram:URIID>\n"
+ " </ram:EmailURIUniversalCommunication>\n";
}
xml = xml + " </ram:DefinedTradeContact>";
}

View File

@@ -63,13 +63,10 @@ public class ZF2PushTest extends TestCase {
.load(SOURCE_PDF)) {
try {
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setContractReferencedDocument(contractID).setOccurrencePeriod(new SimpleDateFormat("yyyyMMdd").parse(occurenceFrom), new SimpleDateFormat("yyyyMMdd").parse(occurenceTo)).setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addBankDetails(new BankDetails("777666555", "DE4321"))).setOwnTaxID("4711").setOwnVATID("DE19990815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").setContact(new Contact("nameRep", "phoneRep", "emailRep@test.com"))).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0))));
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setContractReferencedDocument(contractID).setOccurrencePeriod(new SimpleDateFormat("yyyyMMdd").parse(occurenceFrom), new SimpleDateFormat("yyyyMMdd").parse(occurenceTo)).setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addBankDetails(new BankDetails("777666555", "DE4321"))).setOwnTaxID("4711").setOwnVATID("DE19990815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").setAdditionalAddress("Hinterhaus 3").setContact(new Contact("nameRep", "phoneRep", "emailRep@test.com"))).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0))));
} catch (ParseException ex) {
throw new RuntimeException("Parse exception");
}
String theXML = new String(ze.getProvider().getXML());
assertTrue(theXML.contains("777666555")); //the iban
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
ze.export(TARGET_PDF);
} catch (IOException e) {
@@ -78,11 +75,15 @@ public class ZF2PushTest extends TestCase {
// now check the contents (like MustangReaderTest)
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF);
assertTrue(zi.getUTF8().contains("777666555")); //the iban
assertTrue(zi.getUTF8().contains("EUR"));
assertTrue(zi.getUTF8().contains("<rsm:CrossIndustryInvoice"));
assertTrue(zi.getUTF8().contains("EUR")); //default invoice currency
assertTrue(zi.getUTF8().contains(occurenceFrom));
assertTrue(zi.getUTF8().contains(occurenceTo));
assertTrue(zi.getUTF8().contains(contractID));
assertTrue(zi.getUTF8().contains("Hinterhaus")); // lineTwo/additionalAddress
assertTrue(zi.getUTF8().contains("0815"));
// Reading ZUGFeRD
@@ -159,7 +160,7 @@ public class ZF2PushTest extends TestCase {
// .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)).addAllowance(new Allowance().setPercent(new BigDecimal(50)))));
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE")).setOwnTaxID("4711").setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number)
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE")).setOwnTaxID("4711").setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").setContact(new Contact("contact testname","123456","contact.testemail@example.org" ).setFax("0911623562"))).setNumber(number)
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)).addAllowance(new Allowance(new BigDecimal("0.1"))))
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)).addAllowance(new Allowance().setPercent(new BigDecimal(50))))
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(2.0)).addCharge(new Charge(new BigDecimal(1))))
@@ -178,6 +179,7 @@ public class ZF2PushTest extends TestCase {
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_ITEMCHARGESALLOWANCESPDF);
assertTrue(zi.getUTF8().contains("EUR"));
assertTrue(zi.getUTF8().contains("0911623562")); // fax number
// Reading ZUGFeRD
assertEquals("18.33", zi.getAmount());