Employee Benefit Application - earning component filter by salary structure flexi component
This commit is contained in:
parent
77a91f0d01
commit
43e191289c
@ -5,17 +5,13 @@ frappe.ui.form.on('Employee Benefit Application', {
|
|||||||
setup: function(frm) {
|
setup: function(frm) {
|
||||||
frm.set_query("earning_component", "employee_benefits", function() {
|
frm.set_query("earning_component", "employee_benefits", function() {
|
||||||
return {
|
return {
|
||||||
filters: {
|
query : "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_earning_components",
|
||||||
type: "Earning",
|
filters: {date: frm.doc.date, employee: frm.doc.employee}
|
||||||
is_flexible_benefit: true,
|
|
||||||
is_group: false,
|
|
||||||
flexi_default: false,
|
|
||||||
disabled: false
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
employee: function(frm) {
|
employee: function(frm) {
|
||||||
|
if(frm.doc.employee && frm.doc.date){
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_max_benefits",
|
method: "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_max_benefits",
|
||||||
args:{
|
args:{
|
||||||
@ -31,6 +27,7 @@ frappe.ui.form.on('Employee Benefit Application', {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on("Employee Benefit Application Detail",{
|
frappe.ui.form.on("Employee Benefit Application Detail",{
|
||||||
|
@ -8,6 +8,7 @@ from frappe import _
|
|||||||
from frappe.utils import nowdate, date_diff, getdate
|
from frappe.utils import nowdate, date_diff, getdate
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from erpnext.hr.doctype.payroll_period.payroll_period import get_payroll_period_days
|
from erpnext.hr.doctype.payroll_period.payroll_period import get_payroll_period_days
|
||||||
|
from frappe.desk.reportview import get_match_cond
|
||||||
|
|
||||||
class EmployeeBenefitApplication(Document):
|
class EmployeeBenefitApplication(Document):
|
||||||
def validate(self):
|
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
|
amount_per_day = amount / payroll_period_days
|
||||||
total_amount = amount_per_day * salary_slip_days
|
total_amount = amount_per_day * salary_slip_days
|
||||||
return total_amount
|
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