- $memo_ = sprintf(_("Cost was %s changed to %s x quantity on hand for item '%s'"),
- number_format2($old_cost, 2), number_format2($new_cost, 2), $stock_id);
- add_gl_trans_std_cost(ST_COSTUPDATE, $update_no, $to, $stock_gl_code["cogs_account"],
- $stock_gl_code["dimension_id"], $stock_gl_code["dimension2_id"], $memo_, $diff);
+ $cart = new items_cart(ST_COSTUPDATE);
+ $cart->tran_date = $cart->doc_date = $cart->event_date = $to;
+ if (!is_date_in_fiscalyear($cart->tran_date))
+ $cart->tran_date = end_fiscalyear();
+ $cart->reference = $Refs->get_next(ST_COSTUPDATE, null, $cart->tran_date, $to);
+
+ $cart->memo_ = _("Cost was ") . $old_cost. _(" changed to ") . $new_cost . _(" for item ")."'$stock_id'";