diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 217191a30..ba13a8a10 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -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;