From: Joe Hunt Date: Thu, 25 Jun 2009 22:56:18 +0000 (+0000) Subject: [0000137] Material Cost Averaging Problem (again again) when voiding. X-Git-Tag: 2.3-final~1189 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=b4b624bce74fd33a6a8795b8b4ed01eac47bc0fe;p=fa-stable.git [0000137] Material Cost Averaging Problem (again again) when voiding. --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ac028953..c9a09f96 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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 diff --git a/purchasing/includes/db/invoice_db.inc b/purchasing/includes/db/invoice_db.inc index 38a9ec13..96d82d83 100644 --- a/purchasing/includes/db/invoice_db.inc +++ b/purchasing/includes/db/invoice_db.inc @@ -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? {