From: Joe Hunt Date: Tue, 16 Dec 2008 16:54:35 +0000 (+0000) Subject: [0000100] Keep getting left allocated weird results (rounding problems). X-Git-Tag: 2.3-final~1355 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=4f85173dcfa0e39b8c1c022c563c90d2e9bc4cc4;p=fa-stable.git [0000100] Keep getting left allocated weird results (rounding problems). --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 60355f1d..a26d6818 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,14 @@ Legend: ! -> Note $ -> Affected files +16-Dec-2008 Joe Hunt +# [0000100] Keep getting left allocated weird results (rounding problems). +$ /includes/ui/ui_view.inc + /purchasing/inquiry/supplier_allocation_inquiry.php + /reporting/rep101.php + /reporting/rep201.php + /sales/inquiry/customer_allocation_inquiry.php + 10-Dec-2008 Janusz Dobrowolski # [0000099] New line added to inventory transfer/adjustment sometimes overwrites old one. $ /inlucdes/ui/items_cart.inc diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index 51ea641d..d30db81b 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -495,6 +495,8 @@ function display_allocations($alloc_result, $total) label_cell(systypes::name($alloc_row['type'])); label_cell(get_trans_view_str($alloc_row['type'],$alloc_row['trans_no'])); label_cell(sql2date($alloc_row['tran_date'])); + $alloc_row['Total'] = round2($alloc_row['Total'], user_price_dec()); + $alloc_row['amt'] = round2($alloc_row['amt'], user_price_dec()); amount_cell($alloc_row['Total']); //amount_cell($alloc_row['Total'] - $alloc_row['PrevAllocs'] - $alloc_row['amt']); amount_cell($alloc_row['Total'] - $alloc_row['amt']); @@ -509,6 +511,7 @@ function display_allocations($alloc_result, $total) end_row(); start_row(); label_cell(_("Left to Allocate:"), "align=right colspan=5"); + $total = round2($total, user_price_dec()); amount_cell($total - $total_allocated); end_row(); diff --git a/purchasing/inquiry/supplier_allocation_inquiry.php b/purchasing/inquiry/supplier_allocation_inquiry.php index cc15d580..5ecf5bb7 100644 --- a/purchasing/inquiry/supplier_allocation_inquiry.php +++ b/purchasing/inquiry/supplier_allocation_inquiry.php @@ -166,6 +166,8 @@ if (db_num_rows($result) == 0) label_cell($duedate); if ($_POST['supplier_id'] == reserved_words::get_all()) label_cell($myrow["curr_code"]); + $myrow["TotalAmount"] = round2($myrow["TotalAmount"], user_price_dec()); + $myrow["Allocated"] = round2($myrow["Allocated"], user_price_dec()); if ($myrow["TotalAmount"] >= 0) label_cell(""); amount_cell(abs($myrow["TotalAmount"])); diff --git a/reporting/rep101.php b/reporting/rep101.php index a206239a..cd5bfef7 100644 --- a/reporting/rep101.php +++ b/reporting/rep101.php @@ -125,20 +125,26 @@ function print_customer_balances() $trans['TotalAmount'] *= -1; if ($trans['TotalAmount'] > 0.0) { - $item[0] = abs($trans['TotalAmount']) * $rate; + $item[0] = round2(abs($trans['TotalAmount']) * $rate, $dec); $rep->TextCol(4, 5, number_format2($item[0], $dec)); } else { - $item[1] = Abs($trans['TotalAmount']) * $rate; + $item[1] = round2(Abs($trans['TotalAmount']) * $rate, $dec); $rep->TextCol(5, 6, number_format2($item[1], $dec)); } - $item[2] = $trans['Allocated'] * $rate; + $item[2] = round2($trans['Allocated'] * $rate, $dec); $rep->TextCol(6, 7, number_format2($item[2], $dec)); + /* if ($trans['type'] == 10) $item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate; else $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate; + */ + if ($trans['type'] == 10) + $item[3] = $item[0] + $item[1] - $item[2]; + else + $item[3] = $item[0] - $item[1] + $item[2]; $rep->TextCol(7, 8, number_format2($item[3], $dec)); for ($i = 0; $i < 4; $i++) { diff --git a/reporting/rep201.php b/reporting/rep201.php index 89169ce0..6ba1b3c0 100644 --- a/reporting/rep201.php +++ b/reporting/rep201.php @@ -124,20 +124,26 @@ function print_supplier_balances() $rate = 1.0; if ($trans['TotalAmount'] > 0.0) { - $item[0] = Abs($trans['TotalAmount']) * $rate; + $item[0] = round2(abs($trans['TotalAmount']) * $rate, $dec); $rep->TextCol(4, 5, number_format2($item[0], $dec)); } else { - $item[1] = Abs($trans['TotalAmount']) * $rate; + $item[1] = round2(abs($trans['TotalAmount']) * $rate, $dec); $rep->TextCol(5, 6, number_format2($item[1], $dec)); } - $item[2] = $trans['Allocated'] * $rate; + $item[2] = round2($trans['Allocated'] * $rate, $dec); $rep->TextCol(6, 7, number_format2($item[2], $dec)); + /* if ($trans['type'] == 20) $item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate; else $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate; + */ + if ($trans['type'] == 20) + $item[3] = $item[0] + $item[1] - $item[2]; + else + $item[3] = $item[0] - $item[1] + $item[2]; $rep->TextCol(7, 8, number_format2($item[3], $dec)); for ($i = 0; $i < 4; $i++) { diff --git a/sales/inquiry/customer_allocation_inquiry.php b/sales/inquiry/customer_allocation_inquiry.php index 2770fb22..423ed6b4 100644 --- a/sales/inquiry/customer_allocation_inquiry.php +++ b/sales/inquiry/customer_allocation_inquiry.php @@ -198,6 +198,8 @@ while ($myrow = db_fetch($result)) label_cell($myrow["CustName"]); label_cell($myrow["CustCurrCode"]); } + $myrow["TotalAmount"] = round2($myrow["TotalAmount"], user_price_dec()); + $myrow["Allocated"] = round2($myrow["Allocated"], user_price_dec()); display_debit_or_credit_cells( $myrow['type']==11 || $myrow['type']==12 || $myrow['type']==2 ? -$myrow["TotalAmount"] : $myrow["TotalAmount"]);