[fix] patch missing salary component type based on existing salary slips (#6955)

This commit is contained in:
Rushabh Mehta 2016-11-16 11:18:20 +05:30 committed by GitHub
parent 99a3593a0d
commit 8dfbe7c748
3 changed files with 53 additions and 27 deletions

View File

@ -63,8 +63,8 @@ def get_salary_slips(filters):
order by employee, month""" % conditions, filters, as_dict=1)
if not salary_slips:
msgprint(_("No salary slip found for month: ") + cstr(filters.get("month")) +
_(" and year: ") + cstr(filters.get("fiscal_year")), raise_exception=1)
frappe.throw(_("No salary slip found for month {0} and year {1}").format(
filters.get("month"), filters.get("fiscal_year")))
return salary_slips

View File

@ -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_1.update_invoice_status
erpnext.patches.v7_0.po_status_issue_for_pr_return
erpnext.patches.v7_1.update_missing_salary_component_type

View 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()