Commit 19ab4d17 authored by epsi sayidina's avatar epsi sayidina

PPh ps 17: Tarif Progresif

parent 124cd574
-- pemula haskell
-- penghasilan kena pajak
pkp :: Int
pkp = 10^9
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
pph pkp = round $
(\(t, p, d) -> fromIntegral pkp * p - d * (10^6))
(reff !! last indices)
where
-- [(tingkat, persentase, pengurang)]
reff = [(0, 0.05, 0), (50, 0.15, 5), (250, 0.25, 30), (500, 0.30, 55)]
indices = [ i | (i, (t, p, d)) <- zip [0..] reff, pkp >= (t * 10^6) ]
main = do
print $ pph pkp
-- pemula haskell
-- penghasilan kena pajak
pkp :: Int
pkp = 10^9
t1 = map (* 10^6) [0, 50, 250, 500]
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
pph pkp = round (fromIntegral pkp * a - b * (10^6))
where
range = [(0, 0), (1, 50), (2, 250), (3, 500)]
reff = [(0.05, 0), (0.15, 5), (0.25, 30), (0.30, 55)]
index = last [ i | (i, t) <- range, pkp >= (t * 10^6) ]
(a, b) = reff !! index
main = do
print $ pph pkp
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment