fix: hotfix observationEmail #3396

Open
carlossa wants to merge 1 commits from hotfix-observationEmail into master
1 changed files with 6 additions and 2 deletions

View File

@ -35,7 +35,11 @@ module.exports = Self => {
Object.assign(myOptions, options); Object.assign(myOptions, options);
for (const defaulter of defaulters) { 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', { const body = $t('Added observation', {
user: user.name, user: user.name,
@ -47,7 +51,7 @@ module.exports = Self => {
await models.Mail.create({ await models.Mail.create({
subject: $t('Comment added to client', {clientFk: defaulter.clientFk}), subject: $t('Comment added to client', {clientFk: defaulter.clientFk}),
body: body, body: body,
receiver: `${defaulter.departmentEmail}`, receiver: `${email}`,
replyTo: `${user.name}@verdnatura.es` replyTo: `${user.name}@verdnatura.es`
}, myOptions); }, myOptions);
} }