I have these variables:
$roundoff1 = 1888.8861;
$roundoff2 = 1888.8851;
$roundoff3 = 1888.8841;
$roundoff4 = 1888.8881;
I want these outputs:
$roundoff1 output = 1,888.88
$roundoff2 output = 1,888.89
$roundoff3 output = 1,888.88
$roundoff1 output = 1,888.88
Second digit from right decides the rounding.
Even digit, third digit from right stays the way it is.
Odd digit, third digit from right is rounded up.
if ($waybill_data['discount_amount'] != 0 ) {
$sales_discount = abs($rec->amount * .1);
$holding_tax = abs($rec->amount - $sales_discount) / 1.12 * .02;
$cib = abs($rec->amount - $sales_discount - $holding_tax);
/* CASH IN BANK CLEARING */
// $j->amount = round($cib , 2, PHP_ROUND_HALF_EVEN);
$j->amount = abs($cib);
$j->account = 13006;
$j->type = 'DR';
$j->onpost = 1;
$j->description = 'Payment("'.$waybill_data['customer_type'].'") for Waybill # '.$j->waybillno;
$j->save_on_history1();
//----------------------------------------------------------------------------------------------
/* SALES DISCOUNT */
// $j->amount = round($sales_discount , 2, PHP_ROUND_HALF_EVEN);
$j->amount = abs($sales_discount);
$j->account = 32001;
$j->type = 'DR';
$j->onpost = 1;
$j->description = 'Payment("'.$waybill_data['customer_type'].'") for Waybill # '.$j->waybillno;
$j->save_on_history1();
//----------------------------------------------------------------------------------------------
/* WITH HOLDING TAX */
// $j->amount = round($holding_tax , 2, PHP_ROUND_HALF_EVEN);
$j->amount = abs($holding_tax);
$j->account = 21005;
$j->type = 'DR';
$j->onpost = 1;
$j->description = 'Payment("'.$waybill_data['customer_type'].'") for Waybill # '.$j->waybillno;
$j->save_on_history1();
//----------------------------------------------------------------------------------------------
/* COLLECT */
$j->amount = $rec->amount;
$j->account = $account_type;
$j->type = 'CR';
$j->onpost = 1;
$j->description = 'Payment("'.$waybill_data['customer_type'].'") for Waybill # '.$j->waybillno;
$j->save_on_history1();