diff --git a/src/main/kotlin/com/moa/service/WorkdayService.kt b/src/main/kotlin/com/moa/service/WorkdayService.kt index a5fb71c..3697276 100644 --- a/src/main/kotlin/com/moa/service/WorkdayService.kt +++ b/src/main/kotlin/com/moa/service/WorkdayService.kt @@ -166,8 +166,7 @@ class WorkdayService( DailyWorkScheduleType.VACATION -> { val policy = resolveMonthlyRepresentativePolicyOrNull(memberId, date.year, date.monthValue) ?: throw NotFoundException() - validateVacationInput(date, existingSchedule, policy) - resolveVacationTimes(req, policy) + resolveVacationTimes(date, req, existingSchedule, policy) } DailyWorkScheduleType.NONE -> null to null @@ -313,25 +312,10 @@ class WorkdayService( } } - private fun validateVacationInput( - date: LocalDate, - savedSchedule: DailyWorkSchedule?, - policy: WorkPolicyVersion, - ) { - if (savedSchedule?.type == DailyWorkScheduleType.VACATION) return - - val schedule = resolveSchedule(savedSchedule, policy, date) - val isDefaultWorkSchedule = schedule.type == DailyWorkScheduleType.WORK && - schedule.clockIn == policy.clockInTime && - schedule.clockOut == policy.clockOutTime - - if (!isDefaultWorkSchedule) { - throw BadRequestException(ErrorCode.INVALID_WORKDAY_INPUT) - } - } - private fun resolveVacationTimes( + date: LocalDate, req: WorkdayUpsertRequest, + savedSchedule: DailyWorkSchedule?, policy: WorkPolicyVersion, ): Pair { if (req.clockInTime != null && req.clockOutTime != null) { @@ -340,6 +324,11 @@ class WorkdayService( return clockIn to clockOut } + val schedule = resolveSchedule(savedSchedule, policy, date) + if (schedule.clockIn != null && schedule.clockOut != null) { + return schedule.clockIn to schedule.clockOut + } + return policy.clockInTime to policy.clockOutTime }