fix: Employee Inactive status implications (#26245)
This commit is contained in:
parent
9bcc402f41
commit
1f10a99910
@ -11,5 +11,5 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
|||||||
cur_frm.fields_dict.employee.get_query = function(doc,cdt,cdn) {
|
cur_frm.fields_dict.employee.get_query = function(doc,cdt,cdn) {
|
||||||
return{
|
return{
|
||||||
query: "erpnext.controllers.queries.employee_query"
|
query: "erpnext.controllers.queries.employee_query"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@ class Attendance(Document):
|
|||||||
validate_status(self.status, ["Present", "Absent", "On Leave", "Half Day", "Work From Home"])
|
validate_status(self.status, ["Present", "Absent", "On Leave", "Half Day", "Work From Home"])
|
||||||
self.validate_attendance_date()
|
self.validate_attendance_date()
|
||||||
self.validate_duplicate_record()
|
self.validate_duplicate_record()
|
||||||
|
self.validate_employee_status()
|
||||||
self.check_leave_record()
|
self.check_leave_record()
|
||||||
|
|
||||||
def validate_attendance_date(self):
|
def validate_attendance_date(self):
|
||||||
@ -38,6 +39,10 @@ class Attendance(Document):
|
|||||||
frappe.throw(_("Attendance for employee {0} is already marked for the date {1}").format(
|
frappe.throw(_("Attendance for employee {0} is already marked for the date {1}").format(
|
||||||
frappe.bold(self.employee), frappe.bold(self.attendance_date)))
|
frappe.bold(self.employee), frappe.bold(self.attendance_date)))
|
||||||
|
|
||||||
|
def validate_employee_status(self):
|
||||||
|
if frappe.db.get_value("Employee", self.employee, "status") == "Inactive":
|
||||||
|
frappe.throw(_("Cannot mark attendance for an Inactive employee {0}").format(self.employee))
|
||||||
|
|
||||||
def check_leave_record(self):
|
def check_leave_record(self):
|
||||||
leave_record = frappe.db.sql("""
|
leave_record = frappe.db.sql("""
|
||||||
select leave_type, half_day, half_day_date
|
select leave_type, half_day, half_day_date
|
||||||
|
|||||||
@ -21,6 +21,9 @@ frappe.listview_settings['Attendance'] = {
|
|||||||
label: __('For Employee'),
|
label: __('For Employee'),
|
||||||
fieldtype: 'Link',
|
fieldtype: 'Link',
|
||||||
options: 'Employee',
|
options: 'Employee',
|
||||||
|
get_query: () => {
|
||||||
|
return {query: "erpnext.controllers.queries.employee_query"}
|
||||||
|
},
|
||||||
reqd: 1,
|
reqd: 1,
|
||||||
onchange: function() {
|
onchange: function() {
|
||||||
dialog.set_df_property("unmarked_days", "hidden", 1);
|
dialog.set_df_property("unmarked_days", "hidden", 1);
|
||||||
|
|||||||
@ -459,6 +459,7 @@ def get_emp_list(sal_struct, cond, end_date, payroll_payable_account):
|
|||||||
where
|
where
|
||||||
t1.name = t2.employee
|
t1.name = t2.employee
|
||||||
and t2.docstatus = 1
|
and t2.docstatus = 1
|
||||||
|
and t1.status != 'Inactive'
|
||||||
%s order by t2.from_date desc
|
%s order by t2.from_date desc
|
||||||
""" % cond, {"sal_struct": tuple(sal_struct), "from_date": end_date, "payroll_payable_account": payroll_payable_account}, as_dict=True)
|
""" % cond, {"sal_struct": tuple(sal_struct), "from_date": end_date, "payroll_payable_account": payroll_payable_account}, as_dict=True)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user