diff --git a/app/controllers/GoogleChartController.php b/app/controllers/GoogleChartController.php
index f413c9c5a3..98696a972f 100644
--- a/app/controllers/GoogleChartController.php
+++ b/app/controllers/GoogleChartController.php
@@ -88,7 +88,7 @@ class GoogleChartController extends BaseController
/** @var \FireflyIII\Database\Account\Account $acct */
$acct = App::make('FireflyIII\Database\Account\Account');
- $accounts = count($pref->data) > 0 ? $acct->getByIds($pref->data) : $acct->getAssetAccounts();
+ $accounts = count($pref->data) > 0 ? $acct->getByIds($pref->data) : $acct->getAccountsByType(['Default account', 'Asset account']);
/** @var Account $account */
foreach ($accounts as $account) {
diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php
index 33bd974e5e..485f71cb15 100644
--- a/app/controllers/HomeController.php
+++ b/app/controllers/HomeController.php
@@ -33,7 +33,7 @@ class HomeController extends BaseController
/** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */
$preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface');
- $count = $acct->countAssetAccounts();
+ $count = $acct->countAccountsByType(['Default account', 'Asset account']);
$start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth());
@@ -42,7 +42,7 @@ class HomeController extends BaseController
// get the preference for the home accounts to show:
$frontPage = $preferences->get('frontPageAccounts', []);
if ($frontPage->data == []) {
- $accounts = $acct->getAssetAccounts();
+ $accounts = $acct->getAccountsByType(['Default account', 'Asset account']);
} else {
$accounts = $acct->getByIds($frontPage->data);
}
diff --git a/app/controllers/JsonController.php b/app/controllers/JsonController.php
index fedc5768d2..a0e6f08262 100644
--- a/app/controllers/JsonController.php
+++ b/app/controllers/JsonController.php
@@ -36,7 +36,7 @@ class JsonController extends BaseController
{
/** @var \FireflyIII\Database\Account\Account $accounts */
$accounts = App::make('FireflyIII\Database\Account\Account');
- $list = $accounts->getExpenseAccounts();
+ $list = $accounts->getAccountsByType(['Expense account', 'Beneficiary account']);
$return = [];
foreach ($list as $entry) {
$return[] = $entry->name;
@@ -53,7 +53,7 @@ class JsonController extends BaseController
{
/** @var \FireflyIII\Database\Account\Account $accounts */
$accounts = App::make('FireflyIII\Database\Account\Account');
- $list = $accounts->getRevenueAccounts();
+ $list = $accounts->getAccountsByType(['Revenue account']);
$return = [];
foreach ($list as $entry) {
$return[] = $entry->name;
diff --git a/app/controllers/PiggybankController.php b/app/controllers/PiggybankController.php
index 69222f22fa..16089486f2 100644
--- a/app/controllers/PiggybankController.php
+++ b/app/controllers/PiggybankController.php
@@ -62,7 +62,7 @@ class PiggyBankController extends BaseController
$acct = App::make('FireflyIII\Database\Account\Account');
$periods = Config::get('firefly.piggy_bank_periods');
- $accounts = FFForm::makeSelectList($acct->getAssetAccounts());
+ $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account']));
$subTitle = 'Create new piggy bank';
$subTitleIcon = 'fa-plus';
@@ -107,7 +107,7 @@ class PiggyBankController extends BaseController
$acct = App::make('FireflyIII\Database\Account\Account');
$periods = Config::get('firefly.piggy_bank_periods');
- $accounts = FFForm::makeSelectList($acct->getAssetAccounts());
+ $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account']));
$subTitle = 'Edit piggy bank "' . e($piggyBank->name) . '"';
$subTitleIcon = 'fa-pencil';
diff --git a/app/controllers/PreferencesController.php b/app/controllers/PreferencesController.php
index b1a5ca0fc7..ab4b81f717 100644
--- a/app/controllers/PreferencesController.php
+++ b/app/controllers/PreferencesController.php
@@ -29,7 +29,7 @@ class PreferencesController extends BaseController
/** @var \FireflyIII\Shared\Preferences\Preferences $preferences */
$preferences = App::make('FireflyIII\Shared\Preferences\Preferences');
- $accounts = $acct->getAssetAccounts();
+ $accounts = $acct->getAccountsByType(['Default account', 'Asset account']);
$viewRange = $preferences->get('viewRange', '1M');
$viewRangeValue = $viewRange->data;
$frontPage = $preferences->get('frontPageAccounts', []);
diff --git a/app/controllers/RepeatedExpenseController.php b/app/controllers/RepeatedExpenseController.php
index 652e255578..78272a9453 100644
--- a/app/controllers/RepeatedExpenseController.php
+++ b/app/controllers/RepeatedExpenseController.php
@@ -34,7 +34,7 @@ class RepeatedExpenseController extends BaseController
/** @var \FireflyIII\Database\Account\Account $acct */
$acct = App::make('FireflyIII\Database\Account\Account');
$periods = Config::get('firefly.piggy_bank_periods');
- $accounts = FFForm::makeSelectList($acct->getAssetAccounts());
+ $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account']));
return View::make('repeatedExpense.create', compact('accounts', 'periods'))->with('subTitle', 'Create new repeated expense')->with(
'subTitleIcon', 'fa-plus'
@@ -79,7 +79,7 @@ class RepeatedExpenseController extends BaseController
$acct = App::make('FireflyIII\Database\Account\Account');
$periods = Config::get('firefly.piggy_bank_periods');
- $accounts = FFForm::makeSelectList($acct->getAssetAccounts());
+ $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account']));
$subTitle = 'Edit repeated expense "' . e($repeatedExpense->name) . '"';
$subTitleIcon = 'fa-pencil';
diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php
index 2a4af46abb..74be723b18 100644
--- a/app/controllers/UserController.php
+++ b/app/controllers/UserController.php
@@ -78,9 +78,10 @@ class UserController extends BaseController
if ($user) {
$result = $email->sendVerificationMail($user);
- if($result === false) {
+ if ($result === false) {
$user->delete();
- return View::make('error')->with('message','The email message could not be send. See the log files.');
+
+ return View::make('error')->with('message', 'The email message could not be send. See the log files.');
}
return View::make('user.verification-pending');
@@ -126,7 +127,7 @@ class UserController extends BaseController
public function register()
{
if (Config::get('mail.from.address') == '@gmail.com' || Config::get('mail.from.address') == '') {
- return View::make('error')->with('message', 'Configuration error in app/config/'.App::environment().'/mail.php
');
+ return View::make('error')->with('message', 'Configuration error in app/config/' . App::environment() . '/mail.php
');
}
return View::make('user.register');
diff --git a/app/lib/FireflyIII/Database/Account/Account.php b/app/lib/FireflyIII/Database/Account/Account.php
index 368aeecac6..257ae7b79a 100644
--- a/app/lib/FireflyIII/Database/Account/Account.php
+++ b/app/lib/FireflyIII/Database/Account/Account.php
@@ -41,47 +41,6 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
return $this->getUser()->accounts()->accountTypeIn($types)->count();
}
- /**
- * @return int
- */
- public function countAssetAccounts()
- {
- return $this->countAccountsByType(['Default account', 'Asset account']);
- }
-
- /**
- * @return int
- */
- public function countExpenseAccounts()
- {
- return $this->countAccountsByType(['Expense account', 'Beneficiary account']);
- }
-
- /**
- * Counts the number of total revenue accounts. Useful for DataTables.
- *
- * @return int
- */
- public function countRevenueAccounts()
- {
- return $this->countAccountsByType(['Revenue account']);
- }
-
- /**
- * @param \Account $account
- *
- * @return \Account|null
- */
- public function findInitialBalanceAccount(\Account $account)
- {
- /** @var \FireflyIII\Database\AccountType\AccountType $acctType */
- $acctType = \App::make('FireflyIII\Database\AccountType\AccountType');
-
- $accountType = $acctType->findByWhat('initial');
-
- return $this->getUser()->accounts()->where('account_type_id', $accountType->id)->where('name', 'LIKE', $account->name . '%')->first();
- }
-
/**
* @param array $types
*
@@ -107,57 +66,6 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
return $set;
}
- /**
- * Get all asset accounts. Optional JSON based parameters.
- *
- * @param array $metaFilter
- *
- * @return Collection
- */
- public function getAssetAccounts($metaFilter = [])
- {
- $list = $this->getAccountsByType(['Default account', 'Asset account']);
- $list->each(
- function (\Account $account) {
-
- // get accountRole:
-
- /** @var \AccountMeta $entry */
- $accountRole = $account->accountmeta()->whereName('accountRole')->first();
- if (!$accountRole) {
- $accountRole = new \AccountMeta;
- $accountRole->account_id = $account->id;
- $accountRole->name = 'accountRole';
- $accountRole->data = 'defaultExpense';
- $accountRole->save();
-
- }
- $account->accountRole = $accountRole->data;
- }
- );
-
- return $list;
-
- }
-
- /**
- * @return Collection
- */
- public function getExpenseAccounts()
- {
- return $this->getAccountsByType(['Expense account', 'Beneficiary account']);
- }
-
- /**
- * Get all revenue accounts.
- *
- * @return Collection
- */
- public function getRevenueAccounts()
- {
- return $this->getAccountsByType(['Revenue account']);
- }
-
/**
* @param \Account $account
*
@@ -235,6 +143,31 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
}
+ /**
+ * @param \Account $account
+ *
+ * @return int
+ */
+ public function getLastActivity(\Account $account)
+ {
+ $lastActivityKey = 'account.' . $account->id . '.lastActivityDate';
+ if (\Cache::has($lastActivityKey)) {
+ return \Cache::get($lastActivityKey);
+ }
+
+ $transaction = $account->transactions()
+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
+ ->orderBy('transaction_journals.date', 'DESC')->first();
+ if ($transaction) {
+ $date = $transaction->transactionJournal->date;
+ } else {
+ $date = 0;
+ }
+ \Cache::forever($lastActivityKey, $date);
+
+ return $date;
+ }
+
/**
* @param Eloquent $model
*
@@ -571,57 +504,6 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
}
- /**
- * @param \Account $account
- * @param int $limit
- *
- * @return \Illuminate\Pagination\Paginator
- */
- public function getAllTransactionJournals(\Account $account, $limit = 50)
- {
- $offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0;
- $set = $this->getUser()->transactionJournals()->withRelevantData()->leftJoin(
- 'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
- )->where('transactions.account_id', $account->id)->take($limit)->offset($offset)->orderBy('date', 'DESC')->get(
- ['transaction_journals.*']
- );
- $count = $this->getUser()->transactionJournals()->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
- ->orderBy('date', 'DESC')->where('transactions.account_id', $account->id)->count();
- $items = [];
- foreach ($set as $entry) {
- $items[] = $entry;
- }
-
- return \Paginator::make($items, $count, $limit);
-
-
- }
-
- /**
- * @param \Account $account
- *
- * @return int
- */
- public function getLastActivity(\Account $account)
- {
- $lastActivityKey = 'account.' . $account->id . '.lastActivityDate';
- if (\Cache::has($lastActivityKey)) {
- return \Cache::get($lastActivityKey);
- }
-
- $transaction = $account->transactions()
- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
- ->orderBy('transaction_journals.date', 'DESC')->first();
- if ($transaction) {
- $date = $transaction->transactionJournal->date;
- } else {
- $date = 0;
- }
- \Cache::forever($lastActivityKey, $date);
-
- return $date;
- }
-
/**
* @param \Account $account
* @param int $limit
@@ -656,24 +538,4 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
}
- /**
- * @param \Account $account
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return \Illuminate\Pagination\Paginator
- */
- public function getTransactionJournalsInRange(\Account $account, Carbon $start, Carbon $end)
- {
- $set = $this->getUser()->transactionJournals()->transactionTypes(['Withdrawal'])->withRelevantData()->leftJoin(
- 'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
- )->where('transactions.account_id', $account->id)->before($end)->after($start)->orderBy('date', 'DESC')->get(
- ['transaction_journals.*']
- );
-
- return $set;
-
- }
-
-
}
diff --git a/app/lib/FireflyIII/Database/Account/AccountInterface.php b/app/lib/FireflyIII/Database/Account/AccountInterface.php
index 336df90401..c9d21ba229 100644
--- a/app/lib/FireflyIII/Database/Account/AccountInterface.php
+++ b/app/lib/FireflyIII/Database/Account/AccountInterface.php
@@ -21,34 +21,6 @@ interface AccountInterface
*/
public function countAccountsByType(array $types);
- /**
- * Counts the number of total asset accounts. Useful for DataTables.
- *
- * @return int
- */
- public function countAssetAccounts();
-
- /**
- * Counts the number of total expense accounts. Useful for DataTables.
- *
- * @return int
- */
- public function countExpenseAccounts();
-
- /**
- * Counts the number of total revenue accounts. Useful for DataTables.
- *
- * @return int
- */
- public function countRevenueAccounts();
-
- /**
- * @param \Account $account
- *
- * @return \Account|null
- */
- public function findInitialBalanceAccount(\Account $account);
-
/**
* Get all accounts of the selected types. Is also capable of handling DataTables' parameters.
*
@@ -58,24 +30,6 @@ interface AccountInterface
*/
public function getAccountsByType(array $types);
- /**
- * Get all asset accounts. The parameters are optional and are provided by the DataTables plugin.
- *
- * @return Collection
- */
- public function getAssetAccounts();
-
- /**
- * @return Collection
- */
- public function getExpenseAccounts();
-
- /**
- * Get all revenue accounts.
- *
- * @return Collection
- */
- public function getRevenueAccounts();
/**
* @param \Account $account
diff --git a/app/lib/FireflyIII/Report/Report.php b/app/lib/FireflyIII/Report/Report.php
index 56deca08ec..f3040fe30f 100644
--- a/app/lib/FireflyIII/Report/Report.php
+++ b/app/lib/FireflyIII/Report/Report.php
@@ -387,7 +387,7 @@ class Report implements ReportInterface
$sharedAccounts[] = $account->id;
}
- $accounts = $this->_accounts->getAssetAccounts()->filter(
+ $accounts = $this->_accounts->getAccountsByType(['Default account', 'Asset account'])->filter(
function (\Account $account) use ($sharedAccounts) {
if (!in_array($account->id, $sharedAccounts)) {
return $account;