Sales quotations were displayed even when realized [0000498].
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Fri, 21 Jan 2011 14:41:50 +0000 (14:41 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Fri, 21 Jan 2011 14:41:50 +0000 (14:41 +0000)
sales/includes/db/sales_order_db.inc
sales/includes/sales_db.inc

index eb5665ab71c46165a324d3da8c31661bc826855d..c4e5046529166c66c5ae11bbe94ad4e853c79a8e 100644 (file)
@@ -87,8 +87,10 @@ function add_sales_order(&$order)
                                $line->discount_percent)";
                db_query($sql, "order Details Cannot be Added");
 
+       // Now mark quotation line as processed
+               if ($order->trans_type == ST_SALESORDER && $line->src_id)
+                       update_parent_line(ST_SALESORDER, $line->src_id, $line->qty_dispatched); // clear all the quote despite all or the part was ordered
        } /* inserted line items into sales order details */
-
        add_audit_trail($order->trans_type, $order_no, $order->document_date);
        $Refs->save($order->trans_type, $order_no, $order->reference);
 
@@ -542,7 +544,8 @@ function get_sql_for_sales_orders_view($selected_customer, $trans_type)
                                        ." AND sorder.ord_date <= '$date_before'";
                }
                if ($trans_type == ST_SALESQUOTE && !check_value('show_all'))
-                       $sql .= " AND sorder.delivery_date >= '".date2sql(Today())."'";
+                       $sql .= " AND sorder.delivery_date >= '".date2sql(Today())."' AND line.qty_sent=0"; // show only outstanding, not realized quotes
+
                if ($selected_customer != -1)
                        $sql .= " AND sorder.debtor_no=".db_escape($selected_customer);
 
@@ -554,6 +557,7 @@ function get_sql_for_sales_orders_view($selected_customer, $trans_type)
 
                if ($_POST['order_view_mode']=='OutstandingOnly')
                        $sql .= " AND line.qty_sent < line.quantity";
+
                elseif ($_POST['order_view_mode']=='InvoiceTemplates' || $_POST['order_view_mode']=='DeliveryTemplates')
                        $sql .= " AND sorder.type=1";
 
index 5e6913d16b730795459d21f9d3c706ff68e9767b..e9410251065c33cf4a966ad902055fdcd00711d7 100644 (file)
@@ -204,17 +204,17 @@ function update_parent_line($doc_type, $line_id, $qty_dispatched, $auto=false)
         $qty_dispatched = (float)$qty_dispatched;
 
 //     echo "update line: $line_id, $doc_type, $qty_dispatched";
-       if ($doc_type==0)
+       if ($doc_type == 0)
                return false;
        else {
-               if ($doc_type==ST_SALESORDER)
+               if ($doc_type==ST_SALESORDER || $doc_type==ST_SALESQUOTE)
                {
                        $sql = "UPDATE ".TB_PREF."sales_order_details
                                SET qty_sent = qty_sent + $qty_dispatched";
                        if ($auto)
                                $sql .= ", quantity = quantity + $qty_dispatched";
                        $sql .= " WHERE id=".db_escape($line_id);
-               }               
+               }
                else
                        $sql = "UPDATE ".TB_PREF."debtor_trans_details
                                SET qty_done = qty_done + $qty_dispatched