Skip to content

Instantly share code, notes, and snippets.

@adamyordan
Created March 6, 2019 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamyordan/8828b675ce946c680c5b38d4d7fc68f3 to your computer and use it in GitHub Desktop.
Save adamyordan/8828b675ce946c680c5b38d4d7fc68f3 to your computer and use it in GitHub Desktop.
Indonesia income tax calculator, assuming PTKP single, no dependants.
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