42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
|
var path = require('path');
|
||
|
var database = require(path.join(__dirname, '../../database.js'));
|
||
|
var format = require(path.join(__dirname, '../../util/format.js'));
|
||
|
|
||
|
module.exports = class PaymentUpdate {
|
||
|
getData(params, cb) {
|
||
|
let query = `SELECT
|
||
|
pm.id payMethodFk,
|
||
|
pm.name payMethodName,
|
||
|
c.dueDay,
|
||
|
c.iban,
|
||
|
LOWER(ct.code) countryCode,
|
||
|
c.email recipient
|
||
|
FROM client c
|
||
|
JOIN payMethod pm ON pm.id = c.paymentMethodFk
|
||
|
JOIN country ct ON ct.id = c.countryFk
|
||
|
WHERE c.id = ?`;
|
||
|
database.pool.query(query, [params.recipient], (error, result) => {
|
||
|
if (error || result.length == 0)
|
||
|
return cb({status: 'REJECT', data: {message: 'No data found', error: error}});
|
||
|
|
||
|
Object.assign(this, result[0]);
|
||
|
cb({status: 'ACCEPT', data: {}});
|
||
|
});
|
||
|
}
|
||
|
|
||
|
get paymentDay() {
|
||
|
if (this.payMethodFk != 5) {
|
||
|
return `<div>${this._.paymentDay}: <strong style="font-size: 16px">${this.dueDay} ${this._.everyMonth}</strong></div>`;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
get paymentAdvice() {
|
||
|
switch (this.payMethodFk) {
|
||
|
case 4:
|
||
|
return `${this._.accountPaymentAdviceBefore} ${format.partialAccountAddress(this.iban)} ${this._.accountPaymentAdviceAfter}`;
|
||
|
case 5:
|
||
|
return this._.cardPaymentAdvice;
|
||
|
}
|
||
|
}
|
||
|
};
|