Commit 8a8690ab authored by epsi sayidina's avatar epsi sayidina

PPh ps 17: Tarif Progresif

parent 7078eed9
-- penghasilan kena pajak
pkp :: Float
pkp = 1000000000
main = do
print $ round pkp
-- penghasilan kena pajak
pkp :: Double
pkp = 1000000000
-- pajak penghasilan = tarif progresif pasal 17
(t1, t2, t3) = (50000000, 250000000, 500000000)
pph :: Double -> Double
pph pkp = if pkp <= t1
then pph_t1 pkp
else pph_t2 pkp
pph_t1 :: Double -> Double
pph_t1 pkp = pkp * 0.05
pph_t2 :: Double -> Double
pph_t2 pkp = if pkp <= t2
then (pkp - t1) * 0.15 + pph_t1(t1)
else pph_t3 pkp
pph_t3 :: Double -> Double
pph_t3 pkp = if pkp <= t3
then (pkp - t2) * 0.25 + pph_t2(t2)
else pph_t4 pkp
pph_t4 :: Double -> Double
pph_t4 pkp = (pkp - t3) * 0.30 + pph_t3(t3)
main = do
print $ round $ pph pkp
-- penghasilan kena pajak
pkp :: Int
pkp = 1000000000
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
pph pkp = round(pkpr pkp)
where
pkpr pkp
| pkp <= 50000000 = fromIntegral(pkp) * 0.05
| pkp <= 250000000 = fromIntegral(pkp) * 0.15 - 5000000
| pkp <= 500000000 = fromIntegral(pkp) * 0.25 - 30000000
| otherwise = fromIntegral(pkp) * 0.30 - 55000000
main = do
print $ pph pkp
-- penghasilan kena pajak
pkp :: Double
pkp = 1000000000
-- pajak penghasilan = tarif progresif pasal 17
pph :: Double -> Double
pph pkp
| pkp <= 50000000 = pkp * 0.05
| pkp <= 250000000 = pkp * 0.15 - 5000000
| pkp <= 500000000 = pkp * 0.25 - 30000000
| otherwise = pkp * 0.30 - 55000000
main = do
print $ round $ pph pkp
-- penghasilan kena pajak
pkp :: Int
pkp = 1000000000
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
pph pkp = round(pkpr pkp)
where
pkpr pkp
| pkp > t4*juta = pkp_d * p4 - dj4
| pkp > t3*juta = pkp_d * p3 - dj3
| pkp > t2*juta = pkp_d * p2 - dj2
| pkp > t1*juta = pkp_d * p1 - dj1
-- ambang batas
(t1, t2, t3, t4) = (0, 50, 250, 500)
-- persentase tarif
(p1, p2, p3, p4) = (0.05, 0.15, 0.25, 0.30)
-- pengurang, versi singkat
(d1, d2, d3, d4) = (0, 5, 30, 55)
-- pengurang, versi dalam juta rupiah
[dj1, dj2, dj3, dj4] =
[fromIntegral(x * juta) | x <- [d1, d2, d3, d4]]
-- Typecast, misalnya ke Double
pkp_d = fromIntegral(pkp)
-- untuk menghindari error menulis digit
juta = 1000000
main = do
print $ pph pkp
-- penghasilan kena pajak
pkp :: Int
pkp = 50000000
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
pph pkp
| pkp <= 50000000 = round(fromIntegral pkp * 0.05)
| pkp <= 250000000 = round(fromIntegral pkp * 0.15 - 5000000)
| pkp <= 500000000 = round(fromIntegral pkp * 0.25 - 30000000)
| otherwise = round(fromIntegral pkp * 0.30 - 55000000)
pkpreal :: Int -> Double
pkpreal pkp
| pkp <= 50000000 = fromIntegral pkp * 0.05
| pkp <= 250000000 = fromIntegral pkp * 0.15 - 5000000
| pkp <= 500000000 = fromIntegral pkp * 0.25 - 30000000
| otherwise = fromIntegral pkp * 0.30 - 55000000
ppint1 :: Double -> Int
ppint1 pkpr = round(pkpr)
ppint2 :: Int -> Int
ppint2 pkpr = round(pkpr)
where pkpr = fromIntegral pkp * 0.05
main = do
print $ pph(pkp)
print $ ppint1(pkpreal pkp)
print $ ppint2(pkp)
-- penghasilan kena pajak
pkp :: Int
pkp = 1000000000
ppi :: Int -> Int
ppi pkpr = round(pkpr pkp)
where
pkpr pkp
| pkp <= 50000000 = fromIntegral pkp * 0.05
| pkp <= 250000000 = fromIntegral pkp * 0.15 - 5000000
| pkp <= 500000000 = fromIntegral pkp * 0.25 - 30000000
| otherwise = fromIntegral pkp * 0.30 - 55000000
main = do
print $ ppi(pkp)
-- pemula haskell
pkp :: Int
pkp = 50
ppi :: Int -> Int
ppi pkpr = pkpr (pkp)
where
pkpr pkp
| pkp <= 50 = 1
| pkp <= 250 = 2
| pkp <= 500 = 3
| otherwise = 4
main = do
print $ ppi(pkp)
-- pemula haskell
-- penghasilan kena pajak
pkp :: Int
pkp = 1000000000
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
pph pkp = maximum $ [round(x) | x <- pph_list]
where
-- Typecast, misalnya ke Double
pkp_d = fromIntegral(pkp)
-- untuk menghindari error menulis digit
juta = 1000000
-- persentase tarif
pph_p = [0.05, 0.15, 0.25, 0.30]
-- pengurang, versi singkat
pph_d = [0, 5, 30, 55]
-- pengurang, versi dalam juta rupiah
pph_dj = [fromIntegral(x * juta) | x <- pph_d]
-- daftar tingkat, index dari nol
tingkat = [0, 1, 2, 3]
-- perhitungan utama, semua tingkat dihitung
pph_list = [pkp_d * (pph_p !! x) - (pph_dj !! x) | x <- tingkat]
main = do
print $ pph pkp
-- pemula haskell
pkp :: Int
pkp = 1000000000
(t1, t2, t3, t4) = (0, 50, 250, 500) -- ambang batas (unused)
(p1, p2, p3, p4) = (0.05, 0.15, 0.25, 0.30) -- persentase tarif
(d1, d2, d3, d4) = (0, 5, 30, 55) -- pengurang, versi singkat
juta = 1000000
pph_t1 :: Int -> Double
pph_t1 pkp = fromIntegral(pkp) * p1 - fromIntegral(d1*juta)
pph_t2 :: Int -> Double
pph_t2 pkp = fromIntegral(pkp) * p2 - fromIntegral(d2*juta)
pph_t3 :: Int -> Double
pph_t3 pkp = fromIntegral(pkp) * p3 - fromIntegral(d3*juta)
pph_t4 :: Int -> Double
pph_t4 pkp = fromIntegral(pkp) * p4 - fromIntegral(d4*juta)
list_pph :: [Int]
list_pph = [ round(pph_t1 pkp)
, round(pph_t2 pkp)
, round(pph_t3 pkp)
, round(pph_t4 pkp)]
list_d :: [Double]
list_d = [pph_t1 pkp, pph_t2 pkp, pph_t3 pkp, pph_t4 pkp]
round_list :: [Double] -> [Int]
round_list d = [round(x) | x <- d]
main = do
print $ round(pph_t1 pkp)
print $ round(pph_t2 pkp)
print $ round(pph_t3 pkp)
print $ round(pph_t4 pkp)
putStrLn ""
print $ maximum $ round_list list_d
-- pemula haskell
pkp :: Int
pkp = 1000000000
pph_t = [0, 50, 250, 500] -- ambang batas (unused)
pph_p = [0.05, 0.15, 0.25, 0.30] -- persentase tarif
pph_d = [0, 5, 30, 55] -- pengurang, versi singkat
juta = 1000000
pph_t1 :: Int -> Double
pph_t1 pkp = fromIntegral(pkp) * (pph_p !! 0)
- fromIntegral((pph_d !! 0) * juta)
pph_t2 :: Int -> Double
pph_t2 pkp = fromIntegral(pkp) * (pph_p !! 1)
- fromIntegral((pph_d !! 1) * juta)
pph_t3 :: Int -> Double
pph_t3 pkp = fromIntegral(pkp) * (pph_p !! 2)
- fromIntegral((pph_d !! 2) * juta)
pph_t4 :: Int -> Double
pph_t4 pkp = fromIntegral(pkp) * (pph_p !! 3)
- fromIntegral((pph_d !! 3) * juta)
list_i :: [Int]
list_i = [round(x) |
x <- [pph_t1 pkp, pph_t2 pkp, pph_t3 pkp, pph_t4 pkp]]
main = do
print $ round(pph_t1 pkp)
print $ round(pph_t2 pkp)
print $ round(pph_t3 pkp)
print $ round(pph_t4 pkp)
putStrLn ""
print $ maximum $ list_i
-- pemula haskell
-- penghasilan kena pajak
pkp :: Int
pkp = 1000000000
-- pajak penghasilan = tarif progresif pasal 17
pph_list :: [Int]
pph_list = [round(x) | x <- [t1 pkp, t2 pkp, t3 pkp, t4 pkp]]
where
t1 pkp = pkp_d * (pph_p !! 0) - (pph_dj !! 0)
t2 pkp = pkp_d * (pph_p !! 1) - (pph_dj !! 1)
t3 pkp = pkp_d * (pph_p !! 2) - (pph_dj !! 2)
t4 pkp = pkp_d * (pph_p !! 3) - (pph_dj !! 3)
-- Typecast, misalnya ke Double
pkp_d = fromIntegral(pkp)
-- untuk menghindari error menulis digit
juta = 1000000
-- persentase tarif
pph_p = [0.05, 0.15, 0.25, 0.30]
-- pengurang, versi singkat
pph_d = [0, 5, 30, 55]
-- pengurang, versi dalam juta rupiah
pph_dj = [fromIntegral(x * juta) | x <- pph_d]
main = do
print $ maximum $ pph_list
-- pemula haskell
-- penghasilan kena pajak
pkp :: Int
pkp = 1000000000
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
pph pkp = maximum $ [
round(fromIntegral(pkp) * (pph_p !! x) - (pph_dj !! x))
| x <- [0, 1, 2, 3]]
where
pph_p = [0.05, 0.15, 0.25, 0.30] -- persentase
pph_dj = [fromIntegral(x * 1000000) | x <- [0, 5, 30, 55]] -- pengurang
main = do
print $ pph pkp
-- pemula haskell
-- penghasilan kena pajak
pkp :: Int
pkp = 1000000000
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
pph pkp = maximum $
[ round (fromIntegral(pkp) * fst(x) - fromIntegral(snd(x)*1000000))
| x <- [(0.05, 0), (0.15, 5), (0.25, 30), (0.30, 55)]
]
main = do
print $ pph pkp
-- pemula haskell
-- penghasilan kena pajak
pkp :: Int
pkp = 1000000000
-- [(persentase, pengurang)]
skemaTarif :: [(Double, Int)]
skemaTarif =
[(0.05, 0)
,(0.15, 5)
,(0.25, 30)
,(0.30, 55)
]
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
pph pkp = maximum $ [round(x) | x <- pph_list]
where
-- Typecast, misalnya ke Double
pkp_d = fromIntegral(pkp)
-- untuk menghindari error menulis digit
juta = 1000000
-- pengurang, versi dalam juta rupiah
dj x = fromIntegral(x * juta)
-- daftar tingkat, index dari nol
tingkat = [0, 1, 2, 3]
-- perhitungan utama, semua tingkat dihitung
pph_list = [pkp_d * fst(skemaTarif !! x) - dj(snd(skemaTarif !! x)) | x <- tingkat]
main = do
print $ pph pkp
-- pemula haskell
-- penghasilan kena pajak
pkp :: Int
pkp = 1000000000
-- pajak penghasilan = tarif progresif pasal 17
pph :: Int -> Int
pph pkp = maximum $
[
round (
fromIntegral(pkp) * fst(x)
- fromIntegral(snd(x)*1000000)
)
| x <- [(0.05, 0), (0.15, 5)
, (0.25, 30), (0.30, 55)]
]
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