40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
let database = require('../database.js');
|
|
|
|
module.exports = {
|
|
|
|
/**
|
|
* Devuelve el iban
|
|
* @param {String} addressNumber - Dirección de cuenta bancaria
|
|
* @param {Object} cb - Callback
|
|
*/
|
|
accountAddressIban: function(addressNumber, cb) {
|
|
database.pool.query('SELECT vn2008.cc_to_iban(?) AS iban', [addressNumber], function(error, result) {
|
|
cb(result[0].iban);
|
|
});
|
|
},
|
|
|
|
/**
|
|
* Obtiene el numero de cuenta completo incluyendo iban
|
|
* @param {String} addressNumber - Dirección de cuenta bancaria
|
|
* @return {String} Cuenta bancaria formateada
|
|
*/
|
|
accountAddress: function(addressNumber) {
|
|
var formattedAccountAddress = addressNumber.replace(/(.{4})/g, '$1-');
|
|
return formattedAccountAddress.substring(0, formattedAccountAddress.length - 1);
|
|
},
|
|
|
|
/**
|
|
* Devuelve el numero de cuenta mostrando únicamente los últimos 4 dígitos.
|
|
* @param {String} addressNumber - Dirección de cuenta bancaria
|
|
* @return {String} Cuenta bancaria formateada
|
|
*/
|
|
partialAccountAddress: function(addressNumber) {
|
|
let address = this.accountAddress(addressNumber);
|
|
return address.substring(0, 19).replace(/[0-9]/g, 'X') + address.substring(19, 24);
|
|
},
|
|
|
|
phone: function(number) {
|
|
return number;
|
|
}
|
|
};
|