Merge remote-tracking branch 'remotes/origin/master' into master

This commit is contained in:
Sebastian Sieber
2020-11-20 11:45:38 +01:00
6 changed files with 72 additions and 15 deletions

View File

@@ -1,21 +1,45 @@
package org.mustangproject.ZUGFeRD;
/***
* specifies a kind of a XML completeness levels,
* e.g. Factur-X has 6 (Minimum, Basic-WL, Basic, EN16931, Extended, and XRechnung),
* ZUGFeRD 1 had and Order-X will have three (Basic, Comfort, Extended)
* and the XRechnung has two (Standard, Extension)
* For the XRechnung at the time being please use Factur-X's Xrechnung
*/
public class Profile {
protected String name, id;
/***
* Contruct
* @param name human readable name of the profile, also used as basis to detemine the XMP Name
* @param ID XML Guideline ID
*/
public Profile(String name, String ID) {
this.name = name;
this.id = ID;
}
/***
* gets the name
* @return the name of the profile
*/
public String getName() {
return name;
}
/***
* get guideline id
* @return the XML Guideline ID of the profile
*/
public String getID() {
return id;
}
/***
* if the profile is embedded in PDF we need RDF metadata
* @return the XMP name string of the profile
*/
public String getXMPName() {
if (name.equals("BASICWL")) {
return "BASIC WL";

View File

@@ -184,13 +184,13 @@ public class ZUGFeRD1PullProvider extends ZUGFeRD2PullProvider implements IXMLPr
}
xml = xml + " <ram:SellerTradeParty>\n";
xml += getTradePartyAsXML(trans.getSender(), true);
xml += getTradePartyAsXML(trans.getSender(), true, false);
xml += " </ram:SellerTradeParty>\n"
+ " <ram:BuyerTradeParty>\n";
// + " <ID>GE2020211</ID>\n"
// + " <GlobalID schemeID=\"0088\">4000001987658</GlobalID>\n"
xml += getTradePartyAsXML(trans.getRecipient(), false);
xml += getTradePartyAsXML(trans.getRecipient(), false, false);
if ((trans.getOwnVATID() != null) && (trans.getOwnOrganisationName() != null)) {
xml = xml + " <ram:SpecifiedTaxRegistration>\n" + " <ram:ID schemeID=\"VA\">"
+ XMLTools.encodeXML(trans.getOwnVATID()) + "</ram:ID>\n"
@@ -209,7 +209,7 @@ public class ZUGFeRD1PullProvider extends ZUGFeRD2PullProvider implements IXMLPr
+ " <ram:ApplicableSupplyChainTradeDelivery>\n";
if (this.trans.getDeliveryAddress() != null) {
xml += "<ram:ShipToTradeParty>" +
getTradePartyAsXML(this.trans.getDeliveryAddress(), false) +
getTradePartyAsXML(this.trans.getDeliveryAddress(), false, true) +
"</ram:ShipToTradeParty>";
}

View File

@@ -38,6 +38,7 @@ import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import org.mustangproject.FileAttachment;
import org.mustangproject.XMLTools;
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
public class ZUGFeRD2PullProvider implements IXMLProvider {
@@ -105,14 +106,16 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
return profile;
}
// @todo check if the two boolean args can be refactored
/***
* returns the UN/CEFACT CII XML for companies(tradeparties), which is actually
* the same for ZF1 (v 2013b) and ZF2 (v 2016b)
* @param party
* @param isSender some attributes are allowed only for senders in certain profiles
* @param isShipToTradeParty some attributes are allowed only for senders or recipients
* @return
*/
protected String getTradePartyAsXML(IZUGFeRDExportableTradeParty party, boolean isSender) {
protected String getTradePartyAsXML(IZUGFeRDExportableTradeParty party, boolean isSender, boolean isShipToTradeParty) {
String xml = "";
// According EN16931 either GlobalID or seller assigned ID might be present for BuyerTradeParty
// and ShipToTradeParty, but not both. Prefer seller assigned ID for now.
@@ -164,13 +167,13 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
+ " <ram:CountryID>" + XMLTools.encodeXML(party.getCountry())
+ "</ram:CountryID>\n"
+ " </ram:PostalTradeAddress>\n";
if (party.getVATID() != null) {
if ((party.getVATID() != null)&&(!isShipToTradeParty)) {
xml += " <ram:SpecifiedTaxRegistration>\n"
+ " <ram:ID schemeID=\"VA\">" + XMLTools.encodeXML(party.getVATID())
+ "</ram:ID>\n"
+ " </ram:SpecifiedTaxRegistration>\n";
}
if (party.getTaxID() != null) {
if ((party.getTaxID() != null)&&(!isShipToTradeParty)) {
xml += " <ram:SpecifiedTaxRegistration>\n"
+ " <ram:ID schemeID=\"FC\">" + XMLTools.encodeXML(party.getTaxID())
+ "</ram:ID>\n"
@@ -226,7 +229,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
paymentTermsDescription = trans.getPaymentTermDescription();
}
if (paymentTermsDescription == null) {
if ((paymentTermsDescription == null)&&(trans.getDocumentCode()!= org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants.CORRECTEDINVOICE)) {
paymentTermsDescription = "Zahlbar ohne Abzug bis " + germanDateFormat.format(trans.getDueDate());
}
@@ -396,13 +399,13 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
}
xml = xml + " <ram:SellerTradeParty>\n"
+ getTradePartyAsXML(trans.getSender(), true)
+ getTradePartyAsXML(trans.getSender(), true, false)
+ " </ram:SellerTradeParty>\n"
+ " <ram:BuyerTradeParty>\n";
// + " <ID>GE2020211</ID>\n"
// + " <GlobalID schemeID=\"0088\">4000001987658</GlobalID>\n"
xml += getTradePartyAsXML(trans.getRecipient(), false);
xml += getTradePartyAsXML(trans.getRecipient(), false, false);
xml += " </ram:BuyerTradeParty>\n";
if (trans.getBuyerOrderReferencedDocumentID() != null) {
@@ -436,7 +439,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
+ " <ram:ApplicableHeaderTradeDelivery>\n";
if (this.trans.getDeliveryAddress() != null) {
xml += "<ram:ShipToTradeParty>" +
getTradePartyAsXML(this.trans.getDeliveryAddress(), false) +
getTradePartyAsXML(this.trans.getDeliveryAddress(), false, true) +
"</ram:ShipToTradeParty>";
}
@@ -479,6 +482,9 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
}
}
}
if (trans.getDocumentCode()== DocumentCodeTypeConstants.CORRECTEDINVOICE) {
hasDueDate=false;
}
HashMap<BigDecimal, VATAmount> VATPercentAmountMap = calc.getVATPercentAmountMap();
for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) {