-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] patch missing salary component type based on existing salary slips
- Loading branch information
Showing
3 changed files
with
53 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
erpnext/patches/v7_1/update_missing_salary_component_type.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |