X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Forder_lines.inc;h=5f8d922cbe8458fc0ed226acb81861ab995751d9;hb=3df7c3277a8c0502dca5cfeb32d63db1bef67267;hp=52d315de4b1c84d41cf8262ba28c2294bfb07324;hpb=cf84240d7a69e34b426f69079a966fa3b9b36a76;p=order_line_extra.git diff --git a/includes/order_lines.inc b/includes/order_lines.inc index 52d315d..5f8d922 100644 --- a/includes/order_lines.inc +++ b/includes/order_lines.inc @@ -133,11 +133,13 @@ $row_id = $row['id']; "; } -function get_order_details_extra($customer_id) { +function get_order_details_extra($customer_id, $location) { $sql = "SELECT sod.id , so.order_no , stk_code - , quantity - qty_sent + , sod.quantity - qty_sent + , GREATEST(0, LEAST(qoh.quantity - quantity_before, sod.quantity - qty_sent)) + , quantity_before , required_date ,comment FROM ".TB_PREF."sales_order_details sod @@ -146,7 +148,9 @@ function get_order_details_extra($customer_id) { AND so.trans_type = ".ST_SALESORDER." AND so.debtor_no = $customer_id ) - WHERE quantity > qty_sent + JOIN ".TB_PREF."denorm_qoh qoh ON (stock_id = stk_code AND loc_code = '$location') + JOIN ".TB_PREF."denorm_order_details_queue d ON (d.id = sod.id) + WHERE sod.quantity > qty_sent "; return $sql;