연차계산 로직 수정
This commit is contained in:
parent
df70d798d3
commit
9e141789ae
@ -218,39 +218,39 @@ public class localvacaService {
|
|||||||
return emp;
|
return emp;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 총 연차 계산 로직
|
* 총 연차 계산 로직
|
||||||
*/
|
*/
|
||||||
public int procCalculateTotalVacation(LocalDate hireDate) {
|
public int procCalculateTotalVacation(LocalDate hireDate) {
|
||||||
LocalDate today = LocalDate.now(); //LocalDate.of(2027, 6, 15);
|
LocalDate today = LocalDate.now(); // 현재 날짜
|
||||||
int yearsWorked = hireDate.until(today).getYears();
|
int yearsWorked = hireDate.until(today).getYears();
|
||||||
// 🔹 1년 미만: 연간 12개 지급
|
int hireMonth = hireDate.getMonthValue();
|
||||||
|
|
||||||
|
// 🔹 1년 미만: 입사한 월을 고려하여 연차 개수 계산
|
||||||
if (yearsWorked < 1) {
|
if (yearsWorked < 1) {
|
||||||
return 12;
|
return 12 - hireMonth;
|
||||||
}
|
} else {
|
||||||
|
int totalVacation = 12 - hireMonth; // 1년 미만 사용하고 남은 연차 수 반영
|
||||||
|
LocalDate nextIncreaseDate = hireDate.plusYears(1).withMonth(hireMonth).withDayOfMonth(1);
|
||||||
|
|
||||||
// 🔹 입사 1년 후부터 기본 15개 지급
|
// 🔹 매년 입사월에 15개 지급
|
||||||
int totalVacation = 15;
|
while (!nextIncreaseDate.isAfter(today)) {
|
||||||
LocalDate firstIncreaseDate = hireDate.plusYears(1).withMonth(1).withDayOfMonth(1);
|
|
||||||
|
|
||||||
// 🔹 매년 1월 1일마다 15개씩 증가
|
|
||||||
while (firstIncreaseDate.isBefore(today) || firstIncreaseDate.isEqual(today)) {
|
|
||||||
totalVacation += 15;
|
totalVacation += 15;
|
||||||
firstIncreaseDate = firstIncreaseDate.plusYears(1);
|
nextIncreaseDate = nextIncreaseDate.plusYears(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 🔹 입사월 기준으로 2년마다 1개 추가 증가
|
// 🔹 입사년도 2년마다 입사월에 15개에서 1개씩 추가 지급
|
||||||
LocalDate additionalIncreaseDate = hireDate.plusYears(2).withMonth(hireDate.getMonthValue()).withDayOfMonth(1);
|
LocalDate additionalIncreaseDate = hireDate.plusYears(2).withMonth(hireMonth).withDayOfMonth(1);
|
||||||
while (additionalIncreaseDate.isBefore(today) || additionalIncreaseDate.isEqual(today)) {
|
int extraIncrease = 1;
|
||||||
totalVacation += 1;
|
while (!additionalIncreaseDate.isAfter(today)) {
|
||||||
|
totalVacation += extraIncrease;
|
||||||
additionalIncreaseDate = additionalIncreaseDate.plusYears(2);
|
additionalIncreaseDate = additionalIncreaseDate.plusYears(2);
|
||||||
|
extraIncrease++; // 2년마다 1개씩 증가
|
||||||
}
|
}
|
||||||
|
|
||||||
return totalVacation;
|
return totalVacation;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<MapDto> selectSentVacationCount(MapDto map) {
|
public List<MapDto> selectSentVacationCount(MapDto map) {
|
||||||
return localvacaMapper.selectSentVacationCount(map);
|
return localvacaMapper.selectSentVacationCount(map);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user