From ea4adbea85fb21feea9745cc71234987dca85e15 Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 13 Nov 2024 08:45:44 +0100 Subject: [PATCH] refactor: refs #6924 deleted department check --- .../back/methods/worker/createAbsence.js | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index c7f968edb..036e2bef7 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -120,27 +120,23 @@ module.exports = Self => { dated: args.dated }, myOptions); - const department = labour.department(); - if (department) { - const absenceType = await models.AbsenceType.findById(args.absenceTypeId, null, myOptions); - 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 boss = await models.VnUser.findById(worker.bossFk, null, myOptions); - const url = await Self.app.models.Url.getUrl(); - const body = $t('Created absence', { - author: account.nickname, - employee: subordinated.nickname, - absenceType: absenceType.name, - dated: formatDate(args.dated), - workerUrl: `${url}worker/${id}/calendar` - }); - await models.Mail.create({ - subject: $t('Absence change notification on the labour calendar'), - body: body, - receiver: boss.email - }, myOptions); - } + 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 url = await Self.app.models.Url.getUrl(); + const body = $t('Created absence', { + author: account.nickname, + employee: subordinated.nickname, + absenceType: absenceType.name, + dated: formatDate(args.dated), + workerUrl: `${url}worker/${id}/calendar` + }); + await models.Mail.create({ + subject: $t('Absence change notification on the labour calendar'), + body: body, + receiver: departmentBoss.email + }, myOptions); if (tx) await tx.commit();