Skip to content

Commit

Permalink
test: allocate leaves manually
Browse files Browse the repository at this point in the history
  • Loading branch information
krantheman committed Sep 25, 2024
1 parent 0b1e276 commit 6760943
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions hrms/hr/doctype/leave_allocation/test_earned_leaves.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from frappe.utils import (
add_days,
add_months,
date_diff,
flt,
get_first_day,
get_last_day,
get_year_ending,
Expand Down Expand Up @@ -477,6 +475,32 @@ def test_get_earned_leave_details_for_dashboard(self):
}
self.assertEqual(leave_allocation, expected)

def test_allocate_leaves_manually(self):
frappe.flags.current_date = get_year_start(getdate())
lpas = make_policy_assignment(
self.employee,
allocate_on_day="First Day",
start_date=frappe.flags.current_date,
)

leave_allocation = frappe.get_last_doc(
"Leave Allocation", filters={"leave_policy_assignment": lpas[0]}
)
leave_allocation.allocate_leaves_manually(1)
leave_allocation.allocate_leaves_manually(1)
leave_allocation.allocate_leaves_manually(1)
leave_allocation.allocate_leaves_manually(1)
leave_allocation.allocate_leaves_manually(1)
self.assertEqual(
get_leave_balance_on(self.employee.name, self.leave_type, frappe.flags.current_date), 6
)

leave_allocation.allocate_leaves_manually(6)
self.assertEqual(
get_leave_balance_on(self.employee.name, self.leave_type, frappe.flags.current_date), 12
)
self.assertRaises(frappe.ValidationError, leave_allocation.allocate_leaves_manually, 1)

def tearDown(self):
frappe.db.set_value("Employee", self.employee.name, "date_of_joining", self.original_doj)
frappe.db.set_value("Leave Type", self.leave_type, "max_leaves_allowed", 0)
Expand Down

0 comments on commit 6760943

Please sign in to comment.