|
|
|
|
@@ -18,17 +18,12 @@
|
|
|
|
|
*********************************************************************** */
|
|
|
|
|
package org.mustangproject.ZUGFeRD;
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedWriter;
|
|
|
|
|
import java.io.FileWriter;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.StringWriter;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
import java.text.DecimalFormatSymbols;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.logging.Level;
|
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
@@ -38,6 +33,7 @@ import org.dom4j.DocumentException;
|
|
|
|
|
import org.dom4j.DocumentHelper;
|
|
|
|
|
import org.dom4j.io.OutputFormat;
|
|
|
|
|
import org.dom4j.io.XMLWriter;
|
|
|
|
|
import org.mustangproject.XMLTools;
|
|
|
|
|
import org.mustangproject.toecount.Toecount;
|
|
|
|
|
|
|
|
|
|
public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
@@ -72,6 +68,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
protected byte[] zugferdData;
|
|
|
|
|
private IZUGFeRDExportableTransaction trans;
|
|
|
|
|
private ZUGFeRDConformanceLevel level;
|
|
|
|
|
private String paymentTermsDescription;
|
|
|
|
|
|
|
|
|
|
public void setProfile(ZUGFeRDConformanceLevel level) {
|
|
|
|
|
this.level = level;
|
|
|
|
|
@@ -202,55 +199,28 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
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) {
|
|
|
|
|
this.trans = trans;
|
|
|
|
|
|
|
|
|
|
boolean hasDueDate=false;
|
|
|
|
|
SimpleDateFormat germanDateFormat = new SimpleDateFormat("dd.MM.yyyy"); //$NON-NLS-1$
|
|
|
|
|
SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd"); //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
if (paymentTermsDescription==null) {
|
|
|
|
|
paymentTermsDescription= "Zahlbar ohne Abzug bis " + germanDateFormat.format(trans.getDueDate());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (trans.getPaymentTermDescription()!=null) {
|
|
|
|
|
paymentTermsDescription=trans.getPaymentTermDescription();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String senderReg = "";
|
|
|
|
|
if (trans.getOwnOrganisationFullPlaintextInfo() != null) {
|
|
|
|
|
senderReg = "" + "<ram:IncludedNote>\n" + " <ram:Content>\n"
|
|
|
|
|
+ encodeXML(trans.getOwnOrganisationFullPlaintextInfo()) + " </ram:Content>\n"
|
|
|
|
|
+ XMLTools.encodeXML(trans.getOwnOrganisationFullPlaintextInfo()) + " </ram:Content>\n"
|
|
|
|
|
+ "<ram:SubjectCode>REG</ram:SubjectCode>\n" + "</ram:IncludedNote>\n";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@@ -272,7 +242,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>" + encodeXML(trans.getNumber()) + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:ID>" + XMLTools.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$
|
|
|
|
|
@@ -308,8 +278,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
// + " <GlobalID schemeID=\"0160\">4012345001235</GlobalID>\n"
|
|
|
|
|
// + " <SellerAssignedID>KR3M</SellerAssignedID>\n"
|
|
|
|
|
// + " <BuyerAssignedID>55T01</BuyerAssignedID>\n"
|
|
|
|
|
+ " <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:Name>" + XMLTools.encodeXML(currentItem.getProduct().getName()) + "</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:Description>" + XMLTools.encodeXML(currentItem.getProduct().getDescription()) //$NON-NLS-1$
|
|
|
|
|
+ "</ram:Description>\n" //$NON-NLS-1$
|
|
|
|
|
+ " </ram:SpecifiedTradeProduct>\n" //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
@@ -317,7 +287,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=\"" + encodeXML(currentItem.getProduct().getUnit()) //$NON-NLS-1$
|
|
|
|
|
+ " <ram:BasisQuantity unitCode=\"" + XMLTools.encodeXML(currentItem.getProduct().getUnit()) //$NON-NLS-1$
|
|
|
|
|
+ "\">1.0000</ram:BasisQuantity>\n" //$NON-NLS-1$
|
|
|
|
|
// + " <AppliedTradeAllowanceCharge>\n"
|
|
|
|
|
// + " <ChargeIndicator>false</ChargeIndicator>\n"
|
|
|
|
|
@@ -328,13 +298,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=\"" + encodeXML(currentItem.getProduct().getUnit()) //$NON-NLS-1$
|
|
|
|
|
+ " <ram:BasisQuantity unitCode=\"" + XMLTools.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=\"" + encodeXML(currentItem.getProduct().getUnit()) + "\">" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:BilledQuantity unitCode=\"" + XMLTools.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$
|
|
|
|
|
@@ -355,34 +325,34 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
|
|
|
|
|
xml = xml + " <ram:ApplicableHeaderTradeAgreement>\n"; //$NON-NLS-1$
|
|
|
|
|
if (trans.getReferenceNumber() != null) {
|
|
|
|
|
xml = xml + " <ram:BuyerReference>" + encodeXML(trans.getReferenceNumber()) + "</ram:BuyerReference>\n";
|
|
|
|
|
xml = xml + " <ram:BuyerReference>" + XMLTools.encodeXML(trans.getReferenceNumber()) + "</ram:BuyerReference>\n";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
xml = xml + " <ram:SellerTradeParty>\n" //$NON-NLS-1$
|
|
|
|
|
// + " <GlobalID schemeID=\"0088\">4000001123452</GlobalID>\n"
|
|
|
|
|
+ " <ram:Name>" + encodeXML(trans.getOwnOrganisationName()) + "</ram:Name>\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:Name>" + XMLTools.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'>"
|
|
|
|
|
+ encodeXML(trans.getOwnVATID()) + "</ram:ID>\n" + " <ram:TradingBusinessName>"
|
|
|
|
|
+ encodeXML(trans.getOwnOrganisationName()) + "</ram:TradingBusinessName>\n"
|
|
|
|
|
+ XMLTools.encodeXML(trans.getOwnVATID()) + "</ram:ID>\n" + " <ram:TradingBusinessName>"
|
|
|
|
|
+ XMLTools.encodeXML(trans.getOwnOrganisationName()) + "</ram:TradingBusinessName>\n"
|
|
|
|
|
+ " </ram:SpecifiedLegalOrganization>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (trans.getOwnContact() != null) {
|
|
|
|
|
xml = xml + "<ram:DefinedTradeContact>\n" + " <ram:PersonName>" + encodeXML(trans.getOwnContact().getName())
|
|
|
|
|
xml = xml + "<ram:DefinedTradeContact>\n" + " <ram:PersonName>" + XMLTools.encodeXML(trans.getOwnContact().getName())
|
|
|
|
|
+ "</ram:PersonName>\n";
|
|
|
|
|
if (trans.getOwnContact().getPhone() != null) {
|
|
|
|
|
|
|
|
|
|
xml = xml + " <ram:TelephoneUniversalCommunication>\n" + " <ram:CompleteNumber>"
|
|
|
|
|
+ encodeXML(trans.getOwnContact().getPhone()) + "</ram:CompleteNumber>\n"
|
|
|
|
|
+ XMLTools.encodeXML(trans.getOwnContact().getPhone()) + "</ram:CompleteNumber>\n"
|
|
|
|
|
+ " </ram:TelephoneUniversalCommunication>\n";
|
|
|
|
|
}
|
|
|
|
|
if (trans.getOwnContact().getEMail() != null) {
|
|
|
|
|
|
|
|
|
|
xml = xml + " <ram:EmailURIUniversalCommunication>\n" + " <ram:URIID>"
|
|
|
|
|
+ encodeXML(trans.getOwnContact().getEMail()) + "</ram:URIID>\n"
|
|
|
|
|
+ XMLTools.encodeXML(trans.getOwnContact().getEMail()) + "</ram:URIID>\n"
|
|
|
|
|
+ " </ram:EmailURIUniversalCommunication>\n";
|
|
|
|
|
}
|
|
|
|
|
xml = xml + " </ram:DefinedTradeContact>";
|
|
|
|
|
@@ -390,33 +360,33 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xml = xml + " <ram:PostalTradeAddress>\n" + " <ram:PostcodeCode>"
|
|
|
|
|
+ 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())
|
|
|
|
|
+ XMLTools.encodeXML(trans.getOwnZIP()) + "</ram:PostcodeCode>\n" + " <ram:LineOne>"
|
|
|
|
|
+ XMLTools.encodeXML(trans.getOwnStreet()) + "</ram:LineOne>\n" + " <ram:CityName>" + XMLTools.encodeXML(trans.getOwnLocation())
|
|
|
|
|
+ "</ram:CityName>\n" + " <ram:CountryID>" + XMLTools.encodeXML(trans.getOwnCountry())
|
|
|
|
|
+ "</ram:CountryID>\n" + " </ram:PostalTradeAddress>\n"
|
|
|
|
|
+ " <ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:ID schemeID=\"FC\">" + encodeXML(trans.getOwnTaxID()) + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:ID schemeID=\"FC\">" + XMLTools.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\">" + encodeXML(trans.getOwnVATID()) + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:ID schemeID=\"VA\">" + XMLTools.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>" + encodeXML(trans.getRecipient().getName()) + "</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:Name>" + XMLTools.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>" + 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:PostcodeCode>" + XMLTools.encodeXML(trans.getRecipient().getZIP()) + "</ram:PostcodeCode>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:LineOne>" + XMLTools.encodeXML(trans.getRecipient().getStreet()) + "</ram:LineOne>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:CityName>" + XMLTools.encodeXML(trans.getRecipient().getLocation()) + "</ram:CityName>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:CountryID>" + XMLTools.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\">" + encodeXML(trans.getRecipient().getVATID()) + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:ID schemeID=\"VA\">" + XMLTools.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$
|
|
|
|
|
@@ -436,26 +406,26 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
* " </DeliveryNoteReferencedDocument>\n"
|
|
|
|
|
*/
|
|
|
|
|
+ " </ram:ApplicableHeaderTradeDelivery>\n" + " <ram:ApplicableHeaderTradeSettlement>\n" //$NON-NLS-2$
|
|
|
|
|
+ " <ram:PaymentReference>" + encodeXML(trans.getNumber()) + "</ram:PaymentReference>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
+ " <ram:PaymentReference>" + XMLTools.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()) {
|
|
|
|
|
xml += " <ram:SpecifiedTradeSettlementPaymentMeans>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <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>" + 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$
|
|
|
|
|
|
|
|
|
|
if (trans.getTradeSettlementPayment()!=null) {
|
|
|
|
|
for (IZUGFeRDTradeSettlementPayment payment : trans.getTradeSettlementPayment()) {
|
|
|
|
|
if(payment!=null) {
|
|
|
|
|
hasDueDate=true;
|
|
|
|
|
xml+=payment.getSettlementXML();
|
|
|
|
|
}
|
|
|
|
|
xml+= " </ram:PayeePartyCreditorFinancialAccount>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:PayeeSpecifiedCreditorFinancialInstitution>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <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$
|
|
|
|
|
+ " </ram:SpecifiedTradeSettlementPaymentMeans>\n"; //$NON-NLS-1$
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (trans.getTradeSettlement()!=null) {
|
|
|
|
|
for (IZUGFeRDTradeSettlement payment : trans.getTradeSettlement()) {
|
|
|
|
|
if(payment!=null) {
|
|
|
|
|
if (payment instanceof IZUGFeRDTradeSettlementPayment) {
|
|
|
|
|
hasDueDate=true;
|
|
|
|
|
}
|
|
|
|
|
xml+=payment.getSettlementXML();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HashMap<BigDecimal, VATAmount> VATPercentAmountMap = getVATPercentAmountMap();
|
|
|
|
|
@@ -473,45 +443,29 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* xml+= " + " <SpecifiedTradeAllowanceCharge>\n" +
|
|
|
|
|
* " <ChargeIndicator>false</ChargeIndicator>\n" +
|
|
|
|
|
* " <BasisAmount currencyID=\"EUR\">10</BasisAmount>\n" +
|
|
|
|
|
* " <ActualAmount>1.00</ActualAmount>\n" +
|
|
|
|
|
* " <Reason>Sondernachlass</Reason>\n" +
|
|
|
|
|
* " <CategoryTradeTax>\n" +
|
|
|
|
|
* " <TypeCode>VAT</TypeCode>\n" +
|
|
|
|
|
* " <CategoryCode>S</CategoryCode>\n" +
|
|
|
|
|
* " <ApplicablePercent>19</ApplicablePercent>\n" +
|
|
|
|
|
* " </CategoryTradeTax>\n" +
|
|
|
|
|
* " </SpecifiedTradeAllowanceCharge>\n" +
|
|
|
|
|
* " <SpecifiedTradeAllowanceCharge>\n" +
|
|
|
|
|
* " <ChargeIndicator>false</ChargeIndicator>\n" +
|
|
|
|
|
* " <BasisAmount currencyID=\"EUR\">137.30</BasisAmount>\n" +
|
|
|
|
|
* " <ActualAmount>13.73</ActualAmount>\n" +
|
|
|
|
|
* " <Reason>Sondernachlass</Reason>\n" +
|
|
|
|
|
* " <CategoryTradeTax>\n" +
|
|
|
|
|
* " <TypeCode>VAT</TypeCode>\n" +
|
|
|
|
|
* " <CategoryCode>S</CategoryCode>\n" +
|
|
|
|
|
* " <ApplicablePercent>7</ApplicablePercent>\n" +
|
|
|
|
|
* " </CategoryTradeTax>\n" +
|
|
|
|
|
* " </SpecifiedTradeAllowanceCharge>\n" +
|
|
|
|
|
* " <SpecifiedLogisticsServiceCharge>\n" +
|
|
|
|
|
* " <Description>Versandkosten</Description>\n" +
|
|
|
|
|
* " <AppliedAmount>5.80</AppliedAmount>\n" +
|
|
|
|
|
* " <AppliedTradeTax>\n" +
|
|
|
|
|
* " <TypeCode>VAT</TypeCode>\n" +
|
|
|
|
|
* " <CategoryCode>S</CategoryCode>\n" +
|
|
|
|
|
* " <ApplicablePercent>7</ApplicablePercent>\n" +
|
|
|
|
|
* " </AppliedTradeTax>\n" +
|
|
|
|
|
* " </SpecifiedLogisticsServiceCharge>\n"
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
xml = xml + " <ram:SpecifiedTradePaymentTerms>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:Description>Zahlbar ohne Abzug bis " + germanDateFormat.format(trans.getDueDate())
|
|
|
|
|
+ "</ram:Description>\n" + " <ram:DueDateDateTime><udt:DateTimeString format=\"102\">" //$NON-NLS-2$
|
|
|
|
|
+ zugferdDateFormat.format(trans.getDueDate()) + "</udt:DateTimeString></ram:DueDateDateTime>\n"// 20130704 //$NON-NLS-1$
|
|
|
|
|
+ " </ram:SpecifiedTradePaymentTerms>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:Description>"+
|
|
|
|
|
paymentTermsDescription
|
|
|
|
|
+ "</ram:Description>\n";
|
|
|
|
|
|
|
|
|
|
if (trans.getTradeSettlement()!=null) {
|
|
|
|
|
for (IZUGFeRDTradeSettlement payment : trans.getTradeSettlement()) {
|
|
|
|
|
if(payment!=null) {
|
|
|
|
|
xml+=payment.getPaymentXML();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(hasDueDate) {
|
|
|
|
|
xml=xml+" <ram:DueDateDateTime><udt:DateTimeString format=\"102\">" //$NON-NLS-2$
|
|
|
|
|
+ zugferdDateFormat.format(trans.getDueDate()) + "</udt:DateTimeString></ram:DueDateDateTime>\n";// 20130704 //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xml = xml + " </ram:SpecifiedTradePaymentTerms>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n" //$NON-NLS-1$
|
|
|
|
|
+ " <ram:LineTotalAmount>" + currencyFormat(getTotal()) + "</ram:LineTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
|
// currencyID=\"EUR\"
|
|
|
|
|
|