Skip to content

Firefly III: a personal finances manager

Some code cleanup.

James Coledda3082c7ee7
diff --git a/app/Export/Entry/Entry.php b/app/Export/Entry/Entry.php
index 5a09b343ad..b6ef9a221e 100644
--- a/app/Export/Entry/Entry.php
+++ b/app/Export/Entry/Entry.php
@@ -30,7 +30,7 @@ use Illuminate\Support\Collection;
*
* @package FireflyIII\Export\Entry
*/
-class Entry
+final class Entry
{
/** @var string */
public $amount;
diff --git a/app/Export/Processor.php b/app/Export/Processor.php
index 336cb61a77..80b742f605 100644
--- a/app/Export/Processor.php
+++ b/app/Export/Processor.php
@@ -158,8 +158,6 @@ class Processor
// is part of this job?
$zipFileName = str_replace($this->job->key . '-', '', $entry);
$result = $zip->addFromString($zipFileName, $disk->get($entry));
- if (!$result) {
- }
}
$zip->close();
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php
index 1547eca723..614ce2851f 100644
--- a/app/Http/Controllers/AccountController.php
+++ b/app/Http/Controllers/AccountController.php
@@ -223,8 +223,9 @@ class AccountController extends Controller
if ($cache->has()) {
- // $entries = $cache->get();
- // return view('accounts.show', compact('account', 'what', 'entries', 'subTitleIcon', 'journals', 'subTitle'));
+ $entries = $cache->get();
+
+ return view('accounts.show', compact('account', 'what', 'entries', 'subTitleIcon', 'journals', 'subTitle'));
}
while ($end >= $start) {
diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php
index 0ee7b29337..5174256fa1 100644
--- a/app/Http/Controllers/BudgetController.php
+++ b/app/Http/Controllers/BudgetController.php
@@ -176,12 +176,7 @@ class BudgetController extends Controller
$accounts = $accountRepository->getAccountsByType(['Default account', 'Asset account', 'Cash account']);
$startAsString = $start->format('Y-m-d');
$endAsString = $end->format('Y-m-d');
-
- /**
- * Do some cleanup:
- * TODO reimplement the deletion of budget_limits and limit_repetitions with amount 0
- */
-
+
// loop the budgets:
/** @var Budget $budget */
foreach ($budgets as $budget) {
diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php
index 3b3af3171f..359cc2f505 100644
--- a/app/Http/Controllers/PiggyBankController.php
+++ b/app/Http/Controllers/PiggyBankController.php
@@ -131,9 +131,8 @@ class PiggyBankController extends Controller
/*
* Flash some data to fill the form.
*/
- if (!is_null($piggyBank->targetdate) || !$piggyBank->targetdate == '') {
- $targetDate = new Carbon($piggyBank->targetdate);
- $targetDate = $targetDate->format('Y-m-d');
+ if (!is_null($piggyBank->targetdate)) {
+ $targetDate = $piggyBank->targetdate->format('Y-m-d');
}
$preFilled = ['name' => $piggyBank->name,
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index 6dcb2e3af0..33488585ef 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -194,9 +194,9 @@ class ReportController extends Controller
*/
$auditData[$id]['journals'] = $journals->reverse();
$auditData[$id]['exists'] = $exists;
- $auditData[$id]['end'] = $end->formatLocalized(trans('config.month_and_day'));
+ $auditData[$id]['end'] = $end->formatLocalized(strval(trans('config.month_and_day')));
$auditData[$id]['endBalance'] = Steam::balance($account, $end);
- $auditData[$id]['dayBefore'] = $dayBefore->formatLocalized(trans('config.month_and_day'));
+ $auditData[$id]['dayBefore'] = $dayBefore->formatLocalized(strval(trans('config.month_and_day')));
$auditData[$id]['dayBeforeBalance'] = $dayBeforeBalance;
}
diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.php
index 1b8ec81140..27d6b259fd 100644
--- a/app/Http/Controllers/Transaction/SplitController.php
+++ b/app/Http/Controllers/Transaction/SplitController.php
@@ -198,8 +198,6 @@ class SplitController extends Controller
*/
private function arrayFromJournal(Request $request, TransactionJournal $journal): array
{
- if (Session::has('_old_input')) {
- }
$sourceAccounts = TransactionJournal::sourceAccountList($journal);
$destinationAccounts = TransactionJournal::destinationAccountList($journal);
$array = [
diff --git a/app/Models/LimitRepetition.php b/app/Models/LimitRepetition.php
index 5a1574536b..5bac90d6f9 100644
--- a/app/Models/LimitRepetition.php
+++ b/app/Models/LimitRepetition.php
@@ -27,6 +27,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\LimitRepetition whereEnddate($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\LimitRepetition whereAmount($value)
* @mixin \Eloquent
+ * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\LimitRepetition after($date)
+ * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\LimitRepetition before($date)
*/
class LimitRepetition extends Model
{
diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php
index 396346a03c..f5251e0056 100644
--- a/app/Models/Transaction.php
+++ b/app/Models/Transaction.php
@@ -34,6 +34,7 @@ use Watson\Validating\ValidatingTrait;
* @mixin \Eloquent
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Budget[] $budgets
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Category[] $categories
+ * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Transaction transactionTypes($types)
*/
class Transaction extends Model
{
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php
index e0fbff2814..54e99bd814 100644
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@ -78,6 +78,7 @@ use Watson\Validating\ValidatingTrait;
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal whereTagCount($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal expanded()
* @mixin \Eloquent
+ * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal sortCorrectly()
*/
class TransactionJournal extends TransactionJournalSupport
{
diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php
index fe61b30071..399c81393a 100644
--- a/app/Repositories/Journal/JournalRepository.php
+++ b/app/Repositories/Journal/JournalRepository.php
@@ -218,6 +218,7 @@ class JournalRepository implements JournalRepositoryInterface
*/
public function getTransactions(TransactionJournal $journal): Collection
{
+ $transactions = new Collection;
switch ($journal->transactionType->type) {
case TransactionType::DEPOSIT:
/** @var Collection $transactions */
diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php
index 68b19c30fb..642f42ee5e 100644
--- a/app/Support/ExpandedForm.php
+++ b/app/Support/ExpandedForm.php
@@ -227,6 +227,7 @@ class ExpandedForm
*/
public function makeSelectListWithEmpty(Collection $set): array
{
+ $selectList = [];
$selectList[0] = '(none)';
$fields = ['title', 'name', 'description'];
/** @var Eloquent $entry */
diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.php
index ee96ad85cf..daf5d7f5a6 100644
--- a/app/Support/Twig/Journal.php
+++ b/app/Support/Twig/Journal.php
@@ -6,7 +6,7 @@ namespace FireflyIII\Support\Twig;
use Amount;
use FireflyIII\Models\Account;
-use FireflyIII\Models\Budget;
+use FireflyIII\Models\Budget as ModelBudget;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Support\CacheProperties;
@@ -78,7 +78,7 @@ class Journal extends Twig_Extension
public function formatBudgetPerspective(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
- 'formatBudgetPerspective', function (TransactionJournal $journal, Budget $budget) {
+ 'formatBudgetPerspective', function (TransactionJournal $journal, ModelBudget $budget) {
$cache = new CacheProperties;
$cache->addProperty('formatBudgetPerspective');