X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=purchasing%2Fincludes%2Fdb%2Fgrn_db.inc;h=81b11bb97ed22c8b755f510e8d5bd6ca2862e480;hb=65c68ebb3a09aa06418fb7f5e1712ca8012d756f;hp=910cf9a6f30af6e43fb2cbb91ddf7b0436cc10f3;hpb=e3f700d1e11788f176bf02c7b9969780e66dc167;p=fa-stable.git diff --git a/purchasing/includes/db/grn_db.inc b/purchasing/includes/db/grn_db.inc index 910cf9a6..81b11bb9 100644 --- a/purchasing/includes/db/grn_db.inc +++ b/purchasing/includes/db/grn_db.inc @@ -34,8 +34,11 @@ function add_grn(&$po, $date_, $reference, $location) $myrow = db_fetch($result); $material_cost = $myrow['material_cost']; $qoh = get_qoh_on_date($order_line->stock_id, null, $date_); - $material_cost = ($qoh * $material_cost + $order_line->receive_qty * $price_in_home_currency) / - ($qoh + $order_line->receive_qty); + if ($qoh + $order_line->receive_qty <= 0) + $material_cost = 0; + else + $material_cost = ($qoh * $material_cost + $order_line->receive_qty * $price_in_home_currency) / + ($qoh + $order_line->receive_qty); $sql = "UPDATE ".TB_PREF."stock_master SET material_cost=$material_cost WHERE stock_id='$order_line->stock_id'"; db_query($sql,"The cost details for the inventory item could not be updated"); @@ -56,8 +59,6 @@ function add_grn(&$po, $date_, $reference, $location) } /*quantity received is != 0 */ } /*end of order_line loop */ - add_forms_for_sys_type(25, $grn, $location); - references::save_last($reference, 25); commit_transaction();