protected function updateAccountVirtual(Account $account, Account $previousAccount, $amount, $previousAmount)
    {
        $accountMapper = new AccountMapper(Database::get('money'));

        //~ Revert previous amount on previous account
        if ($previousAccount->getId() > 0) {
            if ($previousAccount->getId() !== $account->getId()) {
                $previousAccount->addAmount(-$previousAmount);
                $accountMapper->update($previousAccount);
            } else {
                $account->addAmount(-$previousAmount);
            }
        }

        //~ Update amount of current account
        $account->addAmount($amount);
        $accountMapper->update($account);
    }
protected function updateAccountVirtual(Account $account, Account $previousAccount, $amount, $previousAmount)
    {
        $accountMapper = new AccountMapper(Database::get('money'));

        //~ Revert previous amount on previous account
        if ($previousAccount->getId() > 0) {
            if ($previousAccount->getId() !== $account->getId()) {
                $previousAccount->addAmount(-$previousAmount);
                $accountMapper->update($previousAccount);
            } else {
                $account->addAmount(-$previousAmount);
            }
        }

        //~ Update amount of current account
        $account->addAmount($amount);
        $accountMapper->update($account);
    }
protected function updateAccountVirtual ( Account $ account , Account $ previousAccount , $ amount , $ previousAmount ) { $ accountMapper = new AccountMapper ( Database :: get ( 'money' ) ) ; //~ Revert previous amount on previous account if ( $ previousAccount -> getId ( ) > 0 ) { if ( $ previousAccount -> getId ( ) !== $ account -> getId ( ) ) { $ previousAccount -> addAmount ( - $ previousAmount ) ; $ accountMapper -> update ( $ previousAccount ) ; } else { $ account -> addAmount ( - $ previousAmount ) ; } } //~ Update amount of current account $ account -> addAmount ( $ amount ) ; $ accountMapper -> update ( $ account ) ; }
Update virtual account

@param  Account $account
@param  Account $previousAccount
@param  float   $amount
@param  float   $previousAmount
@return void
Update virtual account