refactor: refs #7690 unify workerTimeControlParams with workerTimeControlConfig #3191
|
@ -6,10 +6,18 @@ INSERT INTO salix.ACL (model,property,accessType,permission,principalType,princi
|
||||||
('WorkerRelative','updateAttributes','*','ALLOW','ROLE','hr'),
|
('WorkerRelative','updateAttributes','*','ALLOW','ROLE','hr'),
|
||||||
('WorkerRelative','crud','WRITE','ALLOW','ROLE','hr'),
|
('WorkerRelative','crud','WRITE','ALLOW','ROLE','hr'),
|
||||||
('WorkerRelative','findById','*','ALLOW','ROLE','hr'),
|
('WorkerRelative','findById','*','ALLOW','ROLE','hr'),
|
||||||
|
('WorkerRelative','find','*','ALLOW','ROLE','hr'),
|
||||||
|
('WorkerRelative','upsert','*','ALLOW','ROLE','hr'),
|
||||||
|
('WorkerRelative','filter','*','ALLOW','ROLE','hr'),
|
||||||
('WorkerIrpf','updateAttributes','*','ALLOW','ROLE','hr'),
|
('WorkerIrpf','updateAttributes','*','ALLOW','ROLE','hr'),
|
||||||
('WorkerIrpf','crud','*','ALLOW','ROLE','hr'),
|
('WorkerIrpf','crud','*','ALLOW','ROLE','hr'),
|
||||||
('WorkerRelative','findById','*','ALLOW','ROLE','hr'),
|
('WorkerIrpf','findById','*','ALLOW','ROLE','hr'),
|
||||||
|
('WorkerIrpf','find','*','ALLOW','ROLE','hr'),
|
||||||
|
('WorkerIrpf','upsert','*','ALLOW','ROLE','hr'),
|
||||||
|
('WorkerIrpf','filter','*','ALLOW','ROLE','hr'),
|
||||||
('DisabilityGrade','updateAttributes','*','ALLOW','ROLE','hr'),
|
('DisabilityGrade','updateAttributes','*','ALLOW','ROLE','hr'),
|
||||||
('DisabilityGrade','crud','*','ALLOW','ROLE','hr'),
|
('DisabilityGrade','crud','*','ALLOW','ROLE','hr'),
|
||||||
('DisabilityGrade','findById','*','ALLOW','ROLE','hr');
|
('DisabilityGrade','findById','*','ALLOW','ROLE','hr'),
|
||||||
|
('DisabilityGrade','find','*','ALLOW','ROLE','hr'),
|
||||||
|
('DisabilityGrade','upsert','*','ALLOW','ROLE','hr');
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,8 @@ module.exports = Self => {
|
||||||
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 labour = await models.WorkerLabour.findById(args.businessFk, {
|
const labour = await models.WorkerLabour.findById(args.businessFk,
|
||||||
include: {relation: 'department'}
|
{fields: ['started', 'ended', 'businessFk']}, myOptions);
|
||||||
}, myOptions);
|
|
||||||
|
|
||||||
if (args.dated < labour.started || (labour.ended != null && args.dated > labour.ended))
|
if (args.dated < labour.started || (labour.ended != null && args.dated > labour.ended))
|
||||||
throw new UserError(`The contract was not active during the selected date`);
|
throw new UserError(`The contract was not active during the selected date`);
|
||||||
|
@ -87,7 +86,8 @@ module.exports = Self => {
|
||||||
`SELECT COUNT(*) halfHolidayCounter
|
`SELECT COUNT(*) halfHolidayCounter
|
||||||
FROM vn.calendar c
|
FROM vn.calendar c
|
||||||
JOIN vn.business b ON b.id = c.businessFk
|
JOIN vn.business b ON b.id = c.businessFk
|
||||||
WHERE c.dayOffTypeFk = 6
|
JOIN vn.absenceType at ON at.id = c.dayOffTypeFk
|
||||||
|
WHERE at.code = 'halfHoliday'
|
||||||
AND b.workerFk = ?
|
AND b.workerFk = ?
|
||||||
AND c.dated BETWEEN util.firstDayOfYear(?)
|
AND c.dated BETWEEN util.firstDayOfYear(?)
|
||||||
AND LAST_DAY(DATE_ADD(?, INTERVAL 12 - MONTH(?) MONTH))`, [id, date, now, now]);
|
AND LAST_DAY(DATE_ADD(?, INTERVAL 12 - MONTH(?) MONTH))`, [id, date, now, now]);
|
||||||
|
@ -119,11 +119,10 @@ module.exports = Self => {
|
||||||
dated: args.dated
|
dated: args.dated
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
const department = labour.department();
|
|
||||||
if (department && department.notificationEmail) {
|
|
||||||
const absenceType = await models.AbsenceType.findById(args.absenceTypeId, null, myOptions);
|
|
||||||
const account = await models.VnUser.findById(userId, null, myOptions);
|
const account = await models.VnUser.findById(userId, null, myOptions);
|
||||||
const subordinated = await models.VnUser.findById(id, null, myOptions);
|
const subordinated = await models.VnUser.findById(id, null, myOptions);
|
||||||
|
const worker = await models.Worker.findById(subordinated.id, null, myOptions);
|
||||||
|
const departmentBoss = await models.VnUser.findById(worker.bossFk, null, myOptions);
|
||||||
const url = await Self.app.models.Url.getUrl();
|
const url = await Self.app.models.Url.getUrl();
|
||||||
const body = $t('Created absence', {
|
const body = $t('Created absence', {
|
||||||
author: account.nickname,
|
author: account.nickname,
|
||||||
|
@ -135,9 +134,8 @@ module.exports = Self => {
|
||||||
await models.Mail.create({
|
await models.Mail.create({
|
||||||
subject: $t('Absence change notification on the labour calendar'),
|
subject: $t('Absence change notification on the labour calendar'),
|
||||||
body: body,
|
body: body,
|
||||||
receiver: department.notificationEmail
|
receiver: departmentBoss.email
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
}
|
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue