From 3d0121369f5321cd4f91e236a4ffd48ec02e7744 Mon Sep 17 00:00:00 2001 From: Joyce Babu Date: Wed, 6 Mar 2019 13:04:45 +0530 Subject: [PATCH] Add 'Half-Yearly' option to Earned Leave Frequency in addition to the current values of Monthly, Quarterly and Yearly --- erpnext/hr/doctype/leave_type/leave_type.json | 2 +- erpnext/hr/utils.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/hr/doctype/leave_type/leave_type.json b/erpnext/hr/doctype/leave_type/leave_type.json index 8f7b5a876c..6a7a80a784 100644 --- a/erpnext/hr/doctype/leave_type/leave_type.json +++ b/erpnext/hr/doctype/leave_type/leave_type.json @@ -561,7 +561,7 @@ "label": "Earned Leave Frequency", "length": 0, "no_copy": 0, - "options": "Monthly\nQuarterly\nYearly", + "options": "Monthly\nQuarterly\nHalf-Yearly\nYearly", "permlevel": 0, "precision": "", "print_hide": 0, diff --git a/erpnext/hr/utils.py b/erpnext/hr/utils.py index 02262012f1..e0b6a51d1a 100644 --- a/erpnext/hr/utils.py +++ b/erpnext/hr/utils.py @@ -260,7 +260,7 @@ def allocate_earned_leaves(): fields=["name", "max_leaves_allowed", "earned_leave_frequency", "rounding"], filters={'is_earned_leave' : 1}) today = getdate() - divide_by_frequency = {"Yearly": 1, "Quarterly": 4, "Monthly": 12} + divide_by_frequency = {"Yearly": 1, "Half-Yearly": 6, "Quarterly": 4, "Monthly": 12} if e_leave_types: for e_leave_type in e_leave_types: leave_allocations = frappe.db.sql("""select name, employee, from_date, to_date from `tabLeave Allocation` where '{0}' @@ -297,6 +297,9 @@ def check_frequency_hit(from_date, to_date, frequency): if frequency == "Quarterly": if not months % 3: return True + elif frequency == "Half-Yearly": + if not months % 6: + return True elif frequency == "Yearly": if not months % 12: return True