Salary Structure - validate flexi with max benefit
This commit is contained in:
parent
65a5e47e68
commit
9d5d328a4f
@ -238,6 +238,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.is_flexible_benefit != 1",
|
||||
"fieldname": "section_break_2",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@ -566,7 +567,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-05-17 12:43:22.606298",
|
||||
"modified": "2018-05-22 15:11:02.341840",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Salary Detail",
|
||||
@ -581,4 +582,4 @@
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 0,
|
||||
"track_seen": 0
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,15 @@ class SalaryStructure(Document):
|
||||
|
||||
def validate_max_benefits_with_flexi(self):
|
||||
have_a_flexi = False
|
||||
if self.max_benefits > 0 and self.earnings:
|
||||
if 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 have_a_flexi and self.max_benefits == 0:
|
||||
frappe.throw(_("Max benefits should be greater than zero to despense flexi"))
|
||||
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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user