This commit is contained in:
jstaerk
2023-12-23 02:38:21 +01:00
parent c6173dd124
commit eba5413610
6 changed files with 62 additions and 232 deletions

View File

@@ -30,8 +30,8 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
protected List<IZUGFeRDTradeSettlementDebit> debitDetails = new ArrayList<>();
protected Contact contact = null;
protected LegalOrganisation legalOrg = null;
protected SchemedID globalId=null;
protected SchemedID uriUniversalCommunicationId=null; //e.g. the email address of the organization
protected SchemedID globalId = null;
protected SchemedID uriUniversalCommunicationId = null; //e.g. the email address of the organization
/**
* Default constructor.
@@ -153,7 +153,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
if (itemChilds.item(itemChildIndex).getLocalName().equals("GlobalID")) {
if (itemChilds.item(itemChildIndex).getAttributes().getNamedItem("schemeID") != null) {
SchemedID gid=new SchemedID().setScheme(itemChilds.item(itemChildIndex).getAttributes().getNamedItem("schemeID").getNodeValue()).setId(itemChilds.item(itemChildIndex).getTextContent());
SchemedID gid = new SchemedID().setScheme(itemChilds.item(itemChildIndex).getAttributes().getNamedItem("schemeID").getNodeValue()).setId(itemChilds.item(itemChildIndex).getTextContent());
addGlobalID(gid);
}
@@ -198,8 +198,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
if ((taxChilds.item(taxChildIndex).getLocalName().equals("ID"))) {
if (taxChilds.item(taxChildIndex).getAttributes().getNamedItem("schemeID") != null) {
Node firstChild = taxChilds.item(taxChildIndex).getFirstChild();
if (firstChild != null)
{
if (firstChild != null) {
if (taxChilds.item(taxChildIndex).getAttributes()
.getNamedItem("schemeID").getNodeValue().equals("VA")) {
setVATID(firstChild.getNodeValue());
@@ -294,22 +293,19 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
parseFromUBL(nodes);
return;
}
if (itemChilds.item(itemChildIndex).getLocalName().equals("Name")) {
setName(itemChilds.item(itemChildIndex).getTextContent());
}
if (itemChilds.item(itemChildIndex).getLocalName().equals("GlobalID")) {
if (itemChilds.item(itemChildIndex).getAttributes().getNamedItem("schemeID") != null) {
SchemedID gid=new SchemedID().setScheme(itemChilds.item(itemChildIndex).getAttributes().getNamedItem("schemeID").getNodeValue()).setId(itemChilds.item(itemChildIndex).getTextContent());
SchemedID gid = new SchemedID().setScheme(itemChilds.item(itemChildIndex).getAttributes().getNamedItem("schemeID").getNodeValue()).setId(itemChilds.item(itemChildIndex).getTextContent());
addGlobalID(gid);
}
}
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();
for (int postalChildIndex = 0; postalChildIndex < postal.getLength(); postalChildIndex++) {
@@ -337,6 +333,19 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
}
}
if (itemChilds.item(itemChildIndex).getLocalName().equals("URIUniversalCommunication")) {
NodeList URIchilds = itemChilds.item(itemChildIndex).getChildNodes();
for (int URIChildIndex = 0; URIChildIndex < URIchilds.getLength(); URIChildIndex++) {
Node currentNode = URIchilds.item(URIChildIndex);
if ((currentNode.getLocalName() != null) && (currentNode.getLocalName().equals("URIID")
&&
(currentNode.getAttributes().getNamedItem("schemeID") != null))
&& (URIchilds.item(URIChildIndex).getAttributes().getNamedItem("schemeID").getNodeValue().equals("EM"))
) {
setEmail(currentNode.getTextContent());
}
}
}
if (itemChilds.item(itemChildIndex).getLocalName().equals("SpecifiedTaxRegistration")) {
NodeList taxChilds = itemChilds.item(itemChildIndex).getChildNodes();
@@ -345,14 +354,13 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
if ((taxChilds.item(taxChildIndex).getLocalName().equals("ID"))) {
if (taxChilds.item(taxChildIndex).getAttributes().getNamedItem("schemeID") != null) {
Node firstChild = taxChilds.item(taxChildIndex).getFirstChild();
if (firstChild != null)
{
if (firstChild != null) {
if (taxChilds.item(taxChildIndex).getAttributes()
.getNamedItem("schemeID").getNodeValue().equals("VA")) {
.getNamedItem("schemeID").getNodeValue().equals("VA")) {
setVATID(firstChild.getNodeValue());
}
if (taxChilds.item(taxChildIndex).getAttributes()
.getNamedItem("schemeID").getNodeValue().equals("FC")) {
.getNamedItem("schemeID").getNodeValue().equals("FC")) {
setTaxID(firstChild.getNodeValue());
}
}
@@ -374,37 +382,35 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
@Override
public String getGlobalID() {
if (globalId!=null) {
if (globalId != null) {
return globalId.getID();
}
return null;
}
@Override
public String getGlobalIDScheme() {
if (globalId!=null) {
if (globalId != null) {
return globalId.getScheme();
}
return null;
}
@Override
public String getUriUniversalCommunicationID() {
if (uriUniversalCommunicationId!=null) {
if (uriUniversalCommunicationId != null) {
return uriUniversalCommunicationId.getID();
}
return null;
}
@Override
public String getUriUniversalCommunicationIDScheme() {
if (uriUniversalCommunicationId!=null) {
if (uriUniversalCommunicationId != null) {
return uriUniversalCommunicationId.getScheme();
}
return null;
@@ -414,28 +420,15 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
/***
* sets the email of the organization (not the one of the contact person)
* (while setEmail has to be defined here getEmail comes from IZUGFeRDExportableTradeParty)
* @return fluent setter
*/
public TradeParty setEmail(String eMail) {
SchemedID theSchemedID=new SchemedID("EM", eMail);
SchemedID theSchemedID = new SchemedID("EM", eMail);
addUriUniversalCommunicationID(theSchemedID);
return this;
}
/***
* gets the email of the organization (not the one of the contact person)
* will return null if not set or if the provided UriUniversalCommunicationID
* is not a email address
*
* @return String the email, or null
*/
public String getEmail() {
if (uriUniversalCommunicationId.getScheme().equals("EM")) {
return uriUniversalCommunicationId.getID();
}
return null;
}
/**
* if it's a customer, this can e.g. be the customer ID
@@ -460,12 +453,12 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
}
public TradeParty addGlobalID(SchemedID schemedID) {
globalId=schemedID;
globalId = schemedID;
return this;
}
public TradeParty addUriUniversalCommunicationID(SchemedID schemedID) {
uriUniversalCommunicationId=schemedID;
uriUniversalCommunicationId = schemedID;
return this;
}
@@ -496,7 +489,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
}
public TradeParty setLegalOrganisation(LegalOrganisation legalOrganisation) {
legalOrg=legalOrganisation;
legalOrg = legalOrganisation;
return this;
}
@@ -634,8 +627,8 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
return null;
}
List<IZUGFeRDTradeSettlement> tradeSettlements = Stream.concat(bankDetails.stream(), debitDetails.stream())
.map(IZUGFeRDTradeSettlement.class::cast)
.collect(Collectors.toList());
.map(IZUGFeRDTradeSettlement.class::cast)
.collect(Collectors.toList());
IZUGFeRDTradeSettlement[] result = new IZUGFeRDTradeSettlement[tradeSettlements.size()];
for (int i = 0; i < tradeSettlements.size(); i++) {
@@ -651,7 +644,6 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
}
/***
* additional info of the address, e.g. which building or which floor.
* Street address will become "lineOne", this will become "lineTwo".

View File

@@ -79,9 +79,11 @@ public interface IZUGFeRDExportableTradeParty {
return null;
}
/**
* The URIID of URIUniversalCommunicationID
* It is used by some countries, i.e. Luxembourg
* The URIID of URIUniversalCommunicationID (e.g. email address)
* It is used by some countries, i.e. Luxembourg, Peppol
* @return the URI as string
*/
default String getUriUniversalCommunicationID() {
@@ -89,6 +91,24 @@ public interface IZUGFeRDExportableTradeParty {
}
/***
* gets the email of the organization (not the one of the contact person)
* will return null if not set or if the provided UriUniversalCommunicationID
* is not a email address
*
* @return String the email, or null
*/
default String getEmail() {
if ((getUriUniversalCommunicationIDScheme()!=null)&&(getUriUniversalCommunicationIDScheme().equals("EM"))) {
return getUriUniversalCommunicationID();
}
return null;
}
/***
* the named contact person for inquiries
* @return contact
*/
default IZUGFeRDExportableContact getContact() {
return null;
}

View File

@@ -86,8 +86,8 @@ public class XRTest extends TestCase {
FileAttachment fe1=new FileAttachment("one.pdf", "application/pdf", "Alternative", b);
Invoice i = new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date())
.setSender(new TradeParty(orgname,"teststr","55232","teststadt","DE").addTaxID("DE4711").addVATID("DE0815").setContact(new Contact("Hans Test","+49123456789","test@example.org")).addBankDetails(new BankDetails("DE12500105170648489890","COBADEFXXX")))
.setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE"))
.setSender(new TradeParty(orgname,"teststr","55232","teststadt","DE").setEmail("sender@example.com").addTaxID("DE4711").addVATID("DE0815").setContact(new Contact("Hans Test","+49123456789","test@example.org")).addBankDetails(new BankDetails("DE12500105170648489890","COBADEFXXX")))
.setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").setEmail("recipient@sample.org"))
.setReferenceNumber("991-01484-64")//leitweg-id
// not using any VAT, this is also a test of zero-rated goods:
.setNumber(number).setPaymentTermDescription("#SKONTO#TAGE=14#PROZENT=2.25#\n" +

View File

@@ -386,10 +386,10 @@ public class ZF2PushTest extends TestCase {
ze.setTransaction(new Invoice().setCurrency("CHF").addNote("document level 1/2").addNote("document level 2/2").setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date())
.setSellerOrderReferencedDocumentID("9384").setBuyerOrderReferencedDocumentID("28934")
.setDetailedDeliveryPeriod(new SimpleDateFormat("yyyyMMdd").parse(occurrenceFrom), new SimpleDateFormat("yyyyMMdd").parse(occurrenceTo))
.setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID(taxID).setID("0009845"))
.setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID(taxID).setEmail("sender@test.org").setID("0009845"))
.setDeliveryAddress(new TradeParty("just the other side of the street", "teststr.12a", "55232", "Entenhausen", "DE").addVATID("DE47110"))
.setContractReferencedDocument(contractID)
.setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").addGlobalID(gln).addVATID("DE4711").setContact(new Contact("Franz Müller", "01779999999", "franz@mueller.de", "teststr. 12", "55232", "Entenhausen", "DE").setFax("++49555123456")).setAdditionalAddress("Hinterhaus 3"))
.setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").addGlobalID(gln).setEmail("recipient@test.org").addVATID("DE4711").setContact(new Contact("Franz Müller", "01779999999", "franz@mueller.de", "teststr. 12", "55232", "Entenhausen", "DE").setFax("++49555123456")).setAdditionalAddress("Hinterhaus 3"))
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(16)).addGlobalID(gtin).setSellerAssignedID("4711"), price, new BigDecimal(1.0)).addReferencedLineID("xxx").addNote("item level 1/1").addAllowance(new Allowance(new BigDecimal(0.02)).setReason("item discount").setTaxPercent(new BigDecimal(16))).setDetailedDeliveryPeriod(sdf.parse("2020-01-13"), sdf.parse("2020-01-15")))
.addCharge(new Charge(new BigDecimal(0.5)).setReason("quick delivery charge").setTaxPercent(new BigDecimal(16)))
.addAllowance(new Allowance(new BigDecimal(0.2)).setReason("discount").setTaxPercent(new BigDecimal(16)))

View File

@@ -169,6 +169,8 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
// Reading ZUGFeRD
assertEquals("4711", invoice.getZFItems()[0].getProduct().getSellerAssignedID());
assertEquals("9384", invoice.getSellerOrderReferencedDocumentID());
assertEquals("sender@test.org", invoice.getSender().getEmail());
assertEquals("recipient@test.org", invoice.getRecipient().getEmail());
assertEquals("28934", invoice.getBuyerOrderReferencedDocumentID());
}

View File

@@ -1,184 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<rsm:CrossIndustryInvoice xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100" xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100">
<!-- generated by: mustangproject.org vnull-->
<rsm:ExchangedDocumentContext>
<ram:GuidelineSpecifiedDocumentContextParameter>
<ram:ID>urn:cen.eu:en16931:2017</ram:ID>
</ram:GuidelineSpecifiedDocumentContextParameter>
</rsm:ExchangedDocumentContext>
<rsm:ExchangedDocument>
<ram:ID>123</ram:ID>
<ram:TypeCode>380</ram:TypeCode>
<ram:IssueDateTime>
<udt:DateTimeString format="102">20220725</udt:DateTimeString>
</ram:IssueDateTime>
<ram:IncludedNote>
<ram:Content>document level 1/2</ram:Content>
</ram:IncludedNote>
<ram:IncludedNote>
<ram:Content>document level 2/2</ram:Content>
</ram:IncludedNote>
</rsm:ExchangedDocument>
<rsm:SupplyChainTradeTransaction>
<ram:IncludedSupplyChainTradeLineItem>
<ram:AssociatedDocumentLineDocument>
<ram:LineID>1</ram:LineID>
<ram:IncludedNote>
<ram:Content>item level 1/1</ram:Content>
</ram:IncludedNote>
</ram:AssociatedDocumentLineDocument>
<ram:SpecifiedTradeProduct>
<ram:Name>Testprodukt</ram:Name>
<ram:Description/>
</ram:SpecifiedTradeProduct>
<ram:SpecifiedLineTradeAgreement>
<ram:BuyerOrderReferencedDocument>
<ram:LineID>xxx</ram:LineID>
</ram:BuyerOrderReferencedDocument>
<ram:GrossPriceProductTradePrice>
<ram:ChargeAmount>1.0000</ram:ChargeAmount>
<ram:BasisQuantity unitCode="C62">1.0000</ram:BasisQuantity>
<ram:AppliedTradeAllowanceCharge>
<ram:ChargeIndicator>
<udt:Indicator>false</udt:Indicator>
</ram:ChargeIndicator>
<ram:ActualAmount>0.0200</ram:ActualAmount>
</ram:AppliedTradeAllowanceCharge>
</ram:GrossPriceProductTradePrice>
<ram:NetPriceProductTradePrice>
<ram:ChargeAmount>0.9800</ram:ChargeAmount>
<ram:BasisQuantity unitCode="C62">1.0000</ram:BasisQuantity>
</ram:NetPriceProductTradePrice>
</ram:SpecifiedLineTradeAgreement>
<ram:SpecifiedLineTradeDelivery>
<ram:BilledQuantity unitCode="C62">1.0000</ram:BilledQuantity>
</ram:SpecifiedLineTradeDelivery>
<ram:SpecifiedLineTradeSettlement>
<ram:ApplicableTradeTax>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:RateApplicablePercent>16.00</ram:RateApplicablePercent>
</ram:ApplicableTradeTax>
<ram:BillingSpecifiedPeriod>
<ram:StartDateTime>
<udt:DateTimeString format="102">20200113</udt:DateTimeString>
</ram:StartDateTime>
<ram:EndDateTime>
<udt:DateTimeString format="102">20200115</udt:DateTimeString>
</ram:EndDateTime>
</ram:BillingSpecifiedPeriod>
<ram:SpecifiedTradeSettlementLineMonetarySummation>
<ram:LineTotalAmount>0.98</ram:LineTotalAmount>
</ram:SpecifiedTradeSettlementLineMonetarySummation>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:ApplicableHeaderTradeAgreement>
<ram:SellerTradeParty>
<ram:ID>0009845</ram:ID>
<ram:Name>Test company</ram:Name>
<ram:PostalTradeAddress>
<ram:PostcodeCode>55232</ram:PostcodeCode>
<ram:LineOne>teststr</ram:LineOne>
<ram:CityName>teststadt</ram:CityName>
<ram:CountryID>DE</ram:CountryID>
</ram:PostalTradeAddress>
<ram:SpecifiedTaxRegistration>
<ram:ID schemeID="VA">DE0815</ram:ID>
</ram:SpecifiedTaxRegistration>
<ram:SpecifiedTaxRegistration>
<ram:ID schemeID="FC">9990815</ram:ID>
</ram:SpecifiedTaxRegistration>
</ram:SellerTradeParty>
<ram:BuyerTradeParty>
<ram:GlobalID schemeID="0088">4304171000002</ram:GlobalID>
<ram:Name>Franz Müller</ram:Name>
<ram:PostalTradeAddress>
<ram:PostcodeCode>55232</ram:PostcodeCode>
<ram:LineOne>teststr.12</ram:LineOne>
<ram:LineTwo>Hinterhaus 3</ram:LineTwo>
<ram:CityName>Entenhausen</ram:CityName>
<ram:CountryID>DE</ram:CountryID>
</ram:PostalTradeAddress>
<ram:SpecifiedTaxRegistration>
<ram:ID schemeID="VA">DE4711</ram:ID>
</ram:SpecifiedTaxRegistration>
</ram:BuyerTradeParty>
<ram:ContractReferencedDocument>
<ram:IssuerAssignedID>376zreurzu0983</ram:IssuerAssignedID>
</ram:ContractReferencedDocument>
</ram:ApplicableHeaderTradeAgreement>
<ram:ApplicableHeaderTradeDelivery>
<ram:ShipToTradeParty>
<ram:Name>just the other side of the street</ram:Name>
<ram:PostalTradeAddress>
<ram:PostcodeCode>55232</ram:PostcodeCode>
<ram:LineOne>teststr.12a</ram:LineOne>
<ram:CityName>Entenhausen</ram:CityName>
<ram:CountryID>DE</ram:CountryID>
</ram:PostalTradeAddress>
</ram:ShipToTradeParty>
<ram:ActualDeliverySupplyChainEvent>
<ram:OccurrenceDateTime>
<udt:DateTimeString format="102">20201102</udt:DateTimeString>
</ram:OccurrenceDateTime>
</ram:ActualDeliverySupplyChainEvent>
</ram:ApplicableHeaderTradeDelivery>
<ram:ApplicableHeaderTradeSettlement>
<ram:PaymentReference>123</ram:PaymentReference>
<ram:InvoiceCurrencyCode>CHF</ram:InvoiceCurrencyCode>
<ram:ApplicableTradeTax>
<ram:CalculatedAmount>0.20</ram:CalculatedAmount>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:BasisAmount>1.28</ram:BasisAmount>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:RateApplicablePercent>16.00</ram:RateApplicablePercent>
</ram:ApplicableTradeTax>
<ram:BillingSpecifiedPeriod>
<ram:StartDateTime>
<udt:DateTimeString format="102">20201001</udt:DateTimeString>
</ram:StartDateTime>
<ram:EndDateTime>
<udt:DateTimeString format="102">20201005</udt:DateTimeString>
</ram:EndDateTime>
</ram:BillingSpecifiedPeriod>
<ram:SpecifiedTradeAllowanceCharge>
<ram:ChargeIndicator>
<udt:Indicator>true</udt:Indicator>
</ram:ChargeIndicator>
<ram:ActualAmount>0.50</ram:ActualAmount>
<ram:Reason> quick delivery charge</ram:Reason>
<ram:CategoryTradeTax>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:RateApplicablePercent>16.00</ram:RateApplicablePercent>
</ram:CategoryTradeTax>
</ram:SpecifiedTradeAllowanceCharge>
<ram:SpecifiedTradeAllowanceCharge>
<ram:ChargeIndicator>
<udt:Indicator>false</udt:Indicator>
</ram:ChargeIndicator>
<ram:ActualAmount>0.20</ram:ActualAmount>
<ram:Reason> discount</ram:Reason>
<ram:CategoryTradeTax>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:RateApplicablePercent>16.00</ram:RateApplicablePercent>
</ram:CategoryTradeTax>
</ram:SpecifiedTradeAllowanceCharge>
<ram:SpecifiedTradePaymentTerms>
<ram:Description>Zahlbar ohne Abzug bis 25.07.2022</ram:Description>
</ram:SpecifiedTradePaymentTerms>
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
<ram:LineTotalAmount>0.98</ram:LineTotalAmount>
<ram:ChargeTotalAmount>0.50</ram:ChargeTotalAmount>
<ram:AllowanceTotalAmount>0.20</ram:AllowanceTotalAmount>
<ram:TaxBasisTotalAmount>1.28</ram:TaxBasisTotalAmount>
<ram:TaxTotalAmount currencyID="CHF">0.20</ram:TaxTotalAmount>
<ram:GrandTotalAmount>1.48</ram:GrandTotalAmount>
<ram:TotalPrepaidAmount>0.00</ram:TotalPrepaidAmount>
<ram:DuePayableAmount>1.48</ram:DuePayableAmount>
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
</ram:ApplicableHeaderTradeSettlement>
</rsm:SupplyChainTradeTransaction>
</rsm:CrossIndustryInvoice>