import math
def tax_calc_old_regime(income):
if income <= 500000:
tax = 0
elif income <= 1000000:
tax = (income - 500000) * 0.2 + 12500 # 10% on income above 10K
elif income <= 5000000:
tax = (income-1000000) * 0.3 + 112500 # 20% on income above 20K, plus tax on 10K of income below 20K
elif income <= 10000000:
tax = ((income-1000000) * 0.3 + 112500 ) * 1.10 # 10% Surcharge on income above 50 lakhs
elif income <= 20000000: # 15% Surcharge on income above 1cr upto 2 cr
tax = ((income-1000000) * 0.3 + 112500 ) * 1.15
elif income <= 50000000: # 25% Surcharge on income above 2cr upto 5cr
tax = ((income-1000000) * 0.3 + 112500 ) * 1.25
else:
tax = ((income-1000000) * 0.3 + 112500 ) * 1.37 # 37% Surcharge on income above 5cr
return tax
# Tax Calculation in India (New Tax Regime)
def tax_calc_new_regime(income):
if income <= 300000:
tax = 0
elif income <= 600000:
tax = (income - 300000)*0.05 # 5% tax above 3LPA upto 6 LPA
elif income <= 900000:
tax = (income - 600000)*0.1 + 15000 # 10% on income above 6 LPA upto 9 LPA
elif income <= 1200000:
tax = (income - 900000)*0.15 + 45000 # 15% on income from 9 LPA upto 12 LPA
elif income <= 1500000:
tax = (income - 1200000)*0.2 + 90000 # 20% on income from 12 LPA upto 15 LPA
else:
tax = (income - 1500000)*0.3 + 150000 # 30% on income above 15 LPA
if income <= 700000:
tax = 0
# Add surcharge based on income range
if income <= 5000000:
surcharge_rate = 0
elif income <= 10000000:
surcharge_rate = 0.1 # 10% Surcharge on income above 50 lakhs
elif income <= 20000000:
surcharge_rate = 0.15 # 15% Surcharge on income above 1cr upto 2 cr
else:
surcharge_rate = 0.25 # 25% Surcharge on income above 2cr
surcharge = tax * surcharge_rate
total_tax = tax + surcharge
return total_tax
def deduction_old_regime(location, basic_salary, dearness_allownces, hra, hra_actual, special_allowance, pf_deduction, deduction_80c, pt_deduction, deduction_80d, deduction_NPS, deduction_80G, deduction_interest_on_loan):
standard_deduction = 50000
if location == "Metro":
hra_final = max(0,math.ceil(min(0.5 * (basic_salary+dearness_allownces), hra ,(hra_actual - 0.1*(basic_salary+dearness_allownces)))))
else:
hra_final = max(0,math.ceil(min(0.4*( basic_salary+dearness_allownces), hra , (hra_actual - 0.1*(basic_salary+dearness_allownces)))))
taxable_income = basic_salary + hra +dearness_allownces + special_allowance - pf_deduction - pt_deduction-deduction_80d - deduction_NPS - deduction_80G - deduction_interest_on_loan - standard_deduction- hra_final - deduction_80c
total_tax = tax_calc_old_regime(taxable_income)
final_tax = math.ceil(total_tax) * 1.04
return final_tax
def deduction_new_regime(basic_salary, dearness_allownces, hra, special_allowance):
standard_deduction = 50000
taxable_income = basic_salary + hra +dearness_allownces + special_allowance - standard_deduction
total_tax = tax_calc_new_regime(taxable_income)
final_tax = math.ceil(total_tax) * 1.04
return final_tax
def tax_calculation(location, basic_salary, dearness_allownces, hra, hra_actual, special_allowance, pf_deduction, deduction_80c, pt_deduction, deduction_80d, deduction_NPS, deduction_80G, deduction_interest_on_loan, total_income):
if total_income != 0:
# If all the values are 0, then we can assume that the user has not entered any values
basic_salary = total_income
if dearness_allownces == 0 and hra == 0 and hra_actual == 0 and special_allowance == 0 and pf_deduction == 0 and deduction_80c == 0 and deduction_80d == 0 and deduction_NPS == 0 and deduction_80G == 0 and deduction_interest_on_loan == 0:
tax_new_regime = deduction_new_regime(total_income, dearness_allownces, hra, special_allowance)
response = f"Tax Calculation in India under New Tax Regime (FY 2023-24(AY 2024-25)) for your total yearly income {total_income} is: {tax_new_regime} INR"
response_2 = """To get more detailed tax calculation under Tax Regime (FY 2023-24(AY 2024-25)), please provide the following details:
Basic Salary, Location(Metro or Non-Metro), Dearness Allowances, HRA Received(HRA Recieved from Comapny), HRA Actual (Actual rent paid), Special Allowance, PF Deduction, Deduction under 80C ((like ELSS, PPF, etc.) Max limit 1.5 lakhs.), PT Deduction, Deduction under 80D(Medical insurance premium paid, Max Limit 25K), NPS Deduction, Deduction under 80G (Donations made to charitable institutions), Interest on Loan Deduction (Max Limit 2 Lakh)"""
final_response = response + "\n\n" + response_2
return final_response
else:
tax_old_regime = deduction_old_regime(location, basic_salary, dearness_allownces, hra, hra_actual, special_allowance, pf_deduction, deduction_80c, pt_deduction, deduction_80d, deduction_NPS, deduction_80G, deduction_interest_on_loan)
tax_new_regime = deduction_new_regime(basic_salary, dearness_allownces, hra, special_allowance)
response = f"Tax Calculation in India (Old Tax Regime (FY 2023-24(AY 2024-25)): {tax_old_regime} INR\nTax Calculation in India (New Tax Regime (FY 2023-24(AY 2024-25)): {tax_new_regime} INR"
return response
elif basic_salary != 0:
if dearness_allownces == 0 and hra == 0 and hra_actual == 0 and special_allowance == 0 and pf_deduction == 0 and deduction_80c == 0 and pt_deduction == 0 and deduction_80d == 0 and deduction_NPS == 0 and deduction_80G == 0 and deduction_interest_on_loan == 0:
tax_new_regime = deduction_new_regime(total_income, dearness_allownces, hra, special_allowance)
response = f"Tax Calculation in India under New Tax Regime (FY 2023-24(AY 2024-25)) for your total yearly income {basic_salary} is: {tax_new_regime} INR"
response_2 = """To get more detailed tax calculation under Tax Regime (FY 2023-24(AY 2024-25)), please provide the following details:
Basic Salary, Location(Metro or Non-Metro), Dearness Allowances, HRA Received(HRA Recieved from Comapny), HRA Actual (Actual rent paid), Special Allowance, PF Deduction, Deduction under 80C ((like ELSS, PPF, etc.) Max limit 1.5 lakhs.), PT Deduction, Deduction under 80D(Medical insurance premium paid, Max Limit 25K), NPS Deduction, Deduction under 80G (Donations made to charitable institutions), Interest on Loan Deduction (Max Limit 2 Lakh)"""
final_response = response + "\n\n" + response_2
return final_response
else:
tax_old_regime = deduction_old_regime(location, basic_salary, dearness_allownces, hra, hra_actual, special_allowance, pf_deduction, deduction_80c, pt_deduction, deduction_80d, deduction_NPS, deduction_80G, deduction_interest_on_loan)
tax_new_regime = deduction_new_regime(basic_salary, dearness_allownces, hra, special_allowance)
response = f"Tax Calculation in India (Old Tax Regime (FY 2023-24(AY 2024-25)): {tax_old_regime} INR\nTax Calculation in India (New Tax Regime (FY 2023-24(AY 2024-25)): {tax_new_regime} INR"
return response
# If apart from basic_salary all other values are 0, then we can assume that the user has not entered any values
elif basic_salary == 0 and total_income == 0:
response = """To get detailed tax calculation under New and Old Tax Regime (FY 2023-24(AY 2024-25)), please provide the following details:
1. **Basic Salary**
2. **Location(Metro or Non-Metro)**
3. **Dearness Allowances**
4. **HRA Received(HRA Recieved from Comapny)**
5. **HRA Actual (Actual rent paid)**
6. **Special Allowance**
7. **PF Deduction**
8. **Deduction under 80C ((like ELSS, PPF, etc.) Max limit 1.5 lakhs.)**
9. **PT Deduction**
10. **Deduction under 80D**(Medical insurance premium paid, Max Limit 25K)
11. **NPS Deduction**
12. **Deduction under 80G (Donations made to charitable institutions)**
13. **Interest on Loan Deduction (Max Limit 2 Lakh)**
Providing these details will help us in accurately calculating your tax liability."""
return response
elif basic_salary == 0 and dearness_allownces == 0 and hra == 0 and hra_actual == 0 and special_allowance == 0 and pf_deduction == 0 and deduction_80c == 0 and deduction_80d == 0 and deduction_NPS == 0 and deduction_80G == 0 and deduction_interest_on_loan == 0:
response = """To get more detailed tax calculation under New and Old Tax Regime Tax Regime (FY 2023-24(AY 2024-25)), please provide the following details:
1. **Basic Salary**
2. **Location(Metro or Non-Metro)**
3. **Dearness Allowances**
4. **HRA Received(HRA Recieved from Comapny)**
5. **HRA Actual (Actual rent paid)**
6. **Special Allowance**
7. **PF Deduction**
8. **Deduction under 80C ((like ELSS, PPF, etc.) Max limit 1.5 lakhs.)**
9. **PT Deduction**
10. **Deduction under 80D**(Medical insurance premium paid, Max Limit 25K)
11. **NPS Deduction**
12. **Deduction under 80G (Donations made to charitable institutions)**
13. **Interest on Loan Deduction (Max Limit 2 Lakh)**
Providing these details will help us in accurately calculating your tax liability."""
# tax_new_regime = deduction_new_regime(basic_salary, dearness_allownces, hra, special_allowance)
# response_2 = f"Tax Calculation in India under New Tax Regime (FY 2023-24(AY 2024-25)) for your total yearly income {basic_salary} is: {tax_new_regime} INR"
# final_response = response_2 + "\n" + response
return response
# return final_response
else:
tax_old_regime = deduction_old_regime(location, basic_salary, dearness_allownces, hra, hra_actual, special_allowance, pf_deduction, deduction_80c, pt_deduction, deduction_80d, deduction_NPS, deduction_80G, deduction_interest_on_loan)
tax_new_regime = deduction_new_regime(basic_salary, dearness_allownces, hra, special_allowance)
response = f"Tax Calculation in India (Old Tax Regime (FY 2023-24(AY 2024-25)): {tax_old_regime} INR\nTax Calculation in India (New Tax Regime (FY 2023-24(AY 2024-25)): {tax_new_regime} INR"
return response
## Tax Calculation in India (Old Tax Regime)
location = "Metro" # Metro or Non-Metro
basic_salary = 1000000 # Basic Salary throughout the year
dearness_allownces = 125000 # Dearness Allowances throughout the year
hra = 125000 # HRA throughout the year (HRA Recieved from Company)
hra_actual = 0 # HRA throughout the year (Actual Rent Paid)
special_allowance = 0 # Special Allowance throughout the year
pf_deduction = 25000 # PF Deduction throughout the year
deduction_80c = 10000 # 80C Deduction (Max limit 1.5L)
pt_deduction = 50000 # Professional Tax Deduction
deduction_80d = 0 # 80D Deduction (Max limit 25K)
deduction_NPS = 40000 # NPS Deduction (Max limit 2L) (This means that you can invest up to Rs. 2 lakhs in an NPS Tier 1 account and claim the full amount as a deduction, i.e., Rs. 1.50 lakh under Section 80CCD(1) and Rs. 50,000 under Section 80CCD(2) (1B))
deduction_interest_on_loan = 0 # Interest on Loan Deduction (Max limit 2L)
deduction_80G = 0 # The deduction under Section 80G can be claimed on the amount donated to eligible institutions or funds up to a maximum of 50% or 100% of the donated amount, depending on the institution or fund to which the donation has been made.
# print(f"Income Tax for an annual income with exemptions is: {deduction_old_regime(location, basic_salary, dearness_allownces, hra, hra_actual, special_allowance, pf_deduction, deduction_80c, pt_deduction, deduction_80d, deduction_NPS, deduction_80G, deduction_interest_on_loan)} INR")
### Tax Calculation in India (New Tax Regime)
hra = 0 # min_value=0,max_value = int(0.5*basic_salary1)
basic_salary = 1500000
dearness_allownces = 0
special_allowance = 0
# print(tax_calculation(location, basic_salary, dearness_allownces, hra, hra_actual, special_allowance, pf_deduction, deduction_80c, pt_deduction, deduction_80d, deduction_NPS, deduction_80G, deduction_interest_on_loan, total_income=0))