From 49446ba760f7cae69a5d38ed99bfb50eb82fedb2 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 25 Apr 2019 19:54:20 +0530 Subject: [PATCH] fix: test cases --- .../employee_tax_exemption_declaration.py | 2 +- erpnext/hr/utils.py | 1 - erpnext/regional/india/utils.py | 15 ++++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py index f3449d441b..99ad18fc72 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.py @@ -41,7 +41,7 @@ class EmployeeTaxExemptionDeclaration(Document): def calculate_hra_exemption(self): self.salary_structure_hra, self.annual_hra_exemption, self.monthly_hra_exemption = 0, 0, 0 - if self.monthly_house_rent: + if self.get("monthly_house_rent"): hra_exemption = calculate_annual_eligible_hra_exemption(self) if hra_exemption: self.total_exemption_amount += hra_exemption["annual_exemption"] diff --git a/erpnext/hr/utils.py b/erpnext/hr/utils.py index 23bd0c89ca..a600e75884 100644 --- a/erpnext/hr/utils.py +++ b/erpnext/hr/utils.py @@ -227,7 +227,6 @@ def validate_tax_declaration(declarations): subcategories.append(d.exemption_sub_category) def get_total_exemption_amount(declarations): - exemption_category = list(set([d.exemption_category for d in declarations])) exemptions = frappe._dict() for d in declarations: exemptions.setdefault(d.exemption_category, frappe._dict()) diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py index a84638577d..f413a8ed4d 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals import frappe, re from frappe import _ -from frappe.utils import cstr, flt, date_diff, getdate, nowdate +from frappe.utils import cstr, flt, date_diff, nowdate from erpnext.regional.india import states, state_numbers from erpnext.controllers.taxes_and_totals import get_itemised_tax, get_itemised_taxable_amount from erpnext.controllers.accounts_controller import get_taxes_and_charges @@ -231,12 +231,17 @@ def validate_house_rent_dates(doc): select name from `tabEmployee Tax Exemption Proof Submission` where - docstatus=1 and employee='{0}' and payroll_period='{1}' - and (rented_from_date between '{2}' and '{3}' or rented_to_date between '{2}' and '{3}') - """.format(doc.employee, doc.payroll_period, doc.rented_from_date, doc.rented_to_date)) + docstatus=1 and employee=%(employee)s and payroll_period=%(payroll_period)s + and (rented_from_date between %(from_date)s and %(to_date)s or rented_to_date between %(from_date)s and %(to_date)s) + """, { + "employee": doc.employee, + "payroll_period": doc.payroll_period, + "from_date": doc.rented_from_date, + "to_date": doc.rented_to_date + }) if proofs: - frappe.throw(_("House rent paid days overlap with {0}").format(proofs[0][0])) + frappe.throw(_("House rent paid days overlapping with {0}").format(proofs[0][0])) def calculate_hra_exemption_for_period(doc): monthly_rent, eligible_hra = 0, 0