$ -> Affected files
05-Dec-2008 Joe Hunt
-# [0000095] Bad behaviour of routine number_format in Windows.
-$ /includes/current_user.inc
+# [0000095] Bad behaviour of routine number_format and round in Windows.
+$ /gl/includes/gl_db_trans.inc
+ /includes/banking.inc
+ /includes/current_user.inc
+ /purchasing/includes/ui/invoice_ui.inc
+ /reporting/rep107.php
+ /reporting/rep109.php
+ /reporting/rep110.php
+ /reporting/rep209.php
+ /sales/view/view_credit.php
+ /sales/view/view_dispatch.php
+ /sales/view/view_invoice.php
+ /sales/view/view_sales_order.php
04-Dec-2008 Janusz Dobrowolski
# Check write permissions and create per company subdirectory structure.
if ($rate == 0)
$amount_in_home_currency = to_home_currency($amount, $currency, $date_);
else
- $amount_in_home_currency = round($amount * $rate, user_price_dec());
+ $amount_in_home_currency = round2($amount * $rate, user_price_dec());
}
else
- $amount_in_home_currency = round($amount, user_price_dec());
+ $amount_in_home_currency = round2($amount, user_price_dec());
if ($dimension == null || $dimension < 0)
$dimension = 0;
if ($dimension2 == null || $dimension2 < 0)
// Function for even out rounding problems
function add_gl_balance($type, $trans_id, $date_, $amount, $person_type_id=null, $person_id=null)
{
- $amount = round($amount, user_price_dec());
+ $amount = round2($amount, user_price_dec());
if ($amount != 0)
return add_gl_trans($type, $trans_id, $date_, get_company_pref('exchange_diff_act'), 0, 0, "",
$amount, null, $person_type_id, $person_id, "The balanced GL transaction could not be inserted");
function to_home_currency($amount, $currency_code, $date_)
{
$ex_rate = get_exchange_rate_to_home_currency($currency_code, $date_);
- return round($amount / $ex_rate, user_price_dec());
+ return round2($amount / $ex_rate, user_price_dec());
}
//----------------------------------------------------------------------------------
}
if (is_company_currency($curr))
return;
- $inv_amt = round($amount * $trans['rate'], user_price_dec());
- $pay_amt = round($amount * $pyt_trans['rate'], user_price_dec());
+ $inv_amt = round2($amount * $trans['rate'], user_price_dec());
+ $pay_amt = round2($amount * $pyt_trans['rate'], user_price_dec());
if ($inv_amt != $pay_amt)
{
$diff = $inv_amt - $pay_amt;
//--------------------------------------------------------------------------
+function round2($number, $decimals=0)
+{
+ $delta = ($number < 0 ? -.000001 : .000001);
+ return round($number+$delta, $decimals);
+}
+
function number_format2($number, $decimals=0)
{
global $thoseps, $decseps;
$tsep = $thoseps[$_SESSION["wa_current_user"]->prefs->tho_sep()];
$dsep = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()];
//return number_format($number, $decimals, $dsep, $tsep);
- return number_format($number+.000001, $decimals, $dsep, $tsep);
+ $delta = ($number < 0 ? -.000001 : .000001);
+ return number_format($number+$delta, $decimals, $dsep, $tsep);
}
function price_format($number) {
{
foreach ( $supp_trans->grn_items as $grn)
{
- $supp_trans->ov_amount += round(($grn->this_quantity_inv * $grn->chg_price),
+ $supp_trans->ov_amount += round2(($grn->this_quantity_inv * $grn->chg_price),
user_price_dec());
}
}
null, null, $dec);
amount_cells(null, 'ChgPrice'.$n, price_format($myrow["unit_price"]));
if ($supp_trans->is_invoice)
- amount_cell(round($myrow["unit_price"] * ($myrow["qty_recd"] - $myrow["quantity_inv"]), user_price_dec()));
+ amount_cell(round2($myrow["unit_price"] * ($myrow["qty_recd"] - $myrow["quantity_inv"]), user_price_dec()));
else
- amount_cell(round($myrow["unit_price"] * max($myrow['quantity_inv'], 0), user_price_dec()));
+ amount_cell(round2($myrow["unit_price"] * max($myrow['quantity_inv'], 0), user_price_dec()));
if ($supp_trans->is_invoice)
submit_cells('grn_item_id'.$n, _("Add"), '', _("Add to Invoice"), true);
else
}
qty_cell(abs($entered_grn->this_quantity_inv), true, $dec);
amount_cell($entered_grn->chg_price);
- amount_cell( round($entered_grn->chg_price * abs($entered_grn->this_quantity_inv), user_price_dec()), true);
+ amount_cell( round2($entered_grn->chg_price * abs($entered_grn->this_quantity_inv), user_price_dec()), true);
if ($mode == 1)
{
}
end_row();
- $total_grn_value += round($entered_grn->chg_price * abs($entered_grn->this_quantity_inv),
+ $total_grn_value += round2($entered_grn->chg_price * abs($entered_grn->this_quantity_inv),
user_price_dec());
$i++;
$SubTotal = 0;
while ($myrow2=db_fetch($result))
{
- $Net = round($sign * ((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
+ $Net = round2($sign * ((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
user_price_dec());
$SubTotal += $Net;
$DisplayPrice = number_format2($myrow2["unit_price"],$dec);
$SubTotal = 0;
while ($myrow2=db_fetch($result))
{
- $Net = round(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
+ $Net = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
user_price_dec());
$SubTotal += $Net;
$DisplayPrice = number_format2($myrow2["unit_price"],$dec);
$SubTotal = 0;
while ($myrow2=db_fetch($result))
{
- $Net = round(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
+ $Net = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
user_price_dec());
$SubTotal += $Net;
$DisplayPrice = number_format2($myrow2["unit_price"],$dec);
$SubTotal = 0;
while ($myrow2=db_fetch($result))
{
- $Net = round(($myrow2["unit_price"] * $myrow2["quantity_ordered"]),
+ $Net = round2(($myrow2["unit_price"] * $myrow2["quantity_ordered"]),
user_price_dec());
$SubTotal += $Net;
$DisplayPrice = number_format2($myrow2["unit_price"],$dec);
alt_table_row_color($k);
- $value = round(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
+ $value = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
user_price_dec());
$sub_total += $value;
if($myrow2['quantity']==0) continue;
alt_table_row_color($k);
- $value = round(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
+ $value = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
user_price_dec());
$sub_total += $value;
if($myrow2["quantity"]==0) continue;
alt_table_row_color($k);
- $value = round(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
+ $value = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
user_price_dec());
$sub_total += $value;
foreach ($_SESSION['Items']->line_items as $stock_item) {
- $line_total = round($stock_item->quantity * $stock_item->price * (1 - $stock_item->discount_percent),
+ $line_total = round2($stock_item->quantity * $stock_item->price * (1 - $stock_item->discount_percent),
user_price_dec());
alt_table_row_color($k);