Skip to content

Commit

Permalink
Merge pull request #1937 from krantheman/fix-salary-slip-lwp
Browse files Browse the repository at this point in the history
fix(Salary Slip): fetching of lwp/ppl leave applications
  • Loading branch information
krantheman committed Jul 3, 2024
2 parents f08a689 + f7007ac commit 8d8ce3e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hrms/payroll/doctype/salary_slip/salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -2173,7 +2173,7 @@ def get_lwp_or_ppl_for_date_range(employee, start_date, end_date):
& (LeaveApplication.status == "Approved")
& (LeaveApplication.employee == employee)
& ((LeaveApplication.salary_slip.isnull()) | (LeaveApplication.salary_slip == ""))
& ((LeaveApplication.from_date >= start_date) & (LeaveApplication.to_date <= end_date))
& ((LeaveApplication.from_date <= end_date) & (LeaveApplication.to_date >= start_date))
)
).run(as_dict=True)

Expand Down
15 changes: 15 additions & 0 deletions hrms/payroll/doctype/salary_slip/test_salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,21 @@ def test_payment_days_based_on_leave_application(self):

self.assertEqual(ss.payment_days, days_in_month - no_of_holidays - 3.75)

@change_settings("Payroll Settings", {"payroll_based_on": "Leave"})
def test_payment_days_calculation_for_varying_leave_ranges(self):
emp_id = make_employee("[email protected]")

make_leave_application(emp_id, "2024-06-28", "2024-07-03", "Leave Without Pay") # 3 days in July
make_leave_application(emp_id, "2024-07-10", "2024-07-13", "Leave Without Pay") # 4 days in July
make_leave_application(emp_id, "2024-07-28", "2024-08-05", "Leave Without Pay") # 3 days in July

ss = make_employee_salary_slip(
emp_id, "Monthly", "Test Payment Based On Leave Application", "2024-07-01"
)

self.assertEqual(ss.leave_without_pay, 10)
self.assertEqual(ss.payment_days, 17)

@change_settings("Payroll Settings", {"payroll_based_on": "Attendance"})
def test_payment_days_in_salary_slip_based_on_timesheet(self):
from erpnext.projects.doctype.timesheet.test_timesheet import make_timesheet
Expand Down

0 comments on commit 8d8ce3e

Please sign in to comment.