- $problemTransaction = check_bank_account_history(-$amount, $from_account, $date_);
- if ($problemTransaction) {
- // If the target account is the same as that being edited, it may be that voiding old transfer will
- // solve balance problem.
- //
- if ($from_account == $old_from['bank_act'] && sql_date_comp($problemTransaction['trans_date'], $old_from['trans_date']) >=0 ) {
- $problemTransaction = check_bank_account_history(-$amount-$old_from['amount'], $from_account, $date_);
- }
+ $balance_offset = 0;
+ if ($from_account == $old_from['bank_act'] && sql_date_comp(date2sql($date_), $old_from['trans_date']) >= 0) {
+ // If the edited from_account is the same as the original transaction, and the new date is later than the old date
+ // then add the amount from the original from transaction when checking the history to simulate the void that would
+ // take effect from that date.
+ $balance_offset = -$old_from['amount'];