public decimal calculateDailBasedSalaryWithLeaveRequest(List <Request> leaveRequests, decimal dailyBasedSalary) { return(salaryService.calculateDailBasedSalaryWithLeaveRequest(leaveRequests, dailyBasedSalary)); }
public Payslip createPayslip(DateTime startDatePeriod, DateTime endDatePeriod, Employee employee) { // attendanceLogSheet Payslip payslip = new Payslip(); payslip.employee = employee; payslip.startDatePeriod = startDatePeriod; payslip.endDatePeriod = endDatePeriod; List <Attendance> attendances = attendanceService.fetchEmployeeAttendance(startDatePeriod, endDatePeriod, employee); decimal monthlySalary = decimal.Multiply(employee.jobPosition.salary, AVERAGE_WORKING_DAY_PER_MONTH); decimal dailyBasedSalary = 0.00M; dailyBasedSalary = employee.jobPosition.salary; decimal periodSalary = decimal.Round(salaryService.calculatePeriodSalary(attendances, dailyBasedSalary), 2); AttendanceControllerInterface attendanceController = new AttendanceController(); TimeSpan timeSpent = fetchTotalHoursSpent(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, attendanceController); periodSalary = calculateTotalBasePay(timeSpent, payslip.employee.jobPosition.salary); payslip.basePay = periodSalary; decimal totalAllowanceAmount = 0.00M; MiscellaneousControllerInterface miscellaneousController = new MiscellaneousController(); decimal foodAllowanceAmount = fetchFoodAllowance(payslip, miscellaneousController); decimal totalFoodAllowanceAmount = calculateTotalSpecificAllowance(foodAllowanceAmount, timeSpent); totalAllowanceAmount += totalFoodAllowanceAmount; decimal transpoAllowanceAmount = fetchTranspoAllowance(payslip, miscellaneousController); decimal totalTranspoAllowanceAmount = calculateTotalSpecificAllowance(transpoAllowanceAmount, timeSpent); totalAllowanceAmount += totalTranspoAllowanceAmount; List <Request> overtimeRequests = requestService.fetchOvertimeRequests(employee, startDatePeriod, endDatePeriod); payslip.requests = overtimeRequests; List <Request> leaveRequests = requestService.fetchLeaveRequest(employee, startDatePeriod, endDatePeriod); payslip.requests.AddRange(leaveRequests); decimal totalLeaveAmount = decimal.Round(salaryService.calculateDailBasedSalaryWithLeaveRequest(leaveRequests, dailyBasedSalary), 2); List <Miscellaneous> benefits = miscellaneousService.fetchMiscellaneousByBenefitType(employee); payslip.miscellaneous = benefits; RequestControllerInterface requestController = new RequestController(); SalaryControllerInterface salaryController = new SalaryController(); decimal totalOvertimeAmount = calculateDailyBasedSalaryWithOvertimeRequests(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, requestController, salaryController); totalAllowanceAmount += totalOvertimeAmount; payslip.totalBenefits = totalAllowanceAmount + totalLeaveAmount; decimal cashAdvanceAmount = calculateTotalCashAdvanceAmount(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, requestController, salaryController); payslip.sssDeduction = decimal.Divide(salaryService.fetchSssDeductionsWithPeriodSalary(monthlySalary), 2); payslip.sssDeduction = decimal.Round(payslip.sssDeduction, 2); payslip.pagIbigDeduction = decimal.Divide(salaryService.fetchPagIbigDeductionWithPeriodSalary(monthlySalary), 2); payslip.pagIbigDeduction = decimal.Round(payslip.pagIbigDeduction, 2); payslip.philHealthDeduction = decimal.Divide(salaryService.fetchPhilHealthDeductionWithPeriodSalary(monthlySalary), 2); payslip.philHealthDeduction = decimal.Round(payslip.philHealthDeduction, 2); Miscellaneous thirteenMonth = miscellaneousService.calculateThirteenMonth(employee, endDatePeriod); payslip.taxDeduction = decimal.Divide(salaryService.calculatePeriodSalaryTax(employee, monthlySalary), 2); decimal totalDeductions = (decimal.Round(payslip.taxDeduction, 2) + decimal.Round(payslip.sssDeduction, 2) + decimal.Round(payslip.pagIbigDeduction, 2) + decimal.Round(payslip.philHealthDeduction, 2) + decimal.Round(cashAdvanceAmount, 2)); payslip.totalDeduction = totalDeductions; decimal totalSalary = payslip.basePay + payslip.totalBenefits - totalDeductions; payslip.netPay = totalSalary; return(payrollService.createPayslip(employee, payslip)); /* * List<Request> overtimeRequests = requestService.fetchOvertimeRequests(employee, startDatePeriod, endDatePeriod); * payslip.requests = overtimeRequests; * * periodSalary += decimal.Round(salaryService.calculateDailyBasedSalaryWithOvertimeRequests(overtimeRequests, dailyBasedSalary), 2); * Console.WriteLine("periodSalaryWithOvertime---->>" + periodSalary); * * List<Request> leaveRequests = requestService.fetchLeaveRequest(employee, startDatePeriod, endDatePeriod); * payslip.requests.AddRange(leaveRequests); * * periodSalary += decimal.Round(salaryService.calculateDailBasedSalaryWithLeaveRequest(leaveRequests, dailyBasedSalary), 2); * Console.WriteLine("periodSalaryWithLeave---->>" + periodSalary); * * List<Miscellaneous> benefits = miscellaneousService.fetchMiscellaneousByBenefitType(employee); * payslip.miscellaneous = benefits; * * periodSalary += decimal.Round(salaryService.fetchTotalAmountOfBenefits(benefits, attendances, leaveRequests), 2); * Console.WriteLine("periodSalaryWIthBenefits---->>" + periodSalary); * * //List<Miscellaneous> bonuses = miscellaneousService.fetchBonusMiscellaneousByDescriptionAsDate(employee, startDatePeriod, endDatePeriod); * //payslip.miscellaneous.AddRange(bonuses); * * //periodSalary += salaryService.fetchTotalBonus(bonuses); * //Console.WriteLine("periodSalaryWIthBonus---->>" + periodSalary); * * List<Request> cashAdvanceList = requestService.fetchAllApprovedCashAdvanceRequests(startDatePeriod, endDatePeriod, employee); * periodSalary -= decimal.Round(salaryService.fetchTotalCashAdvanceAmount(cashAdvanceList), 2); * Console.WriteLine("periodSalaryWIthCashAdvance---->>" + periodSalary); * * //List<Miscellaneous> deductions = miscellaneousService.fetchMiscellaneousByDeductionType(employee); * * //periodSalary -= decimal.Round(salaryService.fetchTotalDeductions(deductions), 2); * * payslip.sssDeduction = decimal.Divide(salaryService.fetchSssDeductionsWithPeriodSalary(monthlySalary), 2); * payslip.sssDeduction = decimal.Round(payslip.sssDeduction, 2); * * payslip.pagIbigDeduction = decimal.Divide(salaryService.fetchPagIbigDeductionWithPeriodSalary(monthlySalary), 2); * payslip.pagIbigDeduction = decimal.Round(payslip.pagIbigDeduction, 2); * * payslip.philHealthDeduction = decimal.Divide(salaryService.fetchPhilHealthDeductionWithPeriodSalary(monthlySalary), 2); * payslip.philHealthDeduction = decimal.Round(payslip.philHealthDeduction, 2); * * periodSalary -= payslip.sssDeduction; * periodSalary -= payslip.pagIbigDeduction; * periodSalary -= payslip.philHealthDeduction; * Console.WriteLine("periodSalaryWIthDeductions---->>" + periodSalary); * * payslip.taxDeduction = decimal.Divide(salaryService.calculatePeriodSalaryTax(employee, monthlySalary), 2); * periodSalary -= payslip.taxDeduction; * * payslip.netPay = decimal.Round(periodSalary, 2); * Console.WriteLine("periodSalaryWithholdingTax---->>" + periodSalary); */ }