+ if ($trans_type == ST_BANKPAYMENT AND $is_bank_to)
+ {
+ // we don't allow payments to go to a bank account. use transfer for this !
+ display_db_error("invalid payment entered. Cannot pay to another bank account", "");
+ }
+
+ // do the destination account postings
+ $total += add_gl_trans($trans_type, $trans_no, $date_, $gl_item->code_id,
+ $gl_item->dimension_id, $gl_item->dimension2_id, $gl_item->reference,
+ $gl_item->amount, $currency, $person_type_id, $person_id);
+
+ if ($is_bank_to)
+ {
+ add_bank_trans($trans_type, $trans_no, $is_bank_to, $ref,
+ $date_, $gl_item->amount,
+ $person_type_id, $person_id, $currency,
+ "Cannot insert a destination bank transaction");
+ if ($do_exchange_variance)
+ {
+ add_exchange_variation($trans_no1, $date_, $is_bank_to, $gl_item->code_id,
+ $currency, $person_type_id, $person_id);
+ }
+ }
+ // store tax details if the gl account is a tax account
+
+ $amount = $gl_item->amount;
+ $ex_rate = get_exchange_rate_from_home_currency($currency, $date_);
+
+ add_gl_tax_details($gl_item->code_id, $trans_type, $trans_no, -$amount,
+ $ex_rate, $date_, $memo_);
+ }
+ // do the source account postings
+ add_gl_trans($trans_type, $trans_no, $date_, $bank_gl_account, 0, 0, $memo_,
+ -$total, null, $person_type_id, $person_id);
+
+ if ($do_exchange_variance)
+ {
+ if ($exchanged || add_exchange_variation($trans_no1, $date_, $from_account, $bank_gl_account,
+ $currency, $person_type_id, $person_id))
+ {
+ $ref1 = $Refs->get_next(ST_JOURNAL);
+ $Refs->save(ST_JOURNAL, $trans_no1, $ref1);
+ add_audit_trail(ST_JOURNAL, $trans_no1, $date_);
+ }
+ }
+
+ add_comments($trans_type, $trans_no, $date_, $memo_);
+
+ $Refs->save($trans_type, $trans_no, $ref);
+ add_audit_trail($trans_type, $trans_no, $date_);
+
+ if ($use_transaction)
+ commit_transaction();
+
+ return array($trans_type, $trans_no);
+}
+
+//----------------------------------------------------------------------------------------