Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Code cleanup [skip ci]
James Cole550f301ba24d
diff --git a/app/commands/Cleanup.php b/app/commands/Cleanup.phpindex aca68e02a1..db76195588 100644--- a/app/commands/Cleanup.php+++ b/app/commands/Cleanup.php@@ -1,8 +1,6 @@<?phpuse Illuminate\Console\Command;-//use Symfony\Component\Console\Input\InputArgument;-//use Symfony\Component\Console\Input\InputOption;/*** Class Cleanupdiff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.phpindex 7ca74d1cf3..35583db871 100644--- a/app/controllers/AccountController.php+++ b/app/controllers/AccountController.php@@ -187,7 +187,7 @@ class AccountController extends BaseControllerreturn Redirect::route('accounts.create', e($data['what']))->withInput();}- // store:+ // store$this->_repository->store($data);Session::flash('success', 'Account "' . e($data['name']) . '" stored.');if ($data['post_submit_action'] == 'store') {diff --git a/app/controllers/BillController.php b/app/controllers/BillController.phpindex 2b10e6d242..092ea2929b 100644--- a/app/controllers/BillController.php+++ b/app/controllers/BillController.php@@ -149,7 +149,7 @@ class BillController extends BaseControllerreturn Redirect::route('bills.create')->withInput();}- // store:+ // store$this->_repository->store($data);Session::flash('success', 'Bill "' . e($data['name']) . '" stored.');if ($data['post_submit_action'] == 'store') {diff --git a/app/controllers/BudgetController.php b/app/controllers/BudgetController.phpindex a3fa3bd014..4d48ce1e8f 100644--- a/app/controllers/BudgetController.php+++ b/app/controllers/BudgetController.php@@ -179,7 +179,7 @@ class BudgetController extends BaseControllerreturn Redirect::route('budgets.create')->withInput();}- // store:+ // store$this->_repository->store($data);Session::flash('success', 'Budget "' . e($data['name']) . '" stored.');if ($data['post_submit_action'] == 'store') {diff --git a/app/controllers/CategoryController.php b/app/controllers/CategoryController.phpindex a067224a36..3f4062ceea 100644--- a/app/controllers/CategoryController.php+++ b/app/controllers/CategoryController.php@@ -116,7 +116,7 @@ class CategoryController extends BaseControllerreturn Redirect::route('categories.create')->withInput();}- // store:+ // store$this->_repository->store($data);Session::flash('success', 'Category "' . e($data['name']) . '" stored.');if ($data['post_submit_action'] == 'store') {diff --git a/app/controllers/CurrencyController.php b/app/controllers/CurrencyController.phpindex 9daadad525..71c3c92b0b 100644--- a/app/controllers/CurrencyController.php+++ b/app/controllers/CurrencyController.php@@ -145,7 +145,7 @@ class CurrencyController extends BaseControllerreturn Redirect::route('currency.create')->withInput();}- // store:+ // store$this->_repository->store($data);Session::flash('success', 'Currency "' . e($data['name']) . '" stored.');if ($data['post_submit_action'] == 'store') {diff --git a/app/controllers/PiggybankController.php b/app/controllers/PiggybankController.phpindex 64e5917d41..cc262a9e42 100644--- a/app/controllers/PiggybankController.php+++ b/app/controllers/PiggybankController.php@@ -297,7 +297,7 @@ class PiggyBankController extends BaseControllerreturn Redirect::route('piggy_banks.create')->withInput();}- // store:+ // store$piggyBank = $this->_repository->store($data);Event::fire('piggy_bank.store', [$piggyBank]); // new and used.Session::flash('success', 'Piggy bank "' . e($data['name']) . '" stored.');diff --git a/app/controllers/RepeatedExpenseController.php b/app/controllers/RepeatedExpenseController.phpindex 695b5dbd7b..c97e36bc79 100644--- a/app/controllers/RepeatedExpenseController.php+++ b/app/controllers/RepeatedExpenseController.php@@ -168,7 +168,7 @@ class RepeatedExpenseController extends BaseControllerreturn Redirect::route('repeated.create')->withInput();}- // store:+ // store$piggyBank = $this->_repository->store($data);Event::fire('piggy_bank.store', [$piggyBank]); // new and used.Session::flash('success', 'Piggy bank "' . e($data['name']) . '" stored.');diff --git a/app/controllers/ReportController.php b/app/controllers/ReportController.phpindex 037b5e2627..449486e13e 100644--- a/app/controllers/ReportController.php+++ b/app/controllers/ReportController.php@@ -94,7 +94,6 @@ class ReportController extends BaseController$budgets = $this->_repository->getBudgetsForMonth($date);$categories = $this->_repository->getCategoriesForMonth($date, 10);$accounts = $this->_repository->getAccountsForMonth($date);- //$piggyBanks = $this->_repository->getPiggyBanksForMonth($date);return View::make('reports.month',diff --git a/app/controllers/TransactionController.php b/app/controllers/TransactionController.phpindex a7f00e3900..3399cc6212 100644--- a/app/controllers/TransactionController.php+++ b/app/controllers/TransactionController.php@@ -382,7 +382,7 @@ class TransactionController extends BaseControllerreturn Redirect::route('transactions.create', $data['what'])->withInput();}- // store:+ // store$journal = $this->_repository->store($data);Event::fire('transactionJournal.store', [$journal, Input::get('piggy_bank_id')]); // new and used./*diff --git a/app/controllers/UserController.php b/app/controllers/UserController.phpindex 12d35e5d67..5ecd6a4ee4 100644--- a/app/controllers/UserController.php+++ b/app/controllers/UserController.php@@ -76,8 +76,6 @@ class UserController extends BaseController$user = $repository->register(Input::all());-- //$user = $this->user->register(Input::all());if ($user) {$email->sendVerificationMail($user);diff --git a/app/database/migrations/2014_07_09_204843_create_session_table.php b/app/database/migrations/2014_07_09_204843_create_session_table.phpindex 3100f7e9b8..e09703979a 100644--- a/app/database/migrations/2014_07_09_204843_create_session_table.php+++ b/app/database/migrations/2014_07_09_204843_create_session_table.php@@ -1,6 +1,7 @@<?phpuse Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;/*** Class CreateSessionTable@@ -27,11 +28,11 @@ class CreateSessionTable extends Migrationpublic function up(){Schema::create(- 'sessions', function ($t) {- $t->string('id')->unique();- $t->text('payload');- $t->integer('last_activity');- }+ 'sessions', function (Blueprint $table) {+ $table->string('id')->unique();+ $table->text('payload');+ $table->integer('last_activity');+ });}diff --git a/app/database/migrations/2014_12_13_190730_changes_for_v321.php b/app/database/migrations/2014_12_13_190730_changes_for_v321.phpindex 10dc2f221d..4a9a743178 100644--- a/app/database/migrations/2014_12_13_190730_changes_for_v321.php+++ b/app/database/migrations/2014_12_13_190730_changes_for_v321.php@@ -272,19 +272,6 @@ class ChangesForV321 extends Migration$this->dropComponentIdFromBudgetLimits(); // 16.$this->expandCurrencyTable(); // 17.-- // $this->doRenameInLimitRepetitions();- // $this->doBudgetLimits();- // $this->doPiggyBankEvents();- // $this->doCreateCategoryTables();- // $this->doUpdateTransactionTable();- // $this->doDropCompRecurTable();- // $this->doDropCompTransTable();- // $this->doMoveBudgets();- // $this->doMoveCategories();- // $this->doMoveLimitReferences();--}public function createBudgetTable()diff --git a/app/database/migrations/2014_12_24_191544_changes_for_v322.php b/app/database/migrations/2014_12_24_191544_changes_for_v322.phpindex 5fa0ed91fa..0714ea25fe 100644--- a/app/database/migrations/2014_12_24_191544_changes_for_v322.php+++ b/app/database/migrations/2014_12_24_191544_changes_for_v322.php@@ -1,7 +1,6 @@<?phpuse Illuminate\Database\Migrations\Migration;-use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;/**@@ -96,23 +95,6 @@ class ChangesForV322 extends MigrationSchema::rename('piggybank_repetitions', 'piggy_bank_repetitions');Schema::rename('piggybanks', 'piggy_banks');- // drop an invalid index (how, in sqlite?).- Schema::table(- 'budget_limits', function (Blueprint $table) {--// try {-// //$table->dropUnique('unique_ci_combi');-// } catch (QueryException $e) {-// echo 'Could not delete unique_ci_combi';-//-// } catch (PDOException $e) {-// echo 'Could not delete unique_ci_combi';-// } catch (Exception $e) {-// echo 'Could not delete unique_ci_combi';-// }-- }- );// recreate it the correct way:Schema::table('budget_limits', function (Blueprint $table) {diff --git a/app/database/seeds/TestContentSeeder.php b/app/database/seeds/TestContentSeeder.phpindex 16773fd33a..fa9d5c34ae 100644--- a/app/database/seeds/TestContentSeeder.php+++ b/app/database/seeds/TestContentSeeder.php@@ -268,10 +268,10 @@ class TestContentSeeder extends Seeder*/public function createPiggyBanks(User $user){- // account:+ // account$savings = Account::whereName('Savings account')->orderBy('id', 'DESC')->first();- // some dates:+ // some dates$endDate = clone $this->_startOfMonth;$nextYear = clone $this->_startOfMonth;@@ -374,7 +374,7 @@ class TestContentSeeder extends Seeder*/public function createRecurringTransactions(User $user){- // account:+ // account$savings = Account::whereName('Savings account')->orderBy('id', 'DESC')->first();$recurring = PiggyBank::create(diff --git a/app/lib/FireflyIII/Database/Account/Account.php b/app/lib/FireflyIII/Database/Account/Account.phpindex 2db40a05e6..10ebbf5406 100644--- a/app/lib/FireflyIII/Database/Account/Account.php+++ b/app/lib/FireflyIII/Database/Account/Account.php@@ -7,6 +7,7 @@ use FireflyIII\Database\CommonDatabaseCalls;use FireflyIII\Database\CUD;use FireflyIII\Database\SwitchUser;use FireflyIII\Exception\NotImplementedException;+use Illuminate\Database\Eloquent\Builder;use Illuminate\Database\Eloquent\Model as Eloquent;use Illuminate\Support\Collection;use Illuminate\Support\MessageBag;@@ -224,18 +225,18 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface// delete journals:$journals = \TransactionJournal::whereIn(- 'id', function ($query) use ($model) {+ 'id', function (Builder $query) use ($model) {$query->select('transaction_journal_id')->from('transactions')->whereIn(- 'account_id', function ($query) use ($model) {+ 'account_id', function (Builder $query) use ($model) {$query->select('id')->from('accounts')->where(- function ($q) use ($model) {+ function (Builder $q) use ($model) {$q->where('id', $model->id);$q->orWhere(- function ($q) use ($model) {+ function (Builder $q) use ($model) {$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');// TODO magic number!$q->where('accounts.account_type_id', 3);@@ -273,10 +274,10 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface// delete accounts:\Account::where(- function ($q) use ($model) {+ function (Builder $q) use ($model) {$q->where('id', $model->id);$q->orWhere(- function ($q) use ($model) {+ function (Builder $q) use ($model) {$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');// TODO magic number!$q->where('accounts.account_type_id', 3);diff --git a/app/lib/FireflyIII/Database/Budget/Budget.php b/app/lib/FireflyIII/Database/Budget/Budget.phpindex 86f9a9c96c..2717a58f11 100644--- a/app/lib/FireflyIII/Database/Budget/Budget.php+++ b/app/lib/FireflyIII/Database/Budget/Budget.php@@ -10,6 +10,7 @@ use FireflyIII\Exception\NotImplementedException;use Illuminate\Database\Eloquent\Model as Eloquent;use Illuminate\Support\Collection;use Illuminate\Support\MessageBag;+use Illuminate\Database\Eloquent\Builder;/*** Class Budget@@ -265,7 +266,7 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterfacereturn $this->getUser()->transactionjournals()->whereNotIn(- 'transaction_journals.id', function ($query) use ($start, $end) {+ 'transaction_journals.id', function (Builder $query) use ($start, $end) {$query->select('transaction_journals.id')->from('transaction_journals')diff --git a/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php b/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.phpindex 406c5d075f..72e8fc10ea 100644--- a/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php+++ b/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php@@ -158,7 +158,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData$errors->add('description', 'Internal error: need to know type of transaction!');}/*- * Amount:+ * Amount*/if (isset($model['amount']) && floatval($model['amount']) < 0.01) {$errors->add('amount', 'Amount must be > 0.01');@@ -171,7 +171,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData}/*- * Budget:+ * Budget*/if (isset($model['budget_id']) && !ctype_digit($model['budget_id'])) {$errors->add('budget_id', 'Invalid budget');diff --git a/app/lib/FireflyIII/FF3ServiceProvider.php b/app/lib/FireflyIII/FF3ServiceProvider.phpindex 37daab3d37..14e8682d9b 100644--- a/app/lib/FireflyIII/FF3ServiceProvider.php+++ b/app/lib/FireflyIII/FF3ServiceProvider.php@@ -43,8 +43,6 @@ class FF3ServiceProvider extends ServiceProvider*/public function register(){- // FORMAT:- #$this->app->bind('Interface', 'Class');$this->registerFacades();$this->registerInterfaces();$this->registerAliases();@@ -88,10 +86,10 @@ class FF3ServiceProvider extends ServiceProviderpublic function registerInterfaces(){- // preferences:+ // preferences$this->app->bind('FireflyIII\Shared\Preferences\PreferencesInterface', 'FireflyIII\Shared\Preferences\Preferences');- // registration and user mail:+ // registration and user mail$this->app->bind('FireflyIII\Shared\Mail\RegistrationInterface', 'FireflyIII\Shared\Mail\Registration');// reportsdiff --git a/app/lib/FireflyIII/Report/Report.php b/app/lib/FireflyIII/Report/Report.phpindex d96a676900..2c91e217ec 100644--- a/app/lib/FireflyIII/Report/Report.php+++ b/app/lib/FireflyIII/Report/Report.php@@ -365,24 +365,24 @@ class Report implements ReportInterface{return \TransactionJournal::leftJoin(- 'transactions as t_from', function ($join) {+ 'transactions as t_from', function (JoinClause $join) {$join->on('t_from.transaction_journal_id', '=', 'transaction_journals.id')->where('t_from.amount', '<', 0);})->leftJoin('accounts as ac_from', 't_from.account_id', '=', 'ac_from.id')->leftJoin(- 'account_meta as acm_from', function ($join) {+ 'account_meta as acm_from', function (JoinClause $join) {$join->on('ac_from.id', '=', 'acm_from.account_id')->where('acm_from.name', '=', 'accountRole');})->leftJoin(- 'transactions as t_to', function ($join) {+ 'transactions as t_to', function (JoinClause $join) {$join->on('t_to.transaction_journal_id', '=', 'transaction_journals.id')->where('t_to.amount', '>', 0);})->leftJoin('accounts as ac_to', 't_to.account_id', '=', 'ac_to.id')->leftJoin(- 'account_meta as acm_to', function ($join) {+ 'account_meta as acm_to', function (JoinClause $join) {$join->on('ac_to.id', '=', 'acm_to.account_id')->where('acm_to.name', '=', 'accountRole');})diff --git a/app/lib/FireflyIII/Report/ReportQuery.php b/app/lib/FireflyIII/Report/ReportQuery.phpindex e2ccc51ed7..2e5addf156 100644--- a/app/lib/FireflyIII/Report/ReportQuery.php+++ b/app/lib/FireflyIII/Report/ReportQuery.php@@ -287,24 +287,24 @@ class ReportQuery implements ReportQueryInterface{return \TransactionJournal::leftJoin(- 'transactions as t_from', function ($join) {+ 'transactions as t_from', function (JoinClause $join) {$join->on('t_from.transaction_journal_id', '=', 'transaction_journals.id')->where('t_from.amount', '<', 0);})->leftJoin('accounts as ac_from', 't_from.account_id', '=', 'ac_from.id')->leftJoin(- 'account_meta as acm_from', function ($join) {+ 'account_meta as acm_from', function (JoinClause $join) {$join->on('ac_from.id', '=', 'acm_from.account_id')->where('acm_from.name', '=', 'accountRole');})->leftJoin(- 'transactions as t_to', function ($join) {+ 'transactions as t_to', function (JoinClause $join) {$join->on('t_to.transaction_journal_id', '=', 'transaction_journals.id')->where('t_to.amount', '>', 0);})->leftJoin('accounts as ac_to', 't_to.account_id', '=', 'ac_to.id')->leftJoin(- 'account_meta as acm_to', function ($join) {+ 'account_meta as acm_to', function (JoinClause $join) {$join->on('ac_to.id', '=', 'acm_to.account_id')->where('acm_to.name', '=', 'accountRole');})diff --git a/app/lib/FireflyIII/Search/Search.php b/app/lib/FireflyIII/Search/Search.phpindex 810c8f01f6..fb7b648cec 100644--- a/app/lib/FireflyIII/Search/Search.php+++ b/app/lib/FireflyIII/Search/Search.php@@ -4,6 +4,7 @@ namespace FireflyIII\Search;use Illuminate\Support\Collection;+use Illuminate\Database\Eloquent\Builder;/*** Class Search@@ -20,7 +21,7 @@ class Searchpublic function searchAccounts(array $words){return \Auth::user()->accounts()->with('accounttype')->where(- function ($q) use ($words) {+ function (Builder $q) use ($words) {foreach ($words as $word) {$q->orWhere('name', 'LIKE', '%' . e($word) . '%');}@@ -96,7 +97,7 @@ class Searchpublic function searchTransactions(array $words){return \Auth::user()->transactionjournals()->withRelevantData()->where(- function ($q) use ($words) {+ function (Builder $q) use ($words) {foreach ($words as $word) {$q->orWhere('description', 'LIKE', '%' . e($word) . '%');}diff --git a/app/lib/FireflyIII/Shared/Toolkit/Steam.php b/app/lib/FireflyIII/Shared/Toolkit/Steam.phpindex 7daf2708e5..b4bd26aa18 100644--- a/app/lib/FireflyIII/Shared/Toolkit/Steam.php+++ b/app/lib/FireflyIII/Shared/Toolkit/Steam.php@@ -16,6 +16,8 @@ class Steam{/**+ * TODO find a way to reliably remove cache entries for accounts.+ ** @param \Account $account* @param Carbon $date*@@ -23,24 +25,12 @@ class Steam*/public function balance(\Account $account, Carbon $date = null){- \Log::debug('Now in Steam::balance() for account #' . $account->id . ' (' . $account->name . ')');- if (is_null($date)) {- $key = 'account.' . $account->id . '.latestBalance';- } else {- $key = 'account.' . $account->id . '.balanceOn' . $date->format('dmy');- }- if (\Cache::has($key)) {- // TODO find a way to reliably remove cache entries for accounts.- #return \Cache::get($key);- }$date = is_null($date) ? Carbon::now() : $date;- \Log::debug('Now reached the moment we fire the query.');$balance = floatval($account->transactions()->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount'));- \Cache::put($key, $balance, 20160);return $balance;}diff --git a/app/models/Piggybank.php b/app/models/Piggybank.phpindex 8740e6c61c..23b3b703fb 100644--- a/app/models/Piggybank.php+++ b/app/models/Piggybank.php@@ -3,6 +3,7 @@ use Carbon\Carbon;use Illuminate\Database\Eloquent\Model as Eloquent;use Illuminate\Database\Eloquent\SoftDeletingTrait;use Watson\Validating\ValidatingTrait;+use Illuminate\Database\Eloquent\Builder;/*** Class PiggyBank@@ -77,19 +78,19 @@ class PiggyBank extends Eloquentreturn $rep;} else {$query = $this->piggyBankRepetitions()->where(- function ($q) {+ function (Builder $q) {$q->where(- function ($q) {+ function (Builder $q) {$q->where(- function ($q) {+ function (Builder $q) {$today = new Carbon;$q->whereNull('startdate');$q->orWhere('startdate', '<=', $today->format('Y-m-d 00:00:00'));})->where(- function ($q) {+ function (Builder $q) {$today = new Carbon;$q->whereNull('targetdate');$q->orWhere('targetdate', '>=', $today->format('Y-m-d 00:00:00'));@@ -97,7 +98,7 @@ class PiggyBank extends Eloquent);})->orWhere(- function ($q) {+ function (Builder $q) {$today = new Carbon;$q->where('startdate', '>=', $today->format('Y-m-d 00:00:00'));$q->where('targetdate', '>=', $today->format('Y-m-d 00:00:00'));diff --git a/app/models/TransactionJournal.php b/app/models/TransactionJournal.phpindex c6b7a0415b..0cf88ad00d 100644--- a/app/models/TransactionJournal.php+++ b/app/models/TransactionJournal.php@@ -192,7 +192,7 @@ class TransactionJournal extends Eloquentpublic function scopeWithRelevantData(Builder $query){$query->with(- ['transactions' => function ($q) {+ ['transactions' => function (Builder $q) {$q->orderBy('amount', 'ASC');}, 'transactiontype', 'budgets','categories', 'transactions.account.accounttype', 'bill', 'budgets', 'categories']);diff --git a/app/routes.php b/app/routes.phpindex ae34c5cb0a..11b3edf0a4 100644--- a/app/routes.php+++ b/app/routes.php@@ -1,6 +1,6 @@<?php-// models:+// modelsRoute::bind('account',function ($value, $route) {@@ -167,7 +167,6 @@ Route::group(// some date routes used for (well duh) date-based navigation.Route::get('/prev', ['uses' => 'HomeController@sessionPrev', 'as' => 'sessionPrev']);- //Route::get('/repair', ['uses' => 'HomeController@repair']);Route::get('/next', ['uses' => 'HomeController@sessionNext', 'as' => 'sessionNext']);Route::get('/jump/{range}', ['uses' => 'HomeController@rangeJump', 'as' => 'rangeJump']);@@ -268,7 +267,6 @@ Route::group(Route::get('/reports/{year}', ['uses' => 'ReportController@year', 'as' => 'reports.year']);Route::get('/reports/{year}/{month}', ['uses' => 'ReportController@month', 'as' => 'reports.month']);Route::get('/reports/budget/{year}/{month}', ['uses' => 'ReportController@budget', 'as' => 'reports.budget']);- #Route::get('/reports/unbalanced/{year}/{month}', ['uses' => 'ReportController@unbalanced', 'as' => 'reports.unbalanced']);// reminder controllerRoute::get('/reminders/{reminder}', ['uses' => 'ReminderController@show', 'as' => 'reminders.show']);diff --git a/app/start/global.php b/app/start/global.phpindex 36f6db85a9..cbe2ca8b88 100644--- a/app/start/global.php+++ b/app/start/global.php@@ -68,7 +68,7 @@ App::down(});-// forms:+// forms\Form::macro('ffText', function ($name, $value = null, array $options = []) {return \FireflyIII\Form\Form::ffText($name, $value, $options);