diff --git a/services/loopback/common/methods/client/addressesPropagateRe.js b/services/loopback/common/methods/client/addressesPropagateRe.js index 1e37ef80d..b94462c93 100644 --- a/services/loopback/common/methods/client/addressesPropagateRe.js +++ b/services/loopback/common/methods/client/addressesPropagateRe.js @@ -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;