Delivery Against Sales Order Inquiry View, Wrong Remainder Value. Fixed.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Sat, 13 Jun 2020 07:17:55 +0000 (09:17 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Sat, 13 Jun 2020 07:17:55 +0000 (09:17 +0200)
sales/includes/db/sales_order_db.inc

index efbf7ae00210ccd985b10d6efa2cbfb34e88812f..a6bb878cfa2f673127c266aea975cf3c543ed7f2 100644 (file)
@@ -464,6 +464,10 @@ function get_branch_to_order($customer_id, $branch_id) {
 function get_sql_for_sales_orders_view($trans_type, $trans_no, $filter, 
        $stock_item='', $from='', $to='', $ref='', $location=ALL_TEXT, $customer_id=ALL_TEXT)
 {
+    if ($filter=='OutstandingOnly')
+        $order_value = 'Sum(line.unit_price*(line.quantity-line.qty_sent)*(1-line.discount_percent))+freight_cost';
+    else
+        $order_value = 'Sum(line.unit_price*line.quantity*(1-line.discount_percent))+freight_cost';
 
        $sql = "SELECT 
                        sorder.order_no,
@@ -476,7 +480,7 @@ function get_sql_for_sales_orders_view($trans_type, $trans_no, $filter,
                        ."sorder.ord_date,
                        sorder.delivery_date,
                        sorder.deliver_to,
-                       Sum(line.unit_price*line.quantity*(1-line.discount_percent))+freight_cost AS OrderValue,
+                       $order_value AS OrderValue,
                        sorder.type,
                        debtor.curr_code,
                        Sum(line.qty_sent) AS TotDelivered,