Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Some code cleanup and a better chart [skip ci]
James Colea5d5f86aed73
diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.phpindex 3824bfccea..88651bda80 100644--- a/app/Http/Controllers/Chart/ReportController.php+++ b/app/Http/Controllers/Chart/ReportController.php@@ -118,8 +118,8 @@ class ReportController extends Controllerwhile ($currentStart <= $end) {$currentEnd = Navigation::endOfPeriod($currentStart, '1M');$date = $currentStart->format('Y-m');- $spent = $repository->spentInPeriod($accounts, $currentStart, $currentEnd);- $earned = $repository->earnedInPeriod($accounts, $currentStart, $currentEnd);+ $spent = $repository->expensesInPeriod($accounts, $currentStart, $currentEnd);+ $earned = $repository->incomesInPeriod($accounts, $currentStart, $currentEnd);$spentArray[$date] = bcmul($spent, '-1');$earnedArray[$date] = $earned;$currentStart = Navigation::addPeriod($currentStart, '1M', 0);diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.phpindex bee9b686e8..9abd56a515 100644--- a/app/Support/Twig/Journal.php+++ b/app/Support/Twig/Journal.php@@ -15,6 +15,7 @@ namespace FireflyIII\Support\Twig;use Amount;use FireflyIII\Models\Account;use FireflyIII\Models\Budget as ModelBudget;+use FireflyIII\Models\Category;use FireflyIII\Models\Transaction;use FireflyIII\Models\TransactionJournal;use FireflyIII\Support\CacheProperties;@@ -283,26 +284,29 @@ class Journal extends Twig_Extensionif ($cache->has()) {return $cache->get();}--$categories = [];- // get all budgets:+ // get all categories for the journal itself (easy):foreach ($journal->categories as $category) {$categories[] = '<a href="' . route('categories.show', [$category->id]) . '" title="' . e($category->name) . '">' . e($category->name) . '</a>';}- // and more!- foreach ($journal->transactions as $transaction) {- foreach ($transaction->categories as $category) {+ if (count($categories) === 0) {+ $set = Category::distinct()->leftJoin('category_transaction', 'categories.id', '=', 'category_transaction.category_id')+ ->leftJoin('transactions', 'category_transaction.transaction_id', '=', 'transactions.id')+ ->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')+ ->where('categories.user_ud', $journal->user_id)+ ->where('transaction_journals.id', $journal->id)+ ->get(['categories.*']);+ /** @var Category $category */+ foreach ($set as $category) {$categories[] = '<a href="' . route('categories.show', [$category->id]) . '" title="' . e($category->name) . '">' . e($category->name). '</a>';}}+$string = join(', ', array_unique($categories));$cache->store($string);return $string;--});}@@ -370,6 +374,8 @@ class Journal extends Twig_Extension}/**+ * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's 5.+ ** @return Twig_SimpleFilter*/protected function typeIcon(): Twig_SimpleFilter