fix: add mandatory reason fields in leave application
This commit is contained in:
parent
95e5d812fe
commit
c5385e141b
@ -19,6 +19,7 @@ _test_records = [
|
|||||||
"doctype": "Leave Application",
|
"doctype": "Leave Application",
|
||||||
"employee": "_T-Employee-00001",
|
"employee": "_T-Employee-00001",
|
||||||
"from_date": "2013-05-01",
|
"from_date": "2013-05-01",
|
||||||
|
"description": "_Test Reason",
|
||||||
"leave_type": "_Test Leave Type",
|
"leave_type": "_Test Leave Type",
|
||||||
"posting_date": "2013-01-02",
|
"posting_date": "2013-01-02",
|
||||||
"to_date": "2013-05-05"
|
"to_date": "2013-05-05"
|
||||||
@ -28,6 +29,7 @@ _test_records = [
|
|||||||
"doctype": "Leave Application",
|
"doctype": "Leave Application",
|
||||||
"employee": "_T-Employee-00002",
|
"employee": "_T-Employee-00002",
|
||||||
"from_date": "2013-05-01",
|
"from_date": "2013-05-01",
|
||||||
|
"description": "_Test Reason",
|
||||||
"leave_type": "_Test Leave Type",
|
"leave_type": "_Test Leave Type",
|
||||||
"posting_date": "2013-01-02",
|
"posting_date": "2013-01-02",
|
||||||
"to_date": "2013-05-05"
|
"to_date": "2013-05-05"
|
||||||
@ -37,6 +39,7 @@ _test_records = [
|
|||||||
"doctype": "Leave Application",
|
"doctype": "Leave Application",
|
||||||
"employee": "_T-Employee-00001",
|
"employee": "_T-Employee-00001",
|
||||||
"from_date": "2013-01-15",
|
"from_date": "2013-01-15",
|
||||||
|
"description": "_Test Reason",
|
||||||
"leave_type": "_Test Leave Type LWP",
|
"leave_type": "_Test Leave Type LWP",
|
||||||
"posting_date": "2013-01-02",
|
"posting_date": "2013-01-02",
|
||||||
"to_date": "2013-01-15"
|
"to_date": "2013-01-15"
|
||||||
@ -46,8 +49,8 @@ _test_records = [
|
|||||||
|
|
||||||
class TestLeaveApplication(unittest.TestCase):
|
class TestLeaveApplication(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
for dt in ["Leave Application", "Leave Allocation", "Salary Slip"]:
|
for dt in ["Leave Application", "Leave Allocation", "Salary Slip", "Leave Ledger Entry"]:
|
||||||
frappe.db.sql("delete from `tab%s`" % dt)
|
frappe.db.sql("DELETE FROM `tab%s`" % dt)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
@ -270,6 +273,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
doctype = 'Leave Application',
|
doctype = 'Leave Application',
|
||||||
employee = employee.name,
|
employee = employee.name,
|
||||||
company = '_Test Company',
|
company = '_Test Company',
|
||||||
|
description = "_Test Reason",
|
||||||
leave_type = leave_type,
|
leave_type = leave_type,
|
||||||
from_date = date,
|
from_date = date,
|
||||||
to_date = date,
|
to_date = date,
|
||||||
@ -288,8 +292,6 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
self.assertEqual(get_leave_balance_on(employee.name, leave_type, today), 9)
|
self.assertEqual(get_leave_balance_on(employee.name, leave_type, today), 9)
|
||||||
|
|
||||||
def test_leaves_allowed(self):
|
def test_leaves_allowed(self):
|
||||||
frappe.db.sql("delete from `tabLeave Allocation`")
|
|
||||||
frappe.db.sql("delete from `tabLeave Ledger Entry`")
|
|
||||||
employee = get_employee()
|
employee = get_employee()
|
||||||
leave_period = get_leave_period()
|
leave_period = get_leave_period()
|
||||||
frappe.delete_doc_if_exists("Leave Type", "Test Leave Type", force=1)
|
frappe.delete_doc_if_exists("Leave Type", "Test Leave Type", force=1)
|
||||||
@ -307,6 +309,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
doctype = 'Leave Application',
|
doctype = 'Leave Application',
|
||||||
employee = employee.name,
|
employee = employee.name,
|
||||||
leave_type = leave_type.name,
|
leave_type = leave_type.name,
|
||||||
|
description = "_Test Reason",
|
||||||
from_date = date,
|
from_date = date,
|
||||||
to_date = add_days(date, 2),
|
to_date = add_days(date, 2),
|
||||||
company = "_Test Company",
|
company = "_Test Company",
|
||||||
@ -319,6 +322,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
doctype = 'Leave Application',
|
doctype = 'Leave Application',
|
||||||
employee = employee.name,
|
employee = employee.name,
|
||||||
leave_type = leave_type.name,
|
leave_type = leave_type.name,
|
||||||
|
description = "_Test Reason",
|
||||||
from_date = add_days(date, 4),
|
from_date = add_days(date, 4),
|
||||||
to_date = add_days(date, 8),
|
to_date = add_days(date, 8),
|
||||||
company = "_Test Company",
|
company = "_Test Company",
|
||||||
@ -344,6 +348,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
doctype = 'Leave Application',
|
doctype = 'Leave Application',
|
||||||
employee = employee.name,
|
employee = employee.name,
|
||||||
leave_type = leave_type.name,
|
leave_type = leave_type.name,
|
||||||
|
description = "_Test Reason",
|
||||||
from_date = date,
|
from_date = date,
|
||||||
to_date = add_days(date, 4),
|
to_date = add_days(date, 4),
|
||||||
company = "_Test Company",
|
company = "_Test Company",
|
||||||
@ -365,6 +370,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
doctype = 'Leave Application',
|
doctype = 'Leave Application',
|
||||||
employee = employee.name,
|
employee = employee.name,
|
||||||
leave_type = leave_type_1.name,
|
leave_type = leave_type_1.name,
|
||||||
|
description = "_Test Reason",
|
||||||
from_date = date,
|
from_date = date,
|
||||||
to_date = add_days(date, 4),
|
to_date = add_days(date, 4),
|
||||||
company = "_Test Company",
|
company = "_Test Company",
|
||||||
@ -394,6 +400,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
doctype = 'Leave Application',
|
doctype = 'Leave Application',
|
||||||
employee = employee.name,
|
employee = employee.name,
|
||||||
leave_type = leave_type.name,
|
leave_type = leave_type.name,
|
||||||
|
description = "_Test Reason",
|
||||||
from_date = date,
|
from_date = date,
|
||||||
to_date = add_days(date, 4),
|
to_date = add_days(date, 4),
|
||||||
company = "_Test Company",
|
company = "_Test Company",
|
||||||
@ -404,8 +411,6 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
self.assertRaises(frappe.ValidationError, leave_application.insert)
|
self.assertRaises(frappe.ValidationError, leave_application.insert)
|
||||||
|
|
||||||
def test_leave_balance_near_allocaton_expiry(self):
|
def test_leave_balance_near_allocaton_expiry(self):
|
||||||
frappe.db.sql("delete from `tabLeave Allocation`")
|
|
||||||
frappe.db.sql("delete from `tabLeave Ledger Entry`")
|
|
||||||
employee = get_employee()
|
employee = get_employee()
|
||||||
leave_type = create_leave_type(
|
leave_type = create_leave_type(
|
||||||
leave_type_name="_Test_CF_leave_expiry",
|
leave_type_name="_Test_CF_leave_expiry",
|
||||||
@ -463,6 +468,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
doctype = 'Leave Application',
|
doctype = 'Leave Application',
|
||||||
employee = employee.name,
|
employee = employee.name,
|
||||||
leave_type = leave_type,
|
leave_type = leave_type,
|
||||||
|
description = "_Test Reason",
|
||||||
from_date = '2018-10-02',
|
from_date = '2018-10-02',
|
||||||
to_date = '2018-10-02',
|
to_date = '2018-10-02',
|
||||||
company = '_Test Company',
|
company = '_Test Company',
|
||||||
@ -474,7 +480,6 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
self.assertEqual(leave_application.docstatus, 1)
|
self.assertEqual(leave_application.docstatus, 1)
|
||||||
|
|
||||||
def test_creation_of_leave_ledger_entry_on_submit(self):
|
def test_creation_of_leave_ledger_entry_on_submit(self):
|
||||||
frappe.db.sql("delete from `tabLeave Allocation`")
|
|
||||||
employee = get_employee()
|
employee = get_employee()
|
||||||
|
|
||||||
leave_type = create_leave_type(leave_type_name = 'Test Leave Type 1')
|
leave_type = create_leave_type(leave_type_name = 'Test Leave Type 1')
|
||||||
@ -490,6 +495,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
leave_type = leave_type.name,
|
leave_type = leave_type.name,
|
||||||
from_date = add_days(nowdate(), 1),
|
from_date = add_days(nowdate(), 1),
|
||||||
to_date = add_days(nowdate(), 4),
|
to_date = add_days(nowdate(), 4),
|
||||||
|
description = "_Test Reason",
|
||||||
company = "_Test Company",
|
company = "_Test Company",
|
||||||
docstatus = 1,
|
docstatus = 1,
|
||||||
status = "Approved"
|
status = "Approved"
|
||||||
@ -506,8 +512,6 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
self.assertFalse(frappe.db.exists("Leave Ledger Entry", {'transaction_name':leave_application.name}))
|
self.assertFalse(frappe.db.exists("Leave Ledger Entry", {'transaction_name':leave_application.name}))
|
||||||
|
|
||||||
def test_ledger_entry_creation_on_intermediate_allocation_expiry(self):
|
def test_ledger_entry_creation_on_intermediate_allocation_expiry(self):
|
||||||
frappe.db.sql("delete from `tabLeave Allocation`")
|
|
||||||
frappe.db.sql("delete from `tabLeave Ledger Entry`")
|
|
||||||
employee = get_employee()
|
employee = get_employee()
|
||||||
leave_type = create_leave_type(
|
leave_type = create_leave_type(
|
||||||
leave_type_name="_Test_CF_leave_expiry",
|
leave_type_name="_Test_CF_leave_expiry",
|
||||||
@ -523,6 +527,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
leave_type = leave_type.name,
|
leave_type = leave_type.name,
|
||||||
from_date = add_days(nowdate(), -3),
|
from_date = add_days(nowdate(), -3),
|
||||||
to_date = add_days(nowdate(), 7),
|
to_date = add_days(nowdate(), 7),
|
||||||
|
description = "_Test Reason",
|
||||||
company = "_Test Company",
|
company = "_Test Company",
|
||||||
docstatus = 1,
|
docstatus = 1,
|
||||||
status = "Approved"
|
status = "Approved"
|
||||||
@ -558,8 +563,6 @@ def create_carry_forwarded_allocation(employee, leave_type):
|
|||||||
leave_allocation.submit()
|
leave_allocation.submit()
|
||||||
|
|
||||||
def make_allocation_record(employee=None, leave_type=None):
|
def make_allocation_record(employee=None, leave_type=None):
|
||||||
frappe.db.sql("delete from `tabLeave Allocation`")
|
|
||||||
|
|
||||||
allocation = frappe.get_doc({
|
allocation = frappe.get_doc({
|
||||||
"doctype": "Leave Allocation",
|
"doctype": "Leave Allocation",
|
||||||
"employee": employee or "_T-Employee-00001",
|
"employee": employee or "_T-Employee-00001",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user