-
Notifications
You must be signed in to change notification settings - Fork 0
/
nztax
executable file
·35 lines (27 loc) · 872 Bytes
/
nztax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/python3
import sys
salary = float(sys.argv[1])
tax = 0.0
tiers = [
{"thresh": 14000, "rate": 0.105},
{"thresh": 48000, "rate": 0.175},
{"thresh": 70000, "rate": 0.3},
{"thresh": float("inf"), "rate": 0.33},
]
for idx in range(len(tiers)):
thresh = tiers[idx]["thresh"]
rate = tiers[idx]["rate"]
curlimit = min(salary, thresh)
if idx > 0:
tax += (curlimit - tiers[idx - 1]["thresh"]) * rate
else:
tax += curlimit * rate
if salary < thresh:
break
print("annual gross: " + str(salary))
print("monthly gross: " + str(round(salary / 12, 2)))
print("annual net: " + str(salary - tax))
print("annual tax: " + str(tax))
print("monthly net: " + str(round((salary - tax) / 12, 2)))
print("monthly tax: " + str(round(tax / 12, 2)))
print("effective rate: " + str(round(tax / salary * 100, 2)) + "%")