Skip to content

Commit

Permalink
fix: remove function to get earning deduction components (#24465)
Browse files Browse the repository at this point in the history
* fix: remove function to get earning deduction components

* fix: slider
  • Loading branch information
AfshanKhan authored Jan 27, 2021
1 parent 5ba2f58 commit 907e299
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ frappe.ui.form.on('Additional Salary', {
if (!frm.doc.company) return;
frm.set_query("salary_component", function() {
return {
query: "erpnext.payroll.doctype.salary_structure.salary_structure.get_earning_deduction_components",
filters: {type: "earning", company: frm.doc.company}
filters: {type: ["in", ["earning", "deduction"]], company: frm.doc.company}
};
});
},
Expand Down
20 changes: 11 additions & 9 deletions erpnext/payroll/doctype/employee_incentive/employee_incentive.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@ frappe.ui.form.on('Employee Incentive', {
}
};
});

if (!frm.doc.company) return;
frm.set_query("salary_component", function() {
return {
query: "erpnext.payroll.doctype.salary_structure.salary_structure.get_earning_deduction_components",
filters: {type: "earning", company: frm.doc.company}
};
});

frm.trigger('set_earning_component');
},

employee: function(frm) {
Expand All @@ -45,11 +37,21 @@ frappe.ui.form.on('Employee Incentive', {
callback: function(data) {
if (data.message) {
frm.set_value("company", data.message.company);
frm.trigger('set_earning_component');
}
}
});
},

set_earning_component: function(frm) {
if (!frm.doc.company) return;
frm.set_query("salary_component", function() {
return {
filters: {type: "earning", company: frm.doc.company}
};
});
},

get_employee_currency: function(frm) {
frappe.call({
method: "erpnext.payroll.doctype.salary_structure_assignment.salary_structure_assignment.get_employee_currency",
Expand Down
2 changes: 0 additions & 2 deletions erpnext/payroll/doctype/salary_structure/salary_structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,11 @@ frappe.ui.form.on('Salary Structure', {
if(!frm.doc.company) return;
frm.set_query("salary_component", "earnings", function() {
return {
query : "erpnext.payroll.doctype.salary_structure.salary_structure.get_earning_deduction_components",
filters: {type: "earning", company: frm.doc.company}
};
});
frm.set_query("salary_component", "deductions", function() {
return {
query : "erpnext.payroll.doctype.salary_structure.salary_structure.get_earning_deduction_components",
filters: {type: "deduction", company: frm.doc.company}
};
});
Expand Down
19 changes: 0 additions & 19 deletions erpnext/payroll/doctype/salary_structure/salary_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,22 +207,3 @@ def get_employees(salary_structure):

return list(set([d.employee for d in employees]))

@frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs
def get_earning_deduction_components(doctype, txt, searchfield, start, page_len, filters):
if len(filters) < 2:
return {}

return frappe.db.sql("""
select t1.salary_component
from `tabSalary Component` t1, `tabSalary Component Account` t2
where (t1.name = t2.parent
and t1.type = %(type)s
and t2.company = %(company)s)
or (t1.type = %(type)s
and t1.statistical_component = 1)
order by salary_component
""",{
"type": filters['type'],
"company": filters['company']
})

0 comments on commit 907e299

Please sign in to comment.