연차 로직 변경
All checks were successful
LOCALNET-DEV/pipeline/head This commit looks good

This commit is contained in:
dyhj625 2025-07-14 13:57:07 +09:00
parent 7643723f25
commit aae556a180

View File

@ -288,36 +288,29 @@ public class localvacaService {
return emp;
}).collect(Collectors.toList());
}
/**
* 연차 계산 로직
*/
/**
* 연차 계산 로직
*/
public int procCalculateTotalVacation(LocalDate hireDate) {
LocalDate today = LocalDate.now();
int currentYear = today.getYear();
int hireYear = hireDate.getYear();
// 입사일부터 오늘까지의 전체 근속 개월 계산
int workMonths = (int) ChronoUnit.MONTHS.between(hireDate, today);
// 올해 입사자 1년 미만: 입사월 이후로 계산
int currentYear = today.getYear();
// 입사년도와 현재년도가 같으면 : (12 - 입사월)
if (hireYear == currentYear) {
return 12 - workMonths;
}else if(workMonths < 12) {
return 12;
return 12 - hireDate.getMonthValue();
}
// 기본 연차 15
int totalVacation = 15;
// 2년 경과 이후부터, 입사월이 도래했을 1개씩
LocalDate baseDate = hireDate.plusYears(2).withDayOfMonth(1);
// 입사년도 기준 3년차 1월부터, 2년마다 1개씩
LocalDate accrualDate = LocalDate.of(hireYear + 3, 1, 1);
while (!baseDate.isAfter(today)) {
// 입사월이 현재 달과 같거나 지났을 때만 연차 추가
if (baseDate.getYear() == today.getYear() && baseDate.getMonthValue() > today.getMonthValue()) {
break; // 아직 입사월이 도달하지 않았으면 종료
}
totalVacation += 1;
baseDate = baseDate.plusYears(2);
while (!accrualDate.isAfter(today)) {
totalVacation++;
accrualDate = accrualDate.plusYears(2);
}
return totalVacation;