Merge pull request #331 from weclapp-dev/master

Improvement of included notes
This commit is contained in:
Jochen Staerk
2023-07-24 08:22:06 +02:00
committed by GitHub
7 changed files with 323 additions and 190 deletions

View File

@@ -0,0 +1,68 @@
package org.mustangproject;
/**
* A grouping of business terms to indicate accounting-relevant free texts including a qualification of these.
*/
public class IncludedNote {
private final String content;
private final SubjectCode subjectCode;
private static final String INCLUDE_START = "<ram:IncludedNote>";
private static final String INCLUDE_END = "</ram:IncludedNote>";
private static final String CONTENT_START = "<ram:Content>";
private static final String CONTENT_END = "</ram:Content>";
private static final String SUBJECT_CODE_START = "<ram:SubjectCode>";
private static final String SUBJECT_CODE_END = "</ram:SubjectCode>";
private IncludedNote(String content, SubjectCode subjectCode) {
this.content = content;
this.subjectCode = subjectCode;
}
public static IncludedNote generalNote(String content) {
return new IncludedNote(content, SubjectCode.AAI);
}
public static IncludedNote regulatoryNote(String content) {
return new IncludedNote(content, SubjectCode.REG);
}
public static IncludedNote legalNote(String content) {
return new IncludedNote(content, SubjectCode.ABL);
}
public static IncludedNote customsNote(String content) {
return new IncludedNote(content, SubjectCode.CUS);
}
public static IncludedNote sellerNote(String content) {
return new IncludedNote(content, SubjectCode.SUR);
}
public static IncludedNote taxNote(String content) {
return new IncludedNote(content, SubjectCode.TXD);
}
public static IncludedNote introductionNote(String content) {
return new IncludedNote(content, SubjectCode.ACY);
}
public static IncludedNote discountBonusNote(String content) {
return new IncludedNote(content, SubjectCode.AAK);
}
public static IncludedNote unspecifiedNote(String content) {
return new IncludedNote(content, null);
}
public String getContent() {
return content;
}
public SubjectCode getSubjectCode() {
return subjectCode;
}
public String toCiiXml(){
String result = INCLUDE_START + CONTENT_START +
XMLTools.encodeXML(getContent() )+ CONTENT_END;
if (getSubjectCode() != null) {
result += SUBJECT_CODE_START + getSubjectCode() + SUBJECT_CODE_END;
}
return result + INCLUDE_END;
}
}

View File

@@ -22,7 +22,9 @@ package org.mustangproject;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import org.mustangproject.ZUGFeRD.IExportableTransaction;
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
@@ -48,6 +50,7 @@ public class Invoice implements IExportableTransaction {
@JsonDeserialize(contentAs=Item.class)
protected ArrayList<IZUGFeRDExportableItem> ZFItems = null;
protected ArrayList<String> notes = null;
private List<IncludedNote> includedNotes = null;
protected String sellerOrderReferencedDocumentID;
protected String contractReferencedDocument = null;
protected ArrayList<FileAttachment> xmlEmbeddedFiles=null;
@@ -396,7 +399,12 @@ public class Invoice implements IExportableTransaction {
return notes.toArray(new String[0]);
}
@Override
@Override
public List<IncludedNote> getNotesWithSubjectCode() {
return includedNotes;
}
@Override
public String getCurrency() {
return currency;
}
@@ -659,8 +667,8 @@ public class Invoice implements IExportableTransaction {
}
/***
* adds a free text paragraph, which will become a includedNote element
/**
* adds a free text paragraph, which will become an includedNote element
* @param text freeform UTF8 plain text
* @return fluent setter
*/
@@ -672,6 +680,128 @@ public class Invoice implements IExportableTransaction {
return this;
}
public Invoice addNotes(Collection<IncludedNote> notes) {
if (notes == null) {
return this;
}
if (includedNotes == null) {
includedNotes = new ArrayList<>();
}
includedNotes.addAll(notes);
return this;
}
/**
* adds a free text paragraph, which will become an includedNote element with explicit
* subjectCode {@link SubjectCode#AAI}
* @param content freeform UTF8 plain text
* @return fluent setter
*/
public Invoice addGeneralNote(String content) {
if (includedNotes == null) {
includedNotes = new ArrayList<>();
}
includedNotes.add(IncludedNote.generalNote(content));
return this;
}
/**
* adds a free text paragraph, which will become an includedNote element with explicit
* subjectCode {@link SubjectCode#REG}
* @param content freeform UTF8 plain text
* @return fluent setter
*/
public Invoice addRegulatoryNote(String content) {
if (includedNotes == null) {
includedNotes = new ArrayList<>();
}
includedNotes.add(IncludedNote.regulatoryNote(content));
return this;
}
/**
* adds a free text paragraph, which will become an includedNote element with explicit
* subjectCode {@link SubjectCode#ABL}
* @param content freeform UTF8 plain text
* @return fluent setter
*/
public Invoice addLegalNote(String content) {
if (includedNotes == null) {
includedNotes = new ArrayList<>();
}
includedNotes.add(IncludedNote.legalNote(content));
return this;
}
/**
* adds a free text paragraph, which will become an includedNote element with explicit
* subjectCode {@link SubjectCode#CUS}
* @param content freeform UTF8 plain text
* @return fluent setter
*/
public Invoice addCustomsNote(String content) {
if (includedNotes == null) {
includedNotes = new ArrayList<>();
}
includedNotes.add(IncludedNote.customsNote(content));
return this;
}
/**
* adds a free text paragraph, which will become an includedNote element with explicit
* subjectCode {@link SubjectCode#SUR}
* @param content freeform UTF8 plain text
* @return fluent setter
*/
public Invoice addSellerNote(String content) {
if (includedNotes == null) {
includedNotes = new ArrayList<>();
}
includedNotes.add(IncludedNote.sellerNote(content));
return this;
}
/**
* adds a free text paragraph, which will become an includedNote element with explicit
* subjectCode {@link SubjectCode#TXD}
* @param content freeform UTF8 plain text
* @return fluent setter
*/
public Invoice addTaxNote(String content) {
if (includedNotes == null) {
includedNotes = new ArrayList<>();
}
includedNotes.add(IncludedNote.taxNote(content));
return this;
}
/**
* adds a free text paragraph, which will become an includedNote element with explicit
* subjectCode {@link SubjectCode#ACY}
* @param content freeform UTF8 plain text
* @return fluent setter
*/
public Invoice addIntroductionNote(String content) {
if (includedNotes == null) {
includedNotes = new ArrayList<>();
}
includedNotes.add(IncludedNote.introductionNote(content));
return this;
}
/**
* adds a free text paragraph, which will become an includedNote element with explicit
* subjectCode {@link SubjectCode#AAK}
* @param content freeform UTF8 plain text
* @return fluent setter
*/
public Invoice addDiscountBonusNote(String content) {
if (includedNotes == null) {
includedNotes = new ArrayList<>();
}
includedNotes.add(IncludedNote.discountBonusNote(content));
return this;
}
@Override
public String getSpecifiedProcuringProjectID() {
return specifiedProcuringProjectID;

View File

@@ -0,0 +1,40 @@
package org.mustangproject;
/**
* EN16931-ID: BT-21 - the qualification of the free text on the invoice from BT-22<br/>
* In the first step only the recommended codes are implemented.
*/
public enum SubjectCode {
/**
* general information
*/
AAI,
/**
* seller notes
*/
SUR,
/**
* regulatory information
*/
REG,
/**
* legal information
*/
ABL,
/**
* tax information
*/
TXD,
/**
* Customs information
*/
CUS,
/**
* introduction
*/
ACY,
/**
* Discount and bonus agreements
*/
AAK
}

View File

@@ -21,15 +21,10 @@
package org.mustangproject.ZUGFeRD;
import static org.mustangproject.ZUGFeRD.ZUGFeRDDateFormat.DATE;
import static org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants.CORRECTEDINVOICE;
import static org.mustangproject.ZUGFeRD.model.TaxCategoryCodeTypeConstants.CATEGORY_CODES_WITH_EXEMPTION_REASON;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Base64;
import java.util.Date;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -45,37 +40,12 @@ public class DAPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
@Override
public void generateXML(IExportableTransaction trans) {
this.trans = trans;
boolean hasDueDate = false;
final SimpleDateFormat germanDateFormat = new SimpleDateFormat("dd.MM.yyyy");
final String exemptionReason = "";
String senderReg = "";
if (trans.getOwnOrganisationFullPlaintextInfo() != null) {
senderReg = "<ram:IncludedNote><ram:Content>"
+ XMLTools.encodeXML(trans.getOwnOrganisationFullPlaintextInfo()) + "</ram:Content>"
+ "<ram:SubjectCode>REG</ram:SubjectCode></ram:IncludedNote>";
}
String subjectNote = "";
if (trans.getSubjectNote() != null) {
subjectNote = "<ram:IncludedNote><ram:Content>"
+ XMLTools.encodeXML(trans.getSubjectNote()) + "</ram:Content>"
+ "</ram:IncludedNote>";
}
final String typecode = "220";
/*if (trans.getDocumentCode() != null) {
typecode = trans.getDocumentCode();
}*/
String notes = "";
if (trans.getNotes() != null) {
for (final String currentNote : trans.getNotes()) {
notes += "<ram:IncludedNote><ram:Content>" + XMLTools.encodeXML(currentNote) + "</ram:Content></ram:IncludedNote>";
}
}
String testBooleanStr="true";
String xml = "<SCRDMCCBDACIDAMessageStructure\n" +
" xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:25\"\n" +
@@ -99,9 +69,7 @@ public class DAPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
+ "<ram:TypeCode>" + typecode + "</ram:TypeCode>"
+ "<ram:IssueDateTime>"
+ DATE.udtFormat(trans.getIssueDate()) + "</ram:IssueDateTime>" // date
+ notes
+ subjectNote
+ senderReg
+ buildNotes(trans)
+ "</px:ExchangedDocument>"
+ "<px:SupplyChainTradeTransaction>";
@@ -111,18 +79,11 @@ public class DAPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
if (currentItem.getProduct().getTaxExemptionReason() != null) {
// exemptionReason = "<ram:ExemptionReason>" + XMLTools.encodeXML(currentItem.getProduct().getTaxExemptionReason()) + "</ram:ExemptionReason>";
}
notes = "";
if (currentItem.getNotes() != null) {
for (final String currentNote : currentItem.getNotes()) {
notes = notes + "<ram:IncludedNote><ram:Content>" + XMLTools.encodeXML(currentNote) + "</ram:Content></ram:IncludedNote>";
}
}
final LineCalculator lc = new LineCalculator(currentItem);
final LineCalculator lc = new LineCalculator(currentItem);
xml += "<ram:IncludedSupplyChainTradeLineItem>" +
"<ram:AssociatedDocumentLineDocument>"
+ "<ram:LineID>" + lineID + "</ram:LineID>"
+ notes
+ buildItemNotes(currentItem)
+ "</ram:AssociatedDocumentLineDocument>"
+ "<ram:SpecifiedTradeProduct>";
@@ -308,51 +269,17 @@ public class DAPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
return profile;
}
private String buildPaymentTermsXml() {
final IZUGFeRDPaymentTerms paymentTerms = trans.getPaymentTerms();
if (paymentTerms == null) {
return "";
}
String paymentTermsXml = "<ram:SpecifiedTradePaymentTerms>";
final IZUGFeRDPaymentDiscountTerms discountTerms = paymentTerms.getDiscountTerms();
final Date dueDate = paymentTerms.getDueDate();
if (dueDate != null && discountTerms != null && discountTerms.getBaseDate() != null) {
throw new IllegalStateException(
"if paymentTerms.dueDate is specified, paymentTerms.discountTerms.baseDate has not to be specified");
}
paymentTermsXml += "<ram:Description>" + paymentTerms.getDescription() + "</ram:Description>";
if (dueDate != null) {
paymentTermsXml += "<ram:DueDateDateTime>";
paymentTermsXml += DATE.udtFormat(dueDate);
paymentTermsXml += "</ram:DueDateDateTime>";
}
if (discountTerms != null) {
paymentTermsXml += "<ram:ApplicableTradePaymentDiscountTerms>";
final String currency = trans.getCurrency();
final String basisAmount = currencyFormat(calc.getGrandTotal());
paymentTermsXml += "<ram:BasisAmount currencyID=\"" + currency + "\">" + basisAmount + "</ram:BasisAmount>";
paymentTermsXml += "<ram:CalculationPercent>" + discountTerms.getCalculationPercentage().toString()
+ "</ram:CalculationPercent>";
if (discountTerms.getBaseDate() != null) {
final Date baseDate = discountTerms.getBaseDate();
paymentTermsXml += "<ram:BasisDateTime>";
paymentTermsXml += DATE.udtFormat(baseDate);
paymentTermsXml += "</ram:BasisDateTime>";
paymentTermsXml += "<ram:BasisPeriodMeasure unitCode=\"" + discountTerms.getBasePeriodUnitCode() + "\">"
+ discountTerms.getBasePeriodMeasure() + "</ram:BasisPeriodMeasure>";
}
paymentTermsXml += "</ram:ApplicableTradePaymentDiscountTerms>";
}
paymentTermsXml += "</ram:SpecifiedTradePaymentTerms>";
return paymentTermsXml;
}
@Override
protected String buildNotes(IExportableTransaction exportableTransaction) {
Invoice copyWithoutRebateInfo = new Invoice()
.setOwnOrganisationFullPlaintextInfo(exportableTransaction.getOwnOrganisationFullPlaintextInfo())
.addNotes(exportableTransaction.getNotesWithSubjectCode());
if(exportableTransaction.getNotes() != null) {
for (String note : exportableTransaction.getNotes()) {
copyWithoutRebateInfo.addNote(note);
}
}
Optional.ofNullable(exportableTransaction.getSubjectNote()).ifPresent(copyWithoutRebateInfo::addNote);
return super.buildNotes(copyWithoutRebateInfo);
}
}

View File

@@ -29,8 +29,10 @@ package org.mustangproject.ZUGFeRD;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import org.mustangproject.FileAttachment;
import org.mustangproject.IncludedNote;
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
/***
@@ -80,10 +82,13 @@ public interface IExportableTransaction {
/**
* this should be the full sender institution name, details, manager and tax
* registration. It is one of the few functions which may return null. e.g.
* <p>
* <p/>
* Lieferant GmbH Lieferantenstraße 20 80333 München Deutschland
* Geschäftsführer: Hans Muster Handelsregisternummer: H A 123
* <p/>
*
* It is written as an includedNode with subjectCode {@link org.mustangproject.SubjectCode#REG}. See also
* {@link #getNotesWithSubjectCode()}
* @return null or full sender institution name, details, manager and tax
* registration
*/
@@ -489,6 +494,13 @@ public interface IExportableTransaction {
return null;
}
/**
* A grouping of business terms to indicate accounting-relevant free texts including a qualification of these. <p/>
* The information are written to the same xml nodes like {@link #getNotes()} but with explicit subjectCode.
*/
default List<IncludedNote> getNotesWithSubjectCode(){
return null;
}
default String getSpecifiedProcuringProjectName() {
return null;
}

View File

@@ -27,14 +27,18 @@ import static org.mustangproject.ZUGFeRD.model.TaxCategoryCodeTypeConstants.CATE
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.mustangproject.EStandard;
import org.mustangproject.FileAttachment;
import org.mustangproject.IncludedNote;
import org.mustangproject.XMLTools;
public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider {
@@ -64,39 +68,11 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
}
String senderReg = "";
if (trans.getOwnOrganisationFullPlaintextInfo() != null) {
senderReg = "<ram:IncludedNote><ram:Content>"
+ XMLTools.encodeXML(trans.getOwnOrganisationFullPlaintextInfo()) + "</ram:Content>"
+ "<ram:SubjectCode>REG</ram:SubjectCode></ram:IncludedNote>";
}
String rebateAgreement = "";
if (trans.rebateAgreementExists()) {
rebateAgreement = "<ram:IncludedNote><ram:Content>"
+ "Es bestehen Rabatt- und Bonusvereinbarungen.</ram:Content>"
+ "<ram:SubjectCode>AAK</ram:SubjectCode></ram:IncludedNote>";
}
String subjectNote = "";
if (trans.getSubjectNote() != null) {
subjectNote = "<ram:IncludedNote><ram:Content>"
+ XMLTools.encodeXML(trans.getSubjectNote()) + "</ram:Content>"
+ "</ram:IncludedNote>";
}
final String typecode = "220";
/*if (trans.getDocumentCode() != null) {
typecode = trans.getDocumentCode();
}*/
String notes = "";
if (trans.getNotes() != null) {
for (final String currentNote : trans.getNotes()) {
notes += "<ram:IncludedNote><ram:Content>" + XMLTools.encodeXML(currentNote) + "</ram:Content></ram:IncludedNote>";
}
}
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<rsm:SCRDMCCBDACIOMessageStructure\n" +
@@ -126,10 +102,7 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
+ "<ram:TypeCode>" + typecode + "</ram:TypeCode>"
+ "<ram:IssueDateTime>"
+ DATE.udtFormat(trans.getIssueDate()) + "</ram:IssueDateTime>" // date
+ notes
+ subjectNote
+ rebateAgreement
+ senderReg
+ buildNotes(trans)
+ "</rsm:ExchangedDocument>"
+ "<rsm:SupplyChainTradeTransaction>";
@@ -139,18 +112,12 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider
if (currentItem.getProduct().getTaxExemptionReason() != null) {
// exemptionReason = "<ram:ExemptionReason>" + XMLTools.encodeXML(currentItem.getProduct().getTaxExemptionReason()) + "</ram:ExemptionReason>";
}
notes = "";
if (currentItem.getNotes() != null) {
for (final String currentNote : currentItem.getNotes()) {
notes = notes + "<ram:IncludedNote><ram:Content>" + XMLTools.encodeXML(currentNote) + "</ram:Content></ram:IncludedNote>";
}
}
final LineCalculator lc = new LineCalculator(currentItem);
xml += "<ram:IncludedSupplyChainTradeLineItem>" +
"<ram:AssociatedDocumentLineDocument>"
+ "<ram:LineID>" + lineID + "</ram:LineID>"
+ notes
+ buildItemNotes(currentItem)
+ "</ram:AssociatedDocumentLineDocument>"
+ "<ram:SpecifiedTradeProduct>";

View File

@@ -29,11 +29,16 @@ import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.dom4j.Document;
import org.dom4j.DocumentException;
@@ -41,6 +46,7 @@ import org.dom4j.DocumentHelper;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import org.mustangproject.FileAttachment;
import org.mustangproject.IncludedNote;
import org.mustangproject.XMLTools;
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
@@ -289,41 +295,11 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
}
String senderReg = "";
if (trans.getOwnOrganisationFullPlaintextInfo() != null) {
senderReg = "<ram:IncludedNote><ram:Content>"
+ XMLTools.encodeXML(trans.getOwnOrganisationFullPlaintextInfo()) + "</ram:Content>"
+ "<ram:SubjectCode>REG</ram:SubjectCode></ram:IncludedNote>";
}
String rebateAgreement = "";
if (trans.rebateAgreementExists()) {
rebateAgreement = "<ram:IncludedNote><ram:Content>"
+ "Es bestehen Rabatt- und Bonusvereinbarungen.</ram:Content>"
+ "<ram:SubjectCode>AAK</ram:SubjectCode></ram:IncludedNote>";
}
String subjectNote = "";
if (trans.getSubjectNote() != null) {
subjectNote = "<ram:IncludedNote><ram:Content>"
+ XMLTools.encodeXML(trans.getSubjectNote()) + "</ram:Content>"
+ "</ram:IncludedNote>";
}
String typecode = "380";
if (trans.getDocumentCode() != null) {
typecode = trans.getDocumentCode();
}
String notes = "";
if (trans.getNotes() != null) {
for (final String currentNote : trans.getNotes()) {
notes = notes + "<ram:IncludedNote><ram:Content>" + XMLTools.encodeXML(currentNote) + "</ram:Content></ram:IncludedNote>";
}
}
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<rsm:CrossIndustryInvoice xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:rsm=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100\""
// + "
// xsi:schemaLocation=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100
@@ -347,10 +323,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
+ "<ram:TypeCode>" + typecode + "</ram:TypeCode>"
+ "<ram:IssueDateTime>"
+ DATE.udtFormat(trans.getIssueDate()) + "</ram:IssueDateTime>" // date
+ notes
+ subjectNote
+ rebateAgreement
+ senderReg
+ buildNotes(trans)
+ "</rsm:ExchangedDocument>"
+ "<rsm:SupplyChainTradeTransaction>";
@@ -360,20 +333,12 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
if (currentItem.getProduct().getTaxExemptionReason() != null) {
exemptionReason = "<ram:ExemptionReason>" + XMLTools.encodeXML(currentItem.getProduct().getTaxExemptionReason()) + "</ram:ExemptionReason>";
}
notes = "";
if (currentItem.getNotes() != null) {
for (final String currentNote : currentItem.getNotes()) {
notes = notes + "<ram:IncludedNote><ram:Content>" + XMLTools.encodeXML(currentNote) + "</ram:Content></ram:IncludedNote>";
}
}
final LineCalculator lc = new LineCalculator(currentItem);
if ((getProfile() != Profiles.getByName("Minimum")) && (getProfile() != Profiles.getByName("BasicWL"))) {
xml += "<ram:IncludedSupplyChainTradeLineItem>" +
if ((getProfile() != Profiles.getByName("Minimum")) && (getProfile() != Profiles.getByName("BasicWL"))) {
xml += "<ram:IncludedSupplyChainTradeLineItem>" +
"<ram:AssociatedDocumentLineDocument>"
+ "<ram:LineID>" + lineID + "</ram:LineID>"
+ notes
+ buildItemNotes(currentItem)
+ "</ram:AssociatedDocumentLineDocument>"
+ "<ram:SpecifiedTradeProduct>";
@@ -422,16 +387,12 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
"<ram:TypeCode>" + XMLTools.encodeXML(currentReferencedDocument.getTypeCode()) + "</ram:TypeCode>" +
"<ram:ReferenceTypeCode>" + XMLTools.encodeXML(currentReferencedDocument.getReferenceTypeCode()) + "</ram:ReferenceTypeCode>" +
"</ram:AdditionalReferencedDocument>";
}
}
if (currentItem.getBuyerOrderReferencedDocumentLineID() != null) {
xml += "<ram:BuyerOrderReferencedDocument> "
+ "<ram:LineID>" + XMLTools.encodeXML(currentItem.getBuyerOrderReferencedDocumentLineID()) + "</ram:LineID>"
+ "</ram:BuyerOrderReferencedDocument>";
}
xml += "<ram:GrossPriceProductTradePrice>"
+ "<ram:ChargeAmount>" + priceFormat(lc.getPriceGross())
@@ -647,8 +608,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
xml += "<ram:EndDateTime>" + DATE.udtFormat(trans.getDetailedDeliveryPeriodTo()) + "</ram:EndDateTime>";
}
xml += "</ram:BillingSpecifiedPeriod>";
}
if ((trans.getZFCharges() != null) && (trans.getZFCharges().length > 0)) {
@@ -776,7 +735,37 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
}
}
@Override
protected String buildItemNotes(IZUGFeRDExportableItem currentItem) {
if (currentItem.getNotes() == null) {
return "";
}
return Arrays.stream(currentItem.getNotes())
.map(IncludedNote::unspecifiedNote)
.map(IncludedNote::toCiiXml)
.collect(Collectors.joining());
}
protected String buildNotes(IExportableTransaction exportableTransaction) {
final List<IncludedNote> includedNotes = Optional.ofNullable(exportableTransaction.getNotesWithSubjectCode())
.orElse(new ArrayList<>());
if (exportableTransaction.getNotes() != null) {
for (final String currentNote : exportableTransaction.getNotes()) {
includedNotes.add(IncludedNote.unspecifiedNote(currentNote));
}
}
if (exportableTransaction.rebateAgreementExists()) {
includedNotes.add(IncludedNote.discountBonusNote("Es bestehen Rabatt- und Bonusvereinbarungen."));
}
Optional.ofNullable(exportableTransaction.getOwnOrganisationFullPlaintextInfo())
.ifPresent(info -> includedNotes.add(IncludedNote.regulatoryNote(info)));
Optional.ofNullable(exportableTransaction.getSubjectNote())
.ifPresent(note -> includedNotes.add(IncludedNote.unspecifiedNote(note)));
return includedNotes.stream().map(IncludedNote::toCiiXml).collect(Collectors.joining(""));
}
@Override
public void setProfile(Profile p) {
profile = p;
}