Skip to content

Instantly share code, notes, and snippets.

@anonoz
Last active June 28, 2019 17:57

Revisions

  1. anonoz revised this gist Jun 28, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions mysg-income-tax.js
    Original file line number Diff line number Diff line change
    @@ -15,8 +15,8 @@ function MALAYSIA_TAX(amount) {
    else if (amount >= 100001) { return 10900 + (amount - 100001) * 0.24 }
    else if (amount >= 70001) { return 4600 + (amount - 70001) * 0.21 }
    else if (amount >= 50001) { return 1800 + (amount - 50001) * 0.14 }
    else if (amount >= 35001) { return 600 + (amount - 70001) * 0.08 }
    else if (amount >= 20001) { return 1800 + (amount - 50001) * 0.03 }
    else if (amount >= 35001) { return 600 + (amount - 35001) * 0.08 }
    else if (amount >= 20001) { return 150 + (amount - 20001) * 0.03 }
    else if (amount >= 5001) { return 0 + (amount - 5001) * 0.01 }
    else { return 0; }

  2. anonoz created this gist Jun 28, 2019.
    44 changes: 44 additions & 0 deletions mysg-income-tax.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    // Google app script for google sheets!

    /**
    * Calculate Malaysia income tax for YA2020.
    *
    * @param {number} chargeable_income Income after all eligible tax deductions.
    * @return The tax you have to pay
    * @customfunction
    */
    function MALAYSIA_TAX(amount) {
    if (amount > 1000000) { return 237650 + (amount - 1000000) * 0.28 }
    else if (amount >= 600001) { return 133650 + (amount - 600001) * 0.26 }
    else if (amount >= 400001) { return 83650 + (amount - 400001) * 0.25 }
    else if (amount >= 250001) { return 46900 + (amount - 250001) * 0.245 }
    else if (amount >= 100001) { return 10900 + (amount - 100001) * 0.24 }
    else if (amount >= 70001) { return 4600 + (amount - 70001) * 0.21 }
    else if (amount >= 50001) { return 1800 + (amount - 50001) * 0.14 }
    else if (amount >= 35001) { return 600 + (amount - 70001) * 0.08 }
    else if (amount >= 20001) { return 1800 + (amount - 50001) * 0.03 }
    else if (amount >= 5001) { return 0 + (amount - 5001) * 0.01 }
    else { return 0; }

    }

    /**
    * Calculate Singapore income tax for YA2020.
    *
    * @param {number} chargeable_income Income after all eligible tax deductions.
    * @return The tax you have to pay
    * @customfunction
    */
    function SINGAPORE_TAX(amount) {
    if (amount > 320000) { return 44550 + (amount - 320000) * 0.22 }
    else if (amount >= 280000) { return 36550 + (amount - 280000) * 0.20 }
    else if (amount >= 240000) { return 28750 + (amount - 240000) * 0.195 }
    else if (amount >= 200000) { return 21150 + (amount - 200000) * 0.19 }
    else if (amount >= 160000) { return 13950 + (amount - 160000) * 0.18 }
    else if (amount >= 120000) { return 7950 + (amount - 120000) * 0.15 }
    else if (amount >= 80000) { return 3350 + (amount - 80000) * 0.115 }
    else if (amount >= 40000) { return 550 + (amount - 40000) * 0.07 }
    else if (amount >= 30000) { return 200 + (amount - 30000) * 0.035 }
    else if (amount >= 20000) { return 0 + (amount - 20000) * 0.02 }
    else { return 0; }
    }