Add 'Half-Yearly' option to Earned Leave Frequency

in addition to the current values of Monthly, Quarterly and Yearly
This commit is contained in:
Joyce Babu
2019-03-06 13:04:45 +05:30
parent 6e28ef425a
commit 3d0121369f
2 changed files with 5 additions and 2 deletions

View File

@@ -561,7 +561,7 @@
"label": "Earned Leave Frequency", "label": "Earned Leave Frequency",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"options": "Monthly\nQuarterly\nYearly", "options": "Monthly\nQuarterly\nHalf-Yearly\nYearly",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,

View File

@@ -260,7 +260,7 @@ def allocate_earned_leaves():
fields=["name", "max_leaves_allowed", "earned_leave_frequency", "rounding"], fields=["name", "max_leaves_allowed", "earned_leave_frequency", "rounding"],
filters={'is_earned_leave' : 1}) filters={'is_earned_leave' : 1})
today = getdate() 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: if e_leave_types:
for e_leave_type in 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}' 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 frequency == "Quarterly":
if not months % 3: if not months % 3:
return True return True
elif frequency == "Half-Yearly":
if not months % 6:
return True
elif frequency == "Yearly": elif frequency == "Yearly":
if not months % 12: if not months % 12:
return True return True