본문 바로가기
ERP Project

인사팀 기능구현(2)

by kwh_coding 2023. 9. 20.

다음은 추가근무에 대한 급여 정산 기능이다.

 

추가근무는 일반적으로 09:00 ~ 17:00 일 8시간 근무로 생각했을 때 그 외에 시간에 해당한다면 추가근무 등록을 할 수 있도록 하는 기능이다. 

		int month = b6.selectMonth(salary_date);
        
		int employee2_salary = b6.selectSalary(employee2_no);
		
		int year = b6.selectYear(salary_date);
		
		int totalDays = YearMonth.of(year, month).lengthOfMonth();
		
		int weekdays = 0;
		
	       for (int day = 1; day <= totalDays; day++) {
	           LocalDate date = LocalDate.of(year, month, day);
	           if (date.getDayOfWeek() != DayOfWeek.SATURDAY && date.getDayOfWeek() != DayOfWeek.SUNDAY) {
	               weekdays++;
	           }
	       }

뷰페이지에서 받아온 파라미터 값들을 통해 

 

특정 월(month) 내에서 평일(월요일부터 금요일까지)의 수를 계산하는 부분이다.

totalDays 변수에 저장된 특정 월의 총 일수를 기준으로 각 날짜가 평일인지 여부를 확인하고, 평일의 수를 세는 역할을 한다.

 

후에

 	String[] startTokens = salary_start.split(":");
        String[] endTokens = salary_end.split(":");
        
	int startHours = Integer.parseInt(startTokens[0]);
        int startMinutes = Integer.parseInt(startTokens[1]);
        int endHours = Integer.parseInt(endTokens[0]);
        int endMinutes = Integer.parseInt(endTokens[1]);

        int totalStartMinutes = startHours * 60 + startMinutes;
        int totalEndMinutes = endHours * 60 + endMinutes;

        int minutesDifference = totalEndMinutes - totalStartMinutes;
        double hoursDifference = (double) minutesDifference / 60;
        
        double salary_cash = (employee2_salary / 12.0 / weekdays / 8 * hoursDifference) * salarytype_magnification;

를 통해 시작 시간과 종료 시간을 시간과 분으로 분리한다. 이때,

  • totalStartMinutes 및 totalEndMinutes는 시작 시간과 종료 시간을 분 단위로 변환한 값이다.
  • minutesDifference는 근무 시작 시간과 종료 시간의 차이를 분으로 나타낸다

그리고

  • employee2_salary: 직원의 연봉
  • weekdays: 근무 가능한 평일 수
  • 8: 하루의 근무 시간(8시간)
  • salarytype_magnification: 급여 계수(급여 계산에 영향을 미치는 계수

 

이렇게 계산된 salary_cash는 해당 기간동안의 급여가 저장된다.

 

 

 

 

'ERP Project' 카테고리의 다른 글

재무팀 기능구현(2)  (0) 2023.10.10
재무팀 기능구현(1)  (0) 2023.09.20
인사팀 기능구현(1)  (0) 2023.09.20
역할 분담  (0) 2023.09.20
뷰페이지 구성 에러 해결(2)  (0) 2023.07.28