Should fix the last issues.

This commit is contained in:
James Cole 2015-07-06 18:57:15 +02:00
parent 52df2edc8f
commit af13d1943f
2 changed files with 4 additions and 4 deletions

View File

@ -406,7 +406,7 @@ class AccountRepository implements AccountRepositoryInterface
'iban' => '', 'iban' => '',
]; ];
$opposing = $this->storeAccount($opposingData); $opposing = $this->storeAccount($opposingData);
if (!is_null($opposing)) { if (!is_null($opposing) && !is_null($newAccount)) {
$this->storeInitialBalance($newAccount, $opposing, $data); $this->storeInitialBalance($newAccount, $opposing, $data);
} }

View File

@ -248,7 +248,7 @@ class JournalRepository implements JournalRepositoryInterface
} }
// store accounts (depends on type) // store accounts (depends on type)
list($from, $to) = $this->storeAccounts($journal->transactionType, $data); list($fromAccount, $toAccount) = $this->storeAccounts($journal->transactionType, $data);
// update the from and to transaction. // update the from and to transaction.
/** @var Transaction $transaction */ /** @var Transaction $transaction */
@ -256,12 +256,12 @@ class JournalRepository implements JournalRepositoryInterface
if (floatval($transaction->amount) < 0) { if (floatval($transaction->amount) < 0) {
// this is the from transaction, negative amount: // this is the from transaction, negative amount:
$transaction->amount = $data['amount'] * -1; $transaction->amount = $data['amount'] * -1;
$transaction->account_id = $from->id; $transaction->account_id = $fromAccount->id;
$transaction->save(); $transaction->save();
} }
if (floatval($transaction->amount) > 0) { if (floatval($transaction->amount) > 0) {
$transaction->amount = $data['amount']; $transaction->amount = $data['amount'];
$transaction->account_id = $to->id; $transaction->account_id = $toAccount->id;
$transaction->save(); $transaction->save();
} }
} }