From 79f9dfb515bb02c6e0fa223f78f1b467138c0d02 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 15 Apr 2019 08:46:20 +0200 Subject: [PATCH] error when sending to a salesPerson pay-method changes #1338 --- modules/client/back/models/client.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index dd0d61d9c..66c875aa5 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -197,10 +197,11 @@ module.exports = Self => { if (payMethodChanged || ibanChanged || dueDayChanged) { const message = `La forma de pago del cliente con id ${instance.id} ha cambiado`; const salesPersonFk = instance.salesPersonFk; + const salesPerson = await Self.app.models.Worker.findById(salesPersonFk); - if (salesPersonFk) { + if (salesPerson) { await Self.app.models.Message.send(ctx, { - recipientFk: salesPersonFk, + recipientFk: salesPerson.userFk, message: message }); }