- add_gl_trans_std_cost(ST_COSTUPDATE, $update_no, $date_, $stock_gl_code["inventory_account"], 0, 0, $memo_,
- $value_of_change);
+ $cart = new items_cart(ST_COSTUPDATE);
+ $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, $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);