Skip to content

Instantly share code, notes, and snippets.

@anonoz
Last active June 28, 2019 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonoz/2506f97a96da21d600550f2d97a96ee8 to your computer and use it in GitHub Desktop.
Save anonoz/2506f97a96da21d600550f2d97a96ee8 to your computer and use it in GitHub Desktop.
// 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 - 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; }
}
/**
* 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; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment