Employee Benefit Application - whitlist method get_max_benefits

This commit is contained in:
Jamsheer 2018-05-16 17:02:21 +05:30
parent 3e64297a3d
commit 3abae9c1ba
2 changed files with 15 additions and 11 deletions

View File

@ -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){

View File

@ -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()