CItem Cost Update will also regulate the stock moves standard cost to mirror correct GL.
[fa-stable.git] / sales / includes / cart_class.inc
index 9b8c27edf86573716a4b81aa8bff5934615a644c..64a237f320aa824db88f3377e653e6615cbc7132 100644 (file)
@@ -71,7 +71,8 @@ class cart
        var $payment;
        var $payment_terms; // cached payment terms
        var $credit;
-       
+       var $ex_rate;
+
        //-------------------------------------------------------------------------
        //
        //  $trans_no==0 => open new/direct document
@@ -101,12 +102,18 @@ class cart
                return strcmp($a->stock_id, $b->stock_id);
        }
 
-       function sort_items()
+       /*
+               Returns items array optionally sorted by item code.
+       */
+       function get_items()
        {
                global $sort_sales_items;
 
-               if (@$sort_sales_items && !$this->trans_no) // sort items optionally for new transaction
-                       usort($this->line_items, array($this, '_cmp_lines'));
+               $items = $this->line_items;
+               if (@$sort_sales_items)
+                       uasort($items, array($this, '_cmp_lines'));
+
+               return $items;
        }
        //
        //      Prepare cart to new child document entry, just after initial parent doc read.
@@ -366,7 +373,6 @@ class cart
 
                if ($line->valid) {
                        $this->line_items[$line_no] = $line;
-                       $this->sort_items();
                        return 1;
                } else
                        display_error(_("You have to enter valid stock code or nonempty description"));
@@ -381,7 +387,6 @@ class cart
                $this->line_items[$line_no]->qty_dispatched = $qty;
                $this->line_items[$line_no]->price = $price;
                $this->line_items[$line_no]->discount_percent = $disc;
-               $this->sort_items();
        }
 
        function update_add_cart_item_qty($line_no, $qty)