Merge pull request 'fix: hotfix createAbsence' (!3308) from hotfix-6924createAbsence2 into master
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #3308
Reviewed-by: Jon Elias <jon@verdnatura.es>
This commit is contained in:
Carlos Satorres 2024-12-16 07:18:05 +00:00
commit 72f369dc49
1 changed files with 5 additions and 2 deletions

View File

@ -128,7 +128,10 @@ module.exports = Self => {
const account = await models.VnUser.findById(userId, null, myOptions);
const subordinated = await models.VnUser.findById(id, null, myOptions);
const worker = await models.Worker.findById(subordinated.id, null, myOptions);
const departmentBoss = await models.VnUser.findById(worker.bossFk, null, myOptions);
const receiver = await models.EmailUser.findOne({
fields: ['email'],
where: {userFk: worker.bossFk}
}, myOptions);
const url = await Self.app.models.Url.getUrl();
const body = $t('Created absence', {
author: account.nickname,
@ -140,7 +143,7 @@ module.exports = Self => {
await models.Mail.create({
subject: $t('Absence change notification on the labour calendar'),
body: body,
receiver: departmentBoss.email
receiver: receiver.email
}, myOptions);
if (tx) await tx.commit();