From 9e141789ae63db93551796b94ce28e5c1e9ff55d Mon Sep 17 00:00:00 2001 From: dyhj625 Date: Fri, 28 Feb 2025 16:21:36 +0900 Subject: [PATCH] =?UTF-8?q?=EC=97=B0=EC=B0=A8=EA=B3=84=EC=82=B0=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../localhost/service/localvacaService.java | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main/java/io/company/localhost/service/localvacaService.java b/src/main/java/io/company/localhost/service/localvacaService.java index dc847d6..616f91e 100644 --- a/src/main/java/io/company/localhost/service/localvacaService.java +++ b/src/main/java/io/company/localhost/service/localvacaService.java @@ -218,39 +218,39 @@ public class localvacaService { return emp; }).collect(Collectors.toList()); } - - /** - * 총 연차 계산 로직 - */ + /** + * 총 연차 계산 로직 + */ public int procCalculateTotalVacation(LocalDate hireDate) { - LocalDate today = LocalDate.now(); //LocalDate.of(2027, 6, 15); + LocalDate today = LocalDate.now(); // 현재 날짜 int yearsWorked = hireDate.until(today).getYears(); - // 🔹 1년 미만: 연간 12개 지급 + int hireMonth = hireDate.getMonthValue(); + + // 🔹 1년 미만: 입사한 월을 고려하여 연차 개수 계산 if (yearsWorked < 1) { - return 12; + return 12 - hireMonth; + } else { + int totalVacation = 12 - hireMonth; // 1년 미만 사용하고 남은 연차 수 반영 + LocalDate nextIncreaseDate = hireDate.plusYears(1).withMonth(hireMonth).withDayOfMonth(1); + + // 🔹 매년 입사월에 15개 지급 + while (!nextIncreaseDate.isAfter(today)) { + totalVacation += 15; + nextIncreaseDate = nextIncreaseDate.plusYears(1); + } + + // 🔹 입사년도 2년마다 입사월에 15개에서 1개씩 추가 지급 + LocalDate additionalIncreaseDate = hireDate.plusYears(2).withMonth(hireMonth).withDayOfMonth(1); + int extraIncrease = 1; + while (!additionalIncreaseDate.isAfter(today)) { + totalVacation += extraIncrease; + additionalIncreaseDate = additionalIncreaseDate.plusYears(2); + extraIncrease++; // 2년마다 1개씩 증가 + } + + return totalVacation; } - - // 🔹 입사 1년 후부터 기본 15개 지급 - int totalVacation = 15; - LocalDate firstIncreaseDate = hireDate.plusYears(1).withMonth(1).withDayOfMonth(1); - - // 🔹 매년 1월 1일마다 15개씩 증가 - while (firstIncreaseDate.isBefore(today) || firstIncreaseDate.isEqual(today)) { - totalVacation += 15; - firstIncreaseDate = firstIncreaseDate.plusYears(1); - } - - // 🔹 입사월 기준으로 2년마다 1개 추가 증가 - LocalDate additionalIncreaseDate = hireDate.plusYears(2).withMonth(hireDate.getMonthValue()).withDayOfMonth(1); - while (additionalIncreaseDate.isBefore(today) || additionalIncreaseDate.isEqual(today)) { - totalVacation += 1; - additionalIncreaseDate = additionalIncreaseDate.plusYears(2); - } - - return totalVacation; } - - public List selectSentVacationCount(MapDto map) { return localvacaMapper.selectSentVacationCount(map);