From 0709a64dca0f4570a61ea336359ac83e0fa92caa Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 8 May 2024 12:05:47 +0200 Subject: [PATCH] refs #6882 fix back --- e2e/paths/03-worker/05_calendar.spec.js | 4 ++-- modules/worker/back/methods/worker/createAbsence.js | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/e2e/paths/03-worker/05_calendar.spec.js b/e2e/paths/03-worker/05_calendar.spec.js index d4f9be28b..f0af0a053 100644 --- a/e2e/paths/03-worker/05_calendar.spec.js +++ b/e2e/paths/03-worker/05_calendar.spec.js @@ -27,7 +27,7 @@ describe('Worker calendar path', () => { }); describe('as hr', () => { - it('should set two days as holidays on the calendar and check the total holidays increased by 1', async() => { + it('should set two days as holidays on the calendar and check the total holidays increased by 1.5', async() => { await page.waitToClick(selectors.workerCalendar.holidays); await page.waitForTimeout(reasonableTimeBetweenClicks); await page.click(selectors.workerCalendar.penultimateMondayOfJanuary); @@ -56,7 +56,7 @@ describe('Worker calendar path', () => { await page.waitForTimeout(reasonableTimeBetweenClicks); await page.click(selectors.workerCalendar.secondFridayOfJun); - expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 1 '); + expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 1.5 '); }); }); diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index f62c66c8b..75888dae9 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -95,6 +95,9 @@ module.exports = Self => { const hasHalfHoliday = result.halfHolidayCounter > 0; const isHalfHoliday = absenceType.code === 'halfHoliday'; + if (isHalfHoliday && hasHalfHoliday) + throw new UserError(`Cannot add more than one '1/2 day vacation`); + const isFestive = absenceType.isFestiveEligible; const workCenter = await models.Business.findOne({ @@ -106,13 +109,11 @@ module.exports = Self => { dated: args.dated, workCenterFk: workCenter.workCenterFk } - },); + }); + if (holiday && isFestive) throw new UserError(`Cannot add holidays on this day`); - if (isHalfHoliday && (hasHalfHoliday || isFestive)) - throw new UserError(`Cannot add more than one '1/2 day vacation`); - const absence = await models.Calendar.create({ businessFk: labour.businessFk, dayOffTypeFk: args.absenceTypeId,