Federal withold tax calculation for texas

function getTaxBaseSettingData($period=”weekly”)
{
return R::getRow(“SELECT *FROM tax_base_settings WHERE pay_period=’weekly'”);

}
function calculateTax($employee_id,$this_week_total_pay)
{

$employee_data = getEmployeeData($employee_id);
$employee_dependent = $employee_data[“tax_dependent”];
$employee_martial_status = $employee_data[“tax_marital_status”];

$tax_base_data = getTaxBaseSettingData();
$social_security = $tax_base_data[“social_security”];
$medicare = $tax_base_data[“medicare”];
$dependent_allowance = $tax_base_data[“dependent_allowance”];
$dependent_allowance = formatToDecimal($dependent_allowance);
$pay_period = $tax_base_data[“pay_period”];

$totalpay = $this_week_total_pay;
$type = $employee_martial_status;
$allowance = $employee_dependent;

$ss = (($totalpay*$social_security)/100);
$ss = formatToDecimal($ss) ;

$mc = (($totalpay*$medicare)/100);
$mc = formatToDecimal($mc) ;

$al = $dependent_allowance*$employee_dependent;
$al = formatToDecimal($al) ;

//Start Withhold calculation

$table_setting_id = getPercentageTableSettingId($employee_martial_status,$pay_period);
$tax_to_be_withheld = $this_week_total_pay-$al;

$getTaxBracketTable = getTaxBracketTable($table_setting_id,$tax_to_be_withheld);
$tax_amount = $getTaxBracketTable[“tax_amount”];
$tax_percentage = $getTaxBracketTable[“tax_percentage”];
$excess_over = $getTaxBracketTable[“excess_over”];

$applied_percentage_amount = $tax_to_be_withheld-$excess_over;

$withheldtax = ($tax_amount+($applied_percentage_amount*$tax_percentage)/100);
$withheldtax = formatToDecimal($withheldtax);

$data =array($ss,$mc,$al,$withheldtax);
return $data;
}

function getEmployeeData($employee_id)
{
return R::getRow(“SELECT * From employee_names where id=:id”, array(“:id” => $employee_id));

}

function getTaxBracketTable($tax_percentage_table_setting_id,$totalpay)
{
return R::getRow(“SELECT * FROM `tax_percentage_table` WHERE $totalpay BETWEEN over_bracket and but_not_over_bracket and tax_percentage_table_setting_id=’$tax_percentage_table_setting_id'”);

}
function getPercentageTableSettingId($marital_status,$pay_period)
{
$data= R::getRow(“SELECT * From tax_percentage_table_setting where pay_period=:pay_period and martial_status=:marital_status”, array(“:pay_period” => $pay_period,”:marital_status”=>$marital_status));
return $data[“id”];

}

/*************************************Number Formatting********************************/

function formatToDecimal($value,$decimal_point=2)
{
return bcadd(0, $value, $decimal_point) ;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s