diff --git a/.ci/php-cs-fixer/composer.lock b/.ci/php-cs-fixer/composer.lock index 4b2ae2657f..c358fdbe1c 100644 --- a/.ci/php-cs-fixer/composer.lock +++ b/.ci/php-cs-fixer/composer.lock @@ -1369,12 +1369,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -1517,12 +1517,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -2329,12 +2329,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { diff --git a/app/Helpers/Report/NetWorth.php b/app/Helpers/Report/NetWorth.php index 6fc0c3a0c1..9b70e4b713 100644 --- a/app/Helpers/Report/NetWorth.php +++ b/app/Helpers/Report/NetWorth.php @@ -74,7 +74,7 @@ class NetWorth implements NetWorthInterface $cache->addProperty('net-worth-by-accounts'); $cache->addProperty($ids); if ($cache->has()) { - return $cache->get(); + return $cache->get(); } Log::debug(sprintf('Now in byAccounts("%s", "%s")', $ids, $date->format('Y-m-d H:i:s'))); $default = Amount::getDefaultCurrency(); diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.php index 78509f8b17..c49cee169c 100644 --- a/app/Http/Controllers/Budget/IndexController.php +++ b/app/Http/Controllers/Budget/IndexController.php @@ -162,7 +162,7 @@ class IndexController extends Controller private function getAllAvailableBudgets(Carbon $start, Carbon $end): array { - $converter = new ExchangeRateConverter(); + $converter = new ExchangeRateConverter(); // get all available budgets. $ab = $this->abRepository->get($start, $end); $availableBudgets = []; @@ -170,24 +170,25 @@ class IndexController extends Controller // for each, complement with spent amount: /** @var AvailableBudget $entry */ foreach ($ab as $entry) { - $array = $entry->toArray(); - $array['start_date'] = $entry->start_date; - $array['end_date'] = $entry->end_date; + $array = $entry->toArray(); + $array['start_date'] = $entry->start_date; + $array['end_date'] = $entry->end_date; // spent in period: - $spentArr = $this->opsRepository->sumExpenses($entry->start_date, $entry->end_date, null, null, $entry->transactionCurrency); - $array['spent'] = $spentArr[$entry->transaction_currency_id]['sum'] ?? '0'; - $array['native_spent'] = $this->convertToNative && $entry->transaction_currency_id !== $this->defaultCurrency->id ? $converter->convert($entry->transactionCurrency, $this->defaultCurrency, $entry->start_date, $array['spent']) : null; + $spentArr = $this->opsRepository->sumExpenses($entry->start_date, $entry->end_date, null, null, $entry->transactionCurrency); + $array['spent'] = $spentArr[$entry->transaction_currency_id]['sum'] ?? '0'; + $array['native_spent'] = $this->convertToNative && $entry->transaction_currency_id !== $this->defaultCurrency->id ? $converter->convert($entry->transactionCurrency, $this->defaultCurrency, $entry->start_date, $array['spent']) : null; // budgeted in period: - $budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency); - $array['budgeted'] = $budgeted; + $budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency); + $array['budgeted'] = $budgeted; $array['native_budgeted'] = $this->convertToNative && $entry->transaction_currency_id !== $this->defaultCurrency->id ? $converter->convert($entry->transactionCurrency, $this->defaultCurrency, $entry->start_date, $budgeted) : null; // this time, because of complex sums, use the currency converter. - $availableBudgets[] = $array; + $availableBudgets[] = $array; unset($spentArr); } + return $availableBudgets; } diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index c3ffe5f1d2..09d5bb6ccd 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -426,7 +426,7 @@ class AccountController extends Controller $cache->addProperty($this->convertToNative); $cache->addProperty($account->id); if ($cache->has()) { - return response()->json($cache->get()); + return response()->json($cache->get()); } // collect and filter balances for the entire period. diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php index e4cf002336..a5ab00b99b 100644 --- a/app/Http/Controllers/Chart/BillController.php +++ b/app/Http/Controllers/Chart/BillController.php @@ -111,7 +111,7 @@ class BillController extends Controller $cache->addProperty($bill->id); $cache->addProperty($this->convertToNative); if ($cache->has()) { - return response()->json($cache->get()); + return response()->json($cache->get()); } $locale = app('steam')->getLocale(); diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index f830264167..3f92b2dabb 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -97,7 +97,7 @@ class BudgetController extends Controller $cache->addProperty($budget->id); if ($cache->has()) { - return response()->json($cache->get()); + return response()->json($cache->get()); } $step = $this->calculateStep($start, $end); // depending on diff, do something with range of chart. $collection = new Collection([$budget]); @@ -164,15 +164,15 @@ class BudgetController extends Controller $cache->addProperty($budget->id); if ($cache->has()) { - return response()->json($cache->get()); + return response()->json($cache->get()); } $locale = app('steam')->getLocale(); $entries = []; $amount = $budgetLimit->amount; $budgetCollection = new Collection([$budget]); $currency = $budgetLimit->transactionCurrency; - if($this->convertToNative) { - $amount = $budgetLimit->native_amount; + if ($this->convertToNative) { + $amount = $budgetLimit->native_amount; $currency = $this->defaultCurrency; } @@ -221,7 +221,7 @@ class BudgetController extends Controller $cache->addProperty($end); if ($cache->has()) { - return response()->json($cache->get()); + return response()->json($cache->get()); } $collector->setRange($start, $end); $collector->setBudget($budget); @@ -232,22 +232,22 @@ class BudgetController extends Controller // group by asset account ID: foreach ($journals as $journal) { $key = sprintf('%d-%d', $journal['source_account_id'], $journal['currency_id']); - $amount = $journal['amount']; + $amount = $journal['amount']; // if convert to native, use the native things, unless it's the foreign amount which is in the native currency. - if($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] !== $this->defaultCurrency->id) { - $key = sprintf('%d-%d', $journal['source_account_id'], $this->defaultCurrency->id); + if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] !== $this->defaultCurrency->id) { + $key = sprintf('%d-%d', $journal['source_account_id'], $this->defaultCurrency->id); $symbol = $this->defaultCurrency->symbol; - $code = $this->defaultCurrency->code; - $name = $this->defaultCurrency->name; + $code = $this->defaultCurrency->code; + $name = $this->defaultCurrency->name; $amount = $journal['native_amount']; } - if($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] === $this->defaultCurrency->id) { - $key = sprintf('%d-%d', $journal['source_account_id'], $this->defaultCurrency->id); + if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] === $this->defaultCurrency->id) { + $key = sprintf('%d-%d', $journal['source_account_id'], $this->defaultCurrency->id); $symbol = $this->defaultCurrency->symbol; - $code = $this->defaultCurrency->code; - $name = $this->defaultCurrency->name; + $code = $this->defaultCurrency->code; + $name = $this->defaultCurrency->name; $amount = $journal['foreign_amount']; } @@ -312,26 +312,26 @@ class BudgetController extends Controller $chartData = []; foreach ($journals as $journal) { $key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']); - $symbol = $journal['currency_symbol']; - $code = $journal['currency_code']; - $name = $journal['currency_name']; - $amount = $journal['amount']; + $symbol = $journal['currency_symbol']; + $code = $journal['currency_code']; + $name = $journal['currency_name']; + $amount = $journal['amount']; // if convert to native, use the native things, unless it's the foreign amount which is in the native currency. - if($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] !== $this->defaultCurrency->id + if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] !== $this->defaultCurrency->id ) { - $key = sprintf('%d-%d', $journal['category_id'], $this->defaultCurrency->id); + $key = sprintf('%d-%d', $journal['category_id'], $this->defaultCurrency->id); $symbol = $this->defaultCurrency->symbol; - $code = $this->defaultCurrency->code; - $name = $this->defaultCurrency->name; + $code = $this->defaultCurrency->code; + $name = $this->defaultCurrency->name; $amount = $journal['native_amount']; } - if($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] === $this->defaultCurrency->id + if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] === $this->defaultCurrency->id ) { - $key = sprintf('%d-%d', $journal['category_id'], $this->defaultCurrency->id); + $key = sprintf('%d-%d', $journal['category_id'], $this->defaultCurrency->id); $symbol = $this->defaultCurrency->symbol; - $code = $this->defaultCurrency->code; - $name = $this->defaultCurrency->name; + $code = $this->defaultCurrency->code; + $name = $this->defaultCurrency->name; $amount = $journal['foreign_amount']; } @@ -385,7 +385,7 @@ class BudgetController extends Controller $cache->addProperty($end); if ($cache->has()) { - return response()->json($cache->get()); + return response()->json($cache->get()); } $collector->setRange($start, $end); $collector->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withAccountInformation(); @@ -396,22 +396,22 @@ class BudgetController extends Controller /** @var array $journal */ foreach ($journals as $journal) { $key = sprintf('%d-%d', $journal['destination_account_id'], $journal['currency_id']); - $amount = $journal['amount']; + $amount = $journal['amount']; // if convert to native, use the native things, unless it's the foreign amount which is in the native currency. - if($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] !== $this->defaultCurrency->id) { - $key = sprintf('%d-%d', $journal['destination_account_id'], $this->defaultCurrency->id); + if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] !== $this->defaultCurrency->id) { + $key = sprintf('%d-%d', $journal['destination_account_id'], $this->defaultCurrency->id); $symbol = $this->defaultCurrency->symbol; - $code = $this->defaultCurrency->code; - $name = $this->defaultCurrency->name; + $code = $this->defaultCurrency->code; + $name = $this->defaultCurrency->name; $amount = $journal['native_amount']; } - if($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] === $this->defaultCurrency->id) { - $key = sprintf('%d-%d', $journal['destination_account_id'], $this->defaultCurrency->id); + if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] === $this->defaultCurrency->id) { + $key = sprintf('%d-%d', $journal['destination_account_id'], $this->defaultCurrency->id); $symbol = $this->defaultCurrency->symbol; - $code = $this->defaultCurrency->code; - $name = $this->defaultCurrency->name; + $code = $this->defaultCurrency->code; + $name = $this->defaultCurrency->name; $amount = $journal['foreign_amount']; } @@ -419,7 +419,7 @@ class BudgetController extends Controller 'amount' => '0', 'currency_symbol' => $symbol, 'currency_code' => $code, - 'currency_name' => $name + 'currency_name' => $name, ]; $result[$key]['amount'] = bcadd($amount, $result[$key]['amount']); } @@ -457,7 +457,7 @@ class BudgetController extends Controller $cache->addProperty($this->convertToNative); $cache->addProperty('chart.budget.frontpage'); if ($cache->has()) { - return response()->json($cache->get()); + return response()->json($cache->get()); } Log::debug('Regenerate frontpage chart from scratch.'); $chartGenerator = app(FrontpageChartGenerator::class); diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index c48b8cf3ff..9c9fc19ead 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -70,27 +70,27 @@ class CategoryController extends Controller public function all(Category $category): JsonResponse { // cache results: - $cache = new CacheProperties(); + $cache = new CacheProperties(); $cache->addProperty('chart.category.all'); $cache->addProperty($category->id); $cache->addProperty($this->convertToNative); if ($cache->has()) { - return response()->json($cache->get()); + return response()->json($cache->get()); } /** @var CategoryRepositoryInterface $repository */ - $repository = app(CategoryRepositoryInterface::class); - $start = $repository->firstUseDate($category) ?? $this->getDate(); - $range = app('navigation')->getViewRange(false); - $start = app('navigation')->startOfPeriod($start, $range); - $end = $this->getDate(); + $repository = app(CategoryRepositoryInterface::class); + $start = $repository->firstUseDate($category) ?? $this->getDate(); + $range = app('navigation')->getViewRange(false); + $start = app('navigation')->startOfPeriod($start, $range); + $end = $this->getDate(); /** @var WholePeriodChartGenerator $chartGenerator */ $chartGenerator = app(WholePeriodChartGenerator::class); $chartGenerator->convertToNative = $this->convertToNative; - $chartData = $chartGenerator->generate($category, $start, $end); - $data = $this->generator->multiSet($chartData); + $chartData = $chartGenerator->generate($category, $start, $end); + $data = $this->generator->multiSet($chartData); $cache->store($data); return response()->json($data); @@ -107,16 +107,16 @@ class CategoryController extends Controller */ public function frontPage(): JsonResponse { - $start = session('start', today(config('app.timezone'))->startOfMonth()); - $end = session('end', today(config('app.timezone'))->endOfMonth()); + $start = session('start', today(config('app.timezone'))->startOfMonth()); + $end = session('end', today(config('app.timezone'))->endOfMonth()); // chart properties for cache: - $cache = new CacheProperties(); + $cache = new CacheProperties(); $cache->addProperty($start); $cache->addProperty($end); $cache->addProperty($this->convertToNative); $cache->addProperty('chart.category.frontpage'); if ($cache->has()) { - return response()->json($cache->get()); + return response()->json($cache->get()); } $frontpageGenerator = new FrontpageChartGenerator($start, $end); @@ -141,9 +141,9 @@ class CategoryController extends Controller $cache->addProperty($category); $cache->addProperty($this->convertToNative); if ($cache->has()) { - return response()->json($cache->get()); + return response()->json($cache->get()); } - $data = $this->reportPeriodChart($accounts, $start, $end, $category); + $data = $this->reportPeriodChart($accounts, $start, $end, $category); $cache->store($data); @@ -164,8 +164,8 @@ class CategoryController extends Controller $noCatRepository = app(NoCategoryRepositoryInterface::class); // this gives us all currencies - $expenses = $noCatRepository->listExpenses($start, $end, $accounts); - $income = $noCatRepository->listIncome($start, $end, $accounts); + $expenses = $noCatRepository->listExpenses($start, $end, $accounts); + $income = $noCatRepository->listIncome($start, $end, $accounts); } if (null !== $category) { @@ -173,9 +173,9 @@ class CategoryController extends Controller $opsRepository = app(OperationsRepositoryInterface::class); $categoryId = $category->id; // this gives us all currencies - $collection = new Collection([$category]); - $expenses = $opsRepository->listExpenses($start, $end, $accounts, $collection); - $income = $opsRepository->listIncome($start, $end, $accounts, $collection); + $collection = new Collection([$category]); + $expenses = $opsRepository->listExpenses($start, $end, $accounts, $collection); + $income = $opsRepository->listIncome($start, $end, $accounts, $collection); } $currencies = array_unique(array_merge(array_keys($income), array_keys($expenses))); $periods = app('navigation')->listOfPeriods($start, $end); @@ -189,19 +189,19 @@ class CategoryController extends Controller $inKey = sprintf('%d-in', $currencyId); $chartData[$outKey] = [ - 'label' => sprintf('%s (%s)', (string) trans('firefly.spent'), $currencyInfo['currency_name']), - 'entries' => [], - 'type' => 'bar', - 'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red - ]; + 'label' => sprintf('%s (%s)', (string) trans('firefly.spent'), $currencyInfo['currency_name']), + 'entries' => [], + 'type' => 'bar', + 'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red + ]; $chartData[$inKey] - = [ - 'label' => sprintf('%s (%s)', (string) trans('firefly.earned'), $currencyInfo['currency_name']), - 'entries' => [], - 'type' => 'bar', - 'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green - ]; + = [ + 'label' => sprintf('%s (%s)', (string) trans('firefly.earned'), $currencyInfo['currency_name']), + 'entries' => [], + 'type' => 'bar', + 'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green + ]; // loop empty periods: foreach (array_keys($periods) as $period) { $label = $periods[$period]; @@ -209,7 +209,7 @@ class CategoryController extends Controller $chartData[$inKey]['entries'][$label] = '0'; } // loop income and expenses for this category.: - $outSet = $expenses[$currencyId]['categories'][$categoryId] ?? ['transaction_journals' => []]; + $outSet = $expenses[$currencyId]['categories'][$categoryId] ?? ['transaction_journals' => []]; foreach ($outSet['transaction_journals'] as $journal) { $amount = app('steam')->positive($journal['amount']); $date = $journal['date']->isoFormat($format); @@ -218,7 +218,7 @@ class CategoryController extends Controller $chartData[$outKey]['entries'][$date] = bcadd($amount, $chartData[$outKey]['entries'][$date]); } - $inSet = $income[$currencyId]['categories'][$categoryId] ?? ['transaction_journals' => []]; + $inSet = $income[$currencyId]['categories'][$categoryId] ?? ['transaction_journals' => []]; foreach ($inSet['transaction_journals'] as $journal) { $amount = app('steam')->positive($journal['amount']); $date = $journal['date']->isoFormat($format); @@ -244,7 +244,7 @@ class CategoryController extends Controller if ($cache->has()) { return response()->json($cache->get()); } - $data = $this->reportPeriodChart($accounts, $start, $end, null); + $data = $this->reportPeriodChart($accounts, $start, $end, null); $cache->store($data); @@ -259,14 +259,14 @@ class CategoryController extends Controller */ public function specificPeriod(Category $category, Carbon $date): JsonResponse { - $range = app('navigation')->getViewRange(false); - $start = app('navigation')->startOfPeriod($date, $range); - $end = session()->get('end'); + $range = app('navigation')->getViewRange(false); + $start = app('navigation')->startOfPeriod($date, $range); + $end = session()->get('end'); if ($end < $start) { [$end, $start] = [$start, $end]; } - $cache = new CacheProperties(); + $cache = new CacheProperties(); $cache->addProperty($start); $cache->addProperty($end); $cache->addProperty($category->id); diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php index d538ebbd97..cecdde2826 100644 --- a/app/Http/Controllers/Chart/ReportController.php +++ b/app/Http/Controllers/Chart/ReportController.php @@ -145,7 +145,7 @@ class ReportController extends Controller $cache->addProperty($accounts); $cache->addProperty($end); if ($cache->has()) { - return response()->json($cache->get()); + return response()->json($cache->get()); } Log::debug('Going to do operations for accounts ', $accounts->pluck('id')->toArray()); diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.php index d0afef6dfa..7a0b271d14 100644 --- a/app/Http/Controllers/JavascriptController.php +++ b/app/Http/Controllers/JavascriptController.php @@ -95,7 +95,7 @@ class JavascriptController extends Controller public function variables(Request $request, AccountRepositoryInterface $repository): Response { $account = $repository->find((int) $request->get('account')); - $currency = $this->defaultCurrency; + $currency = $this->defaultCurrency; if (null !== $account) { $currency = $repository->getAccountCurrency($account) ?? $this->defaultCurrency; } diff --git a/app/Repositories/Category/OperationsRepository.php b/app/Repositories/Category/OperationsRepository.php index 6741f3ffa8..bca0e084e0 100644 --- a/app/Repositories/Category/OperationsRepository.php +++ b/app/Repositories/Category/OperationsRepository.php @@ -63,13 +63,13 @@ class OperationsRepository implements OperationsRepositoryInterface $collector->setCategories($this->getCategories()); } $collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation(); - $journals = $collector->getExtractedJournals(); - $array = []; + $journals = $collector->getExtractedJournals(); + $array = []; foreach ($journals as $journal) { - $currencyId = (int) $journal['currency_id']; - $categoryId = (int) $journal['category_id']; - $categoryName = (string) $journal['category_name']; + $currencyId = (int) $journal['currency_id']; + $categoryId = (int) $journal['category_id']; + $categoryName = (string) $journal['category_name']; // catch "no category" entries. if (0 === $categoryId) { @@ -77,7 +77,7 @@ class OperationsRepository implements OperationsRepositoryInterface } // info about the currency: - $array[$currencyId] ??= [ + $array[$currencyId] ??= [ 'categories' => [], 'currency_id' => (string) $currencyId, 'currency_name' => $journal['currency_name'], @@ -112,7 +112,7 @@ class OperationsRepository implements OperationsRepositoryInterface return $array; } - public function setUser(null | Authenticatable | User $user): void + public function setUser(null|Authenticatable|User $user): void { if ($user instanceof User) { $this->user = $user; @@ -147,13 +147,13 @@ class OperationsRepository implements OperationsRepositoryInterface $collector->setCategories($this->getCategories()); } $collector->withCategoryInformation()->withAccountInformation(); - $journals = $collector->getExtractedJournals(); - $array = []; + $journals = $collector->getExtractedJournals(); + $array = []; foreach ($journals as $journal) { - $currencyId = (int) $journal['currency_id']; - $categoryId = (int) $journal['category_id']; - $categoryName = (string) $journal['category_name']; + $currencyId = (int) $journal['currency_id']; + $categoryId = (int) $journal['category_id']; + $categoryName = (string) $journal['category_name']; // catch "no category" entries. if (0 === $categoryId) { @@ -161,7 +161,7 @@ class OperationsRepository implements OperationsRepositoryInterface } // info about the currency: - $array[$currencyId] ??= [ + $array[$currencyId] ??= [ 'categories' => [], 'currency_id' => (string) $currencyId, 'currency_name' => $journal['currency_name'], @@ -200,7 +200,8 @@ class OperationsRepository implements OperationsRepositoryInterface /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); $collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionType::TRANSFER]) - ->setDestinationAccounts($accounts)->excludeSourceAccounts($accounts); + ->setDestinationAccounts($accounts)->excludeSourceAccounts($accounts) + ; if (null !== $categories && $categories->count() > 0) { $collector->setCategories($categories); } @@ -208,13 +209,13 @@ class OperationsRepository implements OperationsRepositoryInterface $collector->setCategories($this->getCategories()); } $collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation(); - $journals = $collector->getExtractedJournals(); - $array = []; + $journals = $collector->getExtractedJournals(); + $array = []; foreach ($journals as $journal) { - $currencyId = (int) $journal['currency_id']; - $categoryId = (int) $journal['category_id']; - $categoryName = (string) $journal['category_name']; + $currencyId = (int) $journal['currency_id']; + $categoryId = (int) $journal['category_id']; + $categoryName = (string) $journal['category_name']; // catch "no category" entries. if (0 === $categoryId) { @@ -222,7 +223,7 @@ class OperationsRepository implements OperationsRepositoryInterface } // info about the currency: - $array[$currencyId] ??= [ + $array[$currencyId] ??= [ 'categories' => [], 'currency_id' => (string) $currencyId, 'currency_name' => $journal['currency_name'], @@ -262,7 +263,8 @@ class OperationsRepository implements OperationsRepositoryInterface /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); $collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionType::TRANSFER]) - ->setSourceAccounts($accounts)->excludeDestinationAccounts($accounts); + ->setSourceAccounts($accounts)->excludeDestinationAccounts($accounts) + ; if (null !== $categories && $categories->count() > 0) { $collector->setCategories($categories); } @@ -270,13 +272,13 @@ class OperationsRepository implements OperationsRepositoryInterface $collector->setCategories($this->getCategories()); } $collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation(); - $journals = $collector->getExtractedJournals(); - $array = []; + $journals = $collector->getExtractedJournals(); + $array = []; foreach ($journals as $journal) { - $currencyId = (int) $journal['currency_id']; - $categoryId = (int) $journal['category_id']; - $categoryName = (string) $journal['category_name']; + $currencyId = (int) $journal['currency_id']; + $categoryId = (int) $journal['category_id']; + $categoryName = (string) $journal['category_name']; // catch "no category" entries. if (0 === $categoryId) { @@ -284,7 +286,7 @@ class OperationsRepository implements OperationsRepositoryInterface } // info about the currency: - $array[$currencyId] ??= [ + $array[$currencyId] ??= [ 'categories' => [], 'currency_id' => (string) $currencyId, 'currency_name' => $journal['currency_name'], @@ -325,7 +327,7 @@ class OperationsRepository implements OperationsRepositoryInterface public function sumExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $categories = null): array { /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionTypeEnum::WITHDRAWAL->value]); // default currency information for native stuff. @@ -339,19 +341,19 @@ class OperationsRepository implements OperationsRepositoryInterface } $collector->setCategories($categories); $collector->withCategoryInformation(); - $journals = $collector->getExtractedJournals(); - $array = []; + $journals = $collector->getExtractedJournals(); + $array = []; Log::debug(sprintf('Collected %d journals', count($journals))); foreach ($journals as $journal) { // Almost the same as in \FireflyIII\Repositories\Budget\OperationsRepository::sumExpenses - $amount = '0'; - $currencyId = (int) $journal['currency_id']; - $currencyName = $journal['currency_name']; - $currencySymbol = $journal['currency_symbol']; - $currencyCode = $journal['currency_code']; - $currencyDecimalPlaces = $journal['currency_decimal_places']; + $amount = '0'; + $currencyId = (int) $journal['currency_id']; + $currencyName = $journal['currency_name']; + $currencySymbol = $journal['currency_symbol']; + $currencyCode = $journal['currency_code']; + $currencyDecimalPlaces = $journal['currency_decimal_places']; if ($convertToNative) { $amount = Amount::getAmountFromJournal($journal); if ($default->id !== (int) $journal['currency_id'] && $default->id !== (int) $journal['foreign_currency_id']) { @@ -376,7 +378,7 @@ class OperationsRepository implements OperationsRepositoryInterface $amount = $journal['amount']; } - $array[$currencyId] ??= [ + $array[$currencyId] ??= [ 'sum' => '0', 'currency_id' => (string) $currencyId, 'currency_name' => $currencyName, @@ -396,9 +398,10 @@ class OperationsRepository implements OperationsRepositoryInterface public function sumIncome(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $categories = null): array { /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setUser($this->user)->setRange($start, $end) - ->setTypes([TransactionTypeEnum::DEPOSIT->value]); + ->setTypes([TransactionTypeEnum::DEPOSIT->value]) + ; if (null !== $accounts && $accounts->count() > 0) { $collector->setAccounts($accounts); @@ -407,19 +410,19 @@ class OperationsRepository implements OperationsRepositoryInterface $categories = $this->getCategories(); } $collector->setCategories($categories); - $journals = $collector->getExtractedJournals(); + $journals = $collector->getExtractedJournals(); $convertToNative = app('preferences')->get('convert_to_native', false)->data; $default = app('amount')->getDefaultCurrency(); - $array = []; + $array = []; foreach ($journals as $journal) { // Almost the same as in \FireflyIII\Repositories\Budget\OperationsRepository::sumExpenses - $amount = '0'; - $currencyId = (int) $journal['currency_id']; - $currencyName = $journal['currency_name']; - $currencySymbol = $journal['currency_symbol']; - $currencyCode = $journal['currency_code']; - $currencyDecimalPlaces = $journal['currency_decimal_places']; + $amount = '0'; + $currencyId = (int) $journal['currency_id']; + $currencyName = $journal['currency_name']; + $currencySymbol = $journal['currency_symbol']; + $currencyCode = $journal['currency_code']; + $currencyDecimalPlaces = $journal['currency_decimal_places']; if ($convertToNative) { $amount = Amount::getAmountFromJournal($journal); if ($default->id !== (int) $journal['currency_id'] && $default->id !== (int) $journal['foreign_currency_id']) { @@ -444,7 +447,7 @@ class OperationsRepository implements OperationsRepositoryInterface $amount = $journal['amount']; } - $array[$currencyId] ??= [ + $array[$currencyId] ??= [ 'sum' => '0', 'currency_id' => (string) $currencyId, 'currency_name' => $currencyName, @@ -466,7 +469,8 @@ class OperationsRepository implements OperationsRepositoryInterface /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); $collector->setUser($this->user)->setRange($start, $end) - ->setTypes([TransactionType::TRANSFER]); + ->setTypes([TransactionType::TRANSFER]) + ; if (null !== $accounts && $accounts->count() > 0) { $collector->setAccounts($accounts); @@ -475,12 +479,12 @@ class OperationsRepository implements OperationsRepositoryInterface $categories = $this->getCategories(); } $collector->setCategories($categories); - $journals = $collector->getExtractedJournals(); - $array = []; + $journals = $collector->getExtractedJournals(); + $array = []; foreach ($journals as $journal) { $currencyId = (int) $journal['currency_id']; - $array[$currencyId] ??= [ + $array[$currencyId] ??= [ 'sum' => '0', 'currency_id' => (string) $currencyId, 'currency_name' => $journal['currency_name'], diff --git a/app/Support/Chart/Category/WholePeriodChartGenerator.php b/app/Support/Chart/Category/WholePeriodChartGenerator.php index 2b2e39b182..239015bf20 100644 --- a/app/Support/Chart/Category/WholePeriodChartGenerator.php +++ b/app/Support/Chart/Category/WholePeriodChartGenerator.php @@ -26,7 +26,6 @@ namespace FireflyIII\Support\Chart\Category; use Carbon\Carbon; use FireflyIII\Enums\AccountTypeEnum; -use FireflyIII\Models\AccountType; use FireflyIII\Models\Category; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Category\OperationsRepositoryInterface; diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.php index e3c39ea4b2..ca37bf480e 100644 --- a/app/Support/Http/Controllers/AugumentData.php +++ b/app/Support/Http/Controllers/AugumentData.php @@ -183,7 +183,7 @@ trait AugumentData $cache->addProperty('get-limits'); if ($cache->has()) { - return $cache->get(); + return $cache->get(); } $set = $blRepository->getBudgetLimits($budget, $start, $end); @@ -191,12 +191,12 @@ trait AugumentData $budgetCollection = new Collection([$budget]); // merge sets based on a key, in case of convert to native - $limits = new Collection(); + $limits = new Collection(); /** @var BudgetLimit $entry */ foreach ($set as $entry) { $currency = $entry->transactionCurrency; - if($this->convertToNative) { + if ($this->convertToNative) { // the sumExpenses method already handles this. $currency = $this->defaultCurrency; } diff --git a/app/Support/Http/Controllers/ChartGeneration.php b/app/Support/Http/Controllers/ChartGeneration.php index 3fea9eada1..572f0b6044 100644 --- a/app/Support/Http/Controllers/ChartGeneration.php +++ b/app/Support/Http/Controllers/ChartGeneration.php @@ -54,7 +54,7 @@ trait ChartGeneration $cache->addProperty($accounts); $cache->addProperty($convertToNative); if ($cache->has()) { - return $cache->get(); + return $cache->get(); } app('log')->debug('Regenerate chart.account.account-balance-chart from scratch.'); $locale = app('steam')->getLocale(); diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.php index 925438b375..b66ba5747c 100644 --- a/app/Support/Http/Controllers/PeriodOverview.php +++ b/app/Support/Http/Controllers/PeriodOverview.php @@ -75,11 +75,11 @@ trait PeriodOverview */ protected function getAccountPeriodOverview(Account $account, Carbon $start, Carbon $end): array { - $range = app('navigation')->getViewRange(true); + $range = app('navigation')->getViewRange(true); [$start, $end] = $end < $start ? [$end, $start] : [$start, $end]; // properties for cache - $cache = new CacheProperties(); + $cache = new CacheProperties(); $cache->addProperty($start); $cache->addProperty($end); $cache->addProperty('account-show-period-entries'); @@ -89,32 +89,32 @@ trait PeriodOverview } /** @var array $dates */ - $dates = app('navigation')->blockPeriods($start, $end, $range); - $entries = []; + $dates = app('navigation')->blockPeriods($start, $end, $range); + $entries = []; // collect all expenses in this period: /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setAccounts(new Collection([$account])); $collector->setRange($start, $end); $collector->setTypes([TransactionType::DEPOSIT]); - $earnedSet = $collector->getExtractedJournals(); + $earnedSet = $collector->getExtractedJournals(); // collect all income in this period: /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setAccounts(new Collection([$account])); $collector->setRange($start, $end); $collector->setTypes([TransactionType::WITHDRAWAL]); - $spentSet = $collector->getExtractedJournals(); + $spentSet = $collector->getExtractedJournals(); // collect all transfers in this period: /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setAccounts(new Collection([$account])); $collector->setRange($start, $end); $collector->setTypes([TransactionType::TRANSFER]); - $transferSet = $collector->getExtractedJournals(); + $transferSet = $collector->getExtractedJournals(); // loop dates foreach ($dates as $currentDate) { @@ -125,15 +125,15 @@ trait PeriodOverview $transferredIn = $this->filterTransferredIn($account, $this->filterJournalsByDate($transferSet, $currentDate['start'], $currentDate['end'])); $entries[] = [ - 'title' => $title, - 'route' => route('accounts.show', [$account->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]), + 'title' => $title, + 'route' => route('accounts.show', [$account->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]), - 'total_transactions' => count($spent) + count($earned) + count($transferredAway) + count($transferredIn), - 'spent' => $this->groupByCurrency($spent), - 'earned' => $this->groupByCurrency($earned), - 'transferred_away' => $this->groupByCurrency($transferredAway), - 'transferred_in' => $this->groupByCurrency($transferredIn), - ]; + 'total_transactions' => count($spent) + count($earned) + count($transferredAway) + count($transferredIn), + 'spent' => $this->groupByCurrency($spent), + 'earned' => $this->groupByCurrency($earned), + 'transferred_away' => $this->groupByCurrency($transferredAway), + 'transferred_in' => $this->groupByCurrency($transferredIn), + ]; } $cache->store($entries); @@ -197,13 +197,13 @@ trait PeriodOverview /** @var array $journal */ foreach ($journals as $journal) { - $currencyId = (int) $journal['currency_id']; - $currencyCode = $journal['currency_code']; - $currencyName = $journal['currency_name']; - $currencySymbol = $journal['currency_symbol']; - $currencyDecimalPlaces = $journal['currency_decimal_places']; - $foreignCurrencyId = $journal['foreign_currency_id']; - $amount = $journal['amount']; + $currencyId = (int) $journal['currency_id']; + $currencyCode = $journal['currency_code']; + $currencyName = $journal['currency_name']; + $currencySymbol = $journal['currency_symbol']; + $currencyDecimalPlaces = $journal['currency_decimal_places']; + $foreignCurrencyId = $journal['foreign_currency_id']; + $amount = $journal['amount']; if ($this->convertToNative && $currencyId !== $this->defaultCurrency->id && $foreignCurrencyId !== $this->defaultCurrency->id) { @@ -215,7 +215,7 @@ trait PeriodOverview $currencyDecimalPlaces = $this->defaultCurrency->decimal_places; } if ($this->convertToNative && $currencyId !== $this->defaultCurrency->id && $foreignCurrencyId === $this->defaultCurrency->id) { - $currencyId = (int) $foreignCurrencyId; + $currencyId = (int) $foreignCurrencyId; $currencyCode = $journal['foreign_currency_code']; $currencyName = $journal['foreign_currency_name']; $currencySymbol = $journal['foreign_currency_symbol']; @@ -247,11 +247,11 @@ trait PeriodOverview */ protected function getCategoryPeriodOverview(Category $category, Carbon $start, Carbon $end): array { - $range = app('navigation')->getViewRange(true); + $range = app('navigation')->getViewRange(true); [$start, $end] = $end < $start ? [$end, $start] : [$start, $end]; // properties for entries with their amounts. - $cache = new CacheProperties(); + $cache = new CacheProperties(); $cache->addProperty($start); $cache->addProperty($end); $cache->addProperty($range); @@ -263,32 +263,32 @@ trait PeriodOverview } /** @var array $dates */ - $dates = app('navigation')->blockPeriods($start, $end, $range); - $entries = []; + $dates = app('navigation')->blockPeriods($start, $end, $range); + $entries = []; // collect all expenses in this period: /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setCategory($category); $collector->setRange($start, $end); $collector->setTypes([TransactionType::DEPOSIT]); - $earnedSet = $collector->getExtractedJournals(); + $earnedSet = $collector->getExtractedJournals(); // collect all income in this period: /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setCategory($category); $collector->setRange($start, $end); $collector->setTypes([TransactionType::WITHDRAWAL]); - $spentSet = $collector->getExtractedJournals(); + $spentSet = $collector->getExtractedJournals(); // collect all transfers in this period: /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setCategory($category); $collector->setRange($start, $end); $collector->setTypes([TransactionType::TRANSFER]); - $transferSet = $collector->getExtractedJournals(); + $transferSet = $collector->getExtractedJournals(); foreach ($dates as $currentDate) { $spent = $this->filterJournalsByDate($spentSet, $currentDate['start'], $currentDate['end']); $earned = $this->filterJournalsByDate($earnedSet, $currentDate['start'], $currentDate['end']); @@ -296,17 +296,17 @@ trait PeriodOverview $title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']); $entries[] = [ - 'transactions' => 0, - 'title' => $title, - 'route' => route( - 'categories.show', - [$category->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')] - ), - 'total_transactions' => count($spent) + count($earned) + count($transferred), - 'spent' => $this->groupByCurrency($spent), - 'earned' => $this->groupByCurrency($earned), - 'transferred' => $this->groupByCurrency($transferred), - ]; + 'transactions' => 0, + 'title' => $title, + 'route' => route( + 'categories.show', + [$category->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')] + ), + 'total_transactions' => count($spent) + count($earned) + count($transferred), + 'spent' => $this->groupByCurrency($spent), + 'earned' => $this->groupByCurrency($earned), + 'transferred' => $this->groupByCurrency($transferred), + ]; } $cache->store($entries); @@ -322,43 +322,43 @@ trait PeriodOverview */ protected function getNoBudgetPeriodOverview(Carbon $start, Carbon $end): array { - $range = app('navigation')->getViewRange(true); + $range = app('navigation')->getViewRange(true); [$start, $end] = $end < $start ? [$end, $start] : [$start, $end]; - $cache = new CacheProperties(); + $cache = new CacheProperties(); $cache->addProperty($start); $cache->addProperty($end); $cache->addProperty($this->convertToNative); $cache->addProperty('no-budget-period-entries'); if ($cache->has()) { - return $cache->get(); + return $cache->get(); } /** @var array $dates */ - $dates = app('navigation')->blockPeriods($start, $end, $range); - $entries = []; + $dates = app('navigation')->blockPeriods($start, $end, $range); + $entries = []; // get all expenses without a budget. /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setRange($start, $end)->withoutBudget()->withAccountInformation()->setTypes([TransactionType::WITHDRAWAL]); - $journals = $collector->getExtractedJournals(); + $journals = $collector->getExtractedJournals(); foreach ($dates as $currentDate) { $set = $this->filterJournalsByDate($journals, $currentDate['start'], $currentDate['end']); $title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']); $entries[] = [ - 'title' => $title, - 'route' => route('budgets.no-budget', [$currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]), - 'total_transactions' => count($set), - 'spent' => $this->groupByCurrency($set), - 'earned' => [], - 'transferred_away' => [], - 'transferred_in' => [], - ]; + 'title' => $title, + 'route' => route('budgets.no-budget', [$currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]), + 'total_transactions' => count($set), + 'spent' => $this->groupByCurrency($set), + 'earned' => [], + 'transferred_away' => [], + 'transferred_in' => [], + ]; } $cache->store($entries); @@ -375,38 +375,38 @@ trait PeriodOverview protected function getNoCategoryPeriodOverview(Carbon $theDate): array { app('log')->debug(sprintf('Now in getNoCategoryPeriodOverview(%s)', $theDate->format('Y-m-d'))); - $range = app('navigation')->getViewRange(true); - $first = $this->journalRepos->firstNull(); - $start = null === $first ? new Carbon() : $first->date; - $end = clone $theDate; - $end = app('navigation')->endOfPeriod($end, $range); + $range = app('navigation')->getViewRange(true); + $first = $this->journalRepos->firstNull(); + $start = null === $first ? new Carbon() : $first->date; + $end = clone $theDate; + $end = app('navigation')->endOfPeriod($end, $range); app('log')->debug(sprintf('Start for getNoCategoryPeriodOverview() is %s', $start->format('Y-m-d'))); app('log')->debug(sprintf('End for getNoCategoryPeriodOverview() is %s', $end->format('Y-m-d'))); // properties for cache - $dates = app('navigation')->blockPeriods($start, $end, $range); - $entries = []; + $dates = app('navigation')->blockPeriods($start, $end, $range); + $entries = []; // collect all expenses in this period: /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->withoutCategory(); $collector->setRange($start, $end); $collector->setTypes([TransactionType::DEPOSIT]); - $earnedSet = $collector->getExtractedJournals(); + $earnedSet = $collector->getExtractedJournals(); // collect all income in this period: /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->withoutCategory(); $collector->setRange($start, $end); $collector->setTypes([TransactionType::WITHDRAWAL]); - $spentSet = $collector->getExtractedJournals(); + $spentSet = $collector->getExtractedJournals(); // collect all transfers in this period: /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->withoutCategory(); $collector->setRange($start, $end); $collector->setTypes([TransactionType::TRANSFER]); @@ -420,13 +420,13 @@ trait PeriodOverview $title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']); $entries[] = [ - 'title' => $title, - 'route' => route('categories.no-category', [$currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]), - 'total_transactions' => count($spent) + count($earned) + count($transferred), - 'spent' => $this->groupByCurrency($spent), - 'earned' => $this->groupByCurrency($earned), - 'transferred' => $this->groupByCurrency($transferred), - ]; + 'title' => $title, + 'route' => route('categories.no-category', [$currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]), + 'total_transactions' => count($spent) + count($earned) + count($transferred), + 'spent' => $this->groupByCurrency($spent), + 'earned' => $this->groupByCurrency($earned), + 'transferred' => $this->groupByCurrency($transferred), + ]; } app('log')->debug('End of loops'); @@ -440,11 +440,11 @@ trait PeriodOverview */ protected function getTagPeriodOverview(Tag $tag, Carbon $start, Carbon $end): array // period overview for tags. { - $range = app('navigation')->getViewRange(true); + $range = app('navigation')->getViewRange(true); [$start, $end] = $end < $start ? [$end, $start] : [$start, $end]; // properties for cache - $cache = new CacheProperties(); + $cache = new CacheProperties(); $cache->addProperty($start); $cache->addProperty($end); $cache->addProperty('tag-period-entries'); @@ -454,37 +454,37 @@ trait PeriodOverview } /** @var array $dates */ - $dates = app('navigation')->blockPeriods($start, $end, $range); - $entries = []; + $dates = app('navigation')->blockPeriods($start, $end, $range); + $entries = []; // collect all expenses in this period: /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setTag($tag); $collector->setRange($start, $end); $collector->setTypes([TransactionType::DEPOSIT]); - $earnedSet = $collector->getExtractedJournals(); + $earnedSet = $collector->getExtractedJournals(); // collect all income in this period: /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setTag($tag); $collector->setRange($start, $end); $collector->setTypes([TransactionType::WITHDRAWAL]); - $spentSet = $collector->getExtractedJournals(); + $spentSet = $collector->getExtractedJournals(); // collect all transfers in this period: /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setTag($tag); $collector->setRange($start, $end); $collector->setTypes([TransactionType::TRANSFER]); - $transferSet = $collector->getExtractedJournals(); + $transferSet = $collector->getExtractedJournals(); // filer all of them: - $earnedSet = $this->filterJournalsByTag($earnedSet, $tag); - $spentSet = $this->filterJournalsByTag($spentSet, $tag); - $transferSet = $this->filterJournalsByTag($transferSet, $tag); + $earnedSet = $this->filterJournalsByTag($earnedSet, $tag); + $spentSet = $this->filterJournalsByTag($spentSet, $tag); + $transferSet = $this->filterJournalsByTag($transferSet, $tag); foreach ($dates as $currentDate) { $spent = $this->filterJournalsByDate($spentSet, $currentDate['start'], $currentDate['end']); @@ -493,17 +493,17 @@ trait PeriodOverview $title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']); $entries[] = [ - 'transactions' => 0, - 'title' => $title, - 'route' => route( - 'tags.show', - [$tag->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')] - ), - 'total_transactions' => count($spent) + count($earned) + count($transferred), - 'spent' => $this->groupByCurrency($spent), - 'earned' => $this->groupByCurrency($earned), - 'transferred' => $this->groupByCurrency($transferred), - ]; + 'transactions' => 0, + 'title' => $title, + 'route' => route( + 'tags.show', + [$tag->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')] + ), + 'total_transactions' => count($spent) + count($earned) + count($transferred), + 'spent' => $this->groupByCurrency($spent), + 'earned' => $this->groupByCurrency($earned), + 'transferred' => $this->groupByCurrency($transferred), + ]; } return $entries; @@ -513,7 +513,7 @@ trait PeriodOverview { $return = []; foreach ($set as $entry) { - $found = false; + $found = false; /** @var array $localTag */ foreach ($entry['tags'] as $localTag) { @@ -535,12 +535,12 @@ trait PeriodOverview */ protected function getTransactionPeriodOverview(string $transactionType, Carbon $start, Carbon $end): array { - $range = app('navigation')->getViewRange(true); - $types = config(sprintf('firefly.transactionTypesByType.%s', $transactionType)); + $range = app('navigation')->getViewRange(true); + $types = config(sprintf('firefly.transactionTypesByType.%s', $transactionType)); [$start, $end] = $end < $start ? [$end, $start] : [$start, $end]; // properties for cache - $cache = new CacheProperties(); + $cache = new CacheProperties(); $cache->addProperty($start); $cache->addProperty($end); $cache->addProperty('transactions-period-entries'); @@ -550,13 +550,13 @@ trait PeriodOverview } /** @var array $dates */ - $dates = app('navigation')->blockPeriods($start, $end, $range); - $entries = []; + $dates = app('navigation')->blockPeriods($start, $end, $range); + $entries = []; // collect all journals in this period (regardless of type) - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setTypes($types)->setRange($start, $end); - $genericSet = $collector->getExtractedJournals(); + $genericSet = $collector->getExtractedJournals(); foreach ($dates as $currentDate) { $spent = []; @@ -575,14 +575,14 @@ trait PeriodOverview $transferred = $this->filterJournalsByDate($genericSet, $currentDate['start'], $currentDate['end']); } $entries[] - = [ - 'title' => $title, - 'route' => route('transactions.index', [$transactionType, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]), - 'total_transactions' => count($spent) + count($earned) + count($transferred), - 'spent' => $this->groupByCurrency($spent), - 'earned' => $this->groupByCurrency($earned), - 'transferred' => $this->groupByCurrency($transferred), - ]; + = [ + 'title' => $title, + 'route' => route('transactions.index', [$transactionType, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]), + 'total_transactions' => count($spent) + count($earned) + count($transferred), + 'spent' => $this->groupByCurrency($spent), + 'earned' => $this->groupByCurrency($earned), + 'transferred' => $this->groupByCurrency($transferred), + ]; } return $entries; diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 0201aefba0..1aa9f73bf7 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -84,7 +84,7 @@ class Steam $cache->addProperty($start); $cache->addProperty($end); if ($cache->has()) { - return $cache->get(); + return $cache->get(); } $balances = []; diff --git a/composer.lock b/composer.lock index b9273f3f84..75bfaf5864 100644 --- a/composer.lock +++ b/composer.lock @@ -7330,12 +7330,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -7637,12 +7637,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -7860,12 +7860,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -9670,12 +9670,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -9930,12 +9930,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { diff --git a/config/firefly.php b/config/firefly.php index 604621b9c4..5968f7c992 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -81,7 +81,7 @@ return [ 'running_balance_column' => env('USE_RUNNING_BALANCE', false), // see cer.php for exchange rates feature flag. ], - 'version' => 'branch-v6.2', + 'version' => 'develop/2024-12-27', 'api_version' => '2.1.0', // field is no longer used. 'db_version' => 25, diff --git a/package-lock.json b/package-lock.json index 4077e58d38..bc0e566e97 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5663,9 +5663,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.5.75", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.75.tgz", - "integrity": "sha512-Lf3++DumRE/QmweGjU+ZcKqQ+3bKkU/qjaKYhIJKEOhgIO9Xs6IiAQFkfFoj+RhgDk4LUeNsLo6plExHqSyu6Q==", + "version": "1.5.76", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.76.tgz", + "integrity": "sha512-CjVQyG7n7Sr+eBXE86HIulnL5N8xZY1sgmOPGuq/F0Rr0FJq63lg0kEtOIDfZBk44FnDLf6FUJ+dsJcuiUDdDQ==", "dev": true, "license": "ISC" }, @@ -6967,6 +6967,7 @@ "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" } ], + "license": "MIT", "dependencies": { "@babel/runtime": "^7.23.2" }, @@ -11272,12 +11273,13 @@ } }, "node_modules/vite": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/vite/-/vite-6.0.5.tgz", - "integrity": "sha512-akD5IAH/ID5imgue2DYhzsEwCi0/4VKY31uhMLEYJwPP4TiUp8pL5PIK+Wo7H8qT8JY9i+pVfPydcFPYD1EL7g==", + "version": "6.0.6", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.0.6.tgz", + "integrity": "sha512-NSjmUuckPmDU18bHz7QZ+bTYhRR0iA72cs2QAxCqDpafJ0S6qetco0LB3WW2OxlMHS0JmAv+yZ/R3uPmMyGTjQ==", "dev": true, + "license": "MIT", "dependencies": { - "esbuild": "0.24.0", + "esbuild": "^0.24.2", "postcss": "^8.4.49", "rollup": "^4.23.0" },