I have written an income tax band calculation with PHP and it looks like the code works for some condition and the rest return inaccurate figures. Below is my PHP code for the calculation. Kindly ignore the currency. it could be in UDS
Am trying to calculate the income tax on the amount eg. 1000 with the following tax bands below
// first 3,828 GHS ==> Nil tax
// next 1,200 GHS ==> 5% tax
// next 1,440 GHS ==> 10% tax
// next 36,000 GHS ==> 17.5% tax
// next 197,532 GHS ==> 25% tax
// over 240,000 GHS ==> 30% tax
$income_tax_amount = 0;
//the tops of each tax band
$band1_top = 3828;
$band2_top = 1200;
$band3_top = 1440;
$band4_top = 36000;
$band5_top = 197532;
$band6_top = 240000;
//no top of band 4
//the tax rates of each band
$band1_rate = 0.0;
$band2_rate = 0.05;
$band3_rate = 0.10;
$band4_rate = 0.175;
$band5_rate = 0.25;
$band6_rate = 0.30;
$starting_income = 1000; //set this to your income
$band1 = $band2 = $band3 = $band4 = $band5 = $band6 =0;
if($starting_income >= $band1_top) {
$band1 = ($band1_rate) * $band1_top - ($band1_top);
}
if($starting_income >= $band2_top) {
$band5 = ($band2_rate) * $band2_top - ($band2_top);
}
if($starting_income >= $band4_top) {
$band4 = ($band4_rate) * $band4_top;
}
if($starting_income >= $band3_top) {
$band3 = ($band3_rate) * $band3_top;
}
if($starting_income >= $band2_top) {
$band2 = ($band2_rate) * $band2_top;
}
if($starting_income >= $band1_top) {
$band1 = ($band1_rate) * $band1_top;
}
$income_tax_amount = $band1 + $band2 + $band3 + $band4 + $band5 + $band6;
echo $income_tax_amount;