2017-06-07 13:28:42 +00:00
|
|
|
var path = require('path');
|
|
|
|
var database = require(path.join(__dirname, '../../database.js'));
|
2017-06-07 17:29:16 +00:00
|
|
|
var format = require(path.join(__dirname, '../../util/format.js'));
|
2017-06-07 13:28:42 +00:00
|
|
|
|
|
|
|
module.exports = class PaymentUpdate {
|
|
|
|
getData(params, cb) {
|
2017-06-08 14:53:10 +00:00
|
|
|
let query = `SELECT pm.name AS payMethod, pm.id AS payMethodId, c.vencimiento AS payDay, c.CC AS accountAddress
|
2017-06-07 17:29:16 +00:00
|
|
|
FROM Clientes AS c JOIN pay_met AS pm ON pm.id = c.pay_met_id WHERE Id_Cliente = ?`;
|
|
|
|
database.pool.query(query, [params.userId], (error, result) => {
|
|
|
|
Object.assign(this, result[0]);
|
|
|
|
cb();
|
2017-06-07 13:28:42 +00:00
|
|
|
});
|
|
|
|
}
|
2017-06-08 14:53:10 +00:00
|
|
|
|
|
|
|
get paymentDay() {
|
|
|
|
if (this.payMethodId != 5) {
|
|
|
|
return `<div>${this._.paymentDay}: <strong style="font-size: 16px">${this.payDay} ${this._.everyMonth}</strong></div>`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-07 17:29:16 +00:00
|
|
|
get paymentAdvice() {
|
|
|
|
switch (this.payMethodId) {
|
|
|
|
case 4:
|
|
|
|
return `${this._.accountPaymentAdviceBefore} ${format.partialAccountAddress(this.accountAddress)} ${this._.accountPaymentAdviceAfter}`;
|
|
|
|
case 5:
|
|
|
|
return this._.cardPaymentAdvice;
|
2017-06-07 13:28:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|