Employee Benefit Application - whitlist method get_max_benefits
diff --git a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.js b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.js
index 624a3d5..7859a47 100644
--- a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.js
+++ b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.js
@@ -15,8 +15,11 @@
},
employee: function(frm) {
frappe.call({
- doc: frm.doc,
- method: "get_max_benefits",
+ 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){
diff --git a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py
index 0ce9e0b..8e59bf5 100644
--- a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py
+++ b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py
@@ -48,16 +48,17 @@
if application:
frappe.throw(_("Employee {0} already submited an apllication {1} for the payroll period {2}").format(self.employee, application, self.payroll_period))
- def get_max_benefits(self):
- sal_struct = get_assigned_salary_sturecture(self.employee, self.date)
- if sal_struct:
- max_benefits = frappe.db.get_value("Salary Structure", sal_struct[0][0], "max_benefits")
- if max_benefits > 0:
- return max_benefits
- else:
- frappe.throw(_("Employee {0} has no max benefits in salary structure {1}").format(self.employee, sal_struct[0][0]))
+@frappe.whitelist()
+def get_max_benefits(employee, on_date):
+ sal_struct = get_assigned_salary_sturecture(employee, on_date)
+ if sal_struct:
+ max_benefits = frappe.db.get_value("Salary Structure", sal_struct[0][0], "max_benefits")
+ if max_benefits > 0:
+ return max_benefits
else:
- frappe.throw(_("Employee {0} has no salary structure assigned").format(self.employee))
+ frappe.throw(_("Employee {0} has no max benefits in salary structure {1}").format(employee, sal_struct[0][0]))
+ else:
+ frappe.throw(_("Employee {0} has no salary structure assigned").format(employee))
@frappe.whitelist()