From c114ceb67dd48796a41ff6f5c38c9db134c6f2ec Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 29 Jun 2018 14:35:58 +0530 Subject: [PATCH] Set salary component properties in existing components and salary structures --- .../hr/doctype/salary_structure/salary_structure.py | 7 +++---- .../v11_0/set_salary_component_properties.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 erpnext/patches/v11_0/set_salary_component_properties.py diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py index 9fec4738fe..48d67fc598 100644 --- a/erpnext/hr/doctype/salary_structure/salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/salary_structure.py @@ -38,15 +38,14 @@ class SalaryStructure(Document): 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: + if have_a_flexi and flt(self.max_benefits) == 0: frappe.throw(_("Max benefits should be greater than zero to dispense benefits")) - if have_a_flexi and self.max_benefits > flexi_amount: + if have_a_flexi and flt(self.max_benefits) > flexi_amount: frappe.throw(_("Total flexible benefit 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: + if not have_a_flexi and flt(self.max_benefits) > 0: frappe.throw(_("Salary Structure should have flexible benefit component(s) to dispense benefit amount")) - @frappe.whitelist() def make_salary_slip(source_name, target_doc = None, employee = None, as_print = False, print_format = None): def postprocess(source, target): diff --git a/erpnext/patches/v11_0/set_salary_component_properties.py b/erpnext/patches/v11_0/set_salary_component_properties.py new file mode 100644 index 0000000000..8cc3a330b1 --- /dev/null +++ b/erpnext/patches/v11_0/set_salary_component_properties.py @@ -0,0 +1,13 @@ +import frappe + +def execute(): + frappe.db.sql("update `tabSalary Component` set is_payable=1, is_tax_applicable=1 where type='Earning'") + frappe.db.sql("update `tabSalary Component` set is_payable=0 where type='Deduction'") + + frappe.db.sql("""update `tabSalary Component` set variable_based_on_taxable_salary=1 + where type='Deduction' and name in ('TDS', 'Tax Deducted at Source')""") + + frappe.db.sql("""update `tabSalary Detail` set is_tax_applicable=1 + where parentfield='earnings' and statistical_component=0""") + frappe.db.sql("""update `tabSalary Detail` set variable_based_on_taxable_salary=1 + where parentfield='deductions' and salary_component in ('TDS', 'Tax Deducted at Source')""") \ No newline at end of file