test: creation of ledger entries on application submit
diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py
index d3dcca1..2581c2a 100644
--- a/erpnext/hr/doctype/leave_application/test_leave_application.py
+++ b/erpnext/hr/doctype/leave_application/test_leave_application.py
@@ -457,6 +457,28 @@
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 @@
"docstatus": 1
}).insert()
- allocate_leave.submit()
+ allocate_leave.submit()
\ No newline at end of file