연차계산 로직 수정
This commit is contained in:
parent
df70d798d3
commit
9e141789ae
@ -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);
|
||||
|
||||
// 🔹 입사 1년 후부터 기본 15개 지급
|
||||
int totalVacation = 15;
|
||||
LocalDate firstIncreaseDate = hireDate.plusYears(1).withMonth(1).withDayOfMonth(1);
|
||||
|
||||
// 🔹 매년 1월 1일마다 15개씩 증가
|
||||
while (firstIncreaseDate.isBefore(today) || firstIncreaseDate.isEqual(today)) {
|
||||
// 🔹 매년 입사월에 15개 지급
|
||||
while (!nextIncreaseDate.isAfter(today)) {
|
||||
totalVacation += 15;
|
||||
firstIncreaseDate = firstIncreaseDate.plusYears(1);
|
||||
nextIncreaseDate = nextIncreaseDate.plusYears(1);
|
||||
}
|
||||
|
||||
// 🔹 입사월 기준으로 2년마다 1개 추가 증가
|
||||
LocalDate additionalIncreaseDate = hireDate.plusYears(2).withMonth(hireDate.getMonthValue()).withDayOfMonth(1);
|
||||
while (additionalIncreaseDate.isBefore(today) || additionalIncreaseDate.isEqual(today)) {
|
||||
totalVacation += 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public List<MapDto> selectSentVacationCount(MapDto map) {
|
||||
return localvacaMapper.selectSentVacationCount(map);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user