- $id = get_next_trans_no(ST_JOURNAL);
- $ref = $Refs->get_next(ST_JOURNAL);
- add_gl_trans(ST_JOURNAL, $id, $date_, get_post('acc_act'), 0,
- 0, $ref, $am0 * -1);
- add_gl_trans(ST_JOURNAL, $id, $date_, get_post('res_act'), get_post('dimension_id'),
- get_post('dimension2_id'), $ref, $am0);
- add_comments(ST_JOURNAL, $id, $date_, $memo);
- $Refs->save(ST_JOURNAL, $id, $ref);
+ $cart = new items_cart(ST_JOURNAL);
+ $cart->memo_ = $memo;
+ $cart->reference = $Refs->get_next(ST_JOURNAL, null, $date);
+ $cart->tran_date = $cart->doc_date = $cart->event_date = $date;
+ $cart->add_gl_item(get_post('acc_act'), 0, 0, -$am0, $cart->reference);
+ $cart->add_gl_item(get_post('res_act'), get_post('dimension_id'),
+ get_post('dimension2_id'), $am0, $cart->reference);
+ write_journal_entries($cart);
+ $cart->clear_items();