[0000137] Material Cost Averaging Problem (again again) when voiding.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 25 Jun 2009 22:56:18 +0000 (22:56 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 25 Jun 2009 22:56:18 +0000 (22:56 +0000)
CHANGELOG.txt
purchasing/includes/db/invoice_db.inc

index ac02895307df41a98e34492c2134c1521ae0cfe7..c9a09f967cba2833c8795ad92fb61008e05e1674 100644 (file)
@@ -19,6 +19,10 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+26-Jun-2009 Joe Hunt
+# [0000137] Material Cost Averaging Problem (again again) when voiding.
+$ /purchasing/includes/db/invoice_db.inc
+
 ------------------------------- Release 2.1.3 ----------------------------------
 25-Jun-2009 Joe Hunt
 ! Release 2.1.3
index 38a9ec138e61cd07dd333fc7208979f0afad86a4..96d82d8328444b7e0a21c5e0bc4f93058b07e0f2 100644 (file)
@@ -442,13 +442,17 @@ function void_supp_invoice($type, $type_no)
                                        $sql = "UPDATE ".TB_PREF."grn_items SET qty_recd=qty_recd+".-$details_row["quantity"]."
                                                WHERE id=".$details_row["grn_item_id"];
                                        db_query($sql);
-                       }               
-                               $diff = get_diff_in_home_currency($grn["supplier_id"], $old_date, $date_, $old[2], 
-                                       $details_row["FullUnitPrice"]);
-                               // Only adjust the avg for the diff
-                               $mat_cost = update_average_material_cost(null, $details_row["stock_id"],
-                                       $diff, -$details_row["quantity"], $old_date, true);
-
+                                       $mat_cost = update_average_material_cost($grn["supplier_id"], $details_row["stock_id"],  
+                                               $details_row["FullUnitPrice"], -$details_row["quantity"], $date_);
+                       }
+                       else
+                       {
+                                       $diff = get_diff_in_home_currency($grn["supplier_id"], $old_date, $date_, $old[2], 
+                                               $details_row["FullUnitPrice"]);
+                                       // Only adjust the avg for the diff
+                                       $mat_cost = update_average_material_cost(null, $details_row["stock_id"],
+                                               $diff, -$details_row["quantity"], $old_date, true);
+                               }
                                $deliveries = get_deliveries_between($details_row["stock_id"], $old_date, $date_);
                                if ($deliveries[0] != 0) // have deliveries been done during the period?
                                {