test: creation of ledger entries on application submit

This commit is contained in:
Mangesh-Khairnar 2019-05-13 19:19:39 +05:30
parent 201aeeb20d
commit 964deaca96

View File

@ -457,6 +457,28 @@ class TestLeaveApplication(unittest.TestCase):
leave_application.submit()
self.assertEqual(leave_application.docstatus, 1)
def test_creation_of_leave_ledger_entry_on_submit(self):
leave_application = frappe.get_doc(dict(
doctype = 'Leave Application',
employee = employee.name,
leave_type = leave_type_1.name,
from_date = nowdate(),
to_date = add_days(nowdate(), 4),
company = "_Test Company",
docstatus = 1,
status = "Approved"
)).submit()
leave_ledger_entry = frappe.get_all('Leave Ledger Entry', fields='*', filters=dict(transaction_name=leave_application.name))
self.assertEquals(leave_ledger_entry[0].employee, leave_application.employee)
self.assertEquals(leave_ledger_entry[0].leave_type, leave_application.leave_type)
self.assertEquals(leave_ledger_entry[0].leaves, leave_application.new_leaves_allocated)
# check if leave ledger entry is deleted on cancellation
leave_application.cancel()
self.assertFalse(frappe.db.exists("Leave Ledger Entry", {'transaction_name':leave_application.name}))
def make_allocation_record(employee=None, leave_type=None):
frappe.db.sql("delete from `tabLeave Allocation`")
@ -513,4 +535,4 @@ def allocate_leaves(employee, leave_period, leave_type, new_leaves_allocated, el
"docstatus": 1
}).insert()
allocate_leave.submit()
allocate_leave.submit()