Created
February 18, 2020 09:22
-
-
Save mie00/ac7071461f8582b82fe8e3e7dbcecd86 to your computer and use it in GitHub Desktop.
calculate taxes in the netherlands for 2019-2020
This file contains 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
#2019 | |
def labor2(x): | |
if x <= 9694: | |
return 0.01754 * x | |
elif x <= 34060: | |
return min(3399.0, 0.01754 * 9694 + 0.28712 * (x - 9694)) | |
elif x <= 90710: | |
return 3399.0 - 0.06 * (x - 34060) | |
else: | |
return 0.0 | |
def general2(x): | |
if x <= 20384: | |
return 2477.0 | |
elif x <= 68507: | |
return 2477.0 - 0.05147 * (x - 20384) | |
else: | |
return 0.0 | |
def rate2(x): | |
if x <= 20385: | |
return 0.3665 * x | |
elif x <= 68508: | |
return 0.3665 * 20385 + 0.3810 * (x - 20385) | |
else: | |
return 0.3665 * 20385 + 0.3810 * (68508 - 20385) + 0.5175 * (x - 68508) | |
total2 = lambda x: rate2(x) - labor2(x) - general2(x) | |
total2 = lambda x: max(0, rate2(x) - labor2(x) - general2(x)) | |
totalp2 = lambda x: total2(x) / x * 100 | |
ratep2 = lambda x: rate2(x) / x * 100 | |
generalp2 = lambda x: general2(x) / x * 100 | |
laborp2 = lambda x: labor2(x) / x * 100 | |
total302 = lambda x: total2(x * 0.7) if x >= 37743 else total2(x) | |
totalp302 = lambda x: total302(x) / x * 100 | |
def draw(fns, something='taxes'): | |
import matplotlib.pyplot as plt | |
fig = plt.figure() | |
ax = fig.add_subplot(111) | |
x_points = range(1,200000) | |
for fn in fns: | |
y_points = map(fn, x_points) | |
p = ax.plot(x_points, y_points, 'b') | |
ax.set_xlabel('salary') | |
ax.set_ylabel(something) | |
ax.set_title(something) | |
fig.show() | |
# 2020 | |
def labor(x): | |
if x <= 9912: | |
return 0.02812 * x | |
elif x <= 21430: | |
return 0.02812 * 9912 + 0.28812 * (x - 9912) | |
elif x <= 34954: | |
return 0.02812 * 9912 + 0.28812 * (21430 - 9912) + 0.01656 * (x - 21430) | |
else: | |
return max(0, 0.02812 * 9912 + 0.28812 * (21430 - 9912) + 0.01656 * (34954 - 21430) - 0.06 * (x - 34954)) | |
def general(x): | |
if x <= 20711: | |
return 2711.0 | |
elif x <= 68507: | |
return 2711.0 - 0.05672 * (x - 20711) | |
else: | |
return 0.0 | |
def rate(x): | |
if x <= 68507: | |
return 0.3735 * x | |
else: | |
return 0.3735 * 68507 + 0.4950 * (x - 68507) | |
total = lambda x: max(0, rate(x) - labor(x) - general(x)) | |
totalp = lambda x: total(x) / x * 100 | |
ratep = lambda x: rate(x) / x * 100 | |
generalp = lambda x: general(x) / x * 100 | |
laborp = lambda x: labor(x) / x * 100 | |
total30 = lambda x: total(x * 0.7) if x >= 38347 else total(x) | |
totalp30 = lambda x: total30(x) / x * 100 | |
draw([totalp30, totalp302], something='tax percentage') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment