Skip to content

Commit

Permalink
feat: fetch employees with withheld salaries in payroll entry
Browse files Browse the repository at this point in the history
Co-authored-by: Viny Selopal <viny0698@gmail.com>
(cherry picked from commit 9c5e4c8)

# Conflicts:
#	hrms/payroll/doctype/payroll_employee_detail/payroll_employee_detail.json
  • Loading branch information
ruchamahabal authored and mergify[bot] committed Jul 23, 2024
1 parent 1604939 commit cad5473
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"employee_name",
"column_break_3",
"department",
"designation"
"designation",
"salary_withheld"
],
"fields": [
{
Expand Down Expand Up @@ -47,11 +48,22 @@
"in_list_view": 1,
"label": "Designation",
"read_only": 1
},
{
"default": "0",
"fieldname": "salary_withheld",
"fieldtype": "Check",
"in_list_view": 1,
"label": "Salary Withheld"
}
],
"istable": 1,
"links": [],
<<<<<<< HEAD
"modified": "2020-12-17 15:43:29.542977",
=======
"modified": "2024-07-01 11:52:24.730907",
>>>>>>> 9c5e4c87a (feat: fetch employees with withheld salaries in payroll entry)
"modified_by": "Administrator",
"module": "Payroll",
"name": "Payroll Employee Detail",
Expand Down
21 changes: 21 additions & 0 deletions hrms/payroll/doctype/payroll_entry/payroll_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,30 @@ def fill_employee_details(self):

self.set("employees", employees)
self.number_of_employees = len(self.employees)
self.update_employees_with_withheld_salaries()

return self.get_employees_with_unmarked_attendance()

def update_employees_with_withheld_salaries(self):
Withholding = frappe.qb.DocType("Salary Withholding")
WithholdingCycle = frappe.qb.DocType("Salary Withholding Cycle")
withheld_salaries = (
frappe.qb.from_(Withholding)
.join(WithholdingCycle)
.on(WithholdingCycle.parent == Withholding.name)
.select(Withholding.employee)
.where(
(WithholdingCycle.from_date == self.start_date)
& (WithholdingCycle.to_date == self.end_date)
& (WithholdingCycle.docstatus == 1)
& (WithholdingCycle.is_salary_released != 1)
)
).run(pluck=True)

for employee in self.employees:
if employee.employee in withheld_salaries:
employee.salary_withheld = 1

@frappe.whitelist()
def create_salary_slips(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ frappe.ui.form.on("Salary Withholding", {

frappe
.call({
method: "hrms.hr.doctype.salary_withholding.salary_withholding.get_payroll_frequency",
method: "hrms.payroll.doctype.salary_withholding.salary_withholding.get_payroll_frequency",
args: {
employee: frm.doc.employee,
posting_date: frm.doc.posting_date,
Expand Down

0 comments on commit cad5473

Please sign in to comment.