+ if ($type == ST_SUPPCREDIT) // credit note 2009-06-14 Joe Hunt Must restore the po and grn
+ { // We must get the corresponding invoice item to check for price chg.
+ $match = get_matching_invoice_item($details_row["stock_id"], $details_row["po_detail_item_id"]);
+ if ($match !== false)
+ $mat_cost = update_average_material_cost($grn["supplier_id"], $details_row["stock_id"],
+ $match["unit_price"], -$details_row["quantity"], sql2date($match['tran_date']), $match['tran_date'] !== $trans['tran_date']);
+ else
+ $mat_cost = update_average_material_cost($grn["supplier_id"], $details_row["stock_id"],
+ $details_row["FullUnitPrice"], -$details_row["quantity"], $old_date, $old[1] !== $trans['tran_date']);