fix: workerHoliday hr
gitea/salix/pipeline/pr-master This commit looks good Details

This commit is contained in:
Carlos Satorres 2024-12-02 10:29:12 +01:00
parent cf862202ff
commit 4e6b83809b
2 changed files with 3 additions and 3 deletions

View File

@ -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');

View File

@ -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({