[fix] patch missing salary component type based on existing salary slips (#6955)
This commit is contained in:
parent
99a3593a0d
commit
8dfbe7c748
@ -63,8 +63,8 @@ def get_salary_slips(filters):
|
|||||||
order by employee, month""" % conditions, filters, as_dict=1)
|
order by employee, month""" % conditions, filters, as_dict=1)
|
||||||
|
|
||||||
if not salary_slips:
|
if not salary_slips:
|
||||||
msgprint(_("No salary slip found for month: ") + cstr(filters.get("month")) +
|
frappe.throw(_("No salary slip found for month {0} and year {1}").format(
|
||||||
_(" and year: ") + cstr(filters.get("fiscal_year")), raise_exception=1)
|
filters.get("month"), filters.get("fiscal_year")))
|
||||||
|
|
||||||
return salary_slips
|
return salary_slips
|
||||||
|
|
||||||
|
@ -348,3 +348,4 @@ erpnext.patches.v7_1.add_account_user_role_for_timesheet
|
|||||||
erpnext.patches.v7_0.set_base_amount_in_invoice_payment_table
|
erpnext.patches.v7_0.set_base_amount_in_invoice_payment_table
|
||||||
erpnext.patches.v7_1.update_invoice_status
|
erpnext.patches.v7_1.update_invoice_status
|
||||||
erpnext.patches.v7_0.po_status_issue_for_pr_return
|
erpnext.patches.v7_0.po_status_issue_for_pr_return
|
||||||
|
erpnext.patches.v7_1.update_missing_salary_component_type
|
||||||
|
25
erpnext/patches/v7_1/update_missing_salary_component_type.py
Normal file
25
erpnext/patches/v7_1/update_missing_salary_component_type.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
'''
|
||||||
|
Some components do not have type set, try and guess whether they turn up in
|
||||||
|
earnings or deductions in existing salary slips
|
||||||
|
'''
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
for s in frappe.db.sql('select name from `tabSalary Component` where ifnull(type, "")=""'):
|
||||||
|
compontent = frappe.get_doc('Salary Component', s[0])
|
||||||
|
|
||||||
|
# guess
|
||||||
|
guess = frappe.db.sql('''select
|
||||||
|
parentfield from `tabSalary Detail`
|
||||||
|
where salary_component=%s limit 1''', s[0])
|
||||||
|
|
||||||
|
if guess:
|
||||||
|
compontent.type = 'Earning' if guess[0][0]=='earnings' else 'Deduction'
|
||||||
|
|
||||||
|
else:
|
||||||
|
compontent.type = 'Deduction'
|
||||||
|
|
||||||
|
compontent.save()
|
Loading…
x
Reference in New Issue
Block a user