From 3abae9c1ba7530328c52afe5a1e156ffdf73457c Mon Sep 17 00:00:00 2001 From: Jamsheer Date: Wed, 16 May 2018 17:02:21 +0530 Subject: [PATCH] Employee Benefit Application - whitlist method get_max_benefits --- .../employee_benefit_application.js | 7 +++++-- .../employee_benefit_application.py | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) 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 624a3d5eb0..7859a470cc 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 @@ frappe.ui.form.on('Employee Benefit Application', { }, 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 0ce9e0bbbd..8e59bf556b 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 @@ class EmployeeBenefitApplication(Document): 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()