Bug [0000043] Inventory Adjustment Session doesn't update standard cost
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 2 Sep 2008 22:24:49 +0000 (22:24 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 2 Sep 2008 22:24:49 +0000 (22:24 +0000)
Bug [0000044]Standard Cost error on credit note

CHANGELOG.txt
inventory/includes/db/items_adjust_db.inc
purchasing/includes/db/grn_db.inc
purchasing/includes/db/invoice_db.inc

index 388f1a3feccb02c086541421c44a677555c8bf8b..b796eaaf196d33afe305ece190920b9e553b6681 100644 (file)
@@ -19,6 +19,13 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+03-Sep-2008 Joe Hunt
+# Bug [0000043] Inventory Adjustment Session doesn't update standard cost
+# Bug [0000044]Standard Cost error on credit note
+$ /inventory/includes/db/items_adjust_db.inc
+  /purchasing/includes/db/grn_db.inc
+  /purchasing/includes/invoice_db.inc
+
 02-Sep-2008 Joe Hunt
 # Bug when selecting report, List of Journal Entries, by type. Nothing selected.
 $ /reporting/includes/reports_classes.inc
index bab75ba7cd42533fe8c3e1d14febe76f91a134c7..bd85f6cd8f7ec99a99df049e1f6a5deb0b540459 100644 (file)
@@ -74,6 +74,7 @@ function add_stock_adjustment_item($adj_id, $stock_id, $location, $date_, $type,
 
                add_gl_trans_std_cost(systypes::inventory_adjustment(), $adj_id, $date_, $stock_gl_codes['inventory_account'], 0, 0, $memo_, ($standard_cost * $quantity));
        }
+       update_average_material_cost(null, $stock_id, $standard_cost, $quantity, $date_);
 }
 
 //-------------------------------------------------------------------------------------------------------------
index 756c972fecb5d3f59b6daa7e378999430b263e56..8bd47b45ce3e9fcea6d828eb243e2da58c20c4b7 100644 (file)
@@ -4,7 +4,10 @@
 
 function update_average_material_cost($supplier, $stock_id, $price, $qty, $date, $adj_only=false)
 {
-       $currency = get_supplier_currency($supplier);
+       if ($supplier != null)
+               $currency = get_supplier_currency($supplier);
+       else
+               $currency = null;
        if ($currency != null)
                $price_in_home_currency = to_home_currency($price, $currency, $date);
        else
index 014e5ce85d612c85376ffd50be678b9791a1dad7..a743106fe8d23ecf79948008bd23e6c754a70a87 100644 (file)
@@ -170,6 +170,8 @@ function add_supp_invoice($supp_trans) // do not receive as ref because we chang
        if (!$supp_trans->is_invoice)
        {
                        $entered_grn->this_quantity_inv = -$entered_grn->this_quantity_inv;
+                       update_average_material_cost($supp_trans->supplier_id, $entered_grn->item_code,
+                       $entered_grn->chg_price, $entered_grn->this_quantity_inv, $date_);
        }
 
                $line_taxfree = $entered_grn->taxfree_charge_price($supp_trans->tax_group_id);
@@ -184,7 +186,7 @@ function add_supp_invoice($supp_trans) // do not receive as ref because we chang
                        $entered_grn->this_quantity_inv * $line_taxfree, $supp_trans->supplier_id);
        // -------------- if price changed since po received. 16 Aug 2008 Joe Hunt
                $old_price = $old[0];
-       if ($old_price != $entered_grn->chg_price) // price-change, so update
+       if ($supp_trans->is_invoice && $old_price != $entered_grn->chg_price) // price-change, so update
        {
                $diff = $entered_grn->chg_price - $old_price;
                        $old_date = sql2date($old[1]);