Created
March 6, 2019 05:21
-
-
Save adamyordan/8828b675ce946c680c5b38d4d7fc68f3 to your computer and use it in GitHub Desktop.
Indonesia income tax calculator, assuming PTKP single, no dependants.
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
import sys | |
MILLION = 10 ** 6 | |
PTKP = 54 * MILLION | |
RATES = [ | |
(0.05, 50 * MILLION), | |
(0.15, (250 - 50) * MILLION), | |
(0.25, (500 - 250) * MILLION), | |
(0.3, float('inf')), | |
] | |
def calculate(income): | |
pkp = income - PTKP | |
tax = 0 | |
for rate, amount in RATES: | |
if pkp <= 0: break | |
tax += min(pkp, amount) * rate | |
pkp -= min(pkp, amount) | |
return tax | |
if __name__ == "__main__": | |
try: | |
int(sys.argv[1]) | |
except: | |
print 'usage: pajak.py [income (in millions)]' | |
else: | |
tax = calculate(int(sys.argv[1]) * MILLION) | |
print 'Rp', tax / MILLION, 'juta' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment