From 450baba56a3ff3bba21a6def6757ffde7bbd5d3c Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 26 Jul 2015 17:03:05 +0200 Subject: [PATCH] Removed some dead code and fixed some other. --- .../Account/AccountRepository.php | 25 +++---------------- .../Account/AccountRepositoryInterface.php | 7 ------ 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index b4c466da49..023c74d0d5 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -228,23 +228,6 @@ class AccountRepository implements AccountRepositoryInterface 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. * @@ -583,10 +566,8 @@ class AccountRepository implements AccountRepositoryInterface */ protected function storeInitialBalance(Account $account, Account $opposing, array $data) { - $type = $data['openingBalance'] < 0 ? 'Withdrawal' : 'Deposit'; - $transactionType = TransactionType::whereType($type)->first(); - - $journal = new TransactionJournal( + $transactionType = TransactionType::whereType('Opening balance')->first(); + $journal = TransactionJournal::create( [ 'user_id' => $data['user'], 'transaction_type_id' => $transactionType->id, @@ -598,7 +579,6 @@ class AccountRepository implements AccountRepositoryInterface 'encrypted' => true ] ); - $journal->save(); if ($data['openingBalance'] < 0) { $firstAccount = $opposing; @@ -611,6 +591,7 @@ class AccountRepository implements AccountRepositoryInterface $firstAmount = $data['openingBalance']; $secondAmount = $data['openingBalance'] * -1; } + $one = new Transaction(['account_id' => $firstAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $firstAmount]); $one->save();// first transaction: from diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php index 28c1bd8eec..a6aaba2452 100644 --- a/app/Repositories/Account/AccountRepositoryInterface.php +++ b/app/Repositories/Account/AccountRepositoryInterface.php @@ -102,13 +102,6 @@ interface AccountRepositoryInterface */ public function getJournals(Account $account, $page); - /** - * @param Account $account - * - * @return Carbon|null - */ - public function getLastActivity(Account $account); - /** * @return float */