From ced30add3a23220cf101f4008456067066a9ab9c Mon Sep 17 00:00:00 2001 From: Asmita Hase <44727809+asmitahase@users.noreply.github.com> Date: Tue, 24 Dec 2024 18:15:25 +0530 Subject: [PATCH] Revert "fix: Exclude carry forwarded leaves from expired leaves" (cherry picked from commit 92dda68eaa2774abd5d15be18194a924bf1fd8f7) --- .../employee_leave_balance.py | 3 +- .../test_employee_leave_balance.py | 44 ------------------- 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/hrms/hr/report/employee_leave_balance/employee_leave_balance.py b/hrms/hr/report/employee_leave_balance/employee_leave_balance.py index 6c308b1d6a..d8289bd07e 100644 --- a/hrms/hr/report/employee_leave_balance/employee_leave_balance.py +++ b/hrms/hr/report/employee_leave_balance/employee_leave_balance.py @@ -207,8 +207,7 @@ def get_allocated_and_expired_leaves( carry_forwarded_leaves += record.leaves else: new_allocation += record.leaves - # carry forwarded leaves also get counted in expired, hence subtracting them - expired_leaves -= carry_forwarded_leaves + return new_allocation, expired_leaves, carry_forwarded_leaves diff --git a/hrms/hr/report/employee_leave_balance/test_employee_leave_balance.py b/hrms/hr/report/employee_leave_balance/test_employee_leave_balance.py index 5a8737a985..548742f308 100644 --- a/hrms/hr/report/employee_leave_balance/test_employee_leave_balance.py +++ b/hrms/hr/report/employee_leave_balance/test_employee_leave_balance.py @@ -241,47 +241,3 @@ def test_employee_status_filter(self): ) report = execute(filters) self.assertEqual(len(report[1]), 1) - - @set_holiday_list("_Test Emp Balance Holiday List", "_Test Company") - def test_closing_balance_considers_carry_forwarded_leaves(self): - leave_type = create_leave_type(leave_type_name="_Test_CF_leave_expiry", is_carry_forward=1) - # 30 leaves allocated for first half of the year - allocation1 = make_allocation_record( - employee=self.employee_id, - from_date=self.year_start, - to_date=self.mid_year, - leave_type=leave_type.name, - ) - # 4 days leave application in the first allocation - first_sunday = get_first_sunday(self.holiday_list, for_date=self.year_start) - leave_application = make_leave_application( - self.employee_id, first_sunday, add_days(first_sunday, 3), leave_type.name - ) - leave_application.reload() - # expires 26 leaves - process_expired_allocation() - # carry forward 26 expired leaves + allocate 4 new leaves - allocation2 = make_allocation_record( - employee=self.employee_id, - from_date=add_days(self.mid_year, 1), - to_date=self.year_end, - leaves=4, - carry_forward=True, - leave_type=leave_type.name, - ) - - filters = frappe._dict( - { - "from_date": self.year_start, - "to_date": self.year_end, - "employee": self.employee_id, - } - ) - report = execute(filters) - - closing_balance = ( - allocation1.new_leaves_allocated - - leave_application.total_leave_days - + allocation2.new_leaves_allocated - ) - self.assertEqual(report[1][0].closing_balance, closing_balance)