Skip to content

Instantly share code, notes, and snippets.

@Mizzlr
Created August 25, 2019 14:15
Show Gist options
  • Save Mizzlr/2d0c28ce94dbba6579fdc99e8ac58a93 to your computer and use it in GitHub Desktop.
Save Mizzlr/2d0c28ce94dbba6579fdc99e8ac58a93 to your computer and use it in GitHub Desktop.
This script print tax deduction for various amounts of salary as india's income tax rules.Source https://www.paisabazaar.com/tax/tds-on-salary/
import tabulate
def calc_indian_tds(salary):
if salary < 2.5e5:
tds = 0
elif salary < 5e5:
tds = salary * 0.05
elif salary < 1e6:
tds = (salary - 5e5) * 0.20 + 5e5 * 0.05
else:
tds = (salary - 1e6) * 0.3 + 5e5 * 0.25
if salary < 5e6:
return tds * 1.03
elif salary < 1e7:
return tds * 1.13
else:
return tds * 1.18
print(tabulate.tabulate([
[
round(salary / 1e5, 2),
round(calc_indian_tds(salary) / 1e5, 2),
round((salary - calc_indian_tds(salary)) / 1e5, 2),
str(round(calc_indian_tds(salary) / salary * 100, 2)) + '%',
str(round(salary / 1e5 / 12, 2)) + '/m sal',
str(round(calc_indian_tds(salary) / 1e5 / 12, 2)) + ' /m tax',
str(round((salary - calc_indian_tds(salary)) / 1e5 / 12, 2)) + ' /m hand',
]
for salary in [x * 1e5 for x in range(1, 15)] + [x * 2.5e5 for x in range(6, 200)]
], headers=['salary', 'tds', 'in-hand', 'percentage', 'salary/m', 'tds/m', 'in-hand/m'], tablefmt='fancy_grid'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment