diff --git a/library/src/main/java/org/mustangproject/Invoice.java b/library/src/main/java/org/mustangproject/Invoice.java index 606d19ba..da43eaeb 100644 --- a/library/src/main/java/org/mustangproject/Invoice.java +++ b/library/src/main/java/org/mustangproject/Invoice.java @@ -22,6 +22,7 @@ package org.mustangproject; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Collection; import java.util.Date; import java.util.List; @@ -679,6 +680,17 @@ public class Invoice implements IExportableTransaction { return this; } + public Invoice addNotes(Collection 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} diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/DAPullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/DAPullProvider.java index 81d5e8aa..5a050c7c 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/DAPullProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/DAPullProvider.java @@ -45,37 +45,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 = "" - + XMLTools.encodeXML(trans.getOwnOrganisationFullPlaintextInfo()) + "" - + "REG"; - - } - - String subjectNote = ""; - if (trans.getSubjectNote() != null) { - subjectNote = "" - + XMLTools.encodeXML(trans.getSubjectNote()) + "" - + ""; - } final String typecode = "220"; /*if (trans.getDocumentCode() != null) { typecode = trans.getDocumentCode(); }*/ - String notes = ""; - if (trans.getNotes() != null) { - for (final String currentNote : trans.getNotes()) { - notes += "" + XMLTools.encodeXML(currentNote) + ""; - } - } String testBooleanStr="true"; String xml = "" + typecode + "" + "" + DATE.udtFormat(trans.getIssueDate()) + "" // date - + notes - + subjectNote - + senderReg + + buildNotes(trans) + "" + ""; @@ -111,7 +84,7 @@ public class DAPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider if (currentItem.getProduct().getTaxExemptionReason() != null) { // exemptionReason = "" + XMLTools.encodeXML(currentItem.getProduct().getTaxExemptionReason()) + ""; } - notes = ""; + String notes = ""; if (currentItem.getNotes() != null) { for (final String currentNote : currentItem.getNotes()) { notes = notes + "" + XMLTools.encodeXML(currentNote) + ""; @@ -308,5 +281,19 @@ public class DAPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider return profile; } - + @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); + } + } + if(exportableTransaction.getSubjectNote()!= null) { + copyWithoutRebateInfo.addNote(exportableTransaction.getSubjectNote()); + } + return super.buildNotes(copyWithoutRebateInfo); + } } diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/OXPullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/OXPullProvider.java index 10b4b498..1394e2b0 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/OXPullProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/OXPullProvider.java @@ -64,39 +64,11 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider } - String senderReg = ""; - if (trans.getOwnOrganisationFullPlaintextInfo() != null) { - senderReg = "" - + XMLTools.encodeXML(trans.getOwnOrganisationFullPlaintextInfo()) + "" - + "REG"; - - } - - String rebateAgreement = ""; - if (trans.rebateAgreementExists()) { - rebateAgreement = "" - + "Es bestehen Rabatt- und Bonusvereinbarungen." - + "AAK"; - } - - String subjectNote = ""; - if (trans.getSubjectNote() != null) { - subjectNote = "" - + XMLTools.encodeXML(trans.getSubjectNote()) + "" - + ""; - } - final String typecode = "220"; /*if (trans.getDocumentCode() != null) { typecode = trans.getDocumentCode(); }*/ - String notes = ""; - if (trans.getNotes() != null) { - for (final String currentNote : trans.getNotes()) { - notes += "" + XMLTools.encodeXML(currentNote) + ""; - - } - } + String xml = "" + "" + typecode + "" + "" + DATE.udtFormat(trans.getIssueDate()) + "" // date - + notes - + subjectNote - + rebateAgreement - + senderReg + + buildNotes(trans) + "" + ""; @@ -139,7 +108,7 @@ public class OXPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider if (currentItem.getProduct().getTaxExemptionReason() != null) { // exemptionReason = "" + XMLTools.encodeXML(currentItem.getProduct().getTaxExemptionReason()) + ""; } - notes = ""; + String notes = ""; if (currentItem.getNotes() != null) { for (final String currentNote : currentItem.getNotes()) { notes = notes + "" + XMLTools.encodeXML(currentNote) + ""; diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java index b48446e9..d79d6042 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java @@ -747,7 +747,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { } } - private static String buildNotes(IExportableTransaction exportableTransaction) { + protected String buildNotes(IExportableTransaction exportableTransaction) { final List includedNotes = Optional.ofNullable(exportableTransaction.getNotesWithSubjectCode()) .orElse(new ArrayList<>()); if (exportableTransaction.getNotes() != null) {