Skip to content

Firefly III: a personal finances manager

Removed some dead code and fixed some other.

James Cole450baba56a3f
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
*/