fix: hotfix 7323 createAbsence #3265
|
@ -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`);
|
||||||
|
|
Loading…
Reference in New Issue