Merge branch 'ZUGFeRD:master' into master
This commit is contained in:
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||
|
||||
protected String name, zip, street, location, country;
|
||||
protected String name, zip, street, location, taxScheme;
|
||||
protected String taxID = null, vatID = null;
|
||||
protected String ID = null;
|
||||
protected String description = null;
|
||||
@@ -58,7 +58,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||
this.street = street;
|
||||
this.zip = zip;
|
||||
this.location = location;
|
||||
this.country = country;
|
||||
this.taxScheme = country;
|
||||
|
||||
}
|
||||
|
||||
@@ -90,22 +90,47 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentTopElementName.equals("PartyTaxScheme")) {
|
||||
|
||||
NodeList partyTaxScheme = party.item(partyIndex).getChildNodes();
|
||||
for (int partyTaxSchemeIndex = 0; partyTaxSchemeIndex < partyTaxScheme.getLength(); partyTaxSchemeIndex++) {
|
||||
NodeList partyTaxScheme = party.item(partyIndex).getChildNodes();
|
||||
for (int partyTaxSchemeIndex = 0; partyTaxSchemeIndex < partyTaxScheme.getLength(); partyTaxSchemeIndex++) {
|
||||
if (partyTaxScheme.item(partyTaxSchemeIndex).getLocalName() != null) {
|
||||
|
||||
if (partyTaxScheme.item(partyTaxSchemeIndex).getLocalName().equals("CompanyID")) {
|
||||
setTaxID(partyTaxScheme.item(partyTaxSchemeIndex).getTextContent());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// UBL only: formally it can have a name as well but BT27 party name *should* be stored in
|
||||
// so overwrite if one exists
|
||||
|
||||
// if (currentTopElementName.equals("PartyTaxScheme")) {
|
||||
// NodeList partyTaxScheme = party.item(partyIndex).getChildNodes();
|
||||
// for (int partyTaxSchemeIndex = 0; partyTaxSchemeIndex < partyTaxScheme.getLength(); partyTaxSchemeIndex++) {
|
||||
// if (partyTaxScheme.item(partyTaxSchemeIndex).getLocalName() != null) {
|
||||
// if (partyTaxScheme.item(partyTaxSchemeIndex).getLocalName().equals("TaxScheme")) {
|
||||
// NodeList taxScheme = partyTaxScheme.item(partyTaxSchemeIndex).getChildNodes();
|
||||
// for (int taxSchemeIndex = 0 ; taxSchemeIndex < taxScheme.getLength(); taxSchemeIndex++) {
|
||||
// if (taxScheme.item(taxSchemeIndex).getLocalName() != null) {
|
||||
// if(taxScheme.item(taxSchemeIndex).getLocalName().equals("ID")){
|
||||
// if (partyTaxScheme.item(partyTaxSchemeIndex).getLocalName().equals("CompanyID")) {
|
||||
// setTaxID(partyTaxScheme.item(partyTaxSchemeIndex).getTextContent());
|
||||
// } else {
|
||||
// setVATID(partyTaxScheme.item(partyTaxSchemeIndex).getTextContent());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
/*
|
||||
UBL only: formally it can have a name as well but BT27 party name *should* be stored in
|
||||
so overwrite if one exists
|
||||
*/
|
||||
|
||||
if (currentTopElementName.equals("PartyLegalEntity")) {
|
||||
NodeList legal = party.item(partyIndex).getChildNodes();
|
||||
for (int legalChildIndex = 0; legalChildIndex < legal.getLength(); legalChildIndex++) {
|
||||
@@ -113,6 +138,9 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||
if (legal.item(legalChildIndex).getLocalName().equals("RegistrationName")) {
|
||||
setName(legal.item(legalChildIndex).getTextContent());
|
||||
}
|
||||
if (legal.item(legalChildIndex).getLocalName().equals("CompanyLegalForm")) {
|
||||
setDescription(legal.item(legalChildIndex).getTextContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,26 +253,27 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||
|
||||
}
|
||||
|
||||
if (currentUBLChild.equals("SpecifiedTaxRegistration")) {
|
||||
if (currentUBLChild.equals("PartyTaxScheme")) {
|
||||
NodeList taxChilds = nodes.item(nodeIndex).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) {
|
||||
Node firstChild = taxChilds.item(taxChildIndex).getFirstChild();
|
||||
if (firstChild != null) {
|
||||
if (taxChilds.item(taxChildIndex).getAttributes().getNamedItem("schemeID").getNodeValue().equals("VA")) {
|
||||
setVATID(firstChild.getNodeValue());
|
||||
if ((taxChilds.item(taxChildIndex).getLocalName().equals("TaxScheme"))) {
|
||||
if (taxChilds.item(taxChildIndex).getLocalName().equals("CompanyID")) {
|
||||
if (taxChilds.item(taxChildIndex).getLocalName().equals("ID")) {
|
||||
if (taxChilds.item(taxChildIndex).getLocalName().equals("CompanyID")) {
|
||||
setVATID(taxChilds.item(taxChildIndex).getTextContent());
|
||||
}
|
||||
if (taxChilds.item(taxChildIndex).getAttributes().getNamedItem("schemeID").getNodeValue().equals("FC")) {
|
||||
setTaxID(firstChild.getNodeValue());
|
||||
// setTaxID(partyTaxScheme.item(partyTaxSchemeIndex).getTextContent());
|
||||
if (taxChilds.item(taxChildIndex).getAttributes().getNamedItem("ID").getNodeValue().equals("FC")) {
|
||||
if (taxChilds.item(taxChildIndex).getLocalName().equals("CompanyID")) {
|
||||
setTaxID(taxChilds.item(taxChildIndex).getTextContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -671,7 +700,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||
|
||||
@Override
|
||||
public String getCountry() {
|
||||
return country;
|
||||
return taxScheme;
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -680,7 +709,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||
* @return fluent setter
|
||||
*/
|
||||
public TradeParty setCountry(String country) {
|
||||
this.country = country;
|
||||
this.taxScheme = country;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -269,13 +269,13 @@ public class XMLValidator extends Validator {
|
||||
// saxon java net.sf.saxon.Transform -o tcdl2.0.tsdtf.sch.tmp.xsl -s
|
||||
// tcdl2.0.tsdtf.sch iso_svrl.xsl
|
||||
|
||||
} else if (root.getLocalName().equalsIgnoreCase("Invoice")) {
|
||||
} else if (root.getLocalName().equalsIgnoreCase("Invoice") || root.getLocalName().equalsIgnoreCase("CreditNote") ) {
|
||||
context.setGeneration("2");
|
||||
context.setFormat("UBL");
|
||||
isXRechnung = context.getProfile().contains("xrechnung");
|
||||
// UBL
|
||||
LOGGER.debug("UBL");
|
||||
validateSchema(zfXML.getBytes(StandardCharsets.UTF_8), "UBL_21/maindoc/UBL-Invoice-2.1.xsd", 18, EPart.fx);
|
||||
validateSchema(zfXML.getBytes(StandardCharsets.UTF_8), "UBL_21/maindoc/UBL-"+root.getLocalName()+"-2.1.xsd", 18, EPart.fx);
|
||||
xsltFilename = "/xslt/en16931schematron/EN16931-UBL-validation.xslt";
|
||||
|
||||
mainSchematronSectionErrorTypeCode=24;
|
||||
|
||||
@@ -298,6 +298,22 @@ public class XMLValidatorTest extends ResourceCase {
|
||||
noExceptions = false;
|
||||
}
|
||||
assertTrue(noExceptions);
|
||||
tempFile = getResourceAsFile("ubl-tc434-creditnote1.xml");
|
||||
try {
|
||||
xv.setFilename(tempFile.getAbsolutePath());
|
||||
xv.validate();
|
||||
|
||||
Source source = Input.fromString("<validation>" + xv.getXMLResult() + "</validation>").build();
|
||||
String content = xpath.evaluate("/validation/summary/@status", source);
|
||||
assertEquals("valid", content);
|
||||
|
||||
|
||||
} catch (IrrecoverableValidationError e) {
|
||||
|
||||
noExceptions = false;
|
||||
}
|
||||
assertTrue(noExceptions);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
136
validator/src/test/resources/ubl-tc434-creditnote1.xml
Normal file
136
validator/src/test/resources/ubl-tc434-creditnote1.xml
Normal file
@@ -0,0 +1,136 @@
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
||||
<!--
|
||||
|
||||
Licensed under European Union Public Licence (EUPL) version 1.2.
|
||||
|
||||
-->
|
||||
<CreditNote xmlns="urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2"
|
||||
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
|
||||
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
|
||||
<cbc:CustomizationID>urn:cen.eu:en16931:2017</cbc:CustomizationID>
|
||||
<cbc:ProfileID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</cbc:ProfileID>
|
||||
<cbc:ID>018304 / 28865</cbc:ID>
|
||||
<cbc:IssueDate>2019-09-23</cbc:IssueDate>
|
||||
<cbc:CreditNoteTypeCode>381</cbc:CreditNoteTypeCode>
|
||||
<cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
|
||||
<cbc:BuyerReference>018304 / 28865</cbc:BuyerReference>
|
||||
<cac:InvoicePeriod>
|
||||
<cbc:StartDate>2019-02-01</cbc:StartDate>
|
||||
<cbc:EndDate>2019-02-28</cbc:EndDate>
|
||||
</cac:InvoicePeriod>
|
||||
<cac:AccountingSupplierParty>
|
||||
<cac:Party>
|
||||
<cbc:EndpointID schemeID="0201">0000000196</cbc:EndpointID>
|
||||
<cac:PartyName>
|
||||
<cbc:Name>My Supplier Company N.V.</cbc:Name>
|
||||
</cac:PartyName>
|
||||
<cac:PostalAddress>
|
||||
<cbc:StreetName>De Grote Meir 22</cbc:StreetName>
|
||||
<cbc:CityName>ANTWERPEN</cbc:CityName>
|
||||
<cbc:PostalZone>2000</cbc:PostalZone>
|
||||
<cac:Country>
|
||||
<cbc:IdentificationCode>BE</cbc:IdentificationCode>
|
||||
</cac:Country>
|
||||
</cac:PostalAddress>
|
||||
<cac:PartyTaxScheme>
|
||||
<cbc:CompanyID>BE0000000196</cbc:CompanyID>
|
||||
<cac:TaxScheme>
|
||||
<cbc:ID>VAT</cbc:ID>
|
||||
</cac:TaxScheme>
|
||||
</cac:PartyTaxScheme>
|
||||
<cac:PartyLegalEntity>
|
||||
<cbc:RegistrationName>My Supplier Company</cbc:RegistrationName>
|
||||
<cbc:CompanyID>0000000196</cbc:CompanyID>
|
||||
</cac:PartyLegalEntity>
|
||||
<cac:Contact>
|
||||
<cbc:ElectronicMail>john.doole@mysuppliercompany.be</cbc:ElectronicMail>
|
||||
</cac:Contact>
|
||||
</cac:Party>
|
||||
</cac:AccountingSupplierParty>
|
||||
<cac:AccountingCustomerParty>
|
||||
<cac:Party>
|
||||
<cbc:EndpointID schemeID="0201">0000000295</cbc:EndpointID>
|
||||
<cac:PartyName>
|
||||
<cbc:Name>My Customer Company S.A.</cbc:Name>
|
||||
</cac:PartyName>
|
||||
<cac:PostalAddress>
|
||||
<cbc:StreetName>Boulevard Sint Michel 53</cbc:StreetName>
|
||||
<cbc:CityName>BRUXELLES</cbc:CityName>
|
||||
<cbc:PostalZone>1000</cbc:PostalZone>
|
||||
<cac:Country>
|
||||
<cbc:IdentificationCode>BE</cbc:IdentificationCode>
|
||||
</cac:Country>
|
||||
</cac:PostalAddress>
|
||||
<cac:PartyTaxScheme>
|
||||
<cbc:CompanyID>BE0000000295</cbc:CompanyID>
|
||||
<cac:TaxScheme>
|
||||
<cbc:ID>VAT</cbc:ID>
|
||||
</cac:TaxScheme>
|
||||
</cac:PartyTaxScheme>
|
||||
<cac:PartyLegalEntity>
|
||||
<cbc:RegistrationName>My Customer Company</cbc:RegistrationName>
|
||||
<cbc:CompanyID>0000000295</cbc:CompanyID>
|
||||
</cac:PartyLegalEntity>
|
||||
<cac:Contact>
|
||||
<cbc:ElectronicMail>pete.smith@mycustomercompany.be</cbc:ElectronicMail>
|
||||
</cac:Contact>
|
||||
</cac:Party>
|
||||
</cac:AccountingCustomerParty>
|
||||
<cac:PaymentMeans>
|
||||
<cbc:PaymentMeansCode>1</cbc:PaymentMeansCode>
|
||||
<cbc:PaymentID>010676609538</cbc:PaymentID>
|
||||
<cac:PayeeFinancialAccount>
|
||||
<cbc:ID>BE91000000143476</cbc:ID>
|
||||
<cac:FinancialInstitutionBranch>
|
||||
<cbc:ID>BPOTBEB1</cbc:ID>
|
||||
</cac:FinancialInstitutionBranch>
|
||||
</cac:PayeeFinancialAccount>
|
||||
</cac:PaymentMeans>
|
||||
<cac:TaxTotal>
|
||||
<cbc:TaxAmount currencyID="EUR">0.00</cbc:TaxAmount>
|
||||
<cac:TaxSubtotal>
|
||||
<cbc:TaxableAmount currencyID="EUR">100.11</cbc:TaxableAmount>
|
||||
<cbc:TaxAmount currencyID="EUR">0.00</cbc:TaxAmount>
|
||||
<cac:TaxCategory>
|
||||
<cbc:ID>E</cbc:ID>
|
||||
<cbc:Percent>0.00</cbc:Percent>
|
||||
<cbc:TaxExemptionReason>Taxes are not applicable</cbc:TaxExemptionReason>
|
||||
<cac:TaxScheme>
|
||||
<cbc:ID>VAT</cbc:ID>
|
||||
</cac:TaxScheme>
|
||||
</cac:TaxCategory>
|
||||
</cac:TaxSubtotal>
|
||||
</cac:TaxTotal>
|
||||
<cac:LegalMonetaryTotal>
|
||||
<cbc:LineExtensionAmount currencyID="EUR">100.11</cbc:LineExtensionAmount>
|
||||
<cbc:TaxExclusiveAmount currencyID="EUR">100.11</cbc:TaxExclusiveAmount>
|
||||
<cbc:TaxInclusiveAmount currencyID="EUR">100.11</cbc:TaxInclusiveAmount>
|
||||
<cbc:PayableAmount currencyID="EUR">100.11</cbc:PayableAmount>
|
||||
</cac:LegalMonetaryTotal>
|
||||
<cac:CreditNoteLine>
|
||||
<cbc:ID>1</cbc:ID>
|
||||
<cbc:CreditedQuantity unitCode="C62">1.00</cbc:CreditedQuantity>
|
||||
<cbc:LineExtensionAmount currencyID="EUR">100.11</cbc:LineExtensionAmount>
|
||||
<cac:Item>
|
||||
<cbc:Description>Exonération du versement du PP</cbc:Description>
|
||||
<cbc:Name>Exonération du versement du PP</cbc:Name>
|
||||
<cac:SellersItemIdentification>
|
||||
<cbc:ID>V55</cbc:ID>
|
||||
</cac:SellersItemIdentification>
|
||||
<cac:ClassifiedTaxCategory>
|
||||
<cbc:ID>E</cbc:ID>
|
||||
<cbc:Percent>0.00</cbc:Percent>
|
||||
<cac:TaxScheme>
|
||||
<cbc:ID>VAT</cbc:ID>
|
||||
</cac:TaxScheme>
|
||||
</cac:ClassifiedTaxCategory>
|
||||
<cac:AdditionalItemProperty>
|
||||
<cbc:Name>2</cbc:Name>
|
||||
<cbc:Value>Contributions - précompte professionnel</cbc:Value>
|
||||
</cac:AdditionalItemProperty>
|
||||
</cac:Item>
|
||||
<cac:Price>
|
||||
<cbc:PriceAmount currencyID="EUR">100.11</cbc:PriceAmount>
|
||||
</cac:Price>
|
||||
</cac:CreditNoteLine>
|
||||
</CreditNote>
|
||||
Reference in New Issue
Block a user