diff --git a/app/Helpers/Report/ReportQuery.php b/app/Helpers/Report/ReportQuery.php index 545ebaa145..6714c22e4c 100644 --- a/app/Helpers/Report/ReportQuery.php +++ b/app/Helpers/Report/ReportQuery.php @@ -147,7 +147,11 @@ class ReportQuery implements ReportQueryInterface // 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'] + ['transaction_journals.*', + 'transaction_types.type', 'ac_from.name as name', + 't_from.amount as from_amount', + 't_to.amount as to_amount', + 'ac_from.id as account_id', 'ac_from.encrypted as account_encrypted'] ); $data->each( @@ -157,15 +161,15 @@ class ReportQuery implements ReportQueryInterface } } ); - $data = $data->filter( - function (TransactionJournal $journal) { - if ($journal->amount != 0) { - return $journal; - } - - return null; - } - ); +// $data = $data->filter( +// function (TransactionJournal $journal) { +// if ($journal->amount != 0) { +// return $journal; +// } +// +// return null; +// } +// ); return $data; } @@ -220,7 +224,10 @@ class ReportQuery implements ReportQueryInterface $query->orderBy('transaction_journals.date'); $data = $query->get( // get everything - ['transaction_journals.*', 'transaction_types.type', 'ac_to.name as name', 'ac_to.id as account_id', 'ac_to.encrypted as account_encrypted'] + ['transaction_journals.*', 'transaction_types.type', + 't_from.amount as from_amount', + 't_to.amount as to_amount', + 'ac_to.name as name', 'ac_to.id as account_id', 'ac_to.encrypted as account_encrypted'] ); $data->each( diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php index 026d684bf4..2a0dba184f 100644 --- a/app/Http/Controllers/JsonController.php +++ b/app/Http/Controllers/JsonController.php @@ -59,7 +59,6 @@ class JsonController extends Controller $steps[7]['orphan'] = true; // final in the center again. $steps[7]['backdrop'] = true; $template = view('json.tour')->render(); - return Response::json(['steps' => $steps, 'template' => $template]); } @@ -192,7 +191,7 @@ class JsonController extends Controller return Response::json($cache->get()); // @codeCoverageIgnore } $accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']); - $amount = $reportQuery->incomeInPeriod($start, $end, $accounts)->sum('amount'); + $amount = $reportQuery->incomeInPeriod($start, $end, $accounts)->sum('to_amount'); $data = ['box' => 'in', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]; $cache->store($data); @@ -221,8 +220,7 @@ class JsonController extends Controller return Response::json($cache->get()); // @codeCoverageIgnore } - $amount = $reportQuery->expenseInPeriod($start, $end, $accounts)->sum('amount'); - $amount = $amount * -1; + $amount = $reportQuery->expenseInPeriod($start, $end, $accounts)->sum('to_amount'); $data = ['box' => 'out', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]; $cache->store($data); diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index d57eb6d9ce..446aa85755 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -9,6 +9,7 @@ use FireflyIII\Models\Account; use FireflyIII\Models\Tag; use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionType; +use FireflyIII\Support\CacheProperties; use Illuminate\Support\Collection; /** @@ -111,6 +112,13 @@ class TagRepository implements TagRepositoryInterface */ public function get() { + $cache = new CacheProperties; + $cache->addProperty('tags-list'); + + if ($cache->has()) { + return $cache->get(); + } + /** @var Collection $tags */ $tags = Auth::user()->tags()->get(); $tags = $tags->sortBy( @@ -119,6 +127,8 @@ class TagRepository implements TagRepositoryInterface } ); + $cache->store($tags); + return $tags; }