fix: prevent deleting absences for past dates #3346
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Worker','canDeleteAbsenceInPast','WRITE','ALLOW','ROLE','hr');
|
|
@ -53,6 +53,12 @@ module.exports = Self => {
|
|||
}
|
||||
}
|
||||
}, myOptions);
|
||||
const canDeleteAbsenceInPast =
|
||||
await models.ACL.checkAccessAcl(ctx, 'Worker', 'canDeleteAbsenceInPast', 'WRITE');
|
||||
jorgep marked this conversation as resolved
Outdated
|
||||
|
||||
if (!canDeleteAbsenceInPast && Date.vnNow() > absence.dated.getTime())
|
||||
throw new UserError(`Holidays to past days not available`);
|
||||
|
||||
const result = await absence.destroy(myOptions);
|
||||
const labour = absence.labour();
|
||||
const department = labour && labour.department();
|
||||
|
|
Loading…
Reference in New Issue
En create ya esta codigo parecido
b14268ef1b/modules/worker/back/methods/worker/createAbsence.js (L63)
Ver si unificar