fix: hotfix 7323 createAbsence #3265

Merged
carlossa merged 5 commits from hotfix-7323workerHoliday into master 2024-12-09 12:28:53 +00:00
1 changed files with 2 additions and 2 deletions
Showing only changes of commit fb40e25c7c - Show all commits

View File

@ -54,11 +54,11 @@ module.exports = Self => {
try { try {
const isSubordinate = await models.Worker.isSubordinate(ctx, id, myOptions); const isSubordinate = await models.Worker.isSubordinate(ctx, id, myOptions);
const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE');
const canCreateAbsenceInPast = await models.ACL.checkAccessAcl(ctx, 'Worker', 'canCreateAbsenceInPast', 'WRITE');
if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss))
throw new UserError(`You don't have enough privileges`); throw new UserError(`You don't have enough privileges`);
const canCreateAbsenceInPast = await models.ACL.checkAccessAcl(ctx, 'Worker', 'canCreateAbsenceInPast', 'WRITE');
const labour = await models.WorkerLabour.findById(args.businessFk, { const labour = await models.WorkerLabour.findById(args.businessFk, {
include: {relation: 'department'} include: {relation: 'department'}
}, myOptions); }, myOptions);
@ -114,7 +114,7 @@ module.exports = Self => {
if ((holiday && isFestive) && (workCenter.workcenterFk === holiday.workCenterFk)) if ((holiday && isFestive) && (workCenter.workcenterFk === holiday.workCenterFk))
throw new UserError(`Cannot add holidays on this day`); throw new UserError(`Cannot add holidays on this day`);
const newDate = new Date(ctx.args.dated).getTime(); const newDate = new Date(args.dated).getTime();
const nowDate = now.getTime(); const nowDate = now.getTime();
if ((nowDate > newDate) && !canCreateAbsenceInPast) if ((nowDate > newDate) && !canCreateAbsenceInPast)
throw new UserError(`Holidays to past days not available`); throw new UserError(`Holidays to past days not available`);