Skip to content

Commit

Permalink
Merge pull request #439 from langfr/feature/436
Browse files Browse the repository at this point in the history
Direct Debit: add field CreditorReferenceID.
  • Loading branch information
jstaerk authored Aug 8, 2024
2 parents 8f7744b + b7b0dd2 commit cb25a9a
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 14 deletions.
42 changes: 42 additions & 0 deletions library/src/main/java/org/mustangproject/DirectDebit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.mustangproject;

import org.mustangproject.ZUGFeRD.IZUGFeRDTradeSettlementDebit;

/**
* provides e.g. the IBAN to transfer money to :-)
*/
public class DirectDebit implements IZUGFeRDTradeSettlementDebit {
/**
* Debited account identifier (BT-91)
*/
protected final String IBAN;

/**
* Mandate reference identifier (BT-89)
*/
protected final String mandate;

/***
* constructor for normal use :-)
* @param IBAN the IBAN as string
* @param mandate the mandate as string
*/
public DirectDebit(String IBAN, String mandate) {
this.IBAN = IBAN;
this.mandate = mandate;
}

/***
* getter for the IBAN
* @return IBAN
*/
@Override
public String getIBAN() {
return this.IBAN;
}

@Override
public String getMandate() {
return this.mandate;
}
}
10 changes: 10 additions & 0 deletions library/src/main/java/org/mustangproject/Invoice.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class Invoice implements IExportableTransaction {
protected String specifiedProcuringProjectName = null;
protected String despatchAdviceReferencedDocumentID = null;
protected String vatDueDateTypeCode = null;
protected String creditorReferenceID; // required when direct debit is used.

public Invoice() {
ZFItems = new ArrayList<>();
Expand Down Expand Up @@ -878,4 +879,13 @@ public Invoice setVATDueDateTypeCode(String vatDueDateTypeCode) {
return this;
}

public String getCreditorReferenceID() {
return creditorReferenceID;
}

public Invoice setCreditorReferenceID(String creditorReferenceID) {
this.creditorReferenceID = creditorReferenceID;
return this;
}

}
5 changes: 2 additions & 3 deletions library/src/main/java/org/mustangproject/TradeParty.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableTradeParty;
import org.mustangproject.ZUGFeRD.IZUGFeRDLegalOrganisation;
import org.mustangproject.ZUGFeRD.IZUGFeRDTradeSettlement;
import org.mustangproject.ZUGFeRD.IZUGFeRDTradeSettlementDebit;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

Expand All @@ -27,7 +26,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
protected String additionalAddress = null;
protected String additionalAddressExtension = null;
protected List<BankDetails> bankDetails = new ArrayList<>();
protected List<IZUGFeRDTradeSettlementDebit> debitDetails = new ArrayList<>();
protected List<DirectDebit> debitDetails = new ArrayList<>();
protected Contact contact = null;
protected LegalOrganisation legalOrg = null;
protected SchemedID globalId = null;
Expand Down Expand Up @@ -483,7 +482,7 @@ public TradeParty addBankDetails(BankDetails s) {
* @param debitDetail e.g. containing IBAN and mandate
* @return fluent setter
*/
public TradeParty addDebitDetails(IZUGFeRDTradeSettlementDebit debitDetail) {
public TradeParty addDebitDetails(DirectDebit debitDetail) {
debitDetails.add(debitDetail);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,4 +522,7 @@ default String getVATDueDateTypeCode() {
return null;
}

default String getCreditorReferenceID() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,30 @@

public interface IZUGFeRDTradeSettlementDebit extends IZUGFeRDTradeSettlement {



@Override
default String getSettlementXML() {



String xml = "<ram:SpecifiedTradeSettlementPaymentMeans>"
+ "<ram:TypeCode>59</ram:TypeCode>"
+ "<ram:Information>SEPA direct debit</ram:Information>"
+ "<ram:PayerPartyDebtorFinancialAccount>"
+ "<ram:IBANID>"+XMLTools.encodeXML(getIBAN())+"</ram:IBANID>"
+ "</ram:PayerPartyDebtorFinancialAccount>";
+ "<ram:IBANID>" + XMLTools.encodeXML(getIBAN()) + "</ram:IBANID>"
+ "</ram:PayerPartyDebtorFinancialAccount>";

xml += "</ram:SpecifiedTradeSettlementPaymentMeans>";
return xml;
}

@Override
default String getPaymentXML() {
return "<ram:DirectDebitMandateID>"+XMLTools.encodeXML(getMandate())+"</ram:DirectDebitMandateID>";
return "<ram:DirectDebitMandateID>" + XMLTools.encodeXML(getMandate()) + "</ram:DirectDebitMandateID>";
}


/***
* @return IBAN of the debtor (optional)
*/
String getIBAN();


/***
* @return sepa direct debit mandate reference
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,9 @@ public void generateXML(IExportableTransaction trans) {

xml += "</ram:ApplicableHeaderTradeDelivery>";
xml += "<ram:ApplicableHeaderTradeSettlement>";
if ((trans.getCreditorReferenceID() != null) && (getProfile() != Profiles.getByName("Minimum"))) {
xml += "<ram:CreditorReferenceID>" + XMLTools.encodeXML(trans.getCreditorReferenceID()) + "</ram:CreditorReferenceID>";
}
if ((trans.getNumber() != null) && (getProfile() != Profiles.getByName("Minimum"))) {
xml += "<ram:PaymentReference>" + XMLTools.encodeXML(trans.getNumber()) + "</ram:PaymentReference>";
}
Expand Down

0 comments on commit cb25a9a

Please sign in to comment.