Employee Benefit Application - employee benefit in salary slip
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index b7d26f2..043b693 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -13,7 +13,8 @@
from erpnext.utilities.transaction_base import TransactionBase
from frappe.utils.background_jobs import enqueue
from erpnext.hr.doctype.additional_salary_component.additional_salary_component import get_additional_salary_component
-from erpnext.hr.doctype.employee_benefit_application.employee_benefit_application import get_employee_benefit_application
+from erpnext.hr.doctype.employee_benefit_application.employee_benefit_application import get_employee_benefit_application, get_amount
+from erpnext.hr.doctype.payroll_period.payroll_period import get_payroll_period_days
class SalarySlip(TransactionBase):
def autoname(self):
@@ -71,6 +72,27 @@
for employee_benefit in employee_benefits:
benefit_component = frappe._dict(employee_benefit)
self.update_component_row(frappe._dict(benefit_component.struct_row), benefit_component.amount, "earnings")
+ else:
+ max_benefits = self._salary_structure_doc.get("max_benefits")
+ if max_benefits > 0:
+ default_flexi_compenent = frappe.db.exists(
+ 'Salary Component',
+ {
+ 'is_flexible_benefit': 1,
+ 'is_pro_rata_applicable': 1,
+ 'flexi_default': 1
+ }
+ )
+ if default_flexi_compenent:
+ salary_component = frappe.get_doc("Salary Component", default_flexi_compenent)
+ flexi_struct_row = {}
+ flexi_struct_row['depends_on_lwp'] = salary_component.depends_on_lwp
+ flexi_struct_row['salary_component'] = salary_component.name
+ flexi_struct_row['abbr'] = salary_component.salary_component_abbr
+ flexi_struct_row['do_not_include_in_total'] = salary_component.do_not_include_in_total
+ payroll_period_days = get_payroll_period_days(self.start_date, self.end_date, self.company)
+ amount = get_amount(payroll_period_days, self.start_date, self.end_date, max_benefits)
+ self.update_component_row(flexi_struct_row, amount, "earnings")
def update_component_row(self, struct_row, amount, key):
component_row = None