UNPKG

sepaxmljs

Version:

Generate XML-SEPA credit transfert (SCT)

56 lines (50 loc) 1.23 kB
"use strict"; /** * Credit Transfer Transaction Information */ var CdtTrfTxInf = function (PmtId, creditor, amount, iban, bic, instruction) { this.PmtId = PmtId; this.creditor = creditor; if(amount.hasOwnProperty('amount') && amount.hasOwnProperty('currency')){ this.amount = amount.amount; this.currency = amount.currency } else { this.amount = amount; this.currency = "EUR" } this.iban = iban; this.bic = bic; this.RmtInf = instruction; return this; } CdtTrfTxInf.prototype.toString = function(){ let transaction = { PmtId: { InstrId: this.PmtId, EndToEndId: this.PmtId }, Amt: { InstdAmt: { "@Ccy": "EUR", "#text": this.amount } }, CdtrAgt: { FinInstnId: { BIC: this.bic } }, Cdtr: { Nm: this.creditor }, CdtrAcct: { Id: { IBAN: this.iban } } } if(!this.RmtInf === 'undefined') {transaction.RmtInf.Ustrd = this.RmtInf}; return transaction } module.exports = CdtTrfTxInf;