fix(HR): Fix half day error when only 1 day is selected (#22122)

* fix half day error when only 1 day is selected

* adding validation fix for half day on serverside
This commit is contained in:
Abhishek Balam 2020-06-05 16:46:57 +05:30 committed by GitHub
parent 407c7bc113
commit 328a55749d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -38,6 +38,9 @@ frappe.ui.form.on("Leave Application", {
},
validate: function(frm) {
if (frm.doc.from_date == frm.doc.to_date && frm.doc.half_day == 1){
frm.doc.half_day_date = frm.doc.from_date;
}
frm.toggle_reqd("half_day_date", frm.doc.half_day == 1);
},

View File

@ -33,6 +33,7 @@ class LeaveApplication(Document):
self.validate_block_days()
self.validate_salary_processed_days()
self.validate_attendance()
self.set_half_day_date()
if frappe.db.get_value("Leave Type", self.leave_type, 'is_optional_leave'):
self.validate_optional_leave()
self.validate_applicable_after()
@ -292,6 +293,10 @@ class LeaveApplication(Document):
frappe.throw(_("{0} is not in Optional Holiday List").format(formatdate(day)), NotAnOptionalHoliday)
day = add_days(day, 1)
def set_half_day_date(self):
if self.from_date == self.to_date and self.half_day == 1:
self.half_day_date = self.from_date
def notify_employee(self):
employee = frappe.get_doc("Employee", self.employee)
if not employee.user_id: