|
|
|
|
@@ -201,6 +201,46 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
public String getProfile() {
|
|
|
|
|
return "urn:cen.eu:en16931:2017";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String encodeXML(CharSequence s) {
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
int len = s.length();
|
|
|
|
|
for (int i=0;i<len;i++) {
|
|
|
|
|
int c = s.charAt(i);
|
|
|
|
|
if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
|
|
|
|
|
c = ((c-0xd7c0)<<10) | (s.charAt(++i)&0x3ff); // UTF16 decode
|
|
|
|
|
}
|
|
|
|
|
if (c < 0x80) { // ASCII range: test most common case first
|
|
|
|
|
if (c < 0x20 && (c != '\t' && c != '\r' && c != '\n')) {
|
|
|
|
|
// Illegal XML character, even encoded. Skip or substitute
|
|
|
|
|
sb.append("�"); // Unicode replacement character
|
|
|
|
|
} else {
|
|
|
|
|
switch(c) {
|
|
|
|
|
case '&': sb.append("&"); break;
|
|
|
|
|
case '>': sb.append(">"); break;
|
|
|
|
|
case '<': sb.append("<"); break;
|
|
|
|
|
// Uncomment next two if encoding for an XML attribute
|
|
|
|
|
// case '\'' sb.append("'"); break;
|
|
|
|
|
// case '\"' sb.append("""); break;
|
|
|
|
|
// Uncomment next three if you prefer, but not required
|
|
|
|
|
// case '\n' sb.append(" "); break;
|
|
|
|
|
// case '\r' sb.append(" "); break;
|
|
|
|
|
// case '\t' sb.append("	"); break;
|
|
|
|
|
|
|
|
|
|
default: sb.append((char)c);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if ((c >= 0xd800 && c <= 0xdfff) || c == 0xfffe || c == 0xffff) {
|
|
|
|
|
// Illegal XML character, even encoded. Skip or substitute
|
|
|
|
|
sb.append("�"); // Unicode replacement character
|
|
|
|
|
} else {
|
|
|
|
|
sb.append("&#x");
|
|
|
|
|
sb.append(Integer.toHexString(c));
|
|
|
|
|
sb.append(';');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return sb.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void generateXML(IZUGFeRDExportableTransaction trans) {
|
|
|
|
|
@@ -210,7 +250,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
String senderReg = "";
|
|
|
|
|
if (trans.getOwnOrganisationFullPlaintextInfo() != null) {
|
|
|
|
|
senderReg = "" + "<ram:IncludedNote>\n" + " <ram:Content>\n"
|
|
|
|
|
+ trans.getOwnOrganisationFullPlaintextInfo() + " </ram:Content>\n"
|
|
|
|
|
+ encodeXML(trans.getOwnOrganisationFullPlaintextInfo()) + " </ram:Content>\n"
|
|
|
|
|
+ "<ram:SubjectCode>REG</ram:SubjectCode>\n" + "</ram:IncludedNote>\n";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@@ -232,7 +272,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
+ " </ram:GuidelineSpecifiedDocumentContextParameter>\n" //$NON-NLS-1$
|
|
|
|
|
+ " </rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <rsm:ExchangedDocument>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:ID>" + trans.getNumber() + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:ID>" + encodeXML(trans.getNumber()) + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
// + " <ram:Name>RECHNUNG</ram:Name>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:TypeCode>380</ram:TypeCode>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:IssueDateTime><udt:DateTimeString format=\"102\">" //$NON-NLS-1$
|
|
|
|
|
@@ -268,8 +308,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
// + " <GlobalID schemeID=\"0160\">4012345001235</GlobalID>\n"
|
|
|
|
|
// + " <SellerAssignedID>KR3M</SellerAssignedID>\n"
|
|
|
|
|
// + " <BuyerAssignedID>55T01</BuyerAssignedID>\n"
|
|
|
|
|
+ " <ram:Name>" + currentItem.getProduct().getName() + "</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:Description>" + currentItem.getProduct().getDescription() //$NON-NLS-1$
|
|
|
|
|
+ " <ram:Name>" + encodeXML(currentItem.getProduct().getName()) + "</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:Description>" + encodeXML(currentItem.getProduct().getDescription()) //$NON-NLS-1$
|
|
|
|
|
+ "</ram:Description>\n" //$NON-NLS-1$
|
|
|
|
|
+ " </ram:SpecifiedTradeProduct>\n" //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
@@ -277,7 +317,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
+ " <ram:GrossPriceProductTradePrice>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:ChargeAmount>" + priceFormat(currentItem.getPrice()) //$NON-NLS-1$
|
|
|
|
|
+ "</ram:ChargeAmount>\n" //$NON-NLS-1$ //currencyID=\"EUR\"
|
|
|
|
|
+ " <ram:BasisQuantity unitCode=\"" + currentItem.getProduct().getUnit() //$NON-NLS-1$
|
|
|
|
|
+ " <ram:BasisQuantity unitCode=\"" + encodeXML(currentItem.getProduct().getUnit()) //$NON-NLS-1$
|
|
|
|
|
+ "\">1.0000</ram:BasisQuantity>\n" //$NON-NLS-1$
|
|
|
|
|
// + " <AppliedTradeAllowanceCharge>\n"
|
|
|
|
|
// + " <ChargeIndicator>false</ChargeIndicator>\n"
|
|
|
|
|
@@ -288,13 +328,13 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
+ " <ram:NetPriceProductTradePrice>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:ChargeAmount>" + priceFormat(currentItem.getPrice()) //$NON-NLS-1$
|
|
|
|
|
+ "</ram:ChargeAmount>\n" //$NON-NLS-1$ // currencyID=\"EUR\"
|
|
|
|
|
+ " <ram:BasisQuantity unitCode=\"" + currentItem.getProduct().getUnit() //$NON-NLS-1$
|
|
|
|
|
+ " <ram:BasisQuantity unitCode=\"" + encodeXML(currentItem.getProduct().getUnit()) //$NON-NLS-1$
|
|
|
|
|
+ "\">1.0000</ram:BasisQuantity>\n" //$NON-NLS-1$
|
|
|
|
|
+ " </ram:NetPriceProductTradePrice>\n" //$NON-NLS-1$
|
|
|
|
|
+ " </ram:SpecifiedLineTradeAgreement>\n" //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
+ " <ram:SpecifiedLineTradeDelivery>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:BilledQuantity unitCode=\"" + currentItem.getProduct().getUnit() + "\">" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:BilledQuantity unitCode=\"" + encodeXML(currentItem.getProduct().getUnit()) + "\">" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ quantityFormat(currentItem.getQuantity()) + "</ram:BilledQuantity>\n" //$NON-NLS-1$
|
|
|
|
|
+ " </ram:SpecifiedLineTradeDelivery>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:SpecifiedLineTradeSettlement>\n" //$NON-NLS-1$
|
|
|
|
|
@@ -315,34 +355,34 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
|
|
|
|
|
xml = xml + " <ram:ApplicableHeaderTradeAgreement>\n"; //$NON-NLS-1$
|
|
|
|
|
if (trans.getReferenceNumber() != null) {
|
|
|
|
|
xml = xml + " <ram:BuyerReference>" + trans.getReferenceNumber() + "</ram:BuyerReference>\n";
|
|
|
|
|
xml = xml + " <ram:BuyerReference>" + encodeXML(trans.getReferenceNumber()) + "</ram:BuyerReference>\n";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
xml = xml + " <ram:SellerTradeParty>\n" //$NON-NLS-1$
|
|
|
|
|
// + " <GlobalID schemeID=\"0088\">4000001123452</GlobalID>\n"
|
|
|
|
|
+ " <ram:Name>" + trans.getOwnOrganisationName() + "</ram:Name>\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:Name>" + encodeXML(trans.getOwnOrganisationName()) + "</ram:Name>\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
|
|
|
|
|
if ((trans.getOwnVATID()!=null)&&(trans.getOwnOrganisationName()!=null)) {
|
|
|
|
|
|
|
|
|
|
xml = xml + " <ram:SpecifiedLegalOrganization>\n" + " <ram:ID schemeID='9930'>"
|
|
|
|
|
+ trans.getOwnVATID() + "</ram:ID>\n" + " <ram:TradingBusinessName>"
|
|
|
|
|
+ trans.getOwnOrganisationName() + "</ram:TradingBusinessName>\n"
|
|
|
|
|
+ encodeXML(trans.getOwnVATID()) + "</ram:ID>\n" + " <ram:TradingBusinessName>"
|
|
|
|
|
+ encodeXML(trans.getOwnOrganisationName()) + "</ram:TradingBusinessName>\n"
|
|
|
|
|
+ " </ram:SpecifiedLegalOrganization>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (trans.getOwnContact() != null) {
|
|
|
|
|
xml = xml + "<ram:DefinedTradeContact>\n" + " <ram:PersonName>" + trans.getOwnContact().getName()
|
|
|
|
|
xml = xml + "<ram:DefinedTradeContact>\n" + " <ram:PersonName>" + encodeXML(trans.getOwnContact().getName())
|
|
|
|
|
+ "</ram:PersonName>\n";
|
|
|
|
|
if (trans.getOwnContact().getPhone() != null) {
|
|
|
|
|
|
|
|
|
|
xml = xml + " <ram:TelephoneUniversalCommunication>\n" + " <ram:CompleteNumber>"
|
|
|
|
|
+ trans.getOwnContact().getPhone() + "</ram:CompleteNumber>\n"
|
|
|
|
|
+ encodeXML(trans.getOwnContact().getPhone()) + "</ram:CompleteNumber>\n"
|
|
|
|
|
+ " </ram:TelephoneUniversalCommunication>\n";
|
|
|
|
|
}
|
|
|
|
|
if (trans.getOwnContact().getEMail() != null) {
|
|
|
|
|
|
|
|
|
|
xml = xml + " <ram:EmailURIUniversalCommunication>\n" + " <ram:URIID>"
|
|
|
|
|
+ trans.getOwnContact().getEMail() + "</ram:URIID>\n"
|
|
|
|
|
+ encodeXML(trans.getOwnContact().getEMail()) + "</ram:URIID>\n"
|
|
|
|
|
+ " </ram:EmailURIUniversalCommunication>\n";
|
|
|
|
|
}
|
|
|
|
|
xml = xml + " </ram:DefinedTradeContact>";
|
|
|
|
|
@@ -350,33 +390,33 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xml = xml + " <ram:PostalTradeAddress>\n" + " <ram:PostcodeCode>"
|
|
|
|
|
+ trans.getOwnZIP() + "</ram:PostcodeCode>\n" + " <ram:LineOne>"
|
|
|
|
|
+ trans.getOwnStreet() + "</ram:LineOne>\n" + " <ram:CityName>" + trans.getOwnLocation()
|
|
|
|
|
+ "</ram:CityName>\n" + " <ram:CountryID>" + trans.getOwnCountry()
|
|
|
|
|
+ encodeXML(trans.getOwnZIP()) + "</ram:PostcodeCode>\n" + " <ram:LineOne>"
|
|
|
|
|
+ encodeXML(trans.getOwnStreet()) + "</ram:LineOne>\n" + " <ram:CityName>" + encodeXML(trans.getOwnLocation())
|
|
|
|
|
+ "</ram:CityName>\n" + " <ram:CountryID>" + encodeXML(trans.getOwnCountry())
|
|
|
|
|
+ "</ram:CountryID>\n" + " </ram:PostalTradeAddress>\n"
|
|
|
|
|
+ " <ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:ID schemeID=\"FC\">" + trans.getOwnTaxID() + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:ID schemeID=\"FC\">" + encodeXML(trans.getOwnTaxID()) + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " </ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:ID schemeID=\"VA\">" + trans.getOwnVATID() + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:ID schemeID=\"VA\">" + encodeXML(trans.getOwnVATID()) + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " </ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
|
|
|
|
+ " </ram:SellerTradeParty>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:BuyerTradeParty>\n" //$NON-NLS-1$
|
|
|
|
|
// + " <ID>GE2020211</ID>\n"
|
|
|
|
|
// + " <GlobalID schemeID=\"0088\">4000001987658</GlobalID>\n"
|
|
|
|
|
+ " <ram:Name>" + trans.getRecipient().getName() + "</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:Name>" + encodeXML(trans.getRecipient().getName()) + "</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
// + " <DefinedTradeContact>\n"
|
|
|
|
|
// + " <PersonName>xxx</PersonName>\n"
|
|
|
|
|
// + " </DefinedTradeContact>\n"
|
|
|
|
|
+ " <ram:PostalTradeAddress>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:PostcodeCode>" + trans.getRecipient().getZIP() + "</ram:PostcodeCode>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:LineOne>" + trans.getRecipient().getStreet() + "</ram:LineOne>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:CityName>" + trans.getRecipient().getLocation() + "</ram:CityName>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:CountryID>" + trans.getRecipient().getCountry() + "</ram:CountryID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:PostcodeCode>" + encodeXML(trans.getRecipient().getZIP()) + "</ram:PostcodeCode>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:LineOne>" + encodeXML(trans.getRecipient().getStreet()) + "</ram:LineOne>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:CityName>" + encodeXML(trans.getRecipient().getLocation()) + "</ram:CityName>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:CountryID>" + encodeXML(trans.getRecipient().getCountry()) + "</ram:CountryID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " </ram:PostalTradeAddress>\n"; //$NON-NLS-1$
|
|
|
|
|
if (trans.getRecipient().getVATID() != null) {
|
|
|
|
|
xml += " <ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:ID schemeID=\"VA\">" + trans.getRecipient().getVATID() + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:ID schemeID=\"VA\">" + encodeXML(trans.getRecipient().getVATID()) + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " </ram:SpecifiedTaxRegistration>\n"; //$NON-NLS-1$
|
|
|
|
|
}
|
|
|
|
|
xml += " </ram:BuyerTradeParty>\n" //$NON-NLS-1$
|
|
|
|
|
@@ -396,7 +436,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
* " </DeliveryNoteReferencedDocument>\n"
|
|
|
|
|
*/
|
|
|
|
|
+ " </ram:ApplicableHeaderTradeDelivery>\n" + " <ram:ApplicableHeaderTradeSettlement>\n" //$NON-NLS-2$
|
|
|
|
|
+ " <ram:PaymentReference>" + trans.getNumber() + "</ram:PaymentReference>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:PaymentReference>" + encodeXML(trans.getNumber()) + "</ram:PaymentReference>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>\n"; //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
for (IZUGFeRDTradeSettlementPayment payment : trans.getTradeSettlementPayment()) {
|
|
|
|
|
@@ -404,11 +444,14 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
+ " <ram:TypeCode>42</ram:TypeCode>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:Information>Überweisung</ram:Information>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:PayeePartyCreditorFinancialAccount>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:IBANID>" + payment.getOwnIBAN() + "</ram:IBANID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:ProprietaryID>" + payment.getOwnKto() + "</ram:ProprietaryID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " </ram:PayeePartyCreditorFinancialAccount>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:IBANID>" + encodeXML(payment.getOwnIBAN()) + "</ram:IBANID>\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
if (payment.getOwnKto()!=null) {
|
|
|
|
|
xml+= " <ram:ProprietaryID>" + encodeXML(payment.getOwnKto()) + "</ram:ProprietaryID>\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
xml+= " </ram:PayeePartyCreditorFinancialAccount>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:PayeeSpecifiedCreditorFinancialInstitution>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:BICID>" + payment.getOwnBIC() + "</ram:BICID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:BICID>" + encodeXML(payment.getOwnBIC()) + "</ram:BICID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
// + " <ram:Name>"+trans.getOwnBankName()+"</ram:Name>\n" //$NON-NLS-1$
|
|
|
|
|
// //$NON-NLS-2$
|
|
|
|
|
+ " </ram:PayeeSpecifiedCreditorFinancialInstitution>\n" //$NON-NLS-1$
|
|
|
|
|
|