Skip to content

Commit

Permalink
Merge pull request #3594 from ONE-F-M/188120655
Browse files Browse the repository at this point in the history
fix: Set on hold attendance employees
  • Loading branch information
Talleyrand333 authored Aug 27, 2024
2 parents a1677c1 + 5e3d5a3 commit 2f04c6b
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions one_fm/overrides/payroll_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
from frappe.utils import (
add_to_date,
cint,
getdate,
getdate
)
from frappe.query_builder.functions import Coalesce, Count

from hrms.payroll.doctype.payroll_entry.payroll_entry import ( PayrollEntry, get_employee_list, get_salary_structure, remove_payrolled_employees,
set_fields_to_select, set_searchfield, set_match_conditions)

Expand Down Expand Up @@ -376,27 +374,28 @@ def set_on_hold_employees(
query = query.offset(offset)

employees = query.run(as_dict=as_dict)
mpi_exists = frappe.db.exists("Missing Payroll Information", { "payroll_entry": filters.payroll_entry})

missing_payroll_info = []
for employee in employees:
missing_payroll_info.append({
"employee": employee.employee,
"salary_mode": "N/A",
"issue": "On-Hold attendance records"
})

if mpi_exists:
mpi = frappe.get_doc("Missing Payroll Information", mpi_exists)
for info in missing_payroll_info:
mpi.append("missing_payroll_information_detail", info)
mpi.save(ignore_permissions=True)

else:
mpi = frappe.get_doc({
"doctype":"Missing Payroll Information",
"payroll_entry": filters.payroll_entry,
"missing_payroll_information_detail": missing_payroll_info
}).insert(ignore_permissions=True)

frappe.db.commit()
if len(employees) > 0:
mpi_exists = frappe.db.exists("Missing Payroll Information", { "payroll_entry": filters.payroll_entry})
missing_payroll_info = []
for employee in employees:
missing_payroll_info.append({
"employee": employee.employee,
"salary_mode": "N/A",
"issue": "On-Hold attendance records"
})

if mpi_exists:
mpi = frappe.get_doc("Missing Payroll Information", mpi_exists)
for info in missing_payroll_info:
mpi.append("missing_payroll_information_detail", info)
mpi.save(ignore_permissions=True)

else:
mpi = frappe.get_doc({
"doctype":"Missing Payroll Information",
"payroll_entry": filters.payroll_entry,
"missing_payroll_information_detail": missing_payroll_info
}).insert(ignore_permissions=True)

frappe.db.commit()

0 comments on commit 2f04c6b

Please sign in to comment.