Two smaller bugs [0000023],[0000026]
[fa-stable.git] / sales / includes / sales_db.inc
index 75fca059a1d98575c5077451b45ecbb0819e112c..f368b402180d1c1ba544e4e27e6e24ebad6e306b 100644 (file)
@@ -6,6 +6,7 @@ include_once($path_to_root . "/sales/includes/db/sales_order_db.inc");
 include_once($path_to_root . "/sales/includes/db/sales_credit_db.inc");
 include_once($path_to_root . "/sales/includes/db/sales_invoice_db.inc");
 include_once($path_to_root . "/sales/includes/db/sales_delivery_db.inc");
+include_once($path_to_root . "/sales/includes/db/sales_types_db.inc");
 include_once($path_to_root . "/sales/includes/db/custalloc_db.inc");
 include_once($path_to_root . "/sales/includes/db/cust_trans_db.inc");
 include_once($path_to_root . "/sales/includes/db/cust_trans_details_db.inc");
@@ -46,10 +47,16 @@ function add_gl_trans_customer($type, $type_no, $date_, $account, $dimension, $d
 
 //----------------------------------------------------------------------------------------
 
-function get_price ($stock_id, $currency, $sales_type_id, $factor, $date=null)
+function get_price ($stock_id, $currency, $sales_type_id, $factor=null, $date=null)
 {
        if ($date == null)
            $date = Today();
+
+       if ($factor === null) 
+       {
+               $myrow = get_sales_type(get_post('sales_type_id'));
+               $factor = $myrow['factor'];
+       }
            
        $sql = "SELECT ".TB_PREF."prices.price
                FROM ".TB_PREF."prices
@@ -162,7 +169,7 @@ function update_parent_line($doc_type, $line_id, $qty_dispatched)
 {
        $doc_type = get_parent_type($doc_type);
 
-       //echo "update line: $line_id, $doc_type, $qty_dispatch";
+//     echo "update line: $line_id, $doc_type, $qty_dispatched";
        if ($doc_type==0)
                return false;
        else {