X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=inventory%2Fincludes%2Fdb%2Fitems_trans_db.inc;h=dfbc5eebeb9eab3b9f47cc12bd16511f11dda9ce;hb=66cfb670d9261ad0364a91822dc0766de1620799;hp=c12641463c4f3a50d67927e5d9b5b8222461f6ba;hpb=e9ad9e87f5eb2682d2e91c93134250fd8a8d2ad9;p=fa-stable.git diff --git a/inventory/includes/db/items_trans_db.inc b/inventory/includes/db/items_trans_db.inc index c1264146..dfbc5eeb 100644 --- a/inventory/includes/db/items_trans_db.inc +++ b/inventory/includes/db/items_trans_db.inc @@ -12,7 +12,7 @@ //------------------------------------------------------------------------------------------------------------- function stock_cost_update($stock_id, $material_cost, $labour_cost, $overhead_cost, - $last_cost) + $last_cost, $refline, $memo_) { $mb_flag = get_mb_flag($stock_id); @@ -31,9 +31,8 @@ function stock_cost_update($stock_id, $material_cost, $labour_cost, $overhead_co begin_transaction(); $sql = "UPDATE ".TB_PREF."stock_master SET material_cost=".db_escape($material_cost).", - labour_cost=".db_escape($labour_cost).", - overhead_cost=".db_escape($overhead_cost).", - last_cost=".db_escape($last_cost)." + labour_cost=".db_escape($labour_cost).", + overhead_cost=".db_escape($overhead_cost)." WHERE stock_id=".db_escape($stock_id); db_query($sql,"The cost details for the inventory item could not be updated"); @@ -58,17 +57,19 @@ function stock_cost_update($stock_id, $material_cost, $labour_cost, $overhead_co $cart->tran_date = $cart->doc_date = $cart->event_date = $date_; if (!is_date_in_fiscalyear($cart->tran_date)) $cart->tran_date = end_fiscalyear(); - $cart->reference = $Refs->get_next(ST_COSTUPDATE, null, $cart->tran_date, $date_); - - $cart->memo_ = sprintf(_("Cost was %s changed to %s x quantity on hand of %s"), - number_format2($last_cost, 2), number_format2($new_cost), $qoh); + $cart->reference = $Refs->get_next(ST_COSTUPDATE, $refline, $cart->tran_date, $date_); + + if (empty($memo_)) + $cart->memo_ = sprintf(_("Cost was %s changed to %s x quantity on hand of %s"), + number_format2($last_cost, 2), number_format2($new_cost), $qoh); + else + $cart->memo_ = $memo_; $cart->add_gl_item($stock_gl_code["adjustment_account"], $stock_gl_code["dimension_id"], $stock_gl_code["dimension2_id"], -$value_of_change); $cart->add_gl_item($stock_gl_code["inventory_account"], 0, 0, $value_of_change); write_journal_entries($cart); - change_stock_moves_std_cost($stock_id, $date_, $new_cost - $last_cost); } } @@ -78,13 +79,3 @@ function stock_cost_update($stock_id, $material_cost, $labour_cost, $overhead_co return $update_no; } - -//------------------------------------------------------------------------------------------------------------- - -function change_stock_moves_std_cost($stock_id, $date, $diff_cost) -{ - $date = date2sql($date); - $sql = "UPDATE ".TB_PREF."stock_moves SET standard_cost = standard_cost + ".db_escape($diff_cost). " WHERE stock_id = " - . db_escape($stock_id)." AND tran_date <= '$date' AND qty <> 0 AND standard_cost > 0.001 AND type <> ".ST_LOCTRANSFER; - db_query($sql,"The stock moves cost details for the inventory item could not be updated"); -}