Removed some dead code and fixed some other.

This commit is contained in:
James Cole 2015-07-26 17:03:05 +02:00
parent 17a8c4918c
commit 450baba56a
2 changed files with 3 additions and 29 deletions

View File

@ -228,23 +228,6 @@ class AccountRepository implements AccountRepositoryInterface
return $list; return $list;
} }
/**
* @param Account $account
*
* @return Carbon|null
*/
public function getLastActivity(Account $account)
{
$lastTransaction = $account->transactions()->leftJoin(
'transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
)->orderBy('transaction_journals.date', 'DESC')->first(['transactions.account_id', 'transaction_journals.date']);
if ($lastTransaction) {
return $lastTransaction->date;
}
return null;
}
/** /**
* Get the accounts of a user that have piggy banks connected to them. * Get the accounts of a user that have piggy banks connected to them.
* *
@ -583,10 +566,8 @@ class AccountRepository implements AccountRepositoryInterface
*/ */
protected function storeInitialBalance(Account $account, Account $opposing, array $data) protected function storeInitialBalance(Account $account, Account $opposing, array $data)
{ {
$type = $data['openingBalance'] < 0 ? 'Withdrawal' : 'Deposit'; $transactionType = TransactionType::whereType('Opening balance')->first();
$transactionType = TransactionType::whereType($type)->first(); $journal = TransactionJournal::create(
$journal = new TransactionJournal(
[ [
'user_id' => $data['user'], 'user_id' => $data['user'],
'transaction_type_id' => $transactionType->id, 'transaction_type_id' => $transactionType->id,
@ -598,7 +579,6 @@ class AccountRepository implements AccountRepositoryInterface
'encrypted' => true 'encrypted' => true
] ]
); );
$journal->save();
if ($data['openingBalance'] < 0) { if ($data['openingBalance'] < 0) {
$firstAccount = $opposing; $firstAccount = $opposing;
@ -611,6 +591,7 @@ class AccountRepository implements AccountRepositoryInterface
$firstAmount = $data['openingBalance']; $firstAmount = $data['openingBalance'];
$secondAmount = $data['openingBalance'] * -1; $secondAmount = $data['openingBalance'] * -1;
} }
$one = new Transaction(['account_id' => $firstAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $firstAmount]); $one = new Transaction(['account_id' => $firstAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $firstAmount]);
$one->save();// first transaction: from $one->save();// first transaction: from

View File

@ -102,13 +102,6 @@ interface AccountRepositoryInterface
*/ */
public function getJournals(Account $account, $page); public function getJournals(Account $account, $page);
/**
* @param Account $account
*
* @return Carbon|null
*/
public function getLastActivity(Account $account);
/** /**
* @return float * @return float
*/ */