From 0ed240df0b41659da0a48196d3241a280e6a8882 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 10 Sep 2019 14:12:03 +0200 Subject: [PATCH] Server error on change paymethod #1687 --- modules/client/back/models/client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 0a3efc958..24659b366 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -209,9 +209,9 @@ 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 (salesPerson) { + if (salesPersonFk) { + const salesPerson = await Self.app.models.Worker.findById(salesPersonFk); await Self.app.models.Message.send(ctx, { recipientFk: salesPerson.userFk, message: message