feat(worker_calendar): only can choose one halfHoliday by year
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2021-11-17 14:20:26 +01:00
parent 180fb95a00
commit 651a925708
1 changed files with 7 additions and 1 deletions

View File

@ -68,7 +68,13 @@ module.exports = Self => {
const result = await Self.rawSql(
`SELECT COUNT(*) halfHolidayCounter
FROM vn.calendar c
WHERE c.dayOffTypeFk = 6 AND c.businessFk = ?`, [args.businessFk]);
JOIN postgresql.business b ON b.business_id = c.businessFk
JOIN postgresql.profile p ON p.profile_id = b.client_id
JOIN vn.person pe ON pe.id = p.person_id
WHERE c.dayOffTypeFk = 6
AND pe.workerFk = ?
AND c.dated BETWEEN util.firstDayOfYear(CURDATE())
AND LAST_DAY(DATE_ADD(NOW(), INTERVAL 12-MONTH(NOW()) MONTH))`, [args.id]);
const hasHalfHoliday = result[0].halfHolidayCounter > 0;
const isHalfHoliday = args.absenceTypeId == 6;