mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 02:01:21 +00:00
fix: Fixed merge conflict
This commit is contained in:
@@ -20,7 +20,7 @@ def get_approvers(doctype, txt, searchfield, start, page_len, filters):
|
||||
approvers = []
|
||||
department_details = {}
|
||||
department_list = []
|
||||
employee = frappe.get_value("Employee", filters.get("employee"), ["department", "leave_approver"], as_dict=True)
|
||||
employee = frappe.get_value("Employee", filters.get("employee"), ["employee_name","department", "leave_approver"], as_dict=True)
|
||||
|
||||
employee_department = filters.get("department") or employee.department
|
||||
if employee_department:
|
||||
@@ -36,8 +36,10 @@ def get_approvers(doctype, txt, searchfield, start, page_len, filters):
|
||||
|
||||
if filters.get("doctype") == "Leave Application":
|
||||
parentfield = "leave_approvers"
|
||||
else:
|
||||
field_name = "Leave Approver"
|
||||
elif filters.get("doctype") == "Expense Claim":
|
||||
parentfield = "expense_approvers"
|
||||
field_name = "Expense Approver"
|
||||
if department_list:
|
||||
for d in department_list:
|
||||
approvers += frappe.db.sql("""select user.name, user.first_name, user.last_name from
|
||||
@@ -47,4 +49,10 @@ def get_approvers(doctype, txt, searchfield, start, page_len, filters):
|
||||
and approver.parentfield = %s
|
||||
and approver.approver=user.name""",(d, "%" + txt + "%", parentfield), as_list=True)
|
||||
|
||||
if len(approvers) == 0:
|
||||
error_msg = _("Please set {0} for the Employee: {1}").format(field_name, frappe.bold(employee.employee_name))
|
||||
if department_list:
|
||||
error_msg += _(" or for Department: {0}").format(frappe.bold(employee_department))
|
||||
frappe.throw(error_msg, title=_(field_name + " Missing"))
|
||||
|
||||
return set(tuple(approver) for approver in approvers)
|
||||
|
||||
@@ -172,8 +172,11 @@ class Employee(NestedSet):
|
||||
)
|
||||
if reports_to:
|
||||
link_to_employees = [frappe.utils.get_link_to_form('Employee', employee.name, label=employee.employee_name) for employee in reports_to]
|
||||
throw(_("Employee status cannot be set to 'Left' as following employees are currently reporting to this employee: ")
|
||||
+ ', '.join(link_to_employees), EmployeeLeftValidationError)
|
||||
message = _("The following employees are currently still reporting to {0}:").format(frappe.bold(self.employee_name))
|
||||
message += "<br><br><ul><li>" + "</li><li>".join(link_to_employees)
|
||||
message += "</li></ul><br>"
|
||||
message += _("Please make sure the employees above report to another Active employee.")
|
||||
throw(message, EmployeeLeftValidationError, _("Cannot Relieve Employee"))
|
||||
if not self.relieving_date:
|
||||
throw(_("Please enter relieving date."))
|
||||
|
||||
@@ -206,7 +209,7 @@ class Employee(NestedSet):
|
||||
|
||||
def validate_preferred_email(self):
|
||||
if self.prefered_contact_email and not self.get(scrub(self.prefered_contact_email)):
|
||||
frappe.msgprint(_("Please enter " + self.prefered_contact_email))
|
||||
frappe.msgprint(_("Please enter {0}").format(self.prefered_contact_email))
|
||||
|
||||
def validate_onboarding_process(self):
|
||||
employee_onboarding = frappe.get_all("Employee Onboarding",
|
||||
@@ -407,7 +410,11 @@ def get_employee_emails(employee_list):
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_children(doctype, parent=None, company=None, is_root=False, is_tree=False):
|
||||
filters = [['company', '=', company]]
|
||||
|
||||
filters = [['status', '!=', 'Left']]
|
||||
if company and company != 'All Companies':
|
||||
filters.append(['company', '=', company])
|
||||
|
||||
fields = ['name as value', 'employee_name as title']
|
||||
|
||||
if is_root:
|
||||
|
||||
@@ -302,7 +302,9 @@ class PayrollEntry(Document):
|
||||
jv_name = journal_entry.name
|
||||
self.update_salary_slip_status(jv_name = jv_name)
|
||||
except Exception as e:
|
||||
frappe.msgprint(e)
|
||||
if type(e) in (str, list, tuple):
|
||||
frappe.msgprint(e)
|
||||
raise
|
||||
|
||||
return jv_name
|
||||
|
||||
@@ -379,9 +381,13 @@ class PayrollEntry(Document):
|
||||
employees_to_mark_attendance = []
|
||||
days_in_payroll, days_holiday, days_attendance_marked = 0, 0, 0
|
||||
for employee_detail in self.employees:
|
||||
days_holiday = self.get_count_holidays_of_employee(employee_detail.employee)
|
||||
days_attendance_marked = self.get_count_employee_attendance(employee_detail.employee)
|
||||
days_in_payroll = date_diff(self.end_date, self.start_date) + 1
|
||||
employee_joining_date = frappe.db.get_value("Employee", employee_detail.employee, 'date_of_joining')
|
||||
start_date = self.start_date
|
||||
if employee_joining_date > getdate(self.start_date):
|
||||
start_date = employee_joining_date
|
||||
days_holiday = self.get_count_holidays_of_employee(employee_detail.employee, start_date)
|
||||
days_attendance_marked = self.get_count_employee_attendance(employee_detail.employee, start_date)
|
||||
days_in_payroll = date_diff(self.end_date, start_date) + 1
|
||||
if days_in_payroll > days_holiday + days_attendance_marked:
|
||||
employees_to_mark_attendance.append({
|
||||
"employee": employee_detail.employee,
|
||||
@@ -389,22 +395,25 @@ class PayrollEntry(Document):
|
||||
})
|
||||
return employees_to_mark_attendance
|
||||
|
||||
def get_count_holidays_of_employee(self, employee):
|
||||
def get_count_holidays_of_employee(self, employee, start_date):
|
||||
holiday_list = get_holiday_list_for_employee(employee)
|
||||
holidays = 0
|
||||
if holiday_list:
|
||||
days = frappe.db.sql("""select count(*) from tabHoliday where
|
||||
parent=%s and holiday_date between %s and %s""", (holiday_list,
|
||||
self.start_date, self.end_date))
|
||||
start_date, self.end_date))
|
||||
if days and days[0][0]:
|
||||
holidays = days[0][0]
|
||||
return holidays
|
||||
|
||||
def get_count_employee_attendance(self, employee):
|
||||
def get_count_employee_attendance(self, employee, start_date):
|
||||
marked_days = 0
|
||||
attendances = frappe.db.sql("""select count(*) from tabAttendance where
|
||||
employee=%s and docstatus=1 and attendance_date between %s and %s""",
|
||||
(employee, self.start_date, self.end_date))
|
||||
attendances = frappe.get_all("Attendance",
|
||||
fields = ["count(*)"],
|
||||
filters = {
|
||||
"employee": employee,
|
||||
"attendance_date": ('between', [start_date, self.end_date])
|
||||
}, as_list=1)
|
||||
if attendances and attendances[0][0]:
|
||||
marked_days = attendances[0][0]
|
||||
return marked_days
|
||||
|
||||
Reference in New Issue
Block a user