From afffa93d8907174d92fd25dfca9054bd1c4004d1 Mon Sep 17 00:00:00 2001 From: Sebastian Sieber Date: Thu, 13 Jul 2023 10:58:37 +0200 Subject: [PATCH] Implement Invoice#getNotesWithSubjectCode and convenient setter methods. --- .../main/java/org/mustangproject/Invoice.java | 97 ++++++++++++++++++- 1 file changed, 94 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/org/mustangproject/Invoice.java b/library/src/main/java/org/mustangproject/Invoice.java index 3622b041..2f63578b 100644 --- a/library/src/main/java/org/mustangproject/Invoice.java +++ b/library/src/main/java/org/mustangproject/Invoice.java @@ -23,6 +23,7 @@ package org.mustangproject; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; +import java.util.List; import org.mustangproject.ZUGFeRD.IExportableTransaction; import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge; @@ -48,6 +49,7 @@ public class Invoice implements IExportableTransaction { @JsonDeserialize(contentAs=Item.class) protected ArrayList ZFItems = null; protected ArrayList notes = null; + private List includedNotes = null; protected String sellerOrderReferencedDocumentID; protected String contractReferencedDocument = null; protected ArrayList xmlEmbeddedFiles=null; @@ -396,7 +398,12 @@ public class Invoice implements IExportableTransaction { return notes.toArray(new String[0]); } - @Override + @Override + public List getNotesWithSubjectCode() { + return includedNotes; + } + + @Override public String getCurrency() { return currency; } @@ -659,8 +666,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 */ @@ -671,7 +678,91 @@ public class Invoice implements IExportableTransaction { notes.add(text); 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 regulatoryNote(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 legalNote(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 customsNote(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 sellerNote(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 taxNote(String content) { + if (includedNotes == null) { + includedNotes = new ArrayList<>(); + } + includedNotes.add(IncludedNote.taxNote(content)); + return this; + } + @Override public String getSpecifiedProcuringProjectID() { return specifiedProcuringProjectID;