Tarea #600 Refactor to make it compatible with logs

This commit is contained in:
Gerard 2018-10-03 11:27:55 +02:00
parent a607ac9efb
commit 5eb83ed01e
1 changed files with 6 additions and 5 deletions

View File

@ -1,5 +1,5 @@
module.exports = function(Client) {
Client.remoteMethod('addressesPropagateRe', {
module.exports = function(Self) {
Self.remoteMethod('addressesPropagateRe', {
description: 'Change property isEqualizated in all client addresses',
accessType: 'WRITE',
accepts: [
@ -29,10 +29,11 @@ module.exports = function(Client) {
}
});
Client.addressesPropagateRe = async (id, data) => {
Self.addressesPropagateRe = async (id, data) => {
if (data.hasOwnProperty('isEqualizated')) {
await Client.app.models.Address.updateAll({clientFk: id}, data);
await Client.update({id: id}, {hasToInvoiceByAddress: false});
await Self.app.models.Address.updateAll({clientFk: id}, data);
let client = await Self.app.models.Client.findById(id)
await client.updateAttributes({hasToInvoiceByAddress: false});
return true;
}
return false;