refator: Payroll processing and tax calculation (#17617)

* refactor: Payroll processing and tax calculation

* fix: payroll test cases

* fix: Codacy fixes

* fix: payroll test cases

* fix: removed unwanted code
This commit is contained in:
Nabin Hait
2019-05-16 11:23:04 +05:30
committed by GitHub
parent 0e31089af6
commit 6b9d64ce1d
29 changed files with 2866 additions and 2788 deletions

View File

@@ -146,11 +146,9 @@ def calculate_annual_eligible_hra_exemption(doc):
hra_component = frappe.get_cached_value('Company', doc.company, "hra_component")
if not (basic_component and hra_component):
frappe.throw(_("Please mention Basic and HRA component in Company"))
annual_exemption, monthly_exemption, hra_amount = 0, 0, 0
if hra_component and basic_component:
assignment = get_salary_assignment(doc.employee, nowdate())
if assignment:
hra_component_exists = frappe.db.exists("Salary Detail", {
"parent": assignment.salary_structure,
@@ -158,18 +156,19 @@ def calculate_annual_eligible_hra_exemption(doc):
"parentfield": "earnings",
"parenttype": "Salary Structure"
})
if hra_component_exists:
basic_amount, hra_amount = get_component_amt_from_salary_slip(doc.employee,
assignment.salary_structure, basic_component, hra_component)
if hra_amount:
if doc.monthly_house_rent:
annual_exemption = calculate_hra_exemption(assignment.salary_structure,
basic_amount, hra_amount, doc.monthly_house_rent,
doc.rented_in_metro_city)
basic_amount, hra_amount, doc.monthly_house_rent, doc.rented_in_metro_city)
if annual_exemption > 0:
monthly_exemption = annual_exemption / 12
else:
annual_exemption = 0
elif doc.docstatus == 1:
frappe.throw(_("Salary Structure must be submitted before submission of Tax Ememption Declaration"))
@@ -180,7 +179,7 @@ def calculate_annual_eligible_hra_exemption(doc):
})
def get_component_amt_from_salary_slip(employee, salary_structure, basic_component, hra_component):
salary_slip = make_salary_slip(salary_structure, employee=employee)
salary_slip = make_salary_slip(salary_structure, employee=employee, for_preview=1)
basic_amt, hra_amt = 0, 0
for earning in salary_slip.earnings:
if earning.salary_component == basic_component: