Fix Available quantity and amount bug.
authorMaxime Bourget <bmx007@gmail.com>
Fri, 14 Jun 2013 10:19:57 +0000 (11:19 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Fri, 14 Jun 2013 10:21:52 +0000 (11:21 +0100)
includes/order_lines.inc
order_lines_view.php

index c59f89db2cc14e7d9d07997b0b7984b9fbd35460..95085d9ebce84b4d1a1c02507d72193664aaafa6 100644 (file)
@@ -284,8 +284,7 @@ function get_order_summary($location) {
        , group_concat(distinct comments separator ';') as order_comment
        , group_concat(distinct comment separator ';') as detail_comment
        , max(quantity_before) as quantity_before
-       , sum(if($held_condition, d.quantity, 0)) as quantity_held
-       , sum(if($held_condition, d.quantity, 0)*unit_price*(1-discount_percent/100)) as amount_held
+       , sum(if($held_condition, greatest(least(d.quantity, qoh.quantity - quantity_before), 0), 0)) as quantity_held
        , sum(if($held_condition, 0,  greatest(least(d.quantity, qoh.quantity - quantity_before), 0))) as available_quantity
        , sum(if($held_condition, 0,  greatest(least(d.quantity, qoh.quantity - quantity_before), 0)*unit_price*(1-discount_percent/100))) as available_amount
        , sum(p.quantity) as quantity_to_pick
@@ -311,8 +310,6 @@ function get_order_summary($location) {
        , `min(delivery_date)` as delivery_date
        , sum(sub.quantity) as quantity
        , sum(sub.amount) as amount
-       , sum(greatest(least(sub.quantity -quantity_held, qoh.quantity - quantity_before), 0))
-       , sum(sub.amount*greatest(least(sub.quantity -quantity_held, qoh.quantity - quantity_before), 0)/sub.quantity)
        , sum(sub.available_quantity)
        , sum(sub.available_amount)
        , sum(quantity_held) as quantity_help
index c9e60dbb386e7b6e376f1dda797efdf62d4ecff8..00e0258dd1e112e840e96b5fb5544a5f6c17f459 100644 (file)
@@ -122,13 +122,11 @@ _("Quantity") => array('ord' => '', 'type' => 'qty', 'dec' => 0),
 _("Amount") => array('ord' => '', 'type' => 'amount'),
 _("Avail. Q") => array('ord' => '', 'type' => 'qty', 'dec' => 0),
 _("Avail. A") => array('ord' => '', 'type' => 'amount', 'dec' => 0),
-_("Avai2. Q") => array('ord' => '', 'type' => 'qty', 'dec' => 0),
-_("Avai2. A") => array('ord' => '', 'type' => 'amount', 'dec' => 0),
 _("Held. Q") => array('ord' => '', 'type' => 'qty', 'dec' => 0),
 _("required date") => array('ord' => '', 'type' => 'date'),
 _("Comments") => array('ord' => '', 'fun' => 'aggregate_comment'),
 _("comment 2 ") =>  'skip',
-_("Q to Pick") => array('ord' => '', 'type' => 'qty'),
+_("Q to Pick") => array('ord' => '', 'type' => 'qty', 'dec' => 0),
 _("A to Pick") => array('ord' => '', 'type' => 'amount'),
 _("Pick")=> array('insert'=>true, 'fun'=>'pick_checkbox'),
        );