Add more setter for notes

This commit is contained in:
Sebastian Sieber
2023-07-13 11:22:56 +02:00
parent afffa93d89
commit 7fd3c18547
4 changed files with 54 additions and 8 deletions

View File

@@ -30,6 +30,12 @@ public class IncludedNote {
public static IncludedNote taxNote(String content) { public static IncludedNote taxNote(String content) {
return new IncludedNote(content, SubjectCode.TXD); 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 String getContent() { public String getContent() {
return content; return content;

View File

@@ -699,7 +699,7 @@ public class Invoice implements IExportableTransaction {
* @param content freeform UTF8 plain text * @param content freeform UTF8 plain text
* @return fluent setter * @return fluent setter
*/ */
public Invoice regulatoryNote(String content) { public Invoice addRegulatoryNote(String content) {
if (includedNotes == null) { if (includedNotes == null) {
includedNotes = new ArrayList<>(); includedNotes = new ArrayList<>();
} }
@@ -713,7 +713,7 @@ public class Invoice implements IExportableTransaction {
* @param content freeform UTF8 plain text * @param content freeform UTF8 plain text
* @return fluent setter * @return fluent setter
*/ */
public Invoice legalNote(String content) { public Invoice addLegalNote(String content) {
if (includedNotes == null) { if (includedNotes == null) {
includedNotes = new ArrayList<>(); includedNotes = new ArrayList<>();
} }
@@ -727,7 +727,7 @@ public class Invoice implements IExportableTransaction {
* @param content freeform UTF8 plain text * @param content freeform UTF8 plain text
* @return fluent setter * @return fluent setter
*/ */
public Invoice customsNote(String content) { public Invoice addCustomsNote(String content) {
if (includedNotes == null) { if (includedNotes == null) {
includedNotes = new ArrayList<>(); includedNotes = new ArrayList<>();
} }
@@ -741,7 +741,7 @@ public class Invoice implements IExportableTransaction {
* @param content freeform UTF8 plain text * @param content freeform UTF8 plain text
* @return fluent setter * @return fluent setter
*/ */
public Invoice sellerNote(String content) { public Invoice addSellerNote(String content) {
if (includedNotes == null) { if (includedNotes == null) {
includedNotes = new ArrayList<>(); includedNotes = new ArrayList<>();
} }
@@ -755,7 +755,7 @@ public class Invoice implements IExportableTransaction {
* @param content freeform UTF8 plain text * @param content freeform UTF8 plain text
* @return fluent setter * @return fluent setter
*/ */
public Invoice taxNote(String content) { public Invoice addTaxNote(String content) {
if (includedNotes == null) { if (includedNotes == null) {
includedNotes = new ArrayList<>(); includedNotes = new ArrayList<>();
} }
@@ -763,6 +763,33 @@ public class Invoice implements IExportableTransaction {
return this; 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 @Override
public String getSpecifiedProcuringProjectID() { public String getSpecifiedProcuringProjectID() {
return specifiedProcuringProjectID; return specifiedProcuringProjectID;

View File

@@ -27,5 +27,13 @@ public enum SubjectCode {
/** /**
* Customs information * Customs information
*/ */
CUS CUS,
/**
* introduction
*/
ACY,
/**
* Discount and bonus agreements
*/
AAK
} }

View File

@@ -41,6 +41,7 @@ import org.dom4j.DocumentHelper;
import org.dom4j.io.OutputFormat; import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter; import org.dom4j.io.XMLWriter;
import org.mustangproject.FileAttachment; import org.mustangproject.FileAttachment;
import org.mustangproject.SubjectCode;
import org.mustangproject.XMLTools; import org.mustangproject.XMLTools;
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants; import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
@@ -753,13 +754,17 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
if (trans.rebateAgreementExists()) { if (trans.rebateAgreementExists()) {
notes.append("<ram:IncludedNote><ram:Content>") notes.append("<ram:IncludedNote><ram:Content>")
.append("Es bestehen Rabatt- und Bonusvereinbarungen.</ram:Content>") .append("Es bestehen Rabatt- und Bonusvereinbarungen.</ram:Content>")
.append("<ram:SubjectCode>AAK</ram:SubjectCode></ram:IncludedNote>"); .append("<ram:SubjectCode>")
.append(SubjectCode.AAK)
.append("</ram:SubjectCode></ram:IncludedNote>");
} }
if (trans.getOwnOrganisationFullPlaintextInfo() != null) { if (trans.getOwnOrganisationFullPlaintextInfo() != null) {
notes.append("<ram:IncludedNote><ram:Content>") notes.append("<ram:IncludedNote><ram:Content>")
.append(XMLTools.encodeXML(trans.getOwnOrganisationFullPlaintextInfo())) .append(XMLTools.encodeXML(trans.getOwnOrganisationFullPlaintextInfo()))
.append("</ram:Content>") .append("</ram:Content>")
.append("<ram:SubjectCode>REG</ram:SubjectCode></ram:IncludedNote>"); .append("<ram:SubjectCode>")
.append(SubjectCode.REG)
.append("</ram:SubjectCode></ram:IncludedNote>");
} }
if (trans.getSubjectNote() != null) { if (trans.getSubjectNote() != null) {
notes.append("<ram:IncludedNote><ram:Content>") notes.append("<ram:IncludedNote><ram:Content>")