feat: validate leave expiry days
This commit is contained in:
parent
0c0bfb1ef0
commit
4badca54af
@ -422,7 +422,7 @@
|
||||
"depends_on": "",
|
||||
"description": "calculated in days",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "carry_forward__leave_expiry",
|
||||
"fieldname": "carry_forward_leave_expiry",
|
||||
"fieldtype": "Int",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
@ -431,7 +431,7 @@
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Carry Forward Leave Expiry",
|
||||
"label": "Carry Forward Leave Expiry",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
@ -729,7 +729,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2019-04-04 14:27:47.742997",
|
||||
"modified": "2019-04-11 15:38:39.334283",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Leave Type",
|
||||
|
@ -4,6 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import calendar
|
||||
import frappe
|
||||
from datetime import datetime
|
||||
from frappe import _
|
||||
|
||||
from frappe.model.document import Document
|
||||
@ -14,6 +15,6 @@ class LeaveType(Document):
|
||||
self.validate_carry_forward()
|
||||
|
||||
def validate_carry_forward(self):
|
||||
max_days = 366 if calendar.isleap() else 365
|
||||
if not (1 < self.carry_forward_leave_expiry < max_days):
|
||||
max_days = 366 if calendar.isleap(datetime.now().year) else 365
|
||||
if not (0 <= self.carry_forward_leave_expiry <= max_days):
|
||||
frappe.throw(_('Invalid entry!! Carried forward days need to expire within a year'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user