Set salary component properties in existing components and salary structures

This commit is contained in:
Nabin Hait 2018-06-29 14:35:58 +05:30
parent f184e35a4a
commit c114ceb67d
2 changed files with 16 additions and 4 deletions

View File

@ -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):

View File

@ -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')""")