Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Refactor code to use new “earned in period” method. #524
James Cole7c82f4560443
diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.phpindex b9146890db..44d25e47f1 100644--- a/app/Http/Controllers/CategoryController.php+++ b/app/Http/Controllers/CategoryController.php@@ -319,6 +319,7 @@ class CategoryController extends Controller*/private function getGroupedEntries(Category $category): Collection{+ /** @var CategoryRepositoryInterface $repository */$repository = app(CategoryRepositoryInterface::class);$accountRepository = app(AccountRepositoryInterface::class);$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);@@ -344,8 +345,8 @@ class CategoryController extends Controllerwhile ($end >= $first) {$end = Navigation::startOfPeriod($end, $range);$currentEnd = Navigation::endOfPeriod($end, $range);- $spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $end, $currentEnd);- $earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $end, $currentEnd);+ $spent = $repository->spentInPeriodCollector(new Collection([$category]), $accounts, $end, $currentEnd);+ $earned = $repository->earnedInPeriodCollector(new Collection([$category]), $accounts, $end, $currentEnd);$dateStr = $end->format('Y-m-d');$dateName = Navigation::periodShow($end, $range);$entries->push([$dateStr, $dateName, $spent, $earned]);diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.phpindex 15c807412f..8d7c04c7fe 100644--- a/app/Http/Controllers/Chart/CategoryController.php+++ b/app/Http/Controllers/Chart/CategoryController.php@@ -91,7 +91,7 @@ class CategoryController extends Controllerwhile ($start <= $end) {$currentEnd = Navigation::endOfPeriod($start, $range);$spent = $repository->spentInPeriodCollector(new Collection([$category]), $accounts, $start, $currentEnd);- $earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $start, $currentEnd);+ $earned = $repository->earnedInPeriodCollector(new Collection([$category]), $accounts, $start, $currentEnd);$label = Navigation::periodShow($start, $range);$chartData[0]['entries'][$label] = bcmul($spent, '-1');$chartData[1]['entries'][$label] = $earned;@@ -316,7 +316,7 @@ class CategoryController extends Controllerwhile ($start <= $end) {$spent = $repository->spentInPeriodCollector(new Collection([$category]), $accounts, $start, $start);- $earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $start, $start);+ $earned = $repository->earnedInPeriodCollector(new Collection([$category]), $accounts, $start, $start);$label = Navigation::periodShow($start, '1D');$chartData[0]['entries'][$label] = bcmul($spent, '-1');