Employee Benefit Application - earning component filter by salary structure flexi component
This commit is contained in:
parent
77a91f0d01
commit
43e191289c
@ -5,31 +5,28 @@ frappe.ui.form.on('Employee Benefit Application', {
|
||||
setup: function(frm) {
|
||||
frm.set_query("earning_component", "employee_benefits", function() {
|
||||
return {
|
||||
filters: {
|
||||
type: "Earning",
|
||||
is_flexible_benefit: true,
|
||||
is_group: false,
|
||||
flexi_default: false,
|
||||
disabled: false
|
||||
}
|
||||
query : "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_earning_components",
|
||||
filters: {date: frm.doc.date, employee: frm.doc.employee}
|
||||
};
|
||||
});
|
||||
},
|
||||
employee: function(frm) {
|
||||
frappe.call({
|
||||
method: "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_max_benefits",
|
||||
args:{
|
||||
employee: frm.doc.employee,
|
||||
on_date: frm.doc.date
|
||||
},
|
||||
callback: function (data) {
|
||||
if(!data.exc){
|
||||
if(data.message){
|
||||
frm.set_value("max_benefits", data.message);
|
||||
if(frm.doc.employee && frm.doc.date){
|
||||
frappe.call({
|
||||
method: "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_max_benefits",
|
||||
args:{
|
||||
employee: frm.doc.employee,
|
||||
on_date: frm.doc.date
|
||||
},
|
||||
callback: function (data) {
|
||||
if(!data.exc){
|
||||
if(data.message){
|
||||
frm.set_value("max_benefits", data.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -8,6 +8,7 @@ from frappe import _
|
||||
from frappe.utils import nowdate, date_diff, getdate
|
||||
from frappe.model.document import Document
|
||||
from erpnext.hr.doctype.payroll_period.payroll_period import get_payroll_period_days
|
||||
from frappe.desk.reportview import get_match_cond
|
||||
|
||||
class EmployeeBenefitApplication(Document):
|
||||
def validate(self):
|
||||
@ -130,3 +131,25 @@ def get_amount(payroll_period_days, start_date, end_date, amount):
|
||||
amount_per_day = amount / payroll_period_days
|
||||
total_amount = amount_per_day * salary_slip_days
|
||||
return total_amount
|
||||
|
||||
def get_earning_components(doctype, txt, searchfield, start, page_len, filters):
|
||||
if len(filters) < 2:
|
||||
return {}
|
||||
employee = filters['employee']
|
||||
date = filters['date']
|
||||
salary_structure = get_assigned_salary_sturecture(employee, date)
|
||||
|
||||
if len(salary_structure) > 0:
|
||||
query = """select salary_component from `tabSalary Detail` where parent = '{salary_structure}'
|
||||
and is_flexible_benefit = 1
|
||||
order by name"""
|
||||
|
||||
return frappe.db.sql(query.format(**{
|
||||
"salary_structure": salary_structure[0][0],
|
||||
"mcond": get_match_cond(doctype)
|
||||
}), {
|
||||
'start': start,
|
||||
'page_len': page_len
|
||||
})
|
||||
|
||||
return {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user