From 4e6b83809b21ba4ab74fe448b4eb7a19998958c7 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 2 Dec 2024 10:29:12 +0100 Subject: [PATCH] fix: workerHoliday hr --- db/versions/11372-azureMedeola/00-firstScript.sql | 2 +- modules/worker/back/methods/worker/createAbsence.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/versions/11372-azureMedeola/00-firstScript.sql b/db/versions/11372-azureMedeola/00-firstScript.sql index b98701509..53295e9f8 100644 --- a/db/versions/11372-azureMedeola/00-firstScript.sql +++ b/db/versions/11372-azureMedeola/00-firstScript.sql @@ -1,2 +1,2 @@ INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('Worker','isHr','WRITE','ALLOW','ROLE','hr'); + VALUES ('Worker','canCreateAbsenceInPast','WRITE','ALLOW','ROLE','hr'); diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 264de4dd3..dad02d0dc 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -54,7 +54,7 @@ module.exports = Self => { try { const isSubordinate = await models.Worker.isSubordinate(ctx, id, myOptions); const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); - const isHr = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isHr', 'WRITE'); + const canCreateAbsenceInPast = await models.ACL.checkAccessAcl(ctx, 'Worker', 'canCreateAbsenceInPast', 'WRITE'); if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); @@ -116,7 +116,7 @@ module.exports = Self => { const newDate = new Date(ctx.args.dated).getTime(); const nowDate = now.getTime(); - if ((nowDate > newDate) && !isHr) + if ((nowDate > newDate) && !canCreateAbsenceInPast) throw new UserError(`Holidays to past days not available`); const absence = await models.Calendar.create({