-
-
Save rabb-bit/48244be20d3a81d43f34906d81831b2e to your computer and use it in GitHub Desktop.
Snippet on how to get WTAX in the Philippines.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function getWitholdingTax() | |
{ | |
// Check if within minimum wage salary, then 0 tax | |
// Check from general settings | |
$general_settings = Settings::first(); | |
if ($this->getBasicPay() <= $general_settings->minimum_pay) | |
return 0; | |
$min = array( | |
array( | |
//15 Days and Below | |
array(2083, 2500, 3333, 5000, 7917, 12500, 22917), //0 Dependents | |
array(3125, 3542, 4375, 6042, 8958, 13542, 23958), //1 Dependent | |
array(4167, 4583, 5417, 7083, 10000, 14583, 25000), //2 Dependents | |
array(5208, 5625, 6458, 8125, 11042, 15625, 26042), //3 Dependents | |
array(6250, 6667, 7500, 9167, 12083, 16667, 27083), //4 Dependents | |
), | |
array( | |
//More than 15 Days | |
array(4167, 5000, 6667, 10000, 15833, 25000, 45833), //0 Dependents | |
array(6250, 7083, 8750, 12083, 17917, 27083, 47917), //1 Dependent | |
array(8333, 9167, 10833, 14167, 20000, 29167, 50000), //2 Dependents | |
array(10417, 11250, 12917, 16250, 22083, 31250, 52083), //3 Dependents | |
array(12500, 13333, 15000, 18333, 24167, 33333, 54167), //4 Dependents | |
) | |
); | |
$percentage = array(0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.32); //Salary Excess | |
//Additional deduction for tax | |
$add = array( | |
array(0, 20.83, 104.17, 354.17, 937.50, 2083.33, 5208.33), //15 Days and Below | |
array(0, 41.67, 208.33, 708.33, 1875, 4166.67, 10, 416.67), //More than 15 Days | |
); | |
$dependents = $this->getTotalDependents(); | |
if ($this->working_days <= 15) { | |
$period = 0; | |
} else { | |
$period = 1; | |
} | |
for ($x = count($percentage) - 1; $x >= 0; $x--) { | |
// Find basic_pay range | |
if ($this->getNetAfterContributions() >= $min[$period][$dependents][$x]) { | |
//Compute witholding tax | |
$tax = $this->getNetAfterContributions() - $min[$period][$dependents][$x]; | |
$tax *= $percentage[$x]; | |
$tax += $add[$period][$x]; | |
break; | |
} else { | |
$tax = 0; | |
} | |
} | |
return round($tax, 2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment