mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 12:19:12 +00:00
Salary Structure - validate max benefits with flexi
This commit is contained in:
@@ -13,6 +13,7 @@ class SalaryStructure(Document):
|
||||
def validate(self):
|
||||
self.validate_amount()
|
||||
self.strip_condition_and_formula_fields()
|
||||
self.validate_max_benefits_with_flexi()
|
||||
|
||||
def validate_amount(self):
|
||||
if flt(self.net_pay) < 0 and self.salary_slip_based_on_timesheet:
|
||||
@@ -28,6 +29,22 @@ class SalaryStructure(Document):
|
||||
row.condition = row.condition.strip() if row.condition else ""
|
||||
row.formula = row.formula.strip() if row.formula else ""
|
||||
|
||||
def validate_max_benefits_with_flexi(self):
|
||||
have_a_flexi = False
|
||||
if self.max_benefits > 0 and self.earnings:
|
||||
flexi_amount = 0
|
||||
for earning_component in self.earnings:
|
||||
if earning_component.is_flexible_benefit == 1:
|
||||
have_a_flexi = True
|
||||
max_of_component = frappe.db.get_value("Salary Component", earning_component.salary_component, "max_benefit_amount")
|
||||
flexi_amount += max_of_component
|
||||
if self.max_benefits > flexi_amount:
|
||||
frappe.throw(_("Total flexi component amount {0} should not be less \
|
||||
than max benefits {1}").format(flexi_amount, self.max_benefits))
|
||||
if not have_a_flexi and self.max_benefits > 0:
|
||||
frappe.throw(_("Flexi component require to add max benefit"))
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_salary_slip(source_name, target_doc = None, employee = None, as_print = False, print_format = None):
|
||||
def postprocess(source, target):
|
||||
|
||||
Reference in New Issue
Block a user