diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index 44fb6fd2968..7cbc59687a0 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -238,10 +238,15 @@ def get_total_leave_days(leave_app): ret = {'total_leave_days' : 0.5} if not leave_app.half_day: tot_days = date_diff(leave_app.to_date, leave_app.from_date) + 1 - holidays = leave_app.get_holidays() - ret = { - 'total_leave_days' : flt(tot_days)-flt(holidays) - } + if frappe.db.get_value("Leave Type", self.leave_type, "include_holiday"): + holidays = leave_app.get_holidays() + ret = { + 'total_leave_days' : flt(tot_days)-flt(holidays) + } + else: + ret = { + 'total_leave_days' : flt(tot_days) + } return ret @frappe.whitelist() diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py index 8cf0c806614..9e2170855a7 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.py +++ b/erpnext/hr/doctype/leave_application/test_leave_application.py @@ -246,4 +246,4 @@ class TestLeaveApplication(unittest.TestCase): frappe.db.sql("""delete from `tabEmployee Leave Approver` where parent=%s""", "_T-Employee-0001") - frappe.db.set_value("Employee", "_T-Employee-0001", "department", original_department) + frappe.db.set_value("Employee", "_T-Employee-0001", "department", original_department) \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_type/leave_type.json b/erpnext/hr/doctype/leave_type/leave_type.json index f644c696d18..4493af504cf 100644 --- a/erpnext/hr/doctype/leave_type/leave_type.json +++ b/erpnext/hr/doctype/leave_type/leave_type.json @@ -59,6 +59,12 @@ "fieldtype": "Check", "label": "Allow Negative Balance", "permlevel": 0 + }, + { + "fieldname": "include_holiday", + "fieldtype": "Check", + "label": "Include holidays within leaves as leaves", + "permlevel": 0 } ], "icon": "icon-flag", diff --git a/erpnext/hr/doctype/leave_type/test_records.json b/erpnext/hr/doctype/leave_type/test_records.json index 8042e30f528..2ac46cf626e 100644 --- a/erpnext/hr/doctype/leave_type/test_records.json +++ b/erpnext/hr/doctype/leave_type/test_records.json @@ -1,11 +1,13 @@ [ { "doctype": "Leave Type", - "leave_type_name": "_Test Leave Type" + "leave_type_name": "_Test Leave Type", + "include_holiday": 1 }, { "doctype": "Leave Type", "is_lwp": 1, - "leave_type_name": "_Test Leave Type LWP" + "leave_type_name": "_Test Leave Type LWP", + "include_holiday": 1 } ] \ No newline at end of file diff --git a/erpnext/patches.txt b/erpnext/patches.txt index ef08098c32d..b029d55f5f8 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -181,3 +181,4 @@ erpnext.patches.v5_1.rename_roles erpnext.patches.v5_1.default_bom execute:frappe.delete_doc("DocType", "Party Type") erpnext.patches.v5_4.fix_reserved_qty_and_sle_for_packed_items +execute:frappe.db.sql("update `tabLeave Type` set include_holiday=1") \ No newline at end of file diff --git a/erpnext/setup/page/setup_wizard/install_fixtures.py b/erpnext/setup/page/setup_wizard/install_fixtures.py index 6265e4a36ce..dd3ec3a2e6b 100644 --- a/erpnext/setup/page/setup_wizard/install_fixtures.py +++ b/erpnext/setup/page/setup_wizard/install_fixtures.py @@ -41,11 +41,16 @@ def install(country=None): {'doctype': 'Expense Claim Type', 'name': _('Travel'), 'expense_type': _('Travel')}, # leave type - {'doctype': 'Leave Type', 'leave_type_name': _('Casual Leave'), 'name': _('Casual Leave'), 'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', }, - {'doctype': 'Leave Type', 'leave_type_name': _('Compensatory Off'), 'name': _('Compensatory Off'), 'is_encash': 0, 'is_carry_forward': 0, }, - {'doctype': 'Leave Type', 'leave_type_name': _('Sick Leave'), 'name': _('Sick Leave'), 'is_encash': 0, 'is_carry_forward': 0, }, - {'doctype': 'Leave Type', 'leave_type_name': _('Privilege Leave'), 'name': _('Privilege Leave'), 'is_encash': 0, 'is_carry_forward': 0, }, - {'doctype': 'Leave Type', 'leave_type_name': _('Leave Without Pay'), 'name': _('Leave Without Pay'), 'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1}, + {'doctype': 'Leave Type', 'leave_type_name': _('Casual Leave'), 'name': _('Casual Leave'), + 'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', 'include_holiday': 1}, + {'doctype': 'Leave Type', 'leave_type_name': _('Compensatory Off'), 'name': _('Compensatory Off'), + 'is_encash': 0, 'is_carry_forward': 0, 'include_holiday': 1}, + {'doctype': 'Leave Type', 'leave_type_name': _('Sick Leave'), 'name': _('Sick Leave'), + 'is_encash': 0, 'is_carry_forward': 0, 'include_holiday': 1}, + {'doctype': 'Leave Type', 'leave_type_name': _('Privilege Leave'), 'name': _('Privilege Leave'), + 'is_encash': 0, 'is_carry_forward': 0, 'include_holiday': 1}, + {'doctype': 'Leave Type', 'leave_type_name': _('Leave Without Pay'), 'name': _('Leave Without Pay'), + 'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1, 'include_holiday': 1}, # Employment Type {'doctype': 'Employment Type', 'employee_type_name': _('Full-time')},