Bug 5466: user qty decimals handled incorrectly by code that calls get_item_edit_info...
[fa-stable.git] / includes / db / inventory_db.inc
index 19f54f2b9802d08cafeba64bc362d9266433cad1..4ffda2e7abe2a1ff0497b71d7b2c691ab7e63766 100644 (file)
@@ -93,7 +93,10 @@ function get_item_edit_info($stock_id)
                ." AND item.units=unit.abbr";
        $result = db_query($sql, "The standard cost cannot be retrieved");
 
-       return db_fetch($result);
+       $row = db_fetch($result);
+       if ($row['decimals'] == -1)
+               $row['decimals'] = user_qty_dec();
+       return $row;
 }
 
 //--------------------------------------------------------------------------------------
@@ -110,6 +113,20 @@ function get_unit_cost($stock_id)
        return $myrow[0];
 }
 
+//--------------------------------------------------------------------------------------
+function get_purchase_cost($stock_id)
+{
+       $sql = "SELECT purchase_cost
+               FROM ".TB_PREF."stock_master
+               WHERE stock_id=".db_escape($stock_id);
+       $result = db_query($sql, "The purchase cost cannot be retrieved");
+
+       $myrow = db_fetch_row($result);
+
+       return $myrow[0];
+}
+
 //--------------------------------------------------------------------------------------
 
 function is_inventory_item($stock_id)
@@ -317,7 +334,7 @@ function get_stock_gl_code($stock_id)
 {
        /*Gets the GL Codes relevant to the item account  */
        $sql = "SELECT mb_flag, inventory_account, cogs_account,
-               adjustment_account, sales_account, assembly_account, dimension_id, dimension2_id FROM
+               adjustment_account, sales_account, wip_account, dimension_id, dimension2_id FROM
                ".TB_PREF."stock_master WHERE stock_id = ".db_escape($stock_id);
 
        $get = db_query($sql,"retreive stock gl code");