The Purchasing Price, price can now have up to 6 decimals (fractions of hundredth's) and are presented correctly.
If you need to increase the decimals in a current value, then you have to delete it and create it again with new values.
This is for safety reasons.
! -> Note
$ -> Affected files
+24-Aug-2009 Joe Hunt
+# A Purchasing Price of 12.34 with a conversion factor of 100,0000 caused a false internal rounding error of 12.00.
+! The Purchasing Price, price can now have up to 6 decimals (fractions of hundredth's) and are presented correctly.
+ If you need to increase the decimals in a current value, then you have to delete it and create it again with new values.
+ This is for safety reasons.
+$ /includes/current_user.inc
+ /includes/ui/ui_input.inc
+ /inventory/purchasing_data.php
+ /purchasing/po_receive_items.php
+ /purchasing/includes/ui/invoice_ui.inc
+ /purchasing/includes/ui/po_ui.inc
+ /purchasing/view/view_grn.php
+ /purchasing/view/view_po.php
+ /reporting/rep209.php
+
21-Aut-2009 Joe Hunt
# [0000162] Deleting a GL account may cause problems with quick entries
$ /gl/manage/gl_accounts.php
return number_format2($number,
$_SESSION["wa_current_user"]->prefs->price_dec());
}
+
+function price_decimal_format($number, &$dec)
+{
+ $dec = user_price_dec();
+ $str = strval($number);
+ $pos = strpos($str, '.');
+ if ($pos !== false)
+ {
+ $len = strlen(substr($str, $pos + 1));
+ if ($len > $dec)
+ $dec = $len;
+ }
+ return number_format2($number, $dec);
+}
// 2008-06-15. Added extra parameter $stock_id and reference for $dec
//--------------------------------------------------------------------
function qty_format($number, $stock_id=null, &$dec) {
label_cell("<a href='mailto:$label'>$label</a>", $params, $id);
}
+function amount_decimal_cell($label, $params="", $id=null)
+{
+ $dec = 0;
+ label_cell(price_decimal_format($label, $dec), "nowrap align=right ".$params, $id);
+}
+
function amount_cell($label, $bold=false, $params="", $id=null)
{
if ($bold)
alt_table_row_color($k);
label_cell($myrow["supp_name"]);
- amount_cell($myrow["price"]);
+ amount_decimal_cell($myrow["price"]);
label_cell($myrow["curr_code"]);
label_cell($myrow["suppliers_uom"]);
qty_cell($myrow['conversion_factor'], false, user_exrate_dec());
//-----------------------------------------------------------------------------------------------
+$dec2 = 6;
if ($Mode =='Edit')
{
$myrow = db_fetch($result);
$supp_name = $myrow["supp_name"];
- $_POST['price'] = price_format($myrow["price"]);
+ $_POST['price'] = price_decimal_format($myrow["price"], $dec2);
$_POST['suppliers_uom'] = $myrow["suppliers_uom"];
$_POST['supplier_description'] = $myrow["supplier_description"];
$_POST['conversion_factor'] = exrate_format($myrow["conversion_factor"]);
supplier_list_row(_("Supplier:"), 'supplier_id', null, false, true);
$_POST['price'] = $_POST['suppliers_uom'] = $_POST['conversion_factor'] = $_POST['supplier_description'] = "";
}
-amount_row(_("Price:"), 'price', null,'', get_supplier_currency($selected_id));
+amount_row(_("Price:"), 'price', null,'', get_supplier_currency($selected_id), $dec2);
text_row(_("Suppliers Unit of Measure:"), 'suppliers_uom', null, 50, 51);
if (!isset($_POST['conversion_factor']) || $_POST['conversion_factor'] == "")
else
qty_cells(null, 'This_QuantityCredited'.$n, number_format2(max($myrow["quantity_inv"], 0), $dec),
null, null, $dec);
- amount_cells(null, 'ChgPrice'.$n, price_format($myrow["unit_price"]));
+ $dec2 = 0;
+ amount_cells(null, 'ChgPrice'.$n, price_decimal_format($myrow["unit_price"], $dec2), null, null, $dec2);
if ($supp_trans->is_invoice)
amount_cell(round2($myrow["unit_price"] * ($myrow["qty_recd"] - $myrow["quantity_inv"]), user_price_dec()));
else
qty_cell($entered_grn->prev_quantity_inv, false, $dec);
}
qty_cell(abs($entered_grn->this_quantity_inv), true, $dec);
- amount_cell($entered_grn->chg_price);
+ amount_decimal_cell($entered_grn->chg_price);
amount_cell( round2($entered_grn->chg_price * abs($entered_grn->this_quantity_inv), user_price_dec()), true);
if ($mode == 1)
qty_cell($po_line->qty_received, false, get_qty_dec($po_line->stock_id));
label_cell($po_line->units);
label_cell($po_line->req_del_date);
- amount_cell($po_line->price);
+ amount_decimal_cell($po_line->price);
amount_cell($line_total);
if ($editable)
global $Ajax;
start_row();
+ $dec2 = 0;
$id = find_submit('Edit');
if (($id != -1) && $stock_id != null)
{
$_POST['stock_id'] = $order->line_items[$id]->stock_id;
$dec = get_qty_dec($_POST['stock_id']);
$_POST['qty'] = qty_format($order->line_items[$id]->quantity, $_POST['stock_id'], $dec);
- $_POST['price'] = price_format($order->line_items[$id]->price);
+ //$_POST['price'] = price_format($order->line_items[$id]->price);
+ $_POST['price'] = price_decimal_format($order->line_items[$id]->price, $dec2);
$_POST['req_del_date'] = $order->line_items[$id]->req_del_date;
$_POST['units'] = $order->line_items[$id]->units;
$dec = $item_info["decimals"];
$_POST['qty'] = number_format2(get_purchase_conversion_factor ($order->supplier_id, $_POST['stock_id']), $dec);
- $_POST['price'] = price_format(get_purchase_price ($order->supplier_id, $_POST['stock_id']));
+ //$_POST['price'] = price_format(get_purchase_price ($order->supplier_id, $_POST['stock_id']));
+ $_POST['price'] = price_decimal_format(get_purchase_price ($order->supplier_id, $_POST['stock_id']), $dec2);
$_POST['req_del_date'] = add_days(Today(), 10);
$qty_rcvd = '';
}
label_cell($_POST['units'], '', 'units');
date_cells(null, 'req_del_date', '', null, 0, 0, 0);
- amount_cells(null, 'price', null);
+ amount_cells(null, 'price', null, null, null, $dec2);
//$line_total = $_POST['qty'] * $_POST['price'] * (1 - $_POST['Disc'] / 100);
$line_total = round(input_num('qty') * input_num('price'), user_price_dec());
else
label_cell(number_format2($ln_itm->receive_qty, $dec), "align=right");
- amount_cell($ln_itm->price);
+ amount_decimal_cell($ln_itm->price);
amount_cell($line_total);
end_row();
}
$dec = get_qty_dec($stock_item->stock_id);
qty_cell($stock_item->qty_received, false, $dec);
label_cell($stock_item->units);
- amount_cell($stock_item->price);
+ amount_decimal_cell($stock_item->price);
amount_cell($line_total);
qty_cell($stock_item->qty_inv, false, $dec);
end_row();
$dec = get_qty_dec($stock_item->stock_id);
qty_cell($stock_item->quantity, false, $dec);
label_cell($stock_item->units);
- amount_cell($stock_item->price);
+ amount_decimal_cell($stock_item->price);
amount_cell($line_total);
label_cell($stock_item->req_del_date);
qty_cell($stock_item->qty_received, false, $dec);
}
$Net = round2(($myrow2["unit_price"] * $myrow2["quantity_ordered"]), user_price_dec());
$SubTotal += $Net;
- $DisplayPrice = number_format2($myrow2["unit_price"],$dec);
+ $dec2 = 0;
+ $DisplayPrice = price_decimal_format($myrow2["unit_price"],$dec2);
$DisplayQty = number_format2($myrow2["quantity_ordered"],get_qty_dec($myrow2['item_code']));
$DisplayNet = number_format2($Net,$dec);
//$rep->TextCol(0, 1, $myrow2['item_code'], -2);