mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-30 02:14:48 +00:00
Salary Structure - validate flexi with max benefit
This commit is contained in:
@@ -238,6 +238,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"depends_on": "eval:doc.is_flexible_benefit != 1",
|
||||||
"fieldname": "section_break_2",
|
"fieldname": "section_break_2",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@@ -566,7 +567,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-05-17 12:43:22.606298",
|
"modified": "2018-05-22 15:11:02.341840",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "Salary Detail",
|
"name": "Salary Detail",
|
||||||
|
|||||||
@@ -31,13 +31,15 @@ class SalaryStructure(Document):
|
|||||||
|
|
||||||
def validate_max_benefits_with_flexi(self):
|
def validate_max_benefits_with_flexi(self):
|
||||||
have_a_flexi = False
|
have_a_flexi = False
|
||||||
if self.max_benefits > 0 and self.earnings:
|
if self.earnings:
|
||||||
flexi_amount = 0
|
flexi_amount = 0
|
||||||
for earning_component in self.earnings:
|
for earning_component in self.earnings:
|
||||||
if earning_component.is_flexible_benefit == 1:
|
if earning_component.is_flexible_benefit == 1:
|
||||||
have_a_flexi = True
|
have_a_flexi = True
|
||||||
max_of_component = frappe.db.get_value("Salary Component", earning_component.salary_component, "max_benefit_amount")
|
max_of_component = frappe.db.get_value("Salary Component", earning_component.salary_component, "max_benefit_amount")
|
||||||
flexi_amount += max_of_component
|
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:
|
if self.max_benefits > flexi_amount:
|
||||||
frappe.throw(_("Total flexi component amount {0} should not be less \
|
frappe.throw(_("Total flexi component amount {0} should not be less \
|
||||||
than max benefits {1}").format(flexi_amount, self.max_benefits))
|
than max benefits {1}").format(flexi_amount, self.max_benefits))
|
||||||
|
|||||||
Reference in New Issue
Block a user