[Fix] Additional Salary Component and tax calculation (#14581)

* Additional salary not include in tax calculation

* Additional salary get doubled in salary slip via Payroll Entry - Fix

* Salary Component - if is_additional_component hide flexi
This commit is contained in:
Jamsheer 2018-06-20 10:52:20 +05:30 committed by Nabin Hait
parent 222c550c29
commit c526cad183
3 changed files with 13 additions and 16 deletions

View File

@ -64,6 +64,8 @@ def get_additional_salary_component(employee, start_date, end_date):
struct_row['salary_component'] = salary_component.name struct_row['salary_component'] = salary_component.name
struct_row['abbr'] = salary_component.salary_component_abbr struct_row['abbr'] = salary_component.salary_component_abbr
struct_row['do_not_include_in_total'] = salary_component.do_not_include_in_total struct_row['do_not_include_in_total'] = salary_component.do_not_include_in_total
struct_row['is_tax_applicable'] = salary_component.is_tax_applicable
struct_row['variable_based_on_taxable_salary'] = salary_component.variable_based_on_taxable_salary
additional_components_dict['amount'] = amount additional_components_dict['amount'] = amount
additional_components_dict['struct_row'] = struct_row additional_components_dict['struct_row'] = struct_row
additional_components_dict['type'] = salary_component.type additional_components_dict['type'] = salary_component.type

View File

@ -410,7 +410,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.type==\"Earning\"", "depends_on": "eval:doc.type==\"Earning\" && doc.is_additional_component != 1",
"fieldname": "flexible_benefits", "fieldname": "flexible_benefits",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@ -1002,7 +1002,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2018-06-12 12:09:14.420657", "modified": "2018-06-19 11:37:27.521796",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Salary Component", "name": "Salary Component",

View File

@ -63,27 +63,29 @@ class SalarySlip(TransactionBase):
for key in ('earnings', 'deductions'): for key in ('earnings', 'deductions'):
for struct_row in self._salary_structure_doc.get(key): for struct_row in self._salary_structure_doc.get(key):
amount = self.eval_condition_and_formula(struct_row, data) amount = self.eval_condition_and_formula(struct_row, data)
if amount and struct_row.statistical_component == 0: if amount and struct_row.statistical_component == 0 and struct_row.variable_based_on_taxable_salary != 1:
self.update_component_row(struct_row, amount, key) self.update_component_row(struct_row, amount, key)
if key=="earnings" and struct_row.is_flexible_benefit == 1: if key=="earnings" and struct_row.is_flexible_benefit == 1:
self.add_employee_flexi_benefits(struct_row) self.add_employee_flexi_benefits(struct_row)
if key=="deductions" and struct_row.variable_based_on_taxable_salary:
tax_row, amount = self.calculate_variable_based_on_taxable_salary(struct_row.salary_component)
if tax_row and amount:
self.update_component_row(frappe._dict(tax_row), amount, key)
additional_components = get_additional_salary_component(self.employee, self.start_date, self.end_date) additional_components = get_additional_salary_component(self.employee, self.start_date, self.end_date)
if additional_components: if additional_components:
for additional_component in additional_components: for additional_component in additional_components:
additional_component = frappe._dict(additional_component) additional_component = frappe._dict(additional_component)
amount = additional_component.amount + self.get_amount_from_exisiting_component(frappe._dict(additional_component.struct_row).salary_component) amount = additional_component.amount
key = "earnings" key = "earnings"
if additional_component.type == "Deduction": if additional_component.type == "Deduction":
key = "deductions" key = "deductions"
self.update_component_row(frappe._dict(additional_component.struct_row), amount, key) self.update_component_row(frappe._dict(additional_component.struct_row), amount, key)
# Calculate variable_based_on_taxable_salary after all components updated in salary slip
for struct_row in self._salary_structure_doc.get("deductions"):
if struct_row.variable_based_on_taxable_salary == 1:
tax_row, amount = self.calculate_variable_based_on_taxable_salary(struct_row.salary_component)
if tax_row and amount:
self.update_component_row(frappe._dict(tax_row), amount, "deductions")
def add_employee_flexi_benefits(self, struct_row): def add_employee_flexi_benefits(self, struct_row):
if frappe.db.get_value("Salary Component", struct_row.salary_component, "is_pro_rata_applicable") == 1: if frappe.db.get_value("Salary Component", struct_row.salary_component, "is_pro_rata_applicable") == 1:
benefit_component_amount = get_benefit_component_amount(self.employee, self.start_date, self.end_date, struct_row, self._salary_structure_doc, self.payment_days, self.total_working_days) benefit_component_amount = get_benefit_component_amount(self.employee, self.start_date, self.end_date, struct_row, self._salary_structure_doc, self.payment_days, self.total_working_days)
@ -94,13 +96,6 @@ class SalarySlip(TransactionBase):
if benefit_claim_amount: if benefit_claim_amount:
self.update_component_row(struct_row, benefit_claim_amount, "earnings") self.update_component_row(struct_row, benefit_claim_amount, "earnings")
def get_amount_from_exisiting_component(self, salary_component):
amount = 0
for d in self.get("earnings"):
if d.salary_component == salary_component:
amount = d.amount
return amount
def update_component_row(self, struct_row, amount, key): def update_component_row(self, struct_row, amount, key):
component_row = None component_row = None
for d in self.get(key): for d in self.get(key):