Display quantity left to pick for picked item instead of stock.
authorMaxime Bourget <bmx007@gmail.com>
Fri, 14 Jun 2013 21:40:45 +0000 (22:40 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Fri, 14 Jun 2013 21:40:45 +0000 (22:40 +0100)
haxe/ItemScheduler.hx
hincludes/lib/ItemScheduler.class.php

index 57928f97dfedc65c327cc8ab67056ba92face386..fb5a04f130d6a0530f22a0bb669782e06c41cf58 100644 (file)
@@ -143,9 +143,9 @@ class ItemScheduler {
 
                for(order in orders) {
                        var quantity : Int = Std.parseInt(order.quantity);
+                       var to_pick = toPick(order);
                        // We don't need to remove the quantity which is picked
                        // as we have already counted it in the initial location calculation.
-                       quantity -= toPick(order);
 
                        while(0 >= left && locationIter.hasNext()) {
                                location = locationIter.next();
@@ -154,10 +154,13 @@ class ItemScheduler {
                                left += quantityForLocation;
                                formatLocation(location, "Delivery", left);
                        }
-                       left -= quantity;
+                       if(to_pick>0)
+                               qoh -=  quantity
+                       else
+                               left -= quantity;
 
                        var now = Date.now();
-                       formatOrder(order, left, now.getTime() > location.delivery.getTime() ? now : location.delivery, now);
+                       formatOrder(order, to_pick>0 ? qoh : left, now.getTime() > location.delivery.getTime() ? now : location.delivery, now);
 
                }
                // display the left locations
index 1c6b9ea031f68479f48633c283a25a2d5d7a7fb5..868dab24553505ef6b9a450492ef8b84e2a09831 100644 (file)
@@ -236,7 +236,7 @@ class ItemScheduler {
                                $order = $orders[$_g];
                                ++$_g;
                                $quantity = Std::parseInt($order->quantity);
-                               $quantity -= $this->toPick($order);
+                               $to_pick = $this->toPick($order);
                                while(0 >= $left && $locationIter->hasNext()) {
                                        $location = $locationIter->next();
                                        $quantityForLocation = $location->quantityOnHand($this->stock_id, null) + $location->quantityOnOrder($this->stock_id);
@@ -247,10 +247,14 @@ class ItemScheduler {
                                        $this->formatLocation($location, "Delivery", $left);
                                        unset($quantityForLocation);
                                }
-                               $left -= $quantity;
+                               if($to_pick > 0) {
+                                       $qoh -= $quantity;
+                               } else {
+                                       $left -= $quantity;
+                               }
                                $now = Date::now();
-                               $this->formatOrder($order, $left, ItemScheduler_6($this, $_g, $left, $location, $locationIter, $locations, $now, $order, $orders, $qoh, $quantity, $startDate, $total_picked), $now);
-                               unset($quantity,$order,$now);
+                               $this->formatOrder($order, (($to_pick > 0) ? $qoh : $left), ItemScheduler_6($this, $_g, $left, $location, $locationIter, $locations, $now, $order, $orders, $qoh, $quantity, $startDate, $to_pick, $total_picked), $now);
+                               unset($to_pick,$quantity,$order,$now);
                        }
                }
                while(0 >= $left && $locationIter->hasNext()) {
@@ -338,7 +342,7 @@ function ItemScheduler_5(&$locations, &$startDate, $a, $b) {
                }
        }
 }
-function ItemScheduler_6(&$»this, &$_g, &$left, &$location, &$locationIter, &$locations, &$now, &$order, &$orders, &$qoh, &$quantity, &$startDate, &$total_picked) {
+function ItemScheduler_6(&$»this, &$_g, &$left, &$location, &$locationIter, &$locations, &$now, &$order, &$orders, &$qoh, &$quantity, &$startDate, &$to_pick, &$total_picked) {
        if($now->getTime() > $location->delivery->getTime()) {
                return $now;
        } else {