Last active
April 5, 2020 13:19
-
-
Save gokhansengun/1037d27f67f771c31ab67027e481d853 to your computer and use it in GitHub Desktop.
Income-Tax Mapping for Turkey 2020
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
# build and run with Python >3.6 | |
def build_income_samples(): | |
sample_income_ranges = [] | |
sample_incomes = [] | |
sample_income_ranges.append({ | |
"start": 3000, | |
"step" : 1000, | |
"stop" : 32000 | |
}) | |
sample_income_ranges.append({ | |
"start": 32000, | |
"step" : 10000, | |
"stop" : 200000 | |
}) | |
for income_range in sample_income_ranges: | |
for sample_income in range(income_range["start"], income_range["stop"], income_range["step"]): | |
sample_incomes.append(sample_income) | |
return sample_incomes | |
def calc_tax(income): | |
inf = float("inf") | |
sgk_upper_limit = 22072 | |
sgk_payment = income * 0.14 if income < sgk_upper_limit else sgk_upper_limit * 0.14 | |
yearly_income = (income - sgk_payment) * 12 | |
tax_brackets = { | |
22000 : 15, | |
49000 : 20, | |
180000 : 27, | |
600000 : 35, | |
inf : 40 | |
} | |
total_sgk = sgk_payment * 12 | |
total_tax = 0 | |
last_bracket = 0 | |
for bracket, rate in tax_brackets.items(): | |
if yearly_income > bracket: | |
total_tax += (bracket - last_bracket) * rate / 100.0 | |
last_bracket = bracket | |
else: | |
total_tax += (yearly_income - last_bracket) * rate / 100.0 | |
break | |
return round(total_tax), (total_tax / yearly_income) * 100, round(total_sgk) | |
sample_incomes = build_income_samples() | |
for income in sample_incomes: | |
avg_tax, avg_tax_rate, total_sgk = calc_tax(income) | |
print(f"Montly: {income:6} TL, Yearly: {(12 * income):8} TL, SGK: {total_sgk:5}, Avg Tax: {avg_tax:6} TL, Avg Tax Rate: % {avg_tax_rate:.2f}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment