[0000100] Keep getting left allocated weird results (rounding problems).
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 16 Dec 2008 16:54:35 +0000 (16:54 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 16 Dec 2008 16:54:35 +0000 (16:54 +0000)
CHANGELOG.txt
includes/ui/ui_view.inc
purchasing/inquiry/supplier_allocation_inquiry.php
reporting/rep101.php
reporting/rep201.php
sales/inquiry/customer_allocation_inquiry.php

index 60355f1ddbf2da6ccd98c19346b7c0eb066277ad..a26d681887a70fbdcac8974df46b7a37e99fe04a 100644 (file)
@@ -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
index 51ea641df4dc13940bd1dfd0e1b55d9942b8ca74..d30db81b95249d24db56c692929a248af4553862 100644 (file)
@@ -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();
 
index cc15d580da095e771b02f18ad5df46e4af23c200..5ecf5bb781013210b371a21514027706ba99310b 100644 (file)
@@ -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"]));
index a206239a7ba82ef0c388109d2b957371399eaebc..cd5bfef775f09f373bc33415e0c2423a65fed00c 100644 (file)
@@ -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++)
                        {
index 89169ce0567eb011cdebc0a9627e00f3b8b6fa91..6ba1b3c09bfed1fd931c675a85b9fb71514a36f2 100644 (file)
@@ -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++)
                        {
index 2770fb22bf5357f21be8a18d323b5656fce5441c..423ed6b4774d73735db9473c035631db762bf0e5 100644 (file)
@@ -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"]);