-
Notifications
You must be signed in to change notification settings - Fork 852
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: expire_allocation api endpoint by fetching allocation object (#1576
) * fix: expire_allocation api endpoint by fetching allocation object * fix: add a check to fetch allocation only if the allocation type is str in the expire_allocation endpoint * feat: add a test case test_expire_allocation for leave ledger entry doctype
- Loading branch information
1 parent
43f5f33
commit 6ddfdac
Showing
3 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 37 additions & 2 deletions
39
hrms/hr/doctype/leave_ledger_entry/test_leave_ledger_entry.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,44 @@ | ||
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors | ||
# See license.txt | ||
|
||
# import frappe | ||
import frappe | ||
from frappe.tests.utils import FrappeTestCase | ||
from frappe.utils.data import add_to_date, today | ||
|
||
from erpnext.setup.doctype.employee.test_employee import make_employee | ||
|
||
from hrms.hr.doctype.leave_ledger_entry.leave_ledger_entry import expire_allocation | ||
|
||
|
||
class TestLeaveLedgerEntry(FrappeTestCase): | ||
pass | ||
def setUp(self): | ||
emp_id = make_employee("test_leave_allocation@salary.com", company="_Test Company") | ||
self.employee = frappe.get_doc("Employee", emp_id) | ||
|
||
def test_expire_allocation(self): | ||
import json | ||
|
||
allocation = { | ||
"doctype": "Leave Allocation", | ||
"__islocal": 1, | ||
"employee": self.employee.name, | ||
"employee_name": self.employee.employee_name, | ||
"leave_type": "_Test Leave Type", | ||
"from_date": today(), | ||
"to_date": add_to_date(today(), days=30), | ||
"new_leaves_allocated": 5, | ||
"docstatus": 1, | ||
} | ||
|
||
allocation = frappe.get_doc(allocation).save() | ||
|
||
expire_allocation(json.dumps(allocation.as_dict())) | ||
allocation.reload() | ||
|
||
self.assertEqual(allocation.expired, 1) | ||
|
||
def tearDown(self): | ||
frappe.db.rollback() | ||
|
||
|
||
test_dependencies = ["Employee", "Leave Type"] |