This commit is contained in:
parent
7643723f25
commit
aae556a180
@ -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 currentYear = today.getYear();
|
||||
|
||||
// 입사일부터 오늘까지의 전체 근속 개월 수 계산
|
||||
int workMonths = (int) ChronoUnit.MONTHS.between(hireDate, today);
|
||||
|
||||
// 올해 입사자 → 1년 미만: 입사월 이후로 계산
|
||||
// 입사년도와 현재년도가 같으면 : (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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user