Last active
February 2, 2025 06:56
-
-
Save faizsiddiqui/b3163e05f21a2d288d637d484ed173f2 to your computer and use it in GitHub Desktop.
Basic Tax Calculation (IN)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
def cal_taxable_income(income, deductions, regime): | |
taxable_income = income | |
if regime == 'old': | |
taxable_income -= deductions | |
return taxable_income | |
def income_tax_calculator(income, deductions, rules, regime): | |
taxable_income = cal_taxable_income(income, deductions, regime) | |
print(f'{"*" * 5}\tIncome\t\t: {income}\t{"*" * 5}') | |
print(f'{"*" * 5}\tDeductions\t: {deductions}\t{"*" * 5}') | |
print(f'{"*" * 5}\tTaxable\t\t: {taxable_income}\t{"*" * 5}') | |
_tax = 0 | |
for _key, rule in rules.items(): | |
if taxable_income <= rule["start"]: break | |
if taxable_income <= rule["end"]: | |
rule["end"] = taxable_income | |
print(f'\n{"*" * 5} Rule {_key + 1} : Start = {rule["start"]} | End = {rule["end"]} | Tax = {rule["tax"] * 100}% {"*" * 5}') | |
_tax += ((rule["end"] - rule["start"]) * rule["tax"]) | |
print(f'{"*" * 5}\tTax : {_tax}') | |
net_income = taxable_income - _tax | |
if regime == 'old': | |
net_income += deductions | |
print(f'\n{"*" * 8}\tNet Income : {net_income}\t{"*" * 5}') | |
print(f'{"*" * 8}\tTotal Tax : {_tax}\t{"*" * 5}') | |
income = float(input('Enter total yearly income : ')) | |
deductions = float(input('Enter total yearly deduction : ')) | |
## Rules ## | |
slab_rules_19_20 = { | |
0: { | |
'start': 0, | |
'end': 250000, | |
'tax': 0 | |
}, | |
1: { | |
'start': 250000, | |
'end': 500000, | |
'tax': 0.05 | |
}, | |
2: { | |
'start': 500000, | |
'end': 1000000, | |
'tax': 0.20 | |
}, | |
3: { | |
'start': 1000000, | |
'end': cal_taxable_income(income, deductions, 'old'), | |
'tax': 0.30 | |
} | |
} | |
## New Regime Rules ## | |
slab_rules_fy_20_21 = { | |
0: { | |
'start': 0, | |
'end': 500000, | |
'tax': 0 | |
}, | |
1: { | |
'start': 500000, | |
'end': 750000, | |
'tax': 0.10 | |
}, | |
2: { | |
'start': 750000, | |
'end': 1000000, | |
'tax': 0.15 | |
}, | |
3: { | |
'start': 1000000, | |
'end': 1250000, | |
'tax': 0.20 | |
}, | |
4: { | |
'start': 1250000, | |
'end': 1500000, | |
'tax': 0.25 | |
}, | |
5: { | |
'start': 1500000, | |
'end': cal_taxable_income(income, deductions, 'new'), | |
'tax': 0.30 | |
} | |
} | |
slab_rules_fy_24_25 = { | |
0: { | |
'start': 0, | |
'end': 300000, | |
'tax': 0 | |
}, | |
1: { | |
'start': 300000, | |
'end': 600000, | |
'tax': 0.05 | |
}, | |
2: { | |
'start': 600000, | |
'end': 900000, | |
'tax': 0.10 | |
}, | |
3: { | |
'start': 900000, | |
'end': 1200000, | |
'tax': 0.15 | |
}, | |
4: { | |
'start': 1200000, | |
'end': 1500000, | |
'tax': 0.20 | |
}, | |
5: { | |
'start': 1500000, | |
'end': cal_taxable_income(income, deductions, 'new'), | |
'tax': 0.30 | |
} | |
} | |
slab_rules_fy_25_26 = { | |
0: { | |
'start': 0, | |
'end': 400000, | |
'tax': 0 | |
}, | |
1: { | |
'start': 400000, | |
'end': 800000, | |
'tax': 0.05 | |
}, | |
2: { | |
'start': 800000, | |
'end': 1200000, | |
'tax': 0.10 | |
}, | |
3: { | |
'start': 1200000, | |
'end': 1600000, | |
'tax': 0.15 | |
}, | |
4: { | |
'start': 1600000, | |
'end': 2000000, | |
'tax': 0.20 | |
}, | |
5: { | |
'start': 2000000, | |
'end': 2400000, | |
'tax': 0.25 | |
}, | |
6: { | |
'start': 2400000, | |
'end': cal_taxable_income(income, deductions, 'new'), | |
'tax': 0.30 | |
} | |
} | |
print(f'\n{"*" * 10} Old Regime {"*" * 10}') | |
income_tax_calculator(income, deductions, slab_rules_19_20, 'old') # Old Regime | |
print(f'\n{"*" * 10} New Regime FY24-25 {"*" * 10}') | |
income_tax_calculator(income, deductions, slab_rules_fy_24_25, 'new') # No deduction available in New Regime | |
print(f'\n{"*" * 10} New Regime FY25-26 {"*" * 10}') | |
income_tax_calculator(income, deductions, slab_rules_fy_25_26, 'new') # No deduction available in New Regime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment