Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove function to get earning deduction components #24465

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']
})