Employee Benefit Application - get max benefit
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 f409a13..061eb12 100644
--- a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py
+++ b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py
@@ -5,6 +5,7 @@
 from __future__ import unicode_literals
 import frappe
 from frappe import _
+from frappe.utils import nowdate
 from frappe.model.document import Document
 
 class EmployeeBenefitApplication(Document):
@@ -22,3 +23,26 @@
 		)
 		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:
+			return frappe.db.get_value("Salary Structure", sal_struct[0][0], "max_benefits")
+
+
+@frappe.whitelist()
+def get_assigned_salary_sturecture(employee, _date):
+	if not _date:
+		_date = nowdate()
+	salary_structure = frappe.db.sql("""
+		select salary_structure from `tabSalary Structure Assignment`
+		where employee=%(employee)s
+		and docstatus = 1
+		and (
+			(%(_date)s between from_date and ifnull(to_date, '2199-12-31'))
+		)""", {
+			'employee': employee,
+			'_date': _date,
+		})
+	if salary_structure:
+		return salary_structure