From 367f5694756af79ccb03203e42ee5503b84ef23c Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 29 Jan 2025 10:48:16 +0100 Subject: [PATCH] fix: hotfix observationEmail --- modules/client/back/methods/defaulter/observationEmail.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/client/back/methods/defaulter/observationEmail.js b/modules/client/back/methods/defaulter/observationEmail.js index 797e88f74..57d759cdc 100644 --- a/modules/client/back/methods/defaulter/observationEmail.js +++ b/modules/client/back/methods/defaulter/observationEmail.js @@ -35,7 +35,11 @@ module.exports = Self => { Object.assign(myOptions, options); for (const defaulter of defaulters) { - const user = await models.VnUser.findById(userId, {fields: ['name']}, myOptions); + const user = await models.VnUser.findById(userId, myOptions); + const salesPerson = await models.VnUser.findById(defaulter.salesPersonFk, myOptions); + let email = defaulter.departmentEmail; + if (email == null) + email = salesPerson.email; const body = $t('Added observation', { user: user.name, @@ -47,7 +51,7 @@ module.exports = Self => { await models.Mail.create({ subject: $t('Comment added to client', {clientFk: defaulter.clientFk}), body: body, - receiver: `${defaulter.departmentEmail}`, + receiver: `${email}`, replyTo: `${user.name}@verdnatura.es` }, myOptions); } -- 2.40.1