patch: to link additional salary with salary slip and leave encashment, incentive with additional salary
This commit is contained in:
parent
e15f0da011
commit
09572d9892
@ -211,7 +211,7 @@
|
||||
],
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2020-04-24 20:00:16.475295",
|
||||
"modified": "2020-04-04 20:00:16.475295",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Salary Detail",
|
||||
|
@ -677,3 +677,4 @@ erpnext.patches.v13_0.move_tax_slabs_from_payroll_period_to_income_tax_slab #123
|
||||
erpnext.patches.v12_0.fix_quotation_expired_status
|
||||
erpnext.patches.v12_0.update_appointment_reminder_scheduler_entry
|
||||
erpnext.patches.v12_0.retain_permission_rules_for_video_doctype
|
||||
erpnext.patches.v13_0.patch_to_fix_reverse_linking_in_additional_salary_encashment_and_incentive #gyhdghksdhsjsd
|
||||
|
@ -0,0 +1,35 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
|
||||
additional_salaries = frappe.get_all("Additional Salary", fields = ['name', "salary_slip", "type", "salary_component"], group_by = 'salary_slip')
|
||||
leave_encashments = frappe.get_all("Leave Encashment", fields = ["name","additional_salary"])
|
||||
employee_incentives = frappe.get_all("Employee Incentive", fields= ["name", "additional_salary"])
|
||||
|
||||
for incentive in employee_incentives:
|
||||
frappe.db.sql(""" UPDATE `tabAdditional Salary`
|
||||
SET ref_doctype = 'Employee Incentive', ref_docname = %s
|
||||
WHERE name = %s
|
||||
""", (incentive['name'], incentive['additional_salary']))
|
||||
|
||||
|
||||
for leave_encashment in leave_encashments:
|
||||
frappe.db.sql(""" UPDATE `tabAdditional Salary`
|
||||
SET ref_doctype = 'Leave Encashment', ref_docname = %s
|
||||
WHERE name = %s
|
||||
""", (leave_encashment['name'], leave_encashment['additional_salary']))
|
||||
|
||||
salary_slips = [sal["salary_slip"] for sal in additional_salaries]
|
||||
|
||||
for salary in additional_salaries:
|
||||
comp_type = "earnings" if salary['type'] == 'Earning' else 'deductions'
|
||||
if salary["salary_slip"] and salary_slips.count(salary["salary_slip"]) == 1:
|
||||
frappe.db.sql(""" UPDATE `tabsalary Detail`
|
||||
SET additional_salary = %s
|
||||
WHERE parenttype = 'Salary Slip'
|
||||
and parentfield = %s
|
||||
and parent = %s
|
||||
and salary_component = %s""", (salary["name"], comp_type, salary["salary_slip"], salary["salary_component"]))
|
||||
|
Loading…
x
Reference in New Issue
Block a user