Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Code cleanup.
James Coleb1d3158db1b8
diff --git a/app/Helpers/Collection/Balance.php b/app/Helpers/Collection/Balance.phpindex cbafe987ce..34258fc88f 100644--- a/app/Helpers/Collection/Balance.php+++ b/app/Helpers/Collection/Balance.php@@ -1,6 +1,7 @@<?phpnamespace FireflyIII\Helpers\Collection;+use Illuminate\Support\Collection;/**@@ -60,6 +61,4 @@ class Balance}--}\ No newline at end of filediff --git a/app/Helpers/Collection/BalanceEntry.php b/app/Helpers/Collection/BalanceEntry.phpindex 8ba9a734a0..5f39869920 100644--- a/app/Helpers/Collection/BalanceEntry.php+++ b/app/Helpers/Collection/BalanceEntry.php@@ -17,13 +17,10 @@ class BalanceEntry/** @var AccountModel */protected $account;-/** @var float */- protected $spent = 0.0;-- /** @var float */protected $left = 0.0;-+ /** @var float */+ protected $spent = 0.0;/*** @return AccountModel@@ -44,36 +41,34 @@ class BalanceEntry/*** @return float*/- public function getSpent()+ public function getLeft(){- return $this->spent;+ return $this->left;}/**- * @param float $spent+ * @param float $left*/- public function setSpent($spent)+ public function setLeft($left){- $this->spent = $spent;+ $this->left = $left;}/*** @return float*/- public function getLeft()+ public function getSpent(){- return $this->left;+ return $this->spent;}/**- * @param float $left+ * @param float $spent*/- public function setLeft($left)+ public function setSpent($spent){- $this->left = $left;+ $this->spent = $spent;}--}\ No newline at end of filediff --git a/app/Helpers/Collection/BalanceHeader.php b/app/Helpers/Collection/BalanceHeader.phpindex 3563420408..5c0f46c72a 100644--- a/app/Helpers/Collection/BalanceHeader.php+++ b/app/Helpers/Collection/BalanceHeader.php@@ -43,5 +43,4 @@ class BalanceHeader}-}\ No newline at end of filediff --git a/app/Helpers/Collection/Bill.php b/app/Helpers/Collection/Bill.phpindex 973b886482..28a0036244 100644--- a/app/Helpers/Collection/Bill.php+++ b/app/Helpers/Collection/Bill.php@@ -43,8 +43,9 @@ class Bill$this->bills->sortBy(function (BillLine $bill) {$active = intval($bill->getBill()->active) == 0 ? 1 : 0;- $name = $bill->getBill()->name;- return $active.$name;+ $name = $bill->getBill()->name;++ return $active . $name;});diff --git a/app/Helpers/Collection/Budget.php b/app/Helpers/Collection/Budget.phpindex 7cd5e1f3fa..c551505b78 100644--- a/app/Helpers/Collection/Budget.php+++ b/app/Helpers/Collection/Budget.php@@ -1,6 +1,7 @@<?phpnamespace FireflyIII\Helpers\Collection;+use Illuminate\Support\Collection;/**@@ -71,6 +72,14 @@ class Budget$this->spent += floatval($add);}+ /**+ * @return \Illuminate\Support\Collection+ */+ public function getBudgetLines()+ {+ return $this->budgetLines;+ }+/*** @return float*/@@ -135,15 +144,5 @@ class Budget$this->spent = $spent;}- /**- * @return \Illuminate\Support\Collection- */- public function getBudgetLines()- {- return $this->budgetLines;- }---}\ No newline at end of filediff --git a/app/Helpers/Collection/BudgetLine.php b/app/Helpers/Collection/BudgetLine.phpindex a950ed088f..7c5f48e16c 100644--- a/app/Helpers/Collection/BudgetLine.php+++ b/app/Helpers/Collection/BudgetLine.php@@ -22,13 +22,13 @@ class BudgetLineprotected $repetition;/** @var float */- protected $budgeted = 0;+ protected $budgeted = 0;/** @var float */- protected $left = 0;+ protected $left = 0;/** @var float */protected $overspent = 0;/** @var float */- protected $spent = 0;+ protected $spent = 0;/*** @return BudgetModel@@ -127,8 +127,4 @@ class BudgetLine}----}\ No newline at end of filediff --git a/app/Helpers/Report/ReportQuery.php b/app/Helpers/Report/ReportQuery.phpindex 63432c86f2..a2fd5ee077 100644--- a/app/Helpers/Report/ReportQuery.php+++ b/app/Helpers/Report/ReportQuery.php@@ -113,7 +113,9 @@ class ReportQuery implements ReportQueryInterface$query->orderBy('transaction_journals.date');// get everything- $data = $query->get(['transaction_journals.*', 'transaction_types.type', 'ac_to.name as name','ac_to.id as account_id', 'ac_to.encrypted as account_encrypted']);+ $data = $query->get(+ ['transaction_journals.*', 'transaction_types.type', 'ac_to.name as name', 'ac_to.id as account_id', 'ac_to.encrypted as account_encrypted']+ );$data->each(function (TransactionJournal $journal) {@@ -285,7 +287,9 @@ class ReportQuery implements ReportQueryInterface$query->orderBy('transaction_journals.date');// get everything- $data = $query->get(['transaction_journals.*', 'transaction_types.type', 'ac_from.name as name','ac_from.id as account_id', 'ac_from.encrypted as account_encrypted']);+ $data = $query->get(+ ['transaction_journals.*', 'transaction_types.type', 'ac_from.name as name', 'ac_from.id as account_id', 'ac_from.encrypted as account_encrypted']+ );$data->each(function (TransactionJournal $journal) {diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.phpindex a2877aa940..a5ea27d221 100644--- a/app/Http/Controllers/BillController.php+++ b/app/Http/Controllers/BillController.php@@ -7,7 +7,6 @@ use FireflyIII\Models\Account;use FireflyIII\Models\Bill;use FireflyIII\Models\Transaction;use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Repositories\Bill\BillRepositoryInterface;use Input;use Redirect;diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.phpindex 4de38a9199..d5ca79286c 100644--- a/app/Http/Controllers/Chart/BudgetController.php+++ b/app/Http/Controllers/Chart/BudgetController.php@@ -28,7 +28,7 @@ class BudgetController extends Controller*/public function budget(GChart $chart, BudgetRepositoryInterface $repository, Budget $budget){- $chart->addColumn(trans('firefly.period'),'date');+ $chart->addColumn(trans('firefly.period'), 'date');$chart->addColumn(trans('firefly.spent'), 'number');@@ -50,6 +50,7 @@ class BudgetController extends Controller}$chart->generate();+return Response::json($chart->getData());}diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.phpindex 29a3610556..b7c45506c1 100644--- a/app/Http/Controllers/Chart/CategoryController.php+++ b/app/Http/Controllers/Chart/CategoryController.php@@ -4,7 +4,6 @@ namespace FireflyIII\Http\Controllers\Chart;use Carbon\Carbon;-use Crypt;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\Category;use FireflyIII\Models\LimitRepetition;@@ -82,8 +81,8 @@ class CategoryController extends Controllerforeach ($set as $entry) {$sum = floatval($entry['sum']);- if($sum != 0) {- $chart->addRow($entry['name'], $sum);+ if ($sum != 0) {+ $chart->addRow($entry['name'], $sum);}}diff --git a/app/Http/routes.php b/app/Http/routes.phpindex e232d5172f..1987fbd585 100644--- a/app/Http/routes.php+++ b/app/Http/routes.php@@ -188,7 +188,7 @@ Route::get('/register', ['uses' => 'Auth\AuthController@getRegister', 'as' => 'rRoute::controllers([- 'auth' => 'Auth\AuthController',+ 'auth' => 'Auth\AuthController','password' => 'Auth\PasswordController',]);@@ -276,7 +276,9 @@ Route::group(*/// accounts:Route::get('/chart/account/frontpage', ['uses' => 'Chart\AccountController@frontpage']);- Route::get('/chart/account/month/{year}/{month}/{shared?}', ['uses' => 'Chart\AccountController@all'])->where(['year' => '[0-9]{4}', 'month' => '[0-9]{1,2}', 'shared' => 'shared']);+ Route::get('/chart/account/month/{year}/{month}/{shared?}', ['uses' => 'Chart\AccountController@all'])->where(+ ['year' => '[0-9]{4}', 'month' => '[0-9]{1,2}', 'shared' => 'shared']+ );Route::get('/chart/account/{account}', ['uses' => 'Chart\AccountController@single']);diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex b5e7cfcd31..c8ff2053eb 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -306,7 +306,7 @@ class AccountRepository implements AccountRepositoryInterface/*** @param Account $account- * @param Carbon $date+ * @param Carbon $date** @return float*/diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.phpindex 1a25f120d5..605f8c15c2 100644--- a/app/Repositories/Account/AccountRepositoryInterface.php+++ b/app/Repositories/Account/AccountRepositoryInterface.php@@ -115,7 +115,7 @@ interface AccountRepositoryInterface/*** @param Account $account- * @param Carbon $date+ * @param Carbon $date** @return float*/diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.phpindex 6a0dc8a9d8..3d35eff2a0 100644--- a/app/Repositories/Budget/BudgetRepository.php+++ b/app/Repositories/Budget/BudgetRepository.php@@ -417,6 +417,7 @@ class BudgetRepository implements BudgetRepositoryInterfacepublic function expensesOnDayCorrected(Budget $budget, Carbon $date){$sum = floatval($budget->transactionjournals()->transactionTypes(['Withdrawal'])->onDate($date)->get(['transaction_journals.*'])->sum('amount'));+return $sum * -1;}}diff --git a/app/Repositories/Category/CategoryRepositoryInterface.php b/app/Repositories/Category/CategoryRepositoryInterface.phpindex 23425b5ff7..9f282c84fe 100644--- a/app/Repositories/Category/CategoryRepositoryInterface.php+++ b/app/Repositories/Category/CategoryRepositoryInterface.php@@ -115,6 +115,7 @@ interface CategoryRepositoryInterface/**** Corrected for tags.+ ** @param Category $category* @param Carbon $date*diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.phpindex ab4ad796b3..cc847817b7 100644--- a/app/Repositories/PiggyBank/PiggyBankRepository.php+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php@@ -9,7 +9,6 @@ use FireflyIII\Models\PiggyBank;use FireflyIII\Models\PiggyBankEvent;use FireflyIII\Models\PiggyBankRepetition;use Illuminate\Support\Collection;-use Navigation;/*** Class PiggyBankRepositorydiff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.phpindex 750a0edd84..e117e7ba1b 100644--- a/app/Support/ExpandedForm.php+++ b/app/Support/ExpandedForm.php@@ -51,7 +51,8 @@ class ExpandedFormif (isset($options['label'])) {return $options['label'];}- return trans('form.'.$name);++ return trans('form.' . $name);}diff --git a/app/Support/Twig/Budget.php b/app/Support/Twig/Budget.phpindex 51f449a3bb..787f14bd39 100644--- a/app/Support/Twig/Budget.php+++ b/app/Support/Twig/Budget.php@@ -41,15 +41,16 @@ class Budget extends Twig_Extension$functions[] = new Twig_SimpleFunction('spentInRepetitionCorrected', function (LimitRepetition $repetition) {- $sum =- Auth::user()->transactionjournals()- ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')- ->leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budget_transaction_journal.budget_id')- ->leftJoin('limit_repetitions', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')- ->before($repetition->enddate)- ->after($repetition->startdate)- ->where('limit_repetitions.id', '=', $repetition->id)- ->get(['transaction_journals.*'])->sum('amount');+ $sum+ = Auth::user()->transactionjournals()+ ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')+ ->leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budget_transaction_journal.budget_id')+ ->leftJoin('limit_repetitions', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')+ ->before($repetition->enddate)+ ->after($repetition->startdate)+ ->where('limit_repetitions.id', '=', $repetition->id)+ ->get(['transaction_journals.*'])->sum('amount');+return floatval($sum);});diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.phpindex 299cdaf6d6..a77e29692b 100644--- a/app/Support/Twig/Journal.php+++ b/app/Support/Twig/Journal.php@@ -85,6 +85,7 @@ class Journal extends Twig_Extension// return tag formatted for a "balancing act", even if other// tags are present.$amount = App::make('amount')->formatJournal($journal, false);+return '<a href="' . route('tags.show', $tag->id) . '" class="label label-success" title="' . $amount. '"><i class="fa fa-fw fa-refresh"></i> ' . $tag->tag . '</a>';}@@ -94,6 +95,7 @@ class Journal extends Twig_Extension*/if ($tag->tagMode == 'advancePayment' && $journal->transactionType->type == 'Deposit') {$amount = App::make('amount')->formatJournal($journal, false);+return '<a href="' . route('tags.show', $tag->id) . '" class="label label-success" title="' . $amount. '"><i class="fa fa-fw fa-sort-numeric-desc"></i> ' . $tag->tag . '</a>';}@@ -103,6 +105,7 @@ class Journal extends Twig_Extension*/if ($tag->tagMode == 'advancePayment' && $journal->transactionType->type == 'Withdrawal') {$amount = App::make('amount')->formatJournal($journal);+return '<a href="' . route('tags.show', $tag->id) . '">' . $amount . '</a>';}