Commit b21fe75c by epsi sayidina

### PPh ps 17: Tarif Progresif

parent 8ac0d483
 ... ... @@ -7,19 +7,16 @@ 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 | pkp > t4 = pkp_d * p4 - d4 | pkp > t3 = pkp_d * p3 - d3 | pkp > t2 = pkp_d * p2 - d2 | pkp > t1 = pkp_d * p1 - d1 -- ambang batas (t1, t2, t3, t4) = (0, 50, 250, 500) [t1, t2, t3, t4] = map (*juta) [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]] [d1, d2, d3, d4] = map (fromIntegral <\$> (*juta)) [0, 5, 30, 55] -- Typecast, misalnya ke Double pkp_d = fromIntegral(pkp) -- untuk menghindari error menulis digit ... ...
 ... ... @@ -10,7 +10,7 @@ ppi pkpr = pkpr (pkp) | pkp <= 50 = 1 | pkp <= 250 = 2 | pkp <= 500 = 3 | otherwise = 4 | otherwise = 4 main = do print \$ ppi(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
 -- pemula haskell -- penghasilan kena pajak -- taxable income pkp :: Int pkp = 1000000000 -- pajak penghasilan = tarif progresif pasal 17 -- income tax using progressive tariff 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] -- Typecast, such as to Double pkp_d = fromIntegral(pkp) -- to avoid typo in writing digit million = 10^6 -- tariff rate in percent pph_p = [0.05, 0.15, 0.25, 0.30] -- difference, short version pph_d = [0, 5, 30, 55] -- difference, in million rupiah 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
 -- 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
 ... ... @@ -7,7 +7,7 @@ pkp = 1000000000 -- pajak penghasilan = tarif progresif pasal 17 pph :: Int -> Int pph pkp = round \$ maximum \$ [ fromIntegral pkp * fst(x) - snd(x)*1000000 [ fromIntegral pkp * fst(x) - snd(x)*(10^6) | x <- [(0.05, 0), (0.15, 5), (0.25, 30), (0.30, 55)] ] ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!