Commit b6db7902 authored by epsi sayidina's avatar epsi sayidina

PPh ps 17: Tarif Progresif

parent 19ab4d17
......@@ -13,5 +13,4 @@ pph pkp = round(pkpr pkp)
| pkp <= 500000000 = pkp_d * 0.25 - 30000000
| otherwise = pkp_d * 0.30 - 55000000
main = do
print $ pph pkp
main = print $ pph pkp
......@@ -16,11 +16,10 @@ pph pkp = round(pkpr pkp)
-- persentase tarif
(p1, p2, p3, p4) = (0.05, 0.15, 0.25, 0.30)
-- pengurang, versi dalam juta rupiah
[d1, d2, d3, d4] = map (fromIntegral <$> (*juta)) [0, 5, 30, 55]
[d1, d2, d3, d4] = map (fromIntegral . (*juta)) [0, 5, 30, 55]
-- Typecast, misalnya ke Double
pkp_d = fromIntegral(pkp)
-- untuk menghindari error menulis digit
juta = 1000000
main = do
print $ pph pkp
main = putStrLn $ show $ pph pkp
-- taxable income
pkp :: Int
pkp = 10^9
-- taxable incomes
pkps :: [Int]
pkps = [10^7, 10^8, 10^9]
-- income tax using progressive tariff
pph :: Int -> Int
......@@ -15,11 +15,10 @@ pph pkp = maximum $ [round(x) | x <- pph_list]
-- difference, short version
pph_d = [0, 5, 30, 55]
-- difference, in million rupiah
pph_dj = map (fromIntegral <$> (*million)) pph_d
pph_dj = map (fromIntegral . (*million)) pph_d
-- range list, zero based index
level = [0, 1, 2, 3]
-- main calculation, calulate all level
pph_list = [pkp_d * (pph_p !! x) - (pph_dj !! x) | x <- level]
main = do
print $ pph pkp
main = print $ map pph pkps
-- pemula haskell
-- penghasilan kena pajak
pkp :: Int
pkp = 10^9
pkps :: [Int]
pkps = [50*10^6, 250*10^6, 500*10^6, 10^9]
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
......@@ -11,5 +11,4 @@ pph pkp = round $ maximum $
| (a, b) <- [(0.05, 0), (0.15, 5), (0.25, 30), (0.30, 55)]
]
main = do
print $ pph pkp
main = mapM_ (print . pph) pkps
-- pemula haskell
import Data.Foldable
-- penghasilan kena pajak
pkp :: Int
pkp = 10^9
pkps :: [Int]
pkps = [50*10^6, 250*10^6, 500*10^6, 10^9]
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
......@@ -14,5 +15,4 @@ pph pkp = round $
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
main = forM_ pkps (print . pph)
......@@ -4,8 +4,6 @@
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))
......
-- pemula haskell
import Data.Foldable
-- penghasilan kena pajak
pkps :: [Int]
pkps = [50*10^6, 250*10^6, 500*10^6, 10^9]
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
pph pkp = round $ pph_real $ fromIntegral pkp
where
pph_real pkp_real = pkp_real * p - d * (10^6)
-- [(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) ]
(t, p, d) = (reff !! last indices)
main = forM_ pkps (print . pph)
-- pemula haskell
import Data.Foldable
-- penghasilan kena pajak
pkps :: [Int]
pkps = [0, 50*10^6, 250*10^6, 500*10^6, 10^9]
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
pph pkp = round $ pph_recursive $ fromIntegral pkp
where
pph_recursive 0 = 0
pph_recursive pkp_real = (pkp_real - tm) * p + pph_recursive(tm)
where
-- [(tingkat, persentase)]
reff = [(0, 0.05), (50, 0.15), (250, 0.25), (500, 0.30)]
indices = [ i | (i, (t, p)) <- zip [0..] reff, pkp_real > t * (10^6)]
(t, p) = (reff !! last indices)
tm = t * (10^6)
main = forM_ pkps (print . pph)
-- pemula haskell
import Data.Foldable
-- penghasilan kena pajak
pkps :: [Int]
pkps = [50*10^6, 250*10^6, 500*10^6, 10^9]
-- pajak penghasilan = tarif progresif pasal 17
pph_recursive :: Double -> Double
pph_recursive pkp_real = pkp_guard pkp_real
where
pkp_guard pkp_real
| pkp_real == 0 = 0
| otherwise = (pkp_real - tm) * p + pph_recursive(tm)
-- [(tingkat, persentase, pengurang)]
reff = [(0, 0.05), (50, 0.15), (250, 0.25), (500, 0.30)]
indices = [ i | (i, (t, p)) <- zip [0..] reff, pkp_real > t * (10^6)]
(t, p) = (reff !! last indices)
tm = t * (10^6)
main = forM_ pkps (print . round . pph_recursive . fromIntegral)
import Data.Foldable
-- penghasilan kena pajak
pkps :: [Int]
pkps = [0, 50*10^6, 250*10^6, 500*10^6, 10^9]
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
pph pkp = round $ pph_recursive $ fromIntegral pkp
where
[t1, t2, t3, t4] = map (* 10^6) [0, 50, 250, 500]
pph_recursive pkp_real
| pkp_real > t4 = (pkp_real - t4) * 0.30 + pph_recursive t4
| pkp_real > t3 = (pkp_real - t3) * 0.25 + pph_recursive t3
| pkp_real > t2 = (pkp_real - t2) * 0.15 + pph_recursive t2
| pkp_real > t1 = (pkp_real - t1) * 0.05 + pph_recursive t1
| otherwise = 0
main = forM_ pkps (print . pph)
-- pemula haskell
import Data.Foldable
-- penghasilan kena pajak
pkps :: [Int]
pkps = [0, 50*10^6, 250*10^6, 500*10^6, 10^9]
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
pph pkp = round $ pph_recursive $ fromIntegral pkp
where
pph_recursive pkp_real = pkp_guard pkp_real
where
pkp_guard pkp_real
| pkp_real == 0 = 0
| otherwise = (pkp_real - tm) * p + pph_recursive(tm)
-- [(tingkat, persentase, pengurang)]
reff = [(0, 0.05), (50, 0.15), (250, 0.25), (500, 0.30)]
indices = [ i | (i, (t, p)) <- zip [0..] reff, pkp_real > t * (10^6)]
(t, p) = (reff !! last indices)
tm = t * (10^6)
main = forM_ pkps (print . pph)
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