This commit is contained in:
parent
71fa90d378
commit
7eaa24e4fc
@ -292,34 +292,31 @@ public class localvacaService {
|
||||
* 총 연차 계산 로직
|
||||
*/
|
||||
public int procCalculateTotalVacation(LocalDate hireDate) {
|
||||
LocalDate today = LocalDate.now(); // 현재 날짜
|
||||
int yearsWorked = hireDate.until(today).getYears();
|
||||
LocalDate today = LocalDate.now();
|
||||
int currentYear = today.getYear();
|
||||
int hireYear = hireDate.getYear();
|
||||
int hireMonth = hireDate.getMonthValue();
|
||||
|
||||
// 🔹 1년 미만: 입사한 월을 고려하여 연차 개수 계산
|
||||
if (yearsWorked < 1) {
|
||||
// 올해 입사자 → 1년 미만: 입사월 이후로 계산
|
||||
if (hireYear == currentYear) {
|
||||
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;
|
||||
}
|
||||
|
||||
int totalVacation = 15;
|
||||
|
||||
// 2년 경과 이후부터, 입사월이 도래했을 때 1개씩 추가
|
||||
LocalDate baseDate = hireDate.plusYears(2).withDayOfMonth(1);
|
||||
|
||||
while (!baseDate.isAfter(today)) {
|
||||
// 입사월이 현재 달과 같거나 지났을 때만 연차 추가
|
||||
if (baseDate.getYear() == today.getYear() && baseDate.getMonthValue() > today.getMonthValue()) {
|
||||
break; // 아직 입사월이 도달하지 않았으면 종료
|
||||
}
|
||||
totalVacation += 1;
|
||||
baseDate = baseDate.plusYears(2);
|
||||
}
|
||||
|
||||
return totalVacation;
|
||||
}
|
||||
|
||||
public List<MapDto> selectSentVacationCount(MapDto map) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user