Employee Benefit Application - get max benefit
This commit is contained in:
parent
41616de9cc
commit
779f8ebbb3
@ -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 @@ 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:
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user