test: set country to India before running regional tests
diff --git a/erpnext/payroll/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py b/erpnext/payroll/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py
index e158cc3..6741854 100644
--- a/erpnext/payroll/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py
+++ b/erpnext/payroll/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py
@@ -116,6 +116,10 @@
self.assertEqual(declaration.total_exemption_amount, 100000)
def test_india_hra_exemption(self):
+ # set country
+ current_country = frappe.flags.country
+ frappe.flags.country = "India"
+
setup_hra_exemption_prerequisites("Monthly")
employee = frappe.get_value("Employee", {"user_id": "employee@taxexemption.com"}, "name")
@@ -124,7 +128,7 @@
"doctype": "Employee Tax Exemption Declaration",
"employee": employee,
"company": "_Test Company",
- "payroll_period": "_Test Payroll Period 1",
+ "payroll_period": "_Test Payroll Period",
"currency": "INR",
"monthly_house_rent": 50000,
"rented_in_metro_city": 1,
@@ -150,7 +154,14 @@
# 100000 Standard Exemption + 36000 HRA exemption
self.assertEqual(declaration.total_exemption_amount, 136000)
+ # reset
+ frappe.flags.country = current_country
+
def test_india_hra_exemption_with_daily_payroll_frequency(self):
+ # set country
+ current_country = frappe.flags.country
+ frappe.flags.country = "India"
+
setup_hra_exemption_prerequisites("Daily")
employee = frappe.get_value("Employee", {"user_id": "employee@taxexemption.com"}, "name")
@@ -159,7 +170,7 @@
"doctype": "Employee Tax Exemption Declaration",
"employee": employee,
"company": "_Test Company",
- "payroll_period": "_Test Payroll Period 1",
+ "payroll_period": "_Test Payroll Period",
"currency": "INR",
"monthly_house_rent": 170000,
"rented_in_metro_city": 1,
@@ -180,7 +191,14 @@
# 50000 Standard Exemption + 215000 HRA exemption
self.assertEqual(declaration.total_exemption_amount, 265000)
+ # reset
+ frappe.flags.country = current_country
+
def test_india_hra_exemption_with_weekly_payroll_frequency(self):
+ # set country
+ current_country = frappe.flags.country
+ frappe.flags.country = "India"
+
setup_hra_exemption_prerequisites("Weekly")
employee = frappe.get_value("Employee", {"user_id": "employee@taxexemption.com"}, "name")
@@ -189,7 +207,7 @@
"doctype": "Employee Tax Exemption Declaration",
"employee": employee,
"company": "_Test Company",
- "payroll_period": "_Test Payroll Period 1",
+ "payroll_period": "_Test Payroll Period",
"currency": "INR",
"monthly_house_rent": 170000,
"rented_in_metro_city": 1,
@@ -210,7 +228,14 @@
# 50000 Standard Exemption + 156000 HRA exemption
self.assertEqual(declaration.total_exemption_amount, 206000)
+ # reset
+ frappe.flags.country = current_country
+
def test_india_hra_exemption_with_fortnightly_payroll_frequency(self):
+ # set country
+ current_country = frappe.flags.country
+ frappe.flags.country = "India"
+
setup_hra_exemption_prerequisites("Fortnightly")
employee = frappe.get_value("Employee", {"user_id": "employee@taxexemption.com"}, "name")
@@ -219,7 +244,7 @@
"doctype": "Employee Tax Exemption Declaration",
"employee": employee,
"company": "_Test Company",
- "payroll_period": "_Test Payroll Period 1",
+ "payroll_period": "_Test Payroll Period",
"currency": "INR",
"monthly_house_rent": 170000,
"rented_in_metro_city": 1,
@@ -240,7 +265,14 @@
# 50000 Standard Exemption + 78000 HRA exemption
self.assertEqual(declaration.total_exemption_amount, 128000)
+ # reset
+ frappe.flags.country = current_country
+
def test_india_hra_exemption_with_bimonthly_payroll_frequency(self):
+ # set country
+ current_country = frappe.flags.country
+ frappe.flags.country = "India"
+
setup_hra_exemption_prerequisites("Bimonthly")
employee = frappe.get_value("Employee", {"user_id": "employee@taxexemption.com"}, "name")
@@ -249,7 +281,7 @@
"doctype": "Employee Tax Exemption Declaration",
"employee": employee,
"company": "_Test Company",
- "payroll_period": "_Test Payroll Period 1",
+ "payroll_period": "_Test Payroll Period",
"currency": "INR",
"monthly_house_rent": 50000,
"rented_in_metro_city": 1,
@@ -275,6 +307,9 @@
# 100000 Standard Exemption + 18000 HRA exemption
self.assertEqual(declaration.total_exemption_amount, 118000)
+ # reset
+ frappe.flags.country = current_country
+
def test_india_hra_exemption_with_multiple_salary_structure_assignments(self):
from erpnext.payroll.doctype.salary_slip.test_salary_slip import create_tax_slab
from erpnext.payroll.doctype.salary_structure.test_salary_structure import (
@@ -282,8 +317,12 @@
make_salary_structure,
)
+ # set country
+ current_country = frappe.flags.country
+ frappe.flags.country = "India"
+
employee = make_employee("employee@taxexemption2.com", company="_Test Company")
- payroll_period = create_payroll_period(name="_Test Payroll Period 1", company="_Test Company")
+ payroll_period = create_payroll_period(name="_Test Payroll Period", company="_Test Company")
create_tax_slab(
payroll_period,
@@ -365,6 +404,9 @@
# 50000 Standard Exemption + 102000 HRA exemption
self.assertEqual(declaration.total_exemption_amount, 152000)
+ # reset
+ frappe.flags.country = current_country
+
def create_payroll_period(**args):
args = frappe._dict(args)
@@ -422,7 +464,7 @@
from erpnext.payroll.doctype.salary_slip.test_salary_slip import create_tax_slab
from erpnext.payroll.doctype.salary_structure.test_salary_structure import make_salary_structure
- payroll_period = create_payroll_period(name="_Test Payroll Period 1", company="_Test Company")
+ payroll_period = create_payroll_period(name="_Test Payroll Period", company="_Test Company")
create_tax_slab(
payroll_period,
diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py
index 5bbd686..ee48ccb 100644
--- a/erpnext/regional/india/utils.py
+++ b/erpnext/regional/india/utils.py
@@ -369,6 +369,7 @@
basic_component, hra_component = frappe.db.get_value(
"Company", doc.company, ["basic_component", "hra_component"]
)
+
if not (basic_component and hra_component):
frappe.throw(
_("Please set Basic and HRA component in Company {0}").format(