Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Various PSR12 code cleanup
James Cole6cfdc58cb1fb
diff --git a/app/Http/Controllers/ObjectGroup/DeleteController.php b/app/Http/Controllers/ObjectGroup/DeleteController.phpindex 367ea85a53..b53c5fa710 100644--- a/app/Http/Controllers/ObjectGroup/DeleteController.php+++ b/app/Http/Controllers/ObjectGroup/DeleteController.php@@ -50,7 +50,7 @@ class DeleteController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-envelope-o');- app('view')->share('title', (string) trans('firefly.object_groups_page_title'));+ app('view')->share('title', (string)trans('firefly.object_groups_page_title'));$this->repository = app(ObjectGroupRepositoryInterface::class);@@ -62,13 +62,13 @@ class DeleteController extends Controller/*** Delete a piggy bank.*- * @param ObjectGroup $objectGroup+ * @param ObjectGroup $objectGroup** @return Factory|View*/public function delete(ObjectGroup $objectGroup){- $subTitle = (string) trans('firefly.delete_object_group', ['title' => $objectGroup->title]);+ $subTitle = (string)trans('firefly.delete_object_group', ['title' => $objectGroup->title]);$piggyBanks = $objectGroup->piggyBanks()->count();// put previous url in session@@ -80,13 +80,13 @@ class DeleteController extends Controller/*** Destroy the piggy bank.*- * @param ObjectGroup $objectGroup+ * @param ObjectGroup $objectGroup** @return RedirectResponse*/public function destroy(ObjectGroup $objectGroup): RedirectResponse{- session()->flash('success', (string) trans('firefly.deleted_object_group', ['title' => $objectGroup->title]));+ session()->flash('success', (string)trans('firefly.deleted_object_group', ['title' => $objectGroup->title]));app('preferences')->mark();$this->repository->destroy($objectGroup);diff --git a/app/Http/Controllers/ObjectGroup/EditController.php b/app/Http/Controllers/ObjectGroup/EditController.phpindex 55c0f21366..cdb35c0b81 100644--- a/app/Http/Controllers/ObjectGroup/EditController.php+++ b/app/Http/Controllers/ObjectGroup/EditController.php@@ -53,7 +53,7 @@ class EditController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-envelope-o');- app('view')->share('title', (string) trans('firefly.object_groups_page_title'));+ app('view')->share('title', (string)trans('firefly.object_groups_page_title'));$this->repository = app(ObjectGroupRepositoryInterface::class);@@ -65,13 +65,13 @@ class EditController extends Controller/*** Edit an object group.*- * @param ObjectGroup $objectGroup+ * @param ObjectGroup $objectGroup** @return Factory|View*/public function edit(ObjectGroup $objectGroup){- $subTitle = (string) trans('firefly.edit_object_group', ['title' => $objectGroup->title]);+ $subTitle = (string)trans('firefly.edit_object_group', ['title' => $objectGroup->title]);$subTitleIcon = 'fa-pencil';if (true !== session('object-groups.edit.fromUpdate')) {@@ -85,8 +85,8 @@ class EditController extends Controller/*** Update a piggy bank.*- * @param ObjectGroupFormRequest $request- * @param ObjectGroup $objectGroup+ * @param ObjectGroupFormRequest $request+ * @param ObjectGroup $objectGroup** @return Application|RedirectResponse|Redirector*/@@ -95,12 +95,12 @@ class EditController extends Controller$data = $request->getObjectGroupData();$piggyBank = $this->repository->update($objectGroup, $data);- session()->flash('success', (string) trans('firefly.updated_object_group', ['title' => $objectGroup->title]));+ session()->flash('success', (string)trans('firefly.updated_object_group', ['title' => $objectGroup->title]));app('preferences')->mark();$redirect = redirect($this->getPreviousUrl('object-groups.edit.url'));- if (1 === (int) $request->get('return_to_edit')) {+ if (1 === (int)$request->get('return_to_edit')) {session()->put('object-groups.edit.fromUpdate', true);$redirect = redirect(route('object-groups.edit', [$piggyBank->id]));diff --git a/app/Http/Controllers/ObjectGroup/IndexController.php b/app/Http/Controllers/ObjectGroup/IndexController.phpindex def792d0df..5a5c0fc59e 100644--- a/app/Http/Controllers/ObjectGroup/IndexController.php+++ b/app/Http/Controllers/ObjectGroup/IndexController.php@@ -53,7 +53,7 @@ class IndexController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-envelope-o');- app('view')->share('title', (string) trans('firefly.object_groups_page_title'));+ app('view')->share('title', (string)trans('firefly.object_groups_page_title'));$this->repository = app(ObjectGroupRepositoryInterface::class);return $next($request);@@ -68,22 +68,22 @@ class IndexController extends Controller{$this->repository->deleteEmpty();$this->repository->resetOrder();- $subTitle = (string) trans('firefly.object_groups_index');+ $subTitle = (string)trans('firefly.object_groups_index');$objectGroups = $this->repository->get();return view('object-groups.index', compact('subTitle', 'objectGroups'));}/**- * @param Request $request- * @param ObjectGroup $objectGroup+ * @param Request $request+ * @param ObjectGroup $objectGroup** @return JsonResponse*/public function setOrder(Request $request, ObjectGroup $objectGroup){Log::debug(sprintf('Found object group #%d "%s"', $objectGroup->id, $objectGroup->title));- $newOrder = (int) $request->get('order');+ $newOrder = (int)$request->get('order');$this->repository->setOrder($objectGroup, $newOrder);return response()->json([]);diff --git a/app/Http/Controllers/PiggyBank/AmountController.php b/app/Http/Controllers/PiggyBank/AmountController.phpindex a5d00f662e..b7e4d3af04 100644--- a/app/Http/Controllers/PiggyBank/AmountController.php+++ b/app/Http/Controllers/PiggyBank/AmountController.php@@ -54,7 +54,7 @@ class AmountController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.piggyBanks'));+ app('view')->share('title', (string)trans('firefly.piggyBanks'));app('view')->share('mainTitleIcon', 'fa-bullseye');$this->piggyRepos = app(PiggyBankRepositoryInterface::class);@@ -68,7 +68,7 @@ class AmountController extends Controller/*** Add money to piggy bank.*- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return Factory|View*/@@ -89,7 +89,7 @@ class AmountController extends Controller/*** Add money to piggy bank (for mobile devices).*- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return Factory|View*/@@ -113,8 +113,8 @@ class AmountController extends Controller/*** Add money to piggy bank.*- * @param Request $request- * @param PiggyBank $piggyBank+ * @param Request $request+ * @param PiggyBank $piggyBank** @return RedirectResponse*/@@ -130,7 +130,7 @@ class AmountController extends Controller$this->piggyRepos->addAmount($piggyBank, $amount);session()->flash('success',- (string) trans(+ (string)trans('firefly.added_amount_to_piggy',['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name])@@ -140,10 +140,10 @@ class AmountController extends Controllerreturn redirect(route('piggy-banks.index'));}- Log::error('Cannot add ' . $amount . ' because canAddAmount returned false.');+ Log::error('Cannot add '.$amount.' because canAddAmount returned false.');session()->flash('error',- (string) trans(+ (string)trans('firefly.cannot_add_amount_piggy',['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)])@@ -155,8 +155,8 @@ class AmountController extends Controller/*** Remove money from piggy bank.*- * @param Request $request- * @param PiggyBank $piggyBank+ * @param Request $request+ * @param PiggyBank $piggyBank** @return RedirectResponse*/@@ -172,7 +172,7 @@ class AmountController extends Controller$this->piggyRepos->removeAmount($piggyBank, $amount);session()->flash('success',- (string) trans(+ (string)trans('firefly.removed_amount_from_piggy',['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name])@@ -181,11 +181,11 @@ class AmountController extends Controllerreturn redirect(route('piggy-banks.index'));}- $amount = (string) $request->get('amount');+ $amount = (string)$request->get('amount');session()->flash('error',- (string) trans(+ (string)trans('firefly.cannot_remove_from_piggy',['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)])@@ -197,7 +197,7 @@ class AmountController extends Controller/*** Remove money from piggy bank form.*- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return Factory|View*/@@ -212,7 +212,7 @@ class AmountController extends Controller/*** Remove money from piggy bank (for mobile devices).*- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return Factory|View*/diff --git a/app/Http/Controllers/PiggyBank/CreateController.php b/app/Http/Controllers/PiggyBank/CreateController.phpindex c0da9bd1b7..9347bda81b 100644--- a/app/Http/Controllers/PiggyBank/CreateController.php+++ b/app/Http/Controllers/PiggyBank/CreateController.php@@ -53,7 +53,7 @@ class CreateController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.piggyBanks'));+ app('view')->share('title', (string)trans('firefly.piggyBanks'));app('view')->share('mainTitleIcon', 'fa-bullseye');$this->attachments = app(AttachmentHelperInterface::class);@@ -71,7 +71,7 @@ class CreateController extends Controller*/public function create(){- $subTitle = (string) trans('firefly.new_piggy_bank');+ $subTitle = (string)trans('firefly.new_piggy_bank');$subTitleIcon = 'fa-plus';// put previous url in session if not redirect from store (not "create another").@@ -86,7 +86,7 @@ class CreateController extends Controller/*** Store a new piggy bank.*- * @param PiggyBankStoreRequest $request+ * @param PiggyBankStoreRequest $request** @return RedirectResponse|Redirector* @throws FireflyException@@ -99,7 +99,7 @@ class CreateController extends Controller}$piggyBank = $this->piggyRepos->store($data);- session()->flash('success', (string) trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name]));+ session()->flash('success', (string)trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name]));app('preferences')->mark();// store attachment(s):@@ -109,7 +109,7 @@ class CreateController extends Controller$this->attachments->saveAttachmentsForModel($piggyBank, $files);}if (null !== $files && auth()->user()->hasRole('demo')) {- session()->flash('info', (string) trans('firefly.no_att_demo_user'));+ session()->flash('info', (string)trans('firefly.no_att_demo_user'));}if (count($this->attachments->getMessages()->get('attachments')) > 0) {@@ -117,7 +117,7 @@ class CreateController extends Controller}$redirect = redirect($this->getPreviousUrl('piggy-banks.create.url'));- if (1 === (int) $request->get('create_another')) {+ if (1 === (int)$request->get('create_another')) {session()->put('piggy-banks.create.fromStore', true);$redirect = redirect(route('piggy-banks.create'))->withInput();diff --git a/app/Http/Controllers/PiggyBank/DeleteController.php b/app/Http/Controllers/PiggyBank/DeleteController.phpindex 4fdcf47e83..1c019b2839 100644--- a/app/Http/Controllers/PiggyBank/DeleteController.php+++ b/app/Http/Controllers/PiggyBank/DeleteController.php@@ -49,7 +49,7 @@ class DeleteController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.piggyBanks'));+ app('view')->share('title', (string)trans('firefly.piggyBanks'));app('view')->share('mainTitleIcon', 'fa-bullseye');$this->piggyRepos = app(PiggyBankRepositoryInterface::class);@@ -62,13 +62,13 @@ class DeleteController extends Controller/*** Delete a piggy bank.*- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return Factory|View*/public function delete(PiggyBank $piggyBank){- $subTitle = (string) trans('firefly.delete_piggy_bank', ['name' => $piggyBank->name]);+ $subTitle = (string)trans('firefly.delete_piggy_bank', ['name' => $piggyBank->name]);// put previous url in session$this->rememberPreviousUrl('piggy-banks.delete.url');@@ -79,13 +79,13 @@ class DeleteController extends Controller/*** Destroy the piggy bank.*- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return RedirectResponse*/public function destroy(PiggyBank $piggyBank): RedirectResponse{- session()->flash('success', (string) trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name]));+ session()->flash('success', (string)trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name]));app('preferences')->mark();$this->piggyRepos->destroy($piggyBank);diff --git a/app/Http/Controllers/PiggyBank/IndexController.php b/app/Http/Controllers/PiggyBank/IndexController.phpindex c931c108b4..4a7d4f49af 100644--- a/app/Http/Controllers/PiggyBank/IndexController.php+++ b/app/Http/Controllers/PiggyBank/IndexController.php@@ -25,6 +25,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\PiggyBank;use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\PiggyBank;use FireflyIII\Repositories\ObjectGroup\OrganisesObjectGroups;@@ -35,6 +36,7 @@ use Illuminate\Contracts\View\Factory;use Illuminate\Http\JsonResponse;use Illuminate\Http\Request;use Illuminate\View\View;+use JsonException;use Symfony\Component\HttpFoundation\ParameterBag;/**@@ -57,7 +59,7 @@ class IndexController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.piggyBanks'));+ app('view')->share('title', (string)trans('firefly.piggyBanks'));app('view')->share('mainTitleIcon', 'fa-bullseye');$this->piggyRepos = app(PiggyBankRepositoryInterface::class);@@ -72,11 +74,11 @@ class IndexController extends Controller** TODO very complicated function.*- * @param Request $request+ * @param Request $request** @return Factory|View- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/public function index(Request $request){@@ -104,16 +106,16 @@ class IndexController extends Controller/** @var PiggyBank $piggy */foreach ($collection as $piggy) {$array = $transformer->transform($piggy);- $groupOrder = (int) $array['object_group_order'];+ $groupOrder = (int)$array['object_group_order'];// make group array if necessary:$piggyBanks[$groupOrder] = $piggyBanks[$groupOrder] ?? [- 'object_group_id' => $array['object_group_id'] ?? 0,- 'object_group_title' => $array['object_group_title'] ?? trans('firefly.default_group_title_name'),- 'piggy_banks' => [],- ];+ 'object_group_id' => $array['object_group_id'] ?? 0,+ 'object_group_title' => $array['object_group_title'] ?? trans('firefly.default_group_title_name'),+ 'piggy_banks' => [],+ ];$account = $accountTransformer->transform($piggy->account);- $accountId = (int) $account['id'];+ $accountId = (int)$account['id'];$array['attachments'] = $this->piggyRepos->getAttachments($piggy);if (!array_key_exists($accountId, $accounts)) {// create new:@@ -143,7 +145,7 @@ class IndexController extends Controller}/**- * @param array $piggyBanks+ * @param array $piggyBanks** @return array*/@@ -155,23 +157,23 @@ class IndexController extends Controllerforeach ($group['piggy_banks'] as $piggy) {$currencyId = $piggy['currency_id'];$sums[$groupId][$currencyId] = $sums[$groupId][$currencyId] ?? [- 'target' => '0',- 'saved' => '0',- 'left_to_save' => '0',- 'save_per_month' => '0',- 'currency_id' => $currencyId,- 'currency_code' => $piggy['currency_code'],- 'currency_symbol' => $piggy['currency_symbol'],- 'currency_decimal_places' => $piggy['currency_decimal_places'],- ];+ 'target' => '0',+ 'saved' => '0',+ 'left_to_save' => '0',+ 'save_per_month' => '0',+ 'currency_id' => $currencyId,+ 'currency_code' => $piggy['currency_code'],+ 'currency_symbol' => $piggy['currency_symbol'],+ 'currency_decimal_places' => $piggy['currency_decimal_places'],+ ];// target_amount// current_amount// left_to_save// save_per_month- $sums[$groupId][$currencyId]['target'] = bcadd($sums[$groupId][$currencyId]['target'], (string) $piggy['target_amount']);- $sums[$groupId][$currencyId]['saved'] = bcadd($sums[$groupId][$currencyId]['saved'], (string) $piggy['current_amount']);- $sums[$groupId][$currencyId]['left_to_save'] = bcadd($sums[$groupId][$currencyId]['left_to_save'], (string) $piggy['left_to_save']);- $sums[$groupId][$currencyId]['save_per_month'] = bcadd($sums[$groupId][$currencyId]['save_per_month'], (string) $piggy['save_per_month']);+ $sums[$groupId][$currencyId]['target'] = bcadd($sums[$groupId][$currencyId]['target'], (string)$piggy['target_amount']);+ $sums[$groupId][$currencyId]['saved'] = bcadd($sums[$groupId][$currencyId]['saved'], (string)$piggy['current_amount']);+ $sums[$groupId][$currencyId]['left_to_save'] = bcadd($sums[$groupId][$currencyId]['left_to_save'], (string)$piggy['left_to_save']);+ $sums[$groupId][$currencyId]['save_per_month'] = bcadd($sums[$groupId][$currencyId]['save_per_month'], (string)$piggy['save_per_month']);}}foreach ($piggyBanks as $groupOrder => $group) {@@ -185,15 +187,15 @@ class IndexController extends Controller/*** Set the order of a piggy bank.*- * @param Request $request- * @param PiggyBank $piggyBank+ * @param Request $request+ * @param PiggyBank $piggyBank** @return JsonResponse*/public function setOrder(Request $request, PiggyBank $piggyBank): JsonResponse{- $objectGroupTitle = (string) $request->get('objectGroupTitle');- $newOrder = (int) $request->get('order');+ $objectGroupTitle = (string)$request->get('objectGroupTitle');+ $newOrder = (int)$request->get('order');$this->piggyRepos->setOrder($piggyBank, $newOrder);if ('' !== $objectGroupTitle) {$this->piggyRepos->setObjectGroup($piggyBank, $objectGroupTitle);diff --git a/app/Http/Controllers/PiggyBank/ShowController.php b/app/Http/Controllers/PiggyBank/ShowController.phpindex a73b59f409..93905891c9 100644--- a/app/Http/Controllers/PiggyBank/ShowController.php+++ b/app/Http/Controllers/PiggyBank/ShowController.php@@ -51,7 +51,7 @@ class ShowController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.piggyBanks'));+ app('view')->share('title', (string)trans('firefly.piggyBanks'));app('view')->share('mainTitleIcon', 'fa-bullseye');$this->piggyRepos = app(PiggyBankRepositoryInterface::class);@@ -64,7 +64,7 @@ class ShowController extends Controller/*** Show a single piggy bank.*- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return Factory|View*/diff --git a/app/Http/Controllers/Popup/ReportController.php b/app/Http/Controllers/Popup/ReportController.phpindex b5a442c988..93fdcc9a67 100644--- a/app/Http/Controllers/Popup/ReportController.php+++ b/app/Http/Controllers/Popup/ReportController.php@@ -1,4 +1,5 @@<?php+/*** ReportController.php* Copyright (c) 2019 [email protected]@@ -38,7 +39,7 @@ class ReportController extends Controller/*** Generate popup view.*- * @param Request $request+ * @param Request $request** @return JsonResponse*diff --git a/app/Http/Controllers/Recurring/CreateController.php b/app/Http/Controllers/Recurring/CreateController.phpindex ff2ca1650a..884155e1e9 100644--- a/app/Http/Controllers/Recurring/CreateController.php+++ b/app/Http/Controllers/Recurring/CreateController.php@@ -63,8 +63,8 @@ class CreateController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-paint-brush');- app('view')->share('title', (string) trans('firefly.recurrences'));- app('view')->share('subTitle', (string) trans('firefly.create_new_recurrence'));+ app('view')->share('title', (string)trans('firefly.recurrences'));+ app('view')->share('subTitle', (string)trans('firefly.create_new_recurrence'));$this->recurring = app(RecurringRepositoryInterface::class);$this->budgetRepos = app(BudgetRepositoryInterface::class);@@ -79,7 +79,7 @@ class CreateController extends Controller/*** Create a new recurring transaction.*- * @param Request $request+ * @param Request $request** @return Factory|View*/@@ -98,22 +98,22 @@ class CreateController extends Controller}$request->session()->forget('recurring.create.fromStore');$repetitionEnds = [- 'forever' => (string) trans('firefly.repeat_forever'),- 'until_date' => (string) trans('firefly.repeat_until_date'),- 'times' => (string) trans('firefly.repeat_times'),+ 'forever' => (string)trans('firefly.repeat_forever'),+ 'until_date' => (string)trans('firefly.repeat_until_date'),+ 'times' => (string)trans('firefly.repeat_times'),];$weekendResponses = [- RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),- RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),- RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),- RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),+ RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),+ RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),+ RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),+ RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),];$hasOldInput = null !== $request->old('_token'); // flash some data$preFilled = ['first_date' => $tomorrow->format('Y-m-d'),'transaction_type' => $hasOldInput ? $request->old('transaction_type') : 'withdrawal',- 'active' => $hasOldInput ? (bool) $request->old('active') : true,- 'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : true,+ 'active' => $hasOldInput ? (bool)$request->old('active') : true,+ 'apply_rules' => $hasOldInput ? (bool)$request->old('apply_rules') : true,];$request->session()->flash('preFilled', $preFilled);@@ -124,8 +124,8 @@ class CreateController extends Controller}/**- * @param Request $request- * @param TransactionJournal $journal+ * @param Request $request+ * @param TransactionJournal $journal** @return Factory|\Illuminate\Contracts\View\View*/@@ -144,15 +144,15 @@ class CreateController extends Controller}$request->session()->forget('recurring.create.fromStore');$repetitionEnds = [- 'forever' => (string) trans('firefly.repeat_forever'),- 'until_date' => (string) trans('firefly.repeat_until_date'),- 'times' => (string) trans('firefly.repeat_times'),+ 'forever' => (string)trans('firefly.repeat_forever'),+ 'until_date' => (string)trans('firefly.repeat_until_date'),+ 'times' => (string)trans('firefly.repeat_times'),];$weekendResponses = [- RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),- RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),- RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),- RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),+ RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),+ RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),+ RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),+ RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),];@@ -185,8 +185,8 @@ class CreateController extends Controller'category' => $request->old('category'),'budget_id' => $request->old('budget_id'),'bill_id' => $request->old('bill_id'),- 'active' => (bool) $request->old('active'),- 'apply_rules' => (bool) $request->old('apply_rules'),+ 'active' => (bool)$request->old('active'),+ 'apply_rules' => (bool)$request->old('apply_rules'),];}if (false === $hasOldInput) {@@ -221,7 +221,7 @@ class CreateController extends Controller/*** Store a recurring transaction.*- * @param RecurrenceFormRequest $request+ * @param RecurrenceFormRequest $request** @return RedirectResponse|Redirector* @throws FireflyException@@ -237,7 +237,7 @@ class CreateController extends Controllerreturn redirect(route('recurring.create'))->withInput();}- $request->session()->flash('success', (string) trans('firefly.stored_new_recurrence', ['title' => $recurrence->title]));+ $request->session()->flash('success', (string)trans('firefly.stored_new_recurrence', ['title' => $recurrence->title]));app('preferences')->mark();// store attachment(s):@@ -247,7 +247,7 @@ class CreateController extends Controller$this->attachments->saveAttachmentsForModel($recurrence, $files);}if (null !== $files && auth()->user()->hasRole('demo')) {- session()->flash('info', (string) trans('firefly.no_att_demo_user'));+ session()->flash('info', (string)trans('firefly.no_att_demo_user'));}if (count($this->attachments->getMessages()->get('attachments')) > 0) {@@ -255,7 +255,7 @@ class CreateController extends Controller}$redirect = redirect($this->getPreviousUrl('recurring.create.url'));- if (1 === (int) $request->get('create_another')) {+ if (1 === (int)$request->get('create_another')) {// set value so create routine will not overwrite URL:$request->session()->put('recurring.create.fromStore', true);diff --git a/app/Http/Controllers/Recurring/DeleteController.php b/app/Http/Controllers/Recurring/DeleteController.phpindex 8de42d9b6f..c45bdb1bdb 100644--- a/app/Http/Controllers/Recurring/DeleteController.php+++ b/app/Http/Controllers/Recurring/DeleteController.php@@ -53,7 +53,7 @@ class DeleteController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-paint-brush');- app('view')->share('title', (string) trans('firefly.recurrences'));+ app('view')->share('title', (string)trans('firefly.recurrences'));$this->recurring = app(RecurringRepositoryInterface::class);@@ -65,13 +65,13 @@ class DeleteController extends Controller/*** Delete a recurring transaction form.*- * @param Recurrence $recurrence+ * @param Recurrence $recurrence** @return Factory|View*/public function delete(Recurrence $recurrence){- $subTitle = (string) trans('firefly.delete_recurring', ['title' => $recurrence->title]);+ $subTitle = (string)trans('firefly.delete_recurring', ['title' => $recurrence->title]);// put previous url in session$this->rememberPreviousUrl('recurrences.delete.url');@@ -83,16 +83,16 @@ class DeleteController extends Controller/*** Destroy the recurring transaction.*- * @param RecurringRepositoryInterface $repository- * @param Request $request- * @param Recurrence $recurrence+ * @param RecurringRepositoryInterface $repository+ * @param Request $request+ * @param Recurrence $recurrence** @return RedirectResponse|Redirector*/public function destroy(RecurringRepositoryInterface $repository, Request $request, Recurrence $recurrence){$repository->destroy($recurrence);- $request->session()->flash('success', (string) trans('firefly.' . 'recurrence_deleted', ['title' => $recurrence->title]));+ $request->session()->flash('success', (string)trans('firefly.'.'recurrence_deleted', ['title' => $recurrence->title]));app('preferences')->mark();return redirect($this->getPreviousUrl('recurrences.delete.url'));diff --git a/app/Http/Controllers/Recurring/EditController.php b/app/Http/Controllers/Recurring/EditController.phpindex e9bd8982f5..a0a908ac62 100644--- a/app/Http/Controllers/Recurring/EditController.php+++ b/app/Http/Controllers/Recurring/EditController.php@@ -64,8 +64,8 @@ class EditController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-paint-brush');- app('view')->share('title', (string) trans('firefly.recurrences'));- app('view')->share('subTitle', (string) trans('firefly.recurrences'));+ app('view')->share('title', (string)trans('firefly.recurrences'));+ app('view')->share('subTitle', (string)trans('firefly.recurrences'));$this->recurring = app(RecurringRepositoryInterface::class);$this->budgetRepos = app(BudgetRepositoryInterface::class);@@ -80,8 +80,8 @@ class EditController extends Controller/*** Edit a recurring transaction.*- * @param Request $request- * @param Recurrence $recurrence+ * @param Request $request+ * @param Recurrence $recurrence** @return Factory|View* @throws FireflyException@@ -107,7 +107,7 @@ class EditController extends Controller$repetition = $recurrence->recurrenceRepetitions()->first();$currentRepType = $repetition->repetition_type;if ('' !== $repetition->repetition_moment) {- $currentRepType .= ',' . $repetition->repetition_moment;+ $currentRepType .= ','.$repetition->repetition_moment;}// put previous url in session if not redirect from store (not "return_to_edit").@@ -118,9 +118,9 @@ class EditController extends Controller$repetitionEnd = 'forever';$repetitionEnds = [- 'forever' => (string) trans('firefly.repeat_forever'),- 'until_date' => (string) trans('firefly.repeat_until_date'),- 'times' => (string) trans('firefly.repeat_times'),+ 'forever' => (string)trans('firefly.repeat_forever'),+ 'until_date' => (string)trans('firefly.repeat_until_date'),+ 'times' => (string)trans('firefly.repeat_times'),];if (null !== $recurrence->repeat_until) {$repetitionEnd = 'until_date';@@ -130,22 +130,22 @@ class EditController extends Controller}$weekendResponses = [- RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),- RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),- RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),- RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),+ RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),+ RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),+ RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),+ RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),];$hasOldInput = null !== $request->old('_token');$preFilled = ['transaction_type' => strtolower($recurrence->transactionType->type),- 'active' => $hasOldInput ? (bool) $request->old('active') : $recurrence->active,- 'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : $recurrence->apply_rules,+ 'active' => $hasOldInput ? (bool)$request->old('active') : $recurrence->active,+ 'apply_rules' => $hasOldInput ? (bool)$request->old('apply_rules') : $recurrence->apply_rules,'deposit_source_id' => $array['transactions'][0]['source_id'],'withdrawal_destination_id' => $array['transactions'][0]['destination_id'],];- $array['first_date'] = substr((string) $array['first_date'], 0, 10);- $array['repeat_until'] = substr((string) $array['repeat_until'], 0, 10);+ $array['first_date'] = substr((string)$array['first_date'], 0, 10);+ $array['repeat_until'] = substr((string)$array['repeat_until'], 0, 10);$array['transactions'][0]['tags'] = implode(',', $array['transactions'][0]['tags'] ?? []);return view(@@ -167,8 +167,8 @@ class EditController extends Controller/*** Update the recurring transaction.*- * @param RecurrenceFormRequest $request- * @param Recurrence $recurrence+ * @param RecurrenceFormRequest $request+ * @param Recurrence $recurrence** @return RedirectResponse|Redirector* @throws FireflyException@@ -178,7 +178,7 @@ class EditController extends Controller$data = $request->getAll();$this->recurring->update($recurrence, $data);- $request->session()->flash('success', (string) trans('firefly.updated_recurrence', ['title' => $recurrence->title]));+ $request->session()->flash('success', (string)trans('firefly.updated_recurrence', ['title' => $recurrence->title]));// store new attachment(s):$files = $request->hasFile('attachments') ? $request->file('attachments') : null;@@ -186,7 +186,7 @@ class EditController extends Controller$this->attachments->saveAttachmentsForModel($recurrence, $files);}if (null !== $files && auth()->user()->hasRole('demo')) {- session()->flash('info', (string) trans('firefly.no_att_demo_user'));+ session()->flash('info', (string)trans('firefly.no_att_demo_user'));}if (count($this->attachments->getMessages()->get('attachments')) > 0) {@@ -194,7 +194,7 @@ class EditController extends Controller}app('preferences')->mark();$redirect = redirect($this->getPreviousUrl('recurrences.edit.url'));- if (1 === (int) $request->get('return_to_edit')) {+ if (1 === (int)$request->get('return_to_edit')) {// set value so edit routine will not overwrite URL:$request->session()->put('recurrences.edit.fromUpdate', true);diff --git a/app/Http/Controllers/Recurring/IndexController.php b/app/Http/Controllers/Recurring/IndexController.phpindex 9f6260ac2c..3e0d426941 100644--- a/app/Http/Controllers/Recurring/IndexController.php+++ b/app/Http/Controllers/Recurring/IndexController.php@@ -1,4 +1,5 @@<?php+/*** IndexController.php* Copyright (c) 2019 [email protected]@@ -33,6 +34,8 @@ use Illuminate\Contracts\View\Factory;use Illuminate\Http\Request;use Illuminate\Pagination\LengthAwarePaginator;use Illuminate\View\View;+use Psr\Container\ContainerExceptionInterface;+use Psr\Container\NotFoundExceptionInterface;use Symfony\Component\HttpFoundation\ParameterBag;/**@@ -58,7 +61,7 @@ class IndexController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-paint-brush');- app('view')->share('title', (string) trans('firefly.recurrences'));+ app('view')->share('title', (string)trans('firefly.recurrences'));$this->recurringRepos = app(RecurringRepositoryInterface::class);@@ -71,17 +74,17 @@ class IndexController extends Controller* TODO the notes of a recurrence are pretty pointless at this moment.* Show all recurring transactions.*- * @param Request $request+ * @param Request $request** @return Factory|View* @throws FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/public function index(Request $request){- $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;+ $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;$collection = $this->recurringRepos->get();$today = today(config('app.timezone'));$year = today(config('app.timezone'));diff --git a/app/Http/Controllers/Recurring/TriggerController.php b/app/Http/Controllers/Recurring/TriggerController.phpindex 6e2909a7e4..3ed8570ea4 100644--- a/app/Http/Controllers/Recurring/TriggerController.php+++ b/app/Http/Controllers/Recurring/TriggerController.php@@ -1,4 +1,5 @@<?php+declare(strict_types=1);/** TriggerController.phpdiff --git a/app/Http/Controllers/Report/AccountController.php b/app/Http/Controllers/Report/AccountController.phpindex f174aa744a..c837be0ec4 100644--- a/app/Http/Controllers/Report/AccountController.php+++ b/app/Http/Controllers/Report/AccountController.php@@ -1,4 +1,5 @@<?php+/*** AccountController.php* Copyright (c) 2019 [email protected]@@ -28,7 +29,6 @@ use FireflyIII\Http\Controllers\Controller;use FireflyIII\Repositories\Account\AccountTaskerInterface;use FireflyIII\Support\CacheProperties;use Illuminate\Support\Collection;-use JsonException;use Log;use Throwable;@@ -40,9 +40,9 @@ class AccountController extends Controller/*** Show partial overview for account balances.*- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return mixed|string*/diff --git a/app/Http/Controllers/Report/BalanceController.php b/app/Http/Controllers/Report/BalanceController.phpindex 8fe3c635cb..eb79b1b8e9 100644--- a/app/Http/Controllers/Report/BalanceController.php+++ b/app/Http/Controllers/Report/BalanceController.php@@ -1,4 +1,5 @@<?php+/*** BalanceController.php* Copyright (c) 2019 [email protected]@@ -61,9 +62,9 @@ class BalanceController extends Controller/*** Show overview of budget balances.*- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -104,25 +105,25 @@ class BalanceController extends Controller$sourceAccount = $journal['source_account_id'];$currencyId = $journal['currency_id'];$spent[$sourceAccount] = $spent[$sourceAccount] ?? [- 'source_account_id' => $sourceAccount,- 'currency_id' => $journal['currency_id'],- 'currency_code' => $journal['currency_code'],- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- 'spent' => '0',- ];+ 'source_account_id' => $sourceAccount,+ 'currency_id' => $journal['currency_id'],+ 'currency_code' => $journal['currency_code'],+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ 'spent' => '0',+ ];$spent[$sourceAccount]['spent'] = bcadd($spent[$sourceAccount]['spent'], $journal['amount']);// also fix sum:$report['sums'][$budgetId][$currencyId] = $report['sums'][$budgetId][$currencyId] ?? [- 'sum' => '0',- 'currency_id' => $journal['currency_id'],- 'currency_code' => $journal['currency_code'],- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'sum' => '0',+ 'currency_id' => $journal['currency_id'],+ 'currency_code' => $journal['currency_code'],+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];$report['sums'][$budgetId][$currencyId]['sum'] = bcadd($report['sums'][$budgetId][$currencyId]['sum'], $journal['amount']);$report['accounts'][$sourceAccount]['sum'] = bcadd($report['accounts'][$sourceAccount]['sum'], $journal['amount']);diff --git a/app/Http/Controllers/Report/BillController.php b/app/Http/Controllers/Report/BillController.phpindex 934aa4b7ab..0cc81018c6 100644--- a/app/Http/Controllers/Report/BillController.php+++ b/app/Http/Controllers/Report/BillController.php@@ -29,7 +29,6 @@ use FireflyIII\Helpers\Report\ReportHelperInterface;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Support\CacheProperties;use Illuminate\Support\Collection;-use JsonException;use Log;use Throwable;@@ -39,9 +38,9 @@ use Throwable;class BillController extends Controller{/**- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return mixed|string*/diff --git a/app/Http/Controllers/Report/BudgetController.php b/app/Http/Controllers/Report/BudgetController.phpindex 22b4a49170..c56139c216 100644--- a/app/Http/Controllers/Report/BudgetController.php+++ b/app/Http/Controllers/Report/BudgetController.php@@ -1,4 +1,5 @@<?php+/*** BudgetController.php* Copyright (c) 2019 [email protected]@@ -76,10 +77,10 @@ class BudgetController extends Controller/*** Partial used in the budget report.*- * @param Collection $accounts- * @param Collection $budgets- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $budgets+ * @param Carbon $start+ * @param Carbon $end** @return Factory|View*/@@ -101,10 +102,10 @@ class BudgetController extends Controller}/**- * @param Collection $accounts- * @param Collection $budgets- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $budgets+ * @param Carbon $start+ * @param Carbon $end** @return Factory|View*/@@ -117,33 +118,33 @@ class BudgetController extends Controllerforeach ($accounts as $account) {$accountId = $account->id;$report[$accountId] = $report[$accountId] ?? [- 'name' => $account->name,- 'id' => $account->id,- 'iban' => $account->iban,- 'currencies' => [],- ];+ 'name' => $account->name,+ 'id' => $account->id,+ 'iban' => $account->iban,+ 'currencies' => [],+ ];}// loop expenses.foreach ($spent as $currency) {$currencyId = $currency['currency_id'];$sums[$currencyId] = $sums[$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'sum' => '0',- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'sum' => '0',+ ];foreach ($currency['budgets'] as $budget) {foreach ($budget['transaction_journals'] as $journal) {$sourceAccountId = $journal['source_account_id'];$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'sum' => '0',- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'sum' => '0',+ ];$report[$sourceAccountId]['currencies'][$currencyId]['sum'] = bcadd($report[$sourceAccountId]['currencies'][$currencyId]['sum'],$journal['amount']@@ -157,10 +158,10 @@ class BudgetController extends Controller}/**- * @param Collection $accounts- * @param Collection $budgets- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $budgets+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -174,21 +175,21 @@ class BudgetController extends Controller$destinationId = $journal['destination_account_id'];$key = sprintf('%d-%d', $destinationId, $currency['currency_id']);$result[$key] = $result[$key] ?? [- 'transactions' => 0,- 'sum' => '0',- 'avg' => '0',- 'avg_float' => 0,- 'destination_account_name' => $journal['destination_account_name'],- 'destination_account_id' => $journal['destination_account_id'],- 'currency_id' => $currency['currency_id'],- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- ];+ 'transactions' => 0,+ 'sum' => '0',+ 'avg' => '0',+ 'avg_float' => 0,+ 'destination_account_name' => $journal['destination_account_name'],+ 'destination_account_id' => $journal['destination_account_id'],+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];$result[$key]['transactions']++;$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);- $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);- $result[$key]['avg_float'] = (float) $result[$key]['avg']; // intentional float+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);+ $result[$key]['avg_float'] = (float)$result[$key]['avg']; // intentional float}}}@@ -209,10 +210,10 @@ class BudgetController extends Controller}/**- * @param Collection $accounts- * @param Collection $budgets- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $budgets+ * @param Carbon $start+ * @param Carbon $end** @return Factory|View*/@@ -225,20 +226,20 @@ class BudgetController extends Controllerforeach ($budgets as $budget) {$budgetId = $budget->id;$report[$budgetId] = $report[$budgetId] ?? [- 'name' => $budget->name,- 'id' => $budget->id,- 'currencies' => [],- ];+ 'name' => $budget->name,+ 'id' => $budget->id,+ 'currencies' => [],+ ];}foreach ($spent as $currency) {$currencyId = $currency['currency_id'];$sums[$currencyId] = $sums[$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'sum' => '0',- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'sum' => '0',+ ];/** @var array $budget */foreach ($currency['budgets'] as $budget) {$budgetId = $budget['id'];@@ -246,14 +247,14 @@ class BudgetController extends Controllerforeach ($budget['transaction_journals'] as $journal) {// add currency info to report array:$report[$budgetId]['currencies'][$currencyId] = $report[$budgetId]['currencies'][$currencyId] ?? [- 'sum' => '0',- 'sum_pct' => '0',- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],-- ];+ 'sum' => '0',+ 'sum_pct' => '0',+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],++ ];$report[$budgetId]['currencies'][$currencyId]['sum'] = bcadd($report[$budgetId]['currencies'][$currencyId]['sum'], $journal['amount']);$sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], $journal['amount']);}@@ -267,7 +268,7 @@ class BudgetController extends Controller$total = $sums[$currencyId]['sum'] ?? '0';$pct = '0';if (0 !== bccomp($sum, '0') && 0 !== bccomp($total, '9')) {- $pct = round((float) bcmul(bcdiv($sum, $total), '100')); // intentional float+ $pct = round((float)bcmul(bcdiv($sum, $total), '100')); // intentional float}$report[$budgetId]['currencies'][$currencyId]['sum_pct'] = $pct;}@@ -279,9 +280,9 @@ class BudgetController extends Controller/*** Show partial overview of budgets.*- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -304,9 +305,9 @@ class BudgetController extends Controller/*** Show budget overview for a period.*- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return mixed|string* @throws JsonException@@ -336,20 +337,20 @@ class BudgetController extends Controller$key = sprintf('%d-%d', $budget['id'], $currency['currency_id']);$dateKey = $journal['date']->format($keyFormat);$report[$key] = $report[$key] ?? [- 'id' => $budget['id'],- 'name' => sprintf('%s (%s)', $budget['name'], $currency['currency_name']),- 'sum' => '0',- 'currency_id' => $currency['currency_id'],- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_code' => $currency['currency_code'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'entries' => [],- ];+ 'id' => $budget['id'],+ 'name' => sprintf('%s (%s)', $budget['name'], $currency['currency_name']),+ 'sum' => '0',+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_code' => $currency['currency_code'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'entries' => [],+ ];$report[$key]['entries'][$dateKey] = $report[$key] ['entries'][$dateKey] ?? '0';$report[$key]['entries'][$dateKey] = bcadd($journal['amount'], $report[$key] ['entries'][$dateKey]);$report[$key]['sum'] = bcadd($report[$key] ['sum'], $journal['amount']);- $report[$key]['avg'] = bcdiv($report[$key]['sum'], (string) count($periods));+ $report[$key]['avg'] = bcdiv($report[$key]['sum'], (string)count($periods));}}}@@ -367,10 +368,10 @@ class BudgetController extends Controller}/**- * @param Collection $accounts- * @param Collection $budgets- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $budgets+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -384,7 +385,7 @@ class BudgetController extends Controller$result[] = ['description' => $journal['description'],'transaction_group_id' => $journal['transaction_group_id'],- 'amount_float' => (float) $journal['amount'], // intentional float+ 'amount_float' => (float)$journal['amount'], // intentional float'amount' => $journal['amount'],'date' => $journal['date']->isoFormat($this->monthAndDayFormat),'date_sort' => $journal['date']->format('Y-m-d'),diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.phpindex d67ef1e879..7a8c66f23f 100644--- a/app/Http/Controllers/Report/CategoryController.php+++ b/app/Http/Controllers/Report/CategoryController.php@@ -1,4 +1,5 @@<?php+/*** CategoryController.php* Copyright (c) 2019 [email protected]@@ -68,10 +69,10 @@ class CategoryController extends Controller}/**- * @param Collection $accounts- * @param Collection $categories- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end** @return Factory|View*/@@ -84,11 +85,11 @@ class CategoryController extends Controllerforeach ($accounts as $account) {$accountId = $account->id;$report[$accountId] = $report[$accountId] ?? [- 'name' => $account->name,- 'id' => $account->id,- 'iban' => $account->iban,- 'currencies' => [],- ];+ 'name' => $account->name,+ 'id' => $account->id,+ 'iban' => $account->iban,+ 'currencies' => [],+ ];}// loop expenses.@@ -100,12 +101,12 @@ class CategoryController extends Controllerforeach ($category['transaction_journals'] as $journal) {$sourceAccountId = $journal['source_account_id'];$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'categories' => [],- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'categories' => [],+ ];$report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]= $report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]@@ -167,10 +168,10 @@ class CategoryController extends Controller}/**- * @param Collection $accounts- * @param Collection $categories- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end** @return Factory|View*/@@ -184,37 +185,37 @@ class CategoryController extends Controllerforeach ($accounts as $account) {$accountId = $account->id;$report[$accountId] = $report[$accountId] ?? [- 'name' => $account->name,- 'id' => $account->id,- 'iban' => $account->iban,- 'currencies' => [],- ];+ 'name' => $account->name,+ 'id' => $account->id,+ 'iban' => $account->iban,+ 'currencies' => [],+ ];}// loop expenses.foreach ($spent as $currency) {$currencyId = $currency['currency_id'];$sums[$currencyId] = $sums[$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'spent_sum' => '0',- 'earned_sum' => '0',- 'total_sum' => '0',- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'spent_sum' => '0',+ 'earned_sum' => '0',+ 'total_sum' => '0',+ ];foreach ($currency['categories'] as $category) {foreach ($category['transaction_journals'] as $journal) {$sourceAccountId = $journal['source_account_id'];$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ ];$report[$sourceAccountId]['currencies'][$currencyId]['spent'] = bcadd($report[$sourceAccountId]['currencies'][$currencyId]['spent'],$journal['amount']@@ -233,26 +234,26 @@ class CategoryController extends Controllerforeach ($earned as $currency) {$currencyId = $currency['currency_id'];$sums[$currencyId] = $sums[$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'spent_sum' => '0',- 'earned_sum' => '0',- 'total_sum' => '0',- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'spent_sum' => '0',+ 'earned_sum' => '0',+ 'total_sum' => '0',+ ];foreach ($currency['categories'] as $category) {foreach ($category['transaction_journals'] as $journal) {$destinationAccountId = $journal['destination_account_id'];$report[$destinationAccountId]['currencies'][$currencyId] = $report[$destinationAccountId]['currencies'][$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ ];$report[$destinationAccountId]['currencies'][$currencyId]['earned'] = bcadd($report[$destinationAccountId]['currencies'][$currencyId]['earned'],$journal['amount']@@ -271,10 +272,10 @@ class CategoryController extends Controller}/**- * @param Collection $accounts- * @param Collection $categories- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -288,21 +289,21 @@ class CategoryController extends Controller$destinationId = $journal['destination_account_id'];$key = sprintf('%d-%d', $destinationId, $currency['currency_id']);$result[$key] = $result[$key] ?? [- 'transactions' => 0,- 'sum' => '0',- 'avg' => '0',- 'avg_float' => 0,- 'destination_account_name' => $journal['destination_account_name'],- 'destination_account_id' => $journal['destination_account_id'],- 'currency_id' => $currency['currency_id'],- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- ];+ 'transactions' => 0,+ 'sum' => '0',+ 'avg' => '0',+ 'avg_float' => 0,+ 'destination_account_name' => $journal['destination_account_name'],+ 'destination_account_id' => $journal['destination_account_id'],+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];$result[$key]['transactions']++;$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);- $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);- $result[$key]['avg_float'] = (float) $result[$key]['avg']; // intentional float+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);+ $result[$key]['avg_float'] = (float)$result[$key]['avg']; // intentional float}}}@@ -323,10 +324,10 @@ class CategoryController extends Controller}/**- * @param Collection $accounts- * @param Collection $categories- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -340,21 +341,21 @@ class CategoryController extends Controller$sourceId = $journal['source_account_id'];$key = sprintf('%d-%d', $sourceId, $currency['currency_id']);$result[$key] = $result[$key] ?? [- 'transactions' => 0,- 'sum' => '0',- 'avg' => '0',- 'avg_float' => 0,- 'source_account_name' => $journal['source_account_name'],- 'source_account_id' => $journal['source_account_id'],- 'currency_id' => $currency['currency_id'],- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- ];+ 'transactions' => 0,+ 'sum' => '0',+ 'avg' => '0',+ 'avg_float' => 0,+ 'source_account_name' => $journal['source_account_name'],+ 'source_account_id' => $journal['source_account_id'],+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];$result[$key]['transactions']++;$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);- $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);- $result[$key]['avg_float'] = (float) $result[$key]['avg'];+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);+ $result[$key]['avg_float'] = (float)$result[$key]['avg'];}}}@@ -375,10 +376,10 @@ class CategoryController extends Controller}/**- * @param Collection $accounts- * @param Collection $categories- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end** @return Factory|View*/@@ -392,22 +393,22 @@ class CategoryController extends Controllerforeach ($categories as $category) {$categoryId = $category->id;$report[$categoryId] = $report[$categoryId] ?? [- 'name' => $category->name,- 'id' => $category->id,- 'currencies' => [],- ];+ 'name' => $category->name,+ 'id' => $category->id,+ 'currencies' => [],+ ];}foreach ($spent as $currency) {$currencyId = $currency['currency_id'];$sums[$currencyId] = $sums[$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'earned_sum' => '0',- 'spent_sum' => '0',- 'total_sum' => '0',- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'earned_sum' => '0',+ 'spent_sum' => '0',+ 'total_sum' => '0',+ ];/** @var array $category */foreach ($currency['categories'] as $category) {$categoryId = $category['id'];@@ -415,14 +416,14 @@ class CategoryController extends Controllerforeach ($category['transaction_journals'] as $journal) {// add currency info to report array:$report[$categoryId]['currencies'][$currencyId] = $report[$categoryId]['currencies'][$currencyId] ?? [- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- ];+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];$report[$categoryId]['currencies'][$currencyId]['spent'] = bcadd($report[$categoryId]['currencies'][$currencyId]['spent'],$journal['amount']@@ -441,14 +442,14 @@ class CategoryController extends Controllerforeach ($earned as $currency) {$currencyId = $currency['currency_id'];$sums[$currencyId] = $sums[$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'earned_sum' => '0',- 'spent_sum' => '0',- 'total_sum' => '0',- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'earned_sum' => '0',+ 'spent_sum' => '0',+ 'total_sum' => '0',+ ];/** @var array $category */foreach ($currency['categories'] as $category) {$categoryId = $category['id'];@@ -456,14 +457,14 @@ class CategoryController extends Controllerforeach ($category['transaction_journals'] as $journal) {// add currency info to report array:$report[$categoryId]['currencies'][$currencyId] = $report[$categoryId]['currencies'][$currencyId] ?? [- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- ];+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];$report[$categoryId]['currencies'][$currencyId]['earned'] = bcadd($report[$categoryId]['currencies'][$currencyId]['earned'],$journal['amount']@@ -485,9 +486,9 @@ class CategoryController extends Controller/*** Show overview of expenses in category.*- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return mixed|string* @throws JsonException@@ -523,17 +524,17 @@ class CategoryController extends Controllerforeach ($currencyRow['categories'] as $categoryId => $categoryRow) {$key = sprintf('%d-%d', $currencyId, $categoryId);$data[$key] = $data[$key] ?? [- 'id' => $categoryRow['id'],- 'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']),- 'currency_id' => $currencyRow['currency_id'],- 'currency_symbol' => $currencyRow['currency_symbol'],- 'currency_name' => $currencyRow['currency_name'],- 'currency_code' => $currencyRow['currency_code'],- 'currency_decimal_places' => $currencyRow['currency_decimal_places'],- 'sum' => '0',- 'entries' => [],-- ];+ 'id' => $categoryRow['id'],+ 'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']),+ 'currency_id' => $currencyRow['currency_id'],+ 'currency_symbol' => $currencyRow['currency_symbol'],+ 'currency_name' => $currencyRow['currency_name'],+ 'currency_code' => $currencyRow['currency_code'],+ 'currency_decimal_places' => $currencyRow['currency_decimal_places'],+ 'sum' => '0',+ 'entries' => [],++ ];foreach ($categoryRow['transaction_journals'] as $journal) {$date = $journal['date']->format($format);$data[$key]['entries'][$date] = $data[$key]['entries'][$date] ?? '0';@@ -565,10 +566,10 @@ class CategoryController extends Controller/*** Show overview of income in category.*- * @param Collection $accounts+ * @param Collection $accounts*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return string* @throws JsonException@@ -604,17 +605,17 @@ class CategoryController extends Controllerforeach ($currencyRow['categories'] as $categoryId => $categoryRow) {$key = sprintf('%d-%d', $currencyId, $categoryId);$data[$key] = $data[$key] ?? [- 'id' => $categoryRow['id'],- 'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']),- 'currency_id' => $currencyRow['currency_id'],- 'currency_symbol' => $currencyRow['currency_symbol'],- 'currency_name' => $currencyRow['currency_name'],- 'currency_code' => $currencyRow['currency_code'],- 'currency_decimal_places' => $currencyRow['currency_decimal_places'],- 'sum' => '0',- 'entries' => [],-- ];+ 'id' => $categoryRow['id'],+ 'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']),+ 'currency_id' => $currencyRow['currency_id'],+ 'currency_symbol' => $currencyRow['currency_symbol'],+ 'currency_name' => $currencyRow['currency_name'],+ 'currency_code' => $currencyRow['currency_code'],+ 'currency_decimal_places' => $currencyRow['currency_decimal_places'],+ 'sum' => '0',+ 'entries' => [],++ ];foreach ($categoryRow['transaction_journals'] as $journal) {$date = $journal['date']->format($format);$data[$key]['entries'][$date] = $data[$key]['entries'][$date] ?? '0';@@ -645,9 +646,9 @@ class CategoryController extends Controller/*** Show overview of category transactions on the default report.*- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -673,7 +674,7 @@ class CategoryController extends Controllertry {- $result = (string) view('reports.partials.categories', compact('report'))->render();+ $result = (string)view('reports.partials.categories', compact('report'))->render();$cache->store($result);} catch (Throwable $e) {Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));@@ -685,10 +686,10 @@ class CategoryController extends Controller}/**- * @param Collection $accounts- * @param Collection $categories- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -702,7 +703,7 @@ class CategoryController extends Controller$result[] = ['description' => $journal['description'],'transaction_group_id' => $journal['transaction_group_id'],- 'amount_float' => (float) $journal['amount'],+ 'amount_float' => (float)$journal['amount'],'amount' => $journal['amount'],'date' => $journal['date']->isoFormat($this->monthAndDayFormat),'date_sort' => $journal['date']->format('Y-m-d'),@@ -735,10 +736,10 @@ class CategoryController extends Controller}/**- * @param Collection $accounts- * @param Collection $categories- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -752,7 +753,7 @@ class CategoryController extends Controller$result[] = ['description' => $journal['description'],'transaction_group_id' => $journal['transaction_group_id'],- 'amount_float' => (float) $journal['amount'],+ 'amount_float' => (float)$journal['amount'],'amount' => $journal['amount'],'date' => $journal['date']->isoFormat($this->monthAndDayFormat),'date_sort' => $journal['date']->format('Y-m-d'),diff --git a/app/Http/Controllers/Report/DoubleController.php b/app/Http/Controllers/Report/DoubleController.phpindex 27f72a6b03..50605fb754 100644--- a/app/Http/Controllers/Report/DoubleController.php+++ b/app/Http/Controllers/Report/DoubleController.php@@ -1,4 +1,5 @@<?php+/*** DoubleController.php* Copyright (c) 2019 [email protected]@@ -70,10 +71,10 @@ class DoubleController extends Controller}/**- * @param Collection $accounts- * @param Collection $doubles- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $doubles+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -88,21 +89,21 @@ class DoubleController extends Controller$sourceId = $journal['source_account_id'];$key = sprintf('%d-%d', $sourceId, $currency['currency_id']);$result[$key] = $result[$key] ?? [- 'transactions' => 0,- 'sum' => '0',- 'avg' => '0',- 'avg_float' => 0,- 'source_account_name' => $journal['source_account_name'],- 'source_account_id' => $journal['source_account_id'],- 'currency_id' => $currency['currency_id'],- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- ];+ 'transactions' => 0,+ 'sum' => '0',+ 'avg' => '0',+ 'avg_float' => 0,+ 'source_account_name' => $journal['source_account_name'],+ 'source_account_id' => $journal['source_account_id'],+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];$result[$key]['transactions']++;$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);- $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);- $result[$key]['avg_float'] = (float) $result[$key]['avg'];+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);+ $result[$key]['avg_float'] = (float)$result[$key]['avg'];}}// sort by amount_float@@ -122,10 +123,10 @@ class DoubleController extends Controller}/**- * @param Collection $accounts- * @param Collection $doubles- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $doubles+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -140,21 +141,21 @@ class DoubleController extends Controller$destinationId = $journal['destination_account_id'];$key = sprintf('%d-%d', $destinationId, $currency['currency_id']);$result[$key] = $result[$key] ?? [- 'transactions' => 0,- 'sum' => '0',- 'avg' => '0',- 'avg_float' => 0,- 'destination_account_name' => $journal['destination_account_name'],- 'destination_account_id' => $journal['destination_account_id'],- 'currency_id' => $currency['currency_id'],- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- ];+ 'transactions' => 0,+ 'sum' => '0',+ 'avg' => '0',+ 'avg_float' => 0,+ 'destination_account_name' => $journal['destination_account_name'],+ 'destination_account_id' => $journal['destination_account_id'],+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];$result[$key]['transactions']++;$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);- $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);- $result[$key]['avg_float'] = (float) $result[$key]['avg'];+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);+ $result[$key]['avg_float'] = (float)$result[$key]['avg'];}}// sort by amount_float@@ -174,10 +175,10 @@ class DoubleController extends Controller}/**- * @param Collection $accounts- * @param Collection $double- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $double+ * @param Carbon $start+ * @param Carbon $end** @return Factory|View*/@@ -197,15 +198,15 @@ class DoubleController extends Controller$currencyId = $currency['currency_id'];$sums[$currencyId] = $sums[$currencyId] ?? [- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- 'currency_id' => $currency['currency_id'],- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_code' => $currency['currency_code'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- ];+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_code' => $currency['currency_code'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];/** @var array $journal */foreach ($currency['transaction_journals'] as $journal) {@@ -215,19 +216,19 @@ class DoubleController extends Controller$genericName = $this->getCounterpartName($withCounterpart, $destId, $destName, $destIban);$objectName = sprintf('%s (%s)', $genericName, $currency['currency_name']);$report[$objectName] = $report[$objectName] ?? [- 'dest_name' => '',- 'dest_iban' => '',- 'source_name' => '',- 'source_iban' => '',- 'currency_id' => $currency['currency_id'],- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_code' => $currency['currency_code'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- ];+ 'dest_name' => '',+ 'dest_iban' => '',+ 'source_name' => '',+ 'source_iban' => '',+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_code' => $currency['currency_code'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ ];// set name$report[$objectName]['dest_name'] = $destName;$report[$objectName]['dest_iban'] = $destIban;@@ -245,15 +246,15 @@ class DoubleController extends Controller$currencyId = $currency['currency_id'];$sums[$currencyId] = $sums[$currencyId] ?? [- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- 'currency_id' => $currency['currency_id'],- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_code' => $currency['currency_code'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- ];+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_code' => $currency['currency_code'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];/** @var array $journal */foreach ($currency['transaction_journals'] as $journal) {@@ -263,19 +264,19 @@ class DoubleController extends Controller$genericName = $this->getCounterpartName($withCounterpart, $sourceId, $sourceName, $sourceIban);$objectName = sprintf('%s (%s)', $genericName, $currency['currency_name']);$report[$objectName] = $report[$objectName] ?? [- 'dest_name' => '',- 'dest_iban' => '',- 'source_name' => '',- 'source_iban' => '',- 'currency_id' => $currency['currency_id'],- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_code' => $currency['currency_code'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- ];+ 'dest_name' => '',+ 'dest_iban' => '',+ 'source_name' => '',+ 'source_iban' => '',+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_code' => $currency['currency_code'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ ];// set name$report[$objectName]['source_name'] = $sourceName;@@ -295,10 +296,10 @@ class DoubleController extends Controller/*** TODO this method is duplicated.*- * @param Collection $accounts- * @param int $id- * @param string $name- * @param string|null $iban+ * @param Collection $accounts+ * @param int $id+ * @param string $name+ * @param string|null $iban** @return string*/@@ -318,10 +319,10 @@ class DoubleController extends Controller}/**- * @param Collection $accounts- * @param Collection $double- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $double+ * @param Carbon $start+ * @param Carbon $end** @return Factory|View*/@@ -341,31 +342,31 @@ class DoubleController extends Controller$currencyId = $currency['currency_id'];$sums[$currencyId] = $sums[$currencyId] ?? [- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_code' => $currency['currency_code'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];++ /** @var array $journal */+ foreach ($currency['transaction_journals'] as $journal) {+ $objectName = sprintf('%s (%s)', $journal['source_account_name'], $currency['currency_name']);+ $report[$objectName] = $report[$objectName] ?? [+ 'account_id' => $journal['source_account_id'],+ 'account_name' => $objectName,'currency_id' => $currency['currency_id'],'currency_name' => $currency['currency_name'],'currency_symbol' => $currency['currency_symbol'],'currency_code' => $currency['currency_code'],'currency_decimal_places' => $currency['currency_decimal_places'],+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',];-- /** @var array $journal */- foreach ($currency['transaction_journals'] as $journal) {- $objectName = sprintf('%s (%s)', $journal['source_account_name'], $currency['currency_name']);- $report[$objectName] = $report[$objectName] ?? [- 'account_id' => $journal['source_account_id'],- 'account_name' => $objectName,- 'currency_id' => $currency['currency_id'],- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_code' => $currency['currency_code'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- ];// set name// add amounts:$report[$objectName]['spent'] = bcadd($report[$objectName]['spent'], $journal['amount']);@@ -380,32 +381,32 @@ class DoubleController extends Controller$currencyId = $currency['currency_id'];$sums[$currencyId] = $sums[$currencyId] ?? [- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_code' => $currency['currency_code'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];++ /** @var array $journal */+ foreach ($currency['transaction_journals'] as $journal) {+ $objectName = sprintf('%s (%s)', $journal['destination_account_name'], $currency['currency_name']);+ $report[$objectName] = $report[$objectName] ?? [+ 'account_id' => $journal['destination_account_id'],+ 'account_name' => $objectName,'currency_id' => $currency['currency_id'],'currency_name' => $currency['currency_name'],'currency_symbol' => $currency['currency_symbol'],'currency_code' => $currency['currency_code'],'currency_decimal_places' => $currency['currency_decimal_places'],+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',];- /** @var array $journal */- foreach ($currency['transaction_journals'] as $journal) {- $objectName = sprintf('%s (%s)', $journal['destination_account_name'], $currency['currency_name']);- $report[$objectName] = $report[$objectName] ?? [- 'account_id' => $journal['destination_account_id'],- 'account_name' => $objectName,- 'currency_id' => $currency['currency_id'],- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_code' => $currency['currency_code'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- ];-// add amounts:$report[$objectName]['earned'] = bcadd($report[$objectName]['earned'], $journal['amount']);$report[$objectName]['sum'] = bcadd($report[$objectName]['sum'], $journal['amount']);@@ -418,10 +419,10 @@ class DoubleController extends Controller}/**- * @param Collection $accounts- * @param Collection $doubles- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $doubles+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -436,7 +437,7 @@ class DoubleController extends Controller$result[] = ['description' => $journal['description'],'transaction_group_id' => $journal['transaction_group_id'],- 'amount_float' => (float) $journal['amount'],+ 'amount_float' => (float)$journal['amount'],'amount' => $journal['amount'],'date' => $journal['date']->isoFormat($this->monthAndDayFormat),'date_sort' => $journal['date']->format('Y-m-d'),@@ -468,10 +469,10 @@ class DoubleController extends Controller}/**- * @param Collection $accounts- * @param Collection $doubles- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $doubles+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -486,7 +487,7 @@ class DoubleController extends Controller$result[] = ['description' => $journal['description'],'transaction_group_id' => $journal['transaction_group_id'],- 'amount_float' => (float) $journal['amount'],+ 'amount_float' => (float)$journal['amount'],'amount' => $journal['amount'],'date' => $journal['date']->isoFormat($this->monthAndDayFormat),'date_sort' => $journal['date']->format('Y-m-d'),diff --git a/app/Http/Controllers/Report/OperationsController.php b/app/Http/Controllers/Report/OperationsController.phpindex 722e4820dc..6569fddad0 100644--- a/app/Http/Controllers/Report/OperationsController.php+++ b/app/Http/Controllers/Report/OperationsController.php@@ -1,4 +1,5 @@<?php+/*** OperationsController.php* Copyright (c) 2019 [email protected]@@ -28,7 +29,6 @@ use FireflyIII\Http\Controllers\Controller;use FireflyIII\Repositories\Account\AccountTaskerInterface;use FireflyIII\Support\CacheProperties;use Illuminate\Support\Collection;-use JsonException;use Log;use Throwable;@@ -62,9 +62,9 @@ class OperationsController extends Controller/*** View of income and expense.*- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return mixed|string*/@@ -97,9 +97,9 @@ class OperationsController extends Controller/*** View of income.*- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -132,9 +132,9 @@ class OperationsController extends Controller/*** Overview of income and expense.*- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return mixed|string*/@@ -159,15 +159,15 @@ class OperationsController extends Controllerforeach ($keys as $currencyId) {$currencyInfo = $incomes['sums'][$currencyId] ?? $expenses['sums'][$currencyId];$sums[$currencyId] = $sums[$currencyId] ?? [- 'currency_id' => $currencyId,- 'currency_name' => $currencyInfo['currency_name'],- 'currency_code' => $currencyInfo['currency_code'],- 'currency_symbol' => $currencyInfo['currency_symbol'],- 'currency_decimal_places' => $currencyInfo['currency_decimal_places'],- 'in' => $incomes['sums'][$currencyId]['sum'] ?? '0',- 'out' => $expenses['sums'][$currencyId]['sum'] ?? '0',- 'sum' => '0',- ];+ 'currency_id' => $currencyId,+ 'currency_name' => $currencyInfo['currency_name'],+ 'currency_code' => $currencyInfo['currency_code'],+ 'currency_symbol' => $currencyInfo['currency_symbol'],+ 'currency_decimal_places' => $currencyInfo['currency_decimal_places'],+ 'in' => $incomes['sums'][$currencyId]['sum'] ?? '0',+ 'out' => $expenses['sums'][$currencyId]['sum'] ?? '0',+ 'sum' => '0',+ ];$sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['in'], $sums[$currencyId]['out']);}diff --git a/app/Http/Controllers/Report/TagController.php b/app/Http/Controllers/Report/TagController.phpindex 5cb8b7f3fe..557cb75f84 100644--- a/app/Http/Controllers/Report/TagController.php+++ b/app/Http/Controllers/Report/TagController.php@@ -61,10 +61,10 @@ class TagController extends Controller}/**- * @param Collection $accounts- * @param Collection $tags- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $tags+ * @param Carbon $start+ * @param Carbon $end** @return Factory|View*/@@ -77,11 +77,11 @@ class TagController extends Controllerforeach ($accounts as $account) {$accountId = $account->id;$report[$accountId] = $report[$accountId] ?? [- 'name' => $account->name,- 'id' => $account->id,- 'iban' => $account->iban,- 'currencies' => [],- ];+ 'name' => $account->name,+ 'id' => $account->id,+ 'iban' => $account->iban,+ 'currencies' => [],+ ];}// loop expenses.@@ -93,12 +93,12 @@ class TagController extends Controllerforeach ($tag['transaction_journals'] as $journal) {$sourceAccountId = $journal['source_account_id'];$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'tags' => [],- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'tags' => [],+ ];$report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]= $report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]@@ -160,10 +160,10 @@ class TagController extends Controller}/**- * @param Collection $accounts- * @param Collection $tags- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $tags+ * @param Carbon $start+ * @param Carbon $end** @return Factory|View*/@@ -177,37 +177,37 @@ class TagController extends Controllerforeach ($accounts as $account) {$accountId = $account->id;$report[$accountId] = $report[$accountId] ?? [- 'name' => $account->name,- 'id' => $account->id,- 'iban' => $account->iban,- 'currencies' => [],- ];+ 'name' => $account->name,+ 'id' => $account->id,+ 'iban' => $account->iban,+ 'currencies' => [],+ ];}// loop expenses.foreach ($spent as $currency) {$currencyId = $currency['currency_id'];$sums[$currencyId] = $sums[$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'spent_sum' => '0',- 'earned_sum' => '0',- 'total_sum' => '0',- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'spent_sum' => '0',+ 'earned_sum' => '0',+ 'total_sum' => '0',+ ];foreach ($currency['tags'] as $tag) {foreach ($tag['transaction_journals'] as $journal) {$sourceAccountId = $journal['source_account_id'];$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ ];$report[$sourceAccountId]['currencies'][$currencyId]['spent'] = bcadd($report[$sourceAccountId]['currencies'][$currencyId]['spent'],$journal['amount']@@ -226,26 +226,26 @@ class TagController extends Controllerforeach ($earned as $currency) {$currencyId = $currency['currency_id'];$sums[$currencyId] = $sums[$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'spent_sum' => '0',- 'earned_sum' => '0',- 'total_sum' => '0',- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'spent_sum' => '0',+ 'earned_sum' => '0',+ 'total_sum' => '0',+ ];foreach ($currency['tags'] as $tag) {foreach ($tag['transaction_journals'] as $journal) {$destinationAccountId = $journal['destination_account_id'];$report[$destinationAccountId]['currencies'][$currencyId] = $report[$destinationAccountId]['currencies'][$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ ];$report[$destinationAccountId]['currencies'][$currencyId]['earned'] = bcadd($report[$destinationAccountId]['currencies'][$currencyId]['earned'],$journal['amount']@@ -264,10 +264,10 @@ class TagController extends Controller}/**- * @param Collection $accounts- * @param Collection $tags- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $tags+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -281,21 +281,21 @@ class TagController extends Controller$destinationId = $journal['destination_account_id'];$key = sprintf('%d-%d', $destinationId, $currency['currency_id']);$result[$key] = $result[$key] ?? [- 'transactions' => 0,- 'sum' => '0',- 'avg' => '0',- 'avg_float' => 0,- 'destination_account_name' => $journal['destination_account_name'],- 'destination_account_id' => $journal['destination_account_id'],- 'currency_id' => $currency['currency_id'],- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- ];+ 'transactions' => 0,+ 'sum' => '0',+ 'avg' => '0',+ 'avg_float' => 0,+ 'destination_account_name' => $journal['destination_account_name'],+ 'destination_account_id' => $journal['destination_account_id'],+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];$result[$key]['transactions']++;$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);- $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);- $result[$key]['avg_float'] = (float) $result[$key]['avg'];+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);+ $result[$key]['avg_float'] = (float)$result[$key]['avg'];}}}@@ -316,10 +316,10 @@ class TagController extends Controller}/**- * @param Collection $accounts- * @param Collection $tags- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $tags+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -333,21 +333,21 @@ class TagController extends Controller$sourceId = $journal['source_account_id'];$key = sprintf('%d-%d', $sourceId, $currency['currency_id']);$result[$key] = $result[$key] ?? [- 'transactions' => 0,- 'sum' => '0',- 'avg' => '0',- 'avg_float' => 0,- 'source_account_name' => $journal['source_account_name'],- 'source_account_id' => $journal['source_account_id'],- 'currency_id' => $currency['currency_id'],- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- ];+ 'transactions' => 0,+ 'sum' => '0',+ 'avg' => '0',+ 'avg_float' => 0,+ 'source_account_name' => $journal['source_account_name'],+ 'source_account_id' => $journal['source_account_id'],+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];$result[$key]['transactions']++;$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);- $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);- $result[$key]['avg_float'] = (float) $result[$key]['avg'];+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);+ $result[$key]['avg_float'] = (float)$result[$key]['avg'];}}}@@ -368,10 +368,10 @@ class TagController extends Controller}/**- * @param Collection $accounts- * @param Collection $tags- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $tags+ * @param Carbon $start+ * @param Carbon $end** @return Factory|View*/@@ -385,22 +385,22 @@ class TagController extends Controllerforeach ($tags as $tag) {$tagId = $tag->id;$report[$tagId] = $report[$tagId] ?? [- 'name' => $tag->tag,- 'id' => $tag->id,- 'currencies' => [],- ];+ 'name' => $tag->tag,+ 'id' => $tag->id,+ 'currencies' => [],+ ];}foreach ($spent as $currency) {$currencyId = $currency['currency_id'];$sums[$currencyId] = $sums[$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'earned_sum' => '0',- 'spent_sum' => '0',- 'total_sum' => '0',- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'earned_sum' => '0',+ 'spent_sum' => '0',+ 'total_sum' => '0',+ ];/** @var array $tag */foreach ($currency['tags'] as $tag) {$tagId = $tag['id'];@@ -408,14 +408,14 @@ class TagController extends Controllerforeach ($tag['transaction_journals'] as $journal) {// add currency info to report array:$report[$tagId]['currencies'][$currencyId] = $report[$tagId]['currencies'][$currencyId] ?? [- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- ];+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];$report[$tagId]['currencies'][$currencyId]['spent'] = bcadd($report[$tagId]['currencies'][$currencyId]['spent'],$journal['amount']@@ -434,14 +434,14 @@ class TagController extends Controllerforeach ($earned as $currency) {$currencyId = $currency['currency_id'];$sums[$currencyId] = $sums[$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- 'earned_sum' => '0',- 'spent_sum' => '0',- 'total_sum' => '0',- ];+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'earned_sum' => '0',+ 'spent_sum' => '0',+ 'total_sum' => '0',+ ];/** @var array $tag */foreach ($currency['tags'] as $tag) {$tagId = $tag['id'];@@ -449,14 +449,14 @@ class TagController extends Controllerforeach ($tag['transaction_journals'] as $journal) {// add currency info to report array:$report[$tagId]['currencies'][$currencyId] = $report[$tagId]['currencies'][$currencyId] ?? [- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- 'currency_id' => $currency['currency_id'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_name' => $currency['currency_name'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- ];+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];$report[$tagId]['currencies'][$currencyId]['earned'] = bcadd($report[$tagId]['currencies'][$currencyId]['earned'],$journal['amount']@@ -476,10 +476,10 @@ class TagController extends Controller}/**- * @param Collection $accounts- * @param Collection $tags- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $tags+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -493,7 +493,7 @@ class TagController extends Controller$result[] = ['description' => $journal['description'],'transaction_group_id' => $journal['transaction_group_id'],- 'amount_float' => (float) $journal['amount'],+ 'amount_float' => (float)$journal['amount'],'amount' => $journal['amount'],'date' => $journal['date']->isoFormat($this->monthAndDayFormat),'date_sort' => $journal['date']->format('Y-m-d'),@@ -526,10 +526,10 @@ class TagController extends Controller}/**- * @param Collection $accounts- * @param Collection $tags- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $tags+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -543,7 +543,7 @@ class TagController extends Controller$result[] = ['description' => $journal['description'],'transaction_group_id' => $journal['transaction_group_id'],- 'amount_float' => (float) $journal['amount'], // intentional float.+ 'amount_float' => (float)$journal['amount'], // intentional float.'amount' => $journal['amount'],'date' => $journal['date']->isoFormat($this->monthAndDayFormat),'date_sort' => $journal['date']->format('Y-m-d'),diff --git a/app/Http/Controllers/Rule/CreateController.php b/app/Http/Controllers/Rule/CreateController.phpindex b9cf7191bd..db1bbe7e0d 100644--- a/app/Http/Controllers/Rule/CreateController.php+++ b/app/Http/Controllers/Rule/CreateController.php@@ -26,7 +26,6 @@ namespace FireflyIII\Http\Controllers\Rule;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Http\Requests\RuleFormRequest;use FireflyIII\Models\Bill;-use FireflyIII\Models\Rule;use FireflyIII\Models\RuleGroup;use FireflyIII\Models\TransactionJournal;use FireflyIII\Repositories\Rule\RuleRepositoryInterface;@@ -61,7 +60,7 @@ class CreateController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.rules'));+ app('view')->share('title', (string)trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->ruleRepos = app(RuleRepositoryInterface::class);@@ -74,8 +73,8 @@ class CreateController extends Controller/*** Create a new rule. It will be stored under the given $ruleGroup.*- * @param Request $request- * @param RuleGroup|null $ruleGroup+ * @param Request $request+ * @param RuleGroup|null $ruleGroup** @return Factory|View*/@@ -89,7 +88,7 @@ class CreateController extends Controller$oldActions = [];// build triggers from query, if present.- $query = (string) $request->get('from_query');+ $query = (string)$request->get('from_query');if ('' !== $query) {$search = app(SearchInterface::class);$search->parseQuery($query);@@ -113,9 +112,9 @@ class CreateController extends Controller$subTitleIcon = 'fa-clone';// title depends on whether or not there is a rule group:- $subTitle = (string) trans('firefly.make_new_rule_no_group');+ $subTitle = (string)trans('firefly.make_new_rule_no_group');if (null !== $ruleGroup) {- $subTitle = (string) trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);+ $subTitle = (string)trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);}// flash old data@@ -136,20 +135,20 @@ class CreateController extends Controller/*** Create a new rule. It will be stored under the given $ruleGroup.*- * @param Request $request- * @param Bill $bill+ * @param Request $request+ * @param Bill $bill** @return Factory|View*/public function createFromBill(Request $request, Bill $bill){- $request->session()->flash('info', (string) trans('firefly.instructions_rule_from_bill', ['name' => e($bill->name)]));+ $request->session()->flash('info', (string)trans('firefly.instructions_rule_from_bill', ['name' => e($bill->name)]));$this->createDefaultRuleGroup();$preFilled = ['strict' => true,- 'title' => (string) trans('firefly.new_rule_for_bill_title', ['name' => $bill->name]),- 'description' => (string) trans('firefly.new_rule_for_bill_description', ['name' => $bill->name]),+ 'title' => (string)trans('firefly.new_rule_for_bill_title', ['name' => $bill->name]),+ 'description' => (string)trans('firefly.new_rule_for_bill_description', ['name' => $bill->name]),];// make triggers and actions from the bill itself.@@ -169,7 +168,7 @@ class CreateController extends Controller$subTitleIcon = 'fa-clone';// title depends on whether or not there is a rule group:- $subTitle = (string) trans('firefly.make_new_rule_no_group');+ $subTitle = (string)trans('firefly.make_new_rule_no_group');// flash old data$request->session()->flash('preFilled', $preFilled);@@ -187,17 +186,17 @@ class CreateController extends Controller}/**- * @param Request $request- * @param TransactionJournal $journal+ * @param Request $request+ * @param TransactionJournal $journal** @return Factory|\Illuminate\Contracts\View\View*/public function createFromJournal(Request $request, TransactionJournal $journal){- $request->session()->flash('info', (string) trans('firefly.instructions_rule_from_journal', ['name' => e($journal->description)]));+ $request->session()->flash('info', (string)trans('firefly.instructions_rule_from_journal', ['name' => e($journal->description)]));$subTitleIcon = 'fa-clone';- $subTitle = (string) trans('firefly.make_new_rule_no_group');+ $subTitle = (string)trans('firefly.make_new_rule_no_group');// get triggers and actions for journal.$oldTriggers = $this->getTriggersForJournal($journal);@@ -208,8 +207,8 @@ class CreateController extends Controller// collect pre-filled information:$preFilled = ['strict' => true,- 'title' => (string) trans('firefly.new_rule_for_journal_title', ['description' => $journal->description]),- 'description' => (string) trans('firefly.new_rule_for_journal_description', ['description' => $journal->description]),+ 'title' => (string)trans('firefly.new_rule_for_journal_title', ['description' => $journal->description]),+ 'description' => (string)trans('firefly.new_rule_for_journal_description', ['description' => $journal->description]),];// restore actions and triggers from old input:@@ -237,12 +236,12 @@ class CreateController extends Controller}/**- * @param Request $request+ * @param Request $request* @return JsonResponse*/public function duplicate(Request $request): JsonResponse{- $ruleId = (int) $request->get('id');+ $ruleId = (int)$request->get('id');$rule = $this->ruleRepos->find($ruleId);if (null !== $rule) {$this->ruleRepos->duplicate($rule);@@ -254,7 +253,7 @@ class CreateController extends Controller/*** Store the new rule.*- * @param RuleFormRequest $request+ * @param RuleFormRequest $request** @return RedirectResponse|Redirector*@@ -264,22 +263,22 @@ class CreateController extends Controller$data = $request->getRuleData();$rule = $this->ruleRepos->store($data);- session()->flash('success', (string) trans('firefly.stored_new_rule', ['title' => $rule->title]));+ session()->flash('success', (string)trans('firefly.stored_new_rule', ['title' => $rule->title]));app('preferences')->mark();// redirect to show bill.- if ('true' === $request->get('return_to_bill') && (int) $request->get('bill_id') > 0) {- return redirect(route('bills.show', [(int) $request->get('bill_id')]));+ if ('true' === $request->get('return_to_bill') && (int)$request->get('bill_id') > 0) {+ return redirect(route('bills.show', [(int)$request->get('bill_id')]));}// redirect to new bill creation.- if ((int) $request->get('bill_id') > 0) {+ if ((int)$request->get('bill_id') > 0) {return redirect($this->getPreviousUrl('bills.create.url'));}$redirect = redirect($this->getPreviousUrl('rules.create.url'));- if (1 === (int) $request->get('create_another')) {+ if (1 === (int)$request->get('create_another')) {session()->put('rules.create.fromStore', true);$redirect = redirect(route('rules.create', [$data['rule_group_id']]))->withInput();}diff --git a/app/Http/Controllers/Rule/DeleteController.php b/app/Http/Controllers/Rule/DeleteController.phpindex 2a74e7555f..36c4cba793 100644--- a/app/Http/Controllers/Rule/DeleteController.php+++ b/app/Http/Controllers/Rule/DeleteController.php@@ -49,7 +49,7 @@ class DeleteController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.rules'));+ app('view')->share('title', (string)trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->ruleRepos = app(RuleRepositoryInterface::class);@@ -62,13 +62,13 @@ class DeleteController extends Controller/*** Delete a given rule.*- * @param Rule $rule+ * @param Rule $rule** @return Factory|View*/public function delete(Rule $rule){- $subTitle = (string) trans('firefly.delete_rule', ['title' => $rule->title]);+ $subTitle = (string)trans('firefly.delete_rule', ['title' => $rule->title]);// put previous url in session$this->rememberPreviousUrl('rules.delete.url');@@ -79,7 +79,7 @@ class DeleteController extends Controller/*** Actually destroy the given rule.*- * @param Rule $rule+ * @param Rule $rule** @return RedirectResponse*/@@ -88,7 +88,7 @@ class DeleteController extends Controller$title = $rule->title;$this->ruleRepos->destroy($rule);- session()->flash('success', (string) trans('firefly.deleted_rule', ['title' => $title]));+ session()->flash('success', (string)trans('firefly.deleted_rule', ['title' => $title]));app('preferences')->mark();return redirect($this->getPreviousUrl('rules.delete.url'));diff --git a/app/Http/Controllers/Rule/EditController.php b/app/Http/Controllers/Rule/EditController.phpindex 29639db9ae..1412c86db1 100644--- a/app/Http/Controllers/Rule/EditController.php+++ b/app/Http/Controllers/Rule/EditController.php@@ -61,7 +61,7 @@ class EditController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.rules'));+ app('view')->share('title', (string)trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->ruleRepos = app(RuleRepositoryInterface::class);@@ -74,8 +74,8 @@ class EditController extends Controller/*** Edit a rule.*- * @param Request $request- * @param Rule $rule+ * @param Request $request+ * @param Rule $rule** @return Factory|View*/@@ -87,7 +87,7 @@ class EditController extends Controller$oldTriggers = [];// build triggers from query, if present.- $query = (string) $request->get('from_query');+ $query = (string)$request->get('from_query');if ('' !== $query) {$search = app(SearchInterface::class);$search->parseQuery($query);@@ -117,15 +117,15 @@ class EditController extends Controller$hasOldInput = null !== $request->old('_token');$preFilled = [- 'active' => $hasOldInput ? (bool) $request->old('active') : $rule->active,- 'stop_processing' => $hasOldInput ? (bool) $request->old('stop_processing') : $rule->stop_processing,- 'strict' => $hasOldInput ? (bool) $request->old('strict') : $rule->strict,+ 'active' => $hasOldInput ? (bool)$request->old('active') : $rule->active,+ 'stop_processing' => $hasOldInput ? (bool)$request->old('stop_processing') : $rule->stop_processing,+ 'strict' => $hasOldInput ? (bool)$request->old('strict') : $rule->strict,];// get rule trigger for update / store-journal:$primaryTrigger = $this->ruleRepos->getPrimaryTrigger($rule);- $subTitle = (string) trans('firefly.edit_rule', ['title' => $rule->title]);+ $subTitle = (string)trans('firefly.edit_rule', ['title' => $rule->title]);// put previous url in session if not redirect from store (not "return_to_edit").if (true !== session('rules.edit.fromUpdate')) {@@ -139,7 +139,7 @@ class EditController extends Controller}/**- * @param array $submittedOperators+ * @param array $submittedOperators** @return array*/@@ -151,7 +151,7 @@ class EditController extends Controller$triggers = [];foreach ($operators as $key => $operator) {if ('user_action' !== $key && false === $operator['alias']) {- $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));+ $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));}}asort($triggers);@@ -183,8 +183,8 @@ class EditController extends Controller/*** Update the rule.*- * @param RuleFormRequest $request- * @param Rule $rule+ * @param RuleFormRequest $request+ * @param Rule $rule** @return RedirectResponse|Redirector*/@@ -194,10 +194,10 @@ class EditController extends Controller$this->ruleRepos->update($rule, $data);- session()->flash('success', (string) trans('firefly.updated_rule', ['title' => $rule->title]));+ session()->flash('success', (string)trans('firefly.updated_rule', ['title' => $rule->title]));app('preferences')->mark();$redirect = redirect($this->getPreviousUrl('rules.edit.url'));- if (1 === (int) $request->get('return_to_edit')) {+ if (1 === (int)$request->get('return_to_edit')) {session()->put('rules.edit.fromUpdate', true);$redirect = redirect(route('rules.edit', [$rule->id]))->withInput(['return_to_edit' => 1]);diff --git a/app/Http/Controllers/Rule/IndexController.php b/app/Http/Controllers/Rule/IndexController.phpindex 7323dec1c5..47dd5178db 100644--- a/app/Http/Controllers/Rule/IndexController.php+++ b/app/Http/Controllers/Rule/IndexController.php@@ -1,4 +1,5 @@<?php+/*** IndexController.php* Copyright (c) 2019 [email protected]@@ -54,7 +55,7 @@ class IndexController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.rules'));+ app('view')->share('title', (string)trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->ruleGroupRepos = app(RuleGroupRepositoryInterface::class);$this->ruleRepos = app(RuleRepositoryInterface::class);@@ -79,22 +80,22 @@ class IndexController extends Controller}/**- * @param Request $request- * @param Rule $rule- * @param RuleGroup $ruleGroup+ * @param Request $request+ * @param Rule $rule+ * @param RuleGroup $ruleGroup** @return JsonResponse*/public function moveRule(Request $request, Rule $rule, RuleGroup $ruleGroup): JsonResponse{- $order = (int) $request->get('order');- $this->ruleRepos->moveRule($rule, $ruleGroup, (int) $order);+ $order = (int)$request->get('order');+ $this->ruleRepos->moveRule($rule, $ruleGroup, (int)$order);return response()->json([]);}/**- * @param Rule $rule+ * @param Rule $rule** @return RedirectResponse*/diff --git a/app/Http/Controllers/Rule/SelectController.php b/app/Http/Controllers/Rule/SelectController.phpindex d2346e2801..ad57565d7e 100644--- a/app/Http/Controllers/Rule/SelectController.php+++ b/app/Http/Controllers/Rule/SelectController.php@@ -59,7 +59,7 @@ class SelectController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.rules'));+ app('view')->share('title', (string)trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');return $next($request);@@ -70,8 +70,8 @@ class SelectController extends Controller/*** Execute the given rule on a set of existing transactions.*- * @param SelectTransactionsRequest $request- * @param Rule $rule+ * @param SelectTransactionsRequest $request+ * @param Rule $rule** @return RedirectResponse*/@@ -98,7 +98,7 @@ class SelectController extends Controller$newRuleEngine->fire();$resultCount = $newRuleEngine->getResults();- session()->flash('success', (string) trans_choice('firefly.applied_rule_selection', $resultCount, ['title' => $rule->title]));+ session()->flash('success', (string)trans_choice('firefly.applied_rule_selection', $resultCount, ['title' => $rule->title]));return redirect()->route('rules.index');}@@ -106,7 +106,7 @@ class SelectController extends Controller/*** View to select transactions by a rule.*- * @param Rule $rule+ * @param Rule $rule** @return Factory|View*/@@ -120,7 +120,7 @@ class SelectController extends Controller// does the user have shared accounts?$first = session('first', Carbon::now()->subYear())->format('Y-m-d');$today = Carbon::now()->format('Y-m-d');- $subTitle = (string) trans('firefly.apply_rule_selection', ['title' => $rule->title]);+ $subTitle = (string)trans('firefly.apply_rule_selection', ['title' => $rule->title]);return view('rules.rule.select-transactions', compact('first', 'today', 'rule', 'subTitle'));}@@ -129,7 +129,7 @@ class SelectController extends Controller* This method allows the user to test a certain set of rule triggers. The rule triggers are passed along* using the URL parameters (GET), and are usually put there using a Javascript thing.*- * @param TestRuleFormRequest $request+ * @param TestRuleFormRequest $request** @return JsonResponse*@@ -146,7 +146,7 @@ class SelectController extends Controller// warn if nothing.if (0 === count($textTriggers)) {- return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);+ return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);}foreach ($textTriggers as $textTrigger) {@@ -170,7 +170,7 @@ class SelectController extends Controller// Warn the user if only a subset of transactions is returned$warning = '';if (0 === count($collection)) {- $warning = (string) trans('firefly.warning_no_matching_transactions');+ $warning = (string)trans('firefly.warning_no_matching_transactions');}// Return json response@@ -191,7 +191,7 @@ class SelectController extends Controller* This method allows the user to test a certain set of rule triggers. The rule triggers are grabbed from* the rule itself.*- * @param Rule $rule+ * @param Rule $rule** @return JsonResponse*@@ -201,7 +201,7 @@ class SelectController extends Controller$triggers = $rule->ruleTriggers;if (0 === count($triggers)) {- return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);+ return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);}// create new rule engine:$newRuleEngine = app(RuleEngineInterface::class);@@ -213,7 +213,7 @@ class SelectController extends Controller$warning = '';if (0 === count($collection)) {- $warning = (string) trans('firefly.warning_no_matching_transactions');+ $warning = (string)trans('firefly.warning_no_matching_transactions');}// Return json responsediff --git a/app/Http/Controllers/RuleGroup/CreateController.php b/app/Http/Controllers/RuleGroup/CreateController.phpindex 55c91fdd1f..04df9b1a5f 100644--- a/app/Http/Controllers/RuleGroup/CreateController.php+++ b/app/Http/Controllers/RuleGroup/CreateController.php@@ -50,7 +50,7 @@ class CreateController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.rules'));+ app('view')->share('title', (string)trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->repository = app(RuleGroupRepositoryInterface::class);@@ -68,7 +68,7 @@ class CreateController extends Controllerpublic function create(){$subTitleIcon = 'fa-clone';- $subTitle = (string) trans('firefly.make_new_rule_group');+ $subTitle = (string)trans('firefly.make_new_rule_group');// put previous url in session if not redirect from store (not "create another").if (true !== session('rule-groups.create.fromStore')) {@@ -82,7 +82,7 @@ class CreateController extends Controller/*** Store the rule group.*- * @param RuleGroupFormRequest $request+ * @param RuleGroupFormRequest $request** @return RedirectResponse|Redirector*/@@ -91,11 +91,11 @@ class CreateController extends Controller$data = $request->getRuleGroupData();$ruleGroup = $this->repository->store($data);- session()->flash('success', (string) trans('firefly.created_new_rule_group', ['title' => $ruleGroup->title]));+ session()->flash('success', (string)trans('firefly.created_new_rule_group', ['title' => $ruleGroup->title]));app('preferences')->mark();$redirect = redirect($this->getPreviousUrl('rule-groups.create.url'));- if (1 === (int) $request->get('create_another')) {+ if (1 === (int)$request->get('create_another')) {session()->put('rule-groups.create.fromStore', true);$redirect = redirect(route('rule-groups.create'))->withInput();diff --git a/app/Http/Controllers/RuleGroup/DeleteController.php b/app/Http/Controllers/RuleGroup/DeleteController.phpindex fdc92c527c..eaddb527a3 100644--- a/app/Http/Controllers/RuleGroup/DeleteController.php+++ b/app/Http/Controllers/RuleGroup/DeleteController.php@@ -51,7 +51,7 @@ class DeleteController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.rules'));+ app('view')->share('title', (string)trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->repository = app(RuleGroupRepositoryInterface::class);@@ -64,13 +64,13 @@ class DeleteController extends Controller/*** Delete a rule group.*- * @param RuleGroup $ruleGroup+ * @param RuleGroup $ruleGroup** @return Factory|View*/public function delete(RuleGroup $ruleGroup){- $subTitle = (string) trans('firefly.delete_rule_group', ['title' => $ruleGroup->title]);+ $subTitle = (string)trans('firefly.delete_rule_group', ['title' => $ruleGroup->title]);// put previous url in session$this->rememberPreviousUrl('rule-groups.delete.url');@@ -81,8 +81,8 @@ class DeleteController extends Controller/*** Actually destroy the rule group.*- * @param Request $request- * @param RuleGroup $ruleGroup+ * @param Request $request+ * @param RuleGroup $ruleGroup** @return RedirectResponse|Redirector*/@@ -91,10 +91,10 @@ class DeleteController extends Controller$title = $ruleGroup->title;/** @var RuleGroup $moveTo */- $moveTo = $this->repository->find((int) $request->get('move_rules_before_delete'));+ $moveTo = $this->repository->find((int)$request->get('move_rules_before_delete'));$this->repository->destroy($ruleGroup, $moveTo);- session()->flash('success', (string) trans('firefly.deleted_rule_group', ['title' => $title]));+ session()->flash('success', (string)trans('firefly.deleted_rule_group', ['title' => $title]));app('preferences')->mark();return redirect($this->getPreviousUrl('rule-groups.delete.url'));diff --git a/app/Http/Controllers/RuleGroup/EditController.php b/app/Http/Controllers/RuleGroup/EditController.phpindex 1449fa1a5f..b18e66c888 100644--- a/app/Http/Controllers/RuleGroup/EditController.php+++ b/app/Http/Controllers/RuleGroup/EditController.php@@ -52,7 +52,7 @@ class EditController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.rules'));+ app('view')->share('title', (string)trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->repository = app(RuleGroupRepositoryInterface::class);@@ -65,18 +65,18 @@ class EditController extends Controller/*** Edit a rule group.*- * @param Request $request- * @param RuleGroup $ruleGroup+ * @param Request $request+ * @param RuleGroup $ruleGroup** @return Factory|View*/public function edit(Request $request, RuleGroup $ruleGroup){- $subTitle = (string) trans('firefly.edit_rule_group', ['title' => $ruleGroup->title]);+ $subTitle = (string)trans('firefly.edit_rule_group', ['title' => $ruleGroup->title]);$hasOldInput = null !== $request->old('_token');$preFilled = [- 'active' => $hasOldInput ? (bool) $request->old('active') : $ruleGroup->active,+ 'active' => $hasOldInput ? (bool)$request->old('active') : $ruleGroup->active,];// put previous url in session if not redirect from store (not "return_to_edit").if (true !== session('rule-groups.edit.fromUpdate')) {@@ -91,26 +91,26 @@ class EditController extends Controller/*** Move a rule group in either direction.*- * @param Request $request+ * @param Request $request** @return JsonResponse*/public function moveGroup(Request $request): JsonResponse{- $groupId = (int) $request->get('id');+ $groupId = (int)$request->get('id');$ruleGroup = $this->repository->find($groupId);if (null !== $ruleGroup) {$direction = $request->get('direction');if ('down' === $direction) {$maxOrder = $this->repository->maxOrder();- $order = (int) $ruleGroup->order;+ $order = (int)$ruleGroup->order;if ($order < $maxOrder) {$newOrder = $order + 1;$this->repository->setOrder($ruleGroup, $newOrder);}}if ('up' === $direction) {- $order = (int) $ruleGroup->order;+ $order = (int)$ruleGroup->order;if ($order > 1) {$newOrder = $order - 1;$this->repository->setOrder($ruleGroup, $newOrder);@@ -123,8 +123,8 @@ class EditController extends Controller/*** Update the rule group.*- * @param RuleGroupFormRequest $request- * @param RuleGroup $ruleGroup+ * @param RuleGroupFormRequest $request+ * @param RuleGroup $ruleGroup** @return $this|RedirectResponse|Redirector*/@@ -133,15 +133,15 @@ class EditController extends Controller$data = ['title' => $request->convertString('title'),'description' => $request->stringWithNewlines('description'),- 'active' => 1 === (int) $request->input('active'),+ 'active' => 1 === (int)$request->input('active'),];$this->repository->update($ruleGroup, $data);- session()->flash('success', (string) trans('firefly.updated_rule_group', ['title' => $ruleGroup->title]));+ session()->flash('success', (string)trans('firefly.updated_rule_group', ['title' => $ruleGroup->title]));app('preferences')->mark();$redirect = redirect($this->getPreviousUrl('rule-groups.edit.url'));- if (1 === (int) $request->get('return_to_edit')) {+ if (1 === (int)$request->get('return_to_edit')) {session()->put('rule-groups.edit.fromUpdate', true);$redirect = redirect(route('rule-groups.edit', [$ruleGroup->id]))->withInput(['return_to_edit' => 1]);diff --git a/app/Http/Controllers/RuleGroup/ExecutionController.php b/app/Http/Controllers/RuleGroup/ExecutionController.phpindex 39d0bc89b8..14a75e5ea1 100644--- a/app/Http/Controllers/RuleGroup/ExecutionController.php+++ b/app/Http/Controllers/RuleGroup/ExecutionController.php@@ -53,7 +53,7 @@ class ExecutionController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.rules'));+ app('view')->share('title', (string)trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);@@ -66,8 +66,8 @@ class ExecutionController extends Controller/*** Execute the given rulegroup on a set of existing transactions.*- * @param SelectTransactionsRequest $request- * @param RuleGroup $ruleGroup+ * @param SelectTransactionsRequest $request+ * @param RuleGroup $ruleGroup** @return RedirectResponse* @throws Exception@@ -95,7 +95,7 @@ class ExecutionController extends Controller$newRuleEngine->fire();// Tell the user that the job is queued- session()->flash('success', (string) trans('firefly.applied_rule_group_selection', ['title' => $ruleGroup->title]));+ session()->flash('success', (string)trans('firefly.applied_rule_group_selection', ['title' => $ruleGroup->title]));return redirect()->route('rules.index');}@@ -103,7 +103,7 @@ class ExecutionController extends Controller/*** Select transactions to apply the group on.*- * @param RuleGroup $ruleGroup+ * @param RuleGroup $ruleGroup** @return Factory|View*/@@ -111,7 +111,7 @@ class ExecutionController extends Controller{$first = session('first')->format('Y-m-d');$today = Carbon::now()->format('Y-m-d');- $subTitle = (string) trans('firefly.apply_rule_group_selection', ['title' => $ruleGroup->title]);+ $subTitle = (string)trans('firefly.apply_rule_group_selection', ['title' => $ruleGroup->title]);return view('rules.rule-group.select-transactions', compact('first', 'today', 'ruleGroup', 'subTitle'));}diff --git a/app/Http/Controllers/System/HealthcheckController.php b/app/Http/Controllers/System/HealthcheckController.phpindex 7455aa5cc4..fef70b5b05 100644--- a/app/Http/Controllers/System/HealthcheckController.php+++ b/app/Http/Controllers/System/HealthcheckController.php@@ -1,4 +1,5 @@<?php+/** HealthcheckController.php* Copyright (c) 2021 https://github.com/ajgondiff --git a/app/Http/Controllers/System/InstallController.php b/app/Http/Controllers/System/InstallController.phpindex b4726f047d..66d290d74f 100644--- a/app/Http/Controllers/System/InstallController.php+++ b/app/Http/Controllers/System/InstallController.php@@ -127,22 +127,22 @@ class InstallController extends Controllerpublic function index(){// index will set FF3 version.- app('fireflyconfig')->set('ff3_version', (string) config('firefly.version'));+ app('fireflyconfig')->set('ff3_version', (string)config('firefly.version'));// set new DB version.- app('fireflyconfig')->set('db_version', (int) config('firefly.db_version'));+ app('fireflyconfig')->set('db_version', (int)config('firefly.db_version'));return view('install.index');}/**- * @param Request $request+ * @param Request $request** @return JsonResponse*/public function runCommand(Request $request): JsonResponse{- $requestIndex = (int) $request->get('index');+ $requestIndex = (int)$request->get('index');$response = ['hasNextCommand' => false,'done' => true,@@ -156,7 +156,7 @@ class InstallController extends Controller$index = 0;/*** @var string $command- * @var array $args+ * @var array $args*/foreach ($this->upgradeCommands as $command => $args) {Log::debug(sprintf('Current command is "%s", index is %d', $command, $index));@@ -182,8 +182,8 @@ class InstallController extends Controller}/**- * @param string $command- * @param array $args+ * @param string $command+ * @param array $args** @return bool*/diff --git a/app/Http/Controllers/Transaction/BulkController.php b/app/Http/Controllers/Transaction/BulkController.phpindex 2f20179698..ea63afab36 100644--- a/app/Http/Controllers/Transaction/BulkController.php+++ b/app/Http/Controllers/Transaction/BulkController.php@@ -57,7 +57,7 @@ class BulkController extends Controller$this->middleware(function ($request, $next) {$this->repository = app(JournalRepositoryInterface::class);- app('view')->share('title', (string) trans('firefly.transactions'));+ app('view')->share('title', (string)trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');return $next($request);@@ -70,13 +70,13 @@ class BulkController extends Controller** TODO user wont be able to tell if the journal is part of a split.*- * @param array $journals+ * @param array $journals** @return Factory|View*/public function edit(array $journals){- $subTitle = (string) trans('firefly.mass_bulk_journals');+ $subTitle = (string)trans('firefly.mass_bulk_journals');$this->rememberPreviousUrl('transactions.bulk-edit.url');@@ -93,7 +93,7 @@ class BulkController extends Controller/*** Update all journals.*- * @param BulkEditJournalRequest $request+ * @param BulkEditJournalRequest $request** @return Application|RedirectResponse|Redirector*/@@ -101,14 +101,14 @@ class BulkController extends Controller{$journalIds = $request->get('journals');$journalIds = is_array($journalIds) ? $journalIds : [];- $ignoreCategory = 1 === (int) $request->get('ignore_category');- $ignoreBudget = 1 === (int) $request->get('ignore_budget');+ $ignoreCategory = 1 === (int)$request->get('ignore_category');+ $ignoreBudget = 1 === (int)$request->get('ignore_budget');$tagsAction = $request->get('tags_action');$collection = new Collection();$count = 0;foreach ($journalIds as $journalId) {- $journalId = (int) $journalId;+ $journalId = (int)$journalId;$journal = $this->repository->find($journalId);if (null !== $journal) {$resultA = $this->updateJournalBudget($journal, $ignoreBudget, $request->integer('budget_id'));@@ -128,16 +128,16 @@ class BulkController extends Controller}app('preferences')->mark();- $request->session()->flash('success', (string) trans_choice('firefly.mass_edited_transactions_success', $count));+ $request->session()->flash('success', (string)trans_choice('firefly.mass_edited_transactions_success', $count));// redirect to previous URL:return redirect($this->getPreviousUrl('transactions.bulk-edit.url'));}/**- * @param TransactionJournal $journal- * @param bool $ignoreUpdate- * @param int $budgetId+ * @param TransactionJournal $journal+ * @param bool $ignoreUpdate+ * @param int $budgetId** @return bool*/@@ -153,9 +153,9 @@ class BulkController extends Controller}/**- * @param TransactionJournal $journal- * @param string $action- * @param array $tags+ * @param TransactionJournal $journal+ * @param string $action+ * @param array $tags** @return bool*/@@ -175,9 +175,9 @@ class BulkController extends Controller}/**- * @param TransactionJournal $journal- * @param bool $ignoreUpdate- * @param string $category+ * @param TransactionJournal $journal+ * @param bool $ignoreUpdate+ * @param string $category** @return bool*/diff --git a/app/Http/Controllers/Transaction/ConvertController.php b/app/Http/Controllers/Transaction/ConvertController.phpindex 78ee0fda5b..b64474d184 100644--- a/app/Http/Controllers/Transaction/ConvertController.php+++ b/app/Http/Controllers/Transaction/ConvertController.php@@ -1,4 +1,5 @@<?php+/*** ConvertController.php* Copyright (c) 2019 [email protected]@@ -70,7 +71,7 @@ class ConvertController extends Controllerfunction ($request, $next) {$this->repository = app(JournalRepositoryInterface::class);$this->accountRepository = app(AccountRepositoryInterface::class);- app('view')->share('title', (string) trans('firefly.transactions'));+ app('view')->share('title', (string)trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');return $next($request);@@ -81,8 +82,8 @@ class ConvertController extends Controller/*** Show overview of a to be converted transaction.*- * @param TransactionType $destinationType- * @param TransactionGroup $group+ * @param TransactionType $destinationType+ * @param TransactionGroup $group** @return RedirectResponse|Redirector|Factory|View* @throws Exception@@ -103,7 +104,7 @@ class ConvertController extends Controller$groupTitle = $group->title ?? $first->description;$groupArray = $transformer->transformObject($group);- $subTitle = (string) trans('firefly.convert_to_' . $destinationType->type, ['description' => $groupTitle]);+ $subTitle = (string)trans('firefly.convert_to_'.$destinationType->type, ['description' => $groupTitle]);$subTitleIcon = 'fa-exchange';// get a list of asset accounts and liabilities and stuff, in various combinations:@@ -119,7 +120,7 @@ class ConvertController extends Controllerif ($sourceType->type === $destinationType->type) { // cannot convert to its own type.Log::debug('This is already a transaction of the expected type..');- session()->flash('info', (string) trans('firefly.convert_is_already_type_' . $destinationType->type));+ session()->flash('info', (string)trans('firefly.convert_is_already_type_'.$destinationType->type));return redirect(route('transactions.show', [$group->id]));}@@ -156,7 +157,7 @@ class ConvertController extends Controller// group accounts:/** @var Account $account */foreach ($accountList as $account) {- $role = (string) $this->accountRepository->getMetaValue($account, 'account_role');+ $role = (string)$this->accountRepository->getMetaValue($account, 'account_role');$name = $account->name;if ('' === $role) {$role = 'no_account_type';@@ -164,7 +165,7 @@ class ConvertController extends Controller// maybe it's a liability thing:if (in_array($account->accountType->type, $liabilityTypes, true)) {- $role = 'l_' . $account->accountType->type;+ $role = 'l_'.$account->accountType->type;}if (AccountType::CASH === $account->accountType->type) {$role = 'cash_account';@@ -174,7 +175,7 @@ class ConvertController extends Controller$role = 'revenue_account';}- $key = (string) trans('firefly.opt_group_' . $role);+ $key = (string)trans('firefly.opt_group_'.$role);$grouped[$key][$account->id] = $name;}@@ -195,7 +196,7 @@ class ConvertController extends Controller// group accounts:/** @var Account $account */foreach ($accountList as $account) {- $role = (string) $this->accountRepository->getMetaValue($account, 'account_role');+ $role = (string)$this->accountRepository->getMetaValue($account, 'account_role');$name = $account->name;if ('' === $role) {$role = 'no_account_type';@@ -203,7 +204,7 @@ class ConvertController extends Controller// maybe it's a liability thing:if (in_array($account->accountType->type, $liabilityTypes, true)) {- $role = 'l_' . $account->accountType->type;+ $role = 'l_'.$account->accountType->type;}if (AccountType::CASH === $account->accountType->type) {$role = 'cash_account';@@ -213,7 +214,7 @@ class ConvertController extends Controller$role = 'expense_account';}- $key = (string) trans('firefly.opt_group_' . $role);+ $key = (string)trans('firefly.opt_group_'.$role);$grouped[$key][$account->id] = $name;}@@ -235,9 +236,9 @@ class ConvertController extends Controllerforeach ($accountList as $account) {$balance = app('steam')->balance($account, today());$currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;- $role = 'l_' . $account->accountType->type;- $key = (string) trans('firefly.opt_group_' . $role);- $grouped[$key][$account->id] = $account->name . ' (' . app('amount')->formatAnything($currency, $balance, false) . ')';+ $role = 'l_'.$account->accountType->type;+ $key = (string)trans('firefly.opt_group_'.$role);+ $grouped[$key][$account->id] = $account->name.' ('.app('amount')->formatAnything($currency, $balance, false).')';}return $grouped;@@ -258,13 +259,13 @@ class ConvertController extends Controllerforeach ($accountList as $account) {$balance = app('steam')->balance($account, today());$currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;- $role = (string) $this->accountRepository->getMetaValue($account, 'account_role');+ $role = (string)$this->accountRepository->getMetaValue($account, 'account_role');if ('' === $role) {$role = 'no_account_type';}- $key = (string) trans('firefly.opt_group_' . $role);- $grouped[$key][$account->id] = $account->name . ' (' . app('amount')->formatAnything($currency, $balance, false) . ')';+ $key = (string)trans('firefly.opt_group_'.$role);+ $grouped[$key][$account->id] = $account->name.' ('.app('amount')->formatAnything($currency, $balance, false).')';}return $grouped;@@ -273,9 +274,9 @@ class ConvertController extends Controller/*** Do the conversion.*- * @param Request $request- * @param TransactionType $destinationType- * @param TransactionGroup $group+ * @param Request $request+ * @param TransactionType $destinationType+ * @param TransactionGroup $group** @return RedirectResponse|Redirector*@@ -301,16 +302,16 @@ class ConvertController extends Controller// correct transfers:$group->refresh();- session()->flash('success', (string) trans('firefly.converted_to_' . $destinationType->type));+ session()->flash('success', (string)trans('firefly.converted_to_'.$destinationType->type));event(new UpdatedTransactionGroup($group, true, true));return redirect(route('transactions.show', [$group->id]));}/**- * @param TransactionJournal $journal- * @param TransactionType $transactionType- * @param array $data+ * @param TransactionJournal $journal+ * @param TransactionType $transactionType+ * @param array $data** @return TransactionJournal* @throws FireflyException@@ -328,10 +329,10 @@ class ConvertController extends Controller$destinationName = $data['destination_name'][$journal->id] ?? null;// double check its not an empty string.- $sourceId = '' === $sourceId || null === $sourceId ? null : (int) $sourceId;- $sourceName = '' === $sourceName ? null : (string) $sourceName;- $destinationId = '' === $destinationId || null === $destinationId ? null : (int) $destinationId;- $destinationName = '' === $destinationName ? null : (string) $destinationName;+ $sourceId = '' === $sourceId || null === $sourceId ? null : (int)$sourceId;+ $sourceName = '' === $sourceName ? null : (string)$sourceName;+ $destinationId = '' === $destinationId || null === $destinationId ? null : (int)$destinationId;+ $destinationName = '' === $destinationName ? null : (string)$destinationName;$validSource = $validator->validateSource(['id' => $sourceId, 'name' => $sourceName,]);$validDestination = $validator->validateDestination(['id' => $destinationId, 'name' => $destinationName,]);diff --git a/app/Http/Controllers/Transaction/CreateController.php b/app/Http/Controllers/Transaction/CreateController.phpindex 53cc071651..cdca03ae74 100644--- a/app/Http/Controllers/Transaction/CreateController.php+++ b/app/Http/Controllers/Transaction/CreateController.php@@ -33,6 +33,9 @@ use Illuminate\Contracts\View\Factory;use Illuminate\Contracts\View\View;use Illuminate\Http\JsonResponse;use Illuminate\Http\Request;+use JsonException;+use Psr\Container\ContainerExceptionInterface;+use Psr\Container\NotFoundExceptionInterface;/*** Class CreateController@@ -52,7 +55,7 @@ class CreateController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.transactions'));+ app('view')->share('title', (string)trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');$this->repository = app(TransactionGroupRepositoryInterface::class);@@ -62,13 +65,13 @@ class CreateController extends Controller}/**- * @param Request $request+ * @param Request $request** @return JsonResponse*/public function cloneGroup(Request $request): JsonResponse{- $groupId = (int) $request->get('id');+ $groupId = (int)$request->get('id');if (0 !== $groupId) {$group = $this->repository->find($groupId);if (null !== $group) {@@ -96,26 +99,26 @@ class CreateController extends Controller/*** Create a new transaction group.*- * @param string|null $objectType+ * @param string|null $objectType** @return Factory|View* @throws FireflyException- * @throws \JsonException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws JsonException+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/public function create(?string $objectType){app('preferences')->mark();- $sourceId = (int) request()->get('source');- $destinationId = (int) request()->get('destination');+ $sourceId = (int)request()->get('source');+ $destinationId = (int)request()->get('destination');/** @var AccountRepositoryInterface $accountRepository */$accountRepository = app(AccountRepositoryInterface::class);$cash = $accountRepository->getCashAccount();$preFilled = session()->has('preFilled') ? session('preFilled') : [];- $subTitle = (string) trans(sprintf('breadcrumbs.create_%s', strtolower((string) $objectType)));+ $subTitle = (string)trans(sprintf('breadcrumbs.create_%s', strtolower((string)$objectType)));$subTitleIcon = 'fa-plus';$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;$allowedOpposingTypes = config('firefly.allowed_opposing_types');diff --git a/app/Http/Controllers/Transaction/DeleteController.php b/app/Http/Controllers/Transaction/DeleteController.phpindex 196ca0fca6..39b6290b64 100644--- a/app/Http/Controllers/Transaction/DeleteController.php+++ b/app/Http/Controllers/Transaction/DeleteController.php@@ -23,7 +23,6 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Transaction;-use FireflyIII\Events\DestroyedTransactionGroup;use FireflyIII\Events\UpdatedAccount;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\Account;@@ -57,7 +56,7 @@ class DeleteController extends Controller// translations:$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.transactions'));+ app('view')->share('title', (string)trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');$this->repository = app(TransactionGroupRepositoryInterface::class);@@ -70,7 +69,7 @@ class DeleteController extends Controller/*** Shows the form that allows a user to delete a transaction journal.*- * @param TransactionGroup $group+ * @param TransactionGroup $group** @return Factory|View|Redirector|RedirectResponse*/@@ -87,7 +86,7 @@ class DeleteController extends Controllerthrow new NotFoundHttpException();}$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);- $subTitle = (string) trans('firefly.delete_' . $objectType, ['description' => $group->title ?? $journal->description]);+ $subTitle = (string)trans('firefly.delete_'.$objectType, ['description' => $group->title ?? $journal->description]);$previous = app('steam')->getSafePreviousUrl(route('index'));// put previous url in sessionLog::debug('Will try to remember previous URL');@@ -99,7 +98,7 @@ class DeleteController extends Controller/*** Actually destroys the journal.*- * @param TransactionGroup $group+ * @param TransactionGroup $group** @return RedirectResponse*/@@ -114,7 +113,7 @@ class DeleteController extends Controllerthrow new NotFoundHttpException();}$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);- session()->flash('success', (string) trans('firefly.deleted_' . strtolower($objectType), ['description' => $group->title ?? $journal->description]));+ session()->flash('success', (string)trans('firefly.deleted_'.strtolower($objectType), ['description' => $group->title ?? $journal->description]));// grab asset account(s) from group:$accounts = [];diff --git a/app/Http/Controllers/Transaction/EditController.php b/app/Http/Controllers/Transaction/EditController.phpindex 6593c4f6fc..f34121a3ab 100644--- a/app/Http/Controllers/Transaction/EditController.php+++ b/app/Http/Controllers/Transaction/EditController.php@@ -48,7 +48,7 @@ class EditController extends Controller// some useful repositories:$this->middleware(static function ($request, $next) {- app('view')->share('title', (string) trans('firefly.transactions'));+ app('view')->share('title', (string)trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');return $next($request);@@ -57,7 +57,7 @@ class EditController extends Controller}/**- * @param TransactionGroup $transactionGroup+ * @param TransactionGroup $transactionGroup** @return Factory|View|RedirectResponse|Redirector*/diff --git a/app/Http/Controllers/Transaction/IndexController.php b/app/Http/Controllers/Transaction/IndexController.phpindex dbd6dd594b..e7c01542fc 100644--- a/app/Http/Controllers/Transaction/IndexController.php+++ b/app/Http/Controllers/Transaction/IndexController.php@@ -24,7 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Transaction;use Carbon\Carbon;-use Exception;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Helpers\Collector\GroupCollectorInterface;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Repositories\Journal\JournalRepositoryInterface;@@ -32,6 +32,8 @@ use FireflyIII\Support\Http\Controllers\PeriodOverview;use Illuminate\Contracts\View\Factory;use Illuminate\Http\Request;use Illuminate\View\View;+use Psr\Container\ContainerExceptionInterface;+use Psr\Container\NotFoundExceptionInterface;/*** Class IndexController@@ -55,7 +57,7 @@ class IndexController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-exchange');- app('view')->share('title', (string) trans('firefly.transactions'));+ app('view')->share('title', (string)trans('firefly.transactions'));$this->repository = app(JournalRepositoryInterface::class);@@ -67,15 +69,15 @@ class IndexController extends Controller/*** Index for a range of transactions.*- * @param Request $request- * @param string $objectType- * @param Carbon|null $start- * @param Carbon|null $end+ * @param Request $request+ * @param string $objectType+ * @param Carbon|null $start+ * @param Carbon|null $end** @return Factory|View- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws FireflyException+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/public function index(Request $request, string $objectType, Carbon $start = null, Carbon $end = null){@@ -83,10 +85,10 @@ class IndexController extends Controller$objectType = 'transfer';}- $subTitleIcon = config('firefly.transactionIconsByType.' . $objectType);- $types = config('firefly.transactionTypesByType.' . $objectType);- $page = (int) $request->get('page');- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;+ $subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);+ $types = config('firefly.transactionTypesByType.'.$objectType);+ $page = (int)$request->get('page');+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;if (null === $start) {$start = session('start');$end = session('end');@@ -101,7 +103,7 @@ class IndexController extends Controller$path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);$startStr = $start->isoFormat($this->monthAndDayFormat);$endStr = $end->isoFormat($this->monthAndDayFormat);- $subTitle = (string) trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);+ $subTitle = (string)trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);$firstJournal = $this->repository->firstNull();$startPeriod = null === $firstJournal ? new Carbon() : $firstJournal->date;@@ -128,26 +130,26 @@ class IndexController extends Controller/*** Index for ALL transactions.*- * @param Request $request- * @param string $objectType+ * @param Request $request+ * @param string $objectType** @return Factory|View- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws FireflyException+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/public function indexAll(Request $request, string $objectType){- $subTitleIcon = config('firefly.transactionIconsByType.' . $objectType);- $types = config('firefly.transactionTypesByType.' . $objectType);- $page = (int) $request->get('page');- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;+ $subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);+ $types = config('firefly.transactionTypesByType.'.$objectType);+ $page = (int)$request->get('page');+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;$path = route('transactions.index.all', [$objectType]);$first = $this->repository->firstNull();$start = null === $first ? new Carbon() : $first->date;$last = $this->repository->getLast();$end = $last ? $last->date : today(config('app.timezone'));- $subTitle = (string) trans('firefly.all_' . $objectType);+ $subTitle = (string)trans('firefly.all_'.$objectType);/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);diff --git a/app/Http/Controllers/Transaction/LinkController.php b/app/Http/Controllers/Transaction/LinkController.phpindex 48627302d4..3534bb7b95 100644--- a/app/Http/Controllers/Transaction/LinkController.php+++ b/app/Http/Controllers/Transaction/LinkController.php@@ -1,4 +1,5 @@<?php+/*** LinkController.php* Copyright (c) 2019 [email protected]@@ -54,7 +55,7 @@ class LinkController extends Controller// some useful repositories:$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.transactions'));+ app('view')->share('title', (string)trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');$this->journalRepository = app(JournalRepositoryInterface::class);@@ -68,14 +69,14 @@ class LinkController extends Controller/*** Delete a link.*- * @param TransactionJournalLink $link+ * @param TransactionJournalLink $link** @return Factory|View*/public function delete(TransactionJournalLink $link){$subTitleIcon = 'fa-link';- $subTitle = (string) trans('breadcrumbs.delete_journal_link');+ $subTitle = (string)trans('breadcrumbs.delete_journal_link');$this->rememberPreviousUrl('journal_links.delete.url');return view('transactions.links.delete', compact('link', 'subTitle', 'subTitleIcon'));@@ -84,7 +85,7 @@ class LinkController extends Controller/*** Actually destroy it.*- * @param TransactionJournalLink $link+ * @param TransactionJournalLink $link** @return RedirectResponse|Redirector*/@@ -92,14 +93,14 @@ class LinkController extends Controller{$this->repository->destroyLink($link);- session()->flash('success', (string) trans('firefly.deleted_link'));+ session()->flash('success', (string)trans('firefly.deleted_link'));app('preferences')->mark();- return redirect((string) session('journal_links.delete.url'));+ return redirect((string)session('journal_links.delete.url'));}/**- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return Factory|View*/@@ -113,8 +114,8 @@ class LinkController extends Controller/*** Store a new link.*- * @param JournalLinkRequest $request- * @param TransactionJournal $journal+ * @param JournalLinkRequest $request+ * @param TransactionJournal $journal** @return RedirectResponse|Redirector*/@@ -125,7 +126,7 @@ class LinkController extends ControllerLog::debug('We are here (store)');$other = $this->journalRepository->find($linkInfo['transaction_journal_id']);if (null === $other) {- session()->flash('error', (string) trans('firefly.invalid_link_selection'));+ session()->flash('error', (string)trans('firefly.invalid_link_selection'));return redirect(route('transactions.show', [$journal->transaction_group_id]));}@@ -133,19 +134,19 @@ class LinkController extends Controller$alreadyLinked = $this->repository->findLink($journal, $other);if ($other->id === $journal->id) {- session()->flash('error', (string) trans('firefly.journals_link_to_self'));+ session()->flash('error', (string)trans('firefly.journals_link_to_self'));return redirect(route('transactions.show', [$journal->transaction_group_id]));}if ($alreadyLinked) {- session()->flash('error', (string) trans('firefly.journals_error_linked'));+ session()->flash('error', (string)trans('firefly.journals_error_linked'));return redirect(route('transactions.show', [$journal->transaction_group_id]));}Log::debug(sprintf('Journal is %d, opposing is %d', $journal->id, $other->id));$this->repository->storeLink($linkInfo, $other, $journal);- session()->flash('success', (string) trans('firefly.journals_linked'));+ session()->flash('success', (string)trans('firefly.journals_linked'));return redirect(route('transactions.show', [$journal->transaction_group_id]));}@@ -153,12 +154,12 @@ class LinkController extends Controller/*** Switch link from A <> B to B <> A.*- * @param Request $request+ * @param Request $request* @return RedirectResponse|Redirector*/public function switchLink(Request $request){- $linkId = (int) $request->get('id');+ $linkId = (int)$request->get('id');$this->repository->switchLinkById($linkId);return redirect(app('steam')->getSafePreviousUrl());diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.phpindex efee9b13e0..91457cbdb2 100644--- a/app/Http/Controllers/Transaction/MassController.php+++ b/app/Http/Controllers/Transaction/MassController.php@@ -1,4 +1,5 @@<?php+/*** MassController.php* Copyright (c) 2019 [email protected]@@ -61,7 +62,7 @@ class MassController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.transactions'));+ app('view')->share('title', (string)trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');$this->repository = app(JournalRepositoryInterface::class);@@ -73,13 +74,13 @@ class MassController extends Controller/*** Mass delete transactions.*- * @param array $journals+ * @param array $journals** @return IlluminateView*/public function delete(array $journals): IlluminateView{- $subTitle = (string) trans('firefly.mass_delete_journals');+ $subTitle = (string)trans('firefly.mass_delete_journals');// put previous url in session$this->rememberPreviousUrl('transactions.mass-delete.url');@@ -90,7 +91,7 @@ class MassController extends Controller/*** Do the mass delete.*- * @param MassDeleteJournalRequest $request+ * @param MassDeleteJournalRequest $request** @return Application|Redirector|RedirectResponse*@@ -103,15 +104,15 @@ class MassController extends Controller/** @var string $journalId */foreach ($ids as $journalId) {/** @var TransactionJournal $journal */- $journal = $this->repository->find((int) $journalId);- if (null !== $journal && (int) $journalId === $journal->id) {+ $journal = $this->repository->find((int)$journalId);+ if (null !== $journal && (int)$journalId === $journal->id) {$this->repository->destroyJournal($journal);++$count;}}}app('preferences')->mark();- session()->flash('success', (string) trans_choice('firefly.mass_deleted_transactions_success', $count));+ session()->flash('success', (string)trans_choice('firefly.mass_deleted_transactions_success', $count));// redirect to previous URL:return redirect($this->getPreviousUrl('transactions.mass-delete.url'));@@ -120,13 +121,13 @@ class MassController extends Controller/*** Mass edit of journals.*- * @param array $journals+ * @param array $journals** @return IlluminateView*/public function edit(array $journals): IlluminateView{- $subTitle = (string) trans('firefly.mass_edit_journals');+ $subTitle = (string)trans('firefly.mass_edit_journals');/** @var AccountRepositoryInterface $accountRepository */$accountRepository = app(AccountRepositoryInterface::class);@@ -158,7 +159,7 @@ class MassController extends Controller/*** Mass update of journals.*- * @param MassEditJournalRequest $request+ * @param MassEditJournalRequest $request** @return RedirectResponse|Redirector* @throws FireflyException@@ -173,7 +174,7 @@ class MassController extends Controller$count = 0;/** @var string $journalId */foreach ($journalIds as $journalId) {- $integer = (int) $journalId;+ $integer = (int)$journalId;try {$this->updateJournal($integer, $request);$count++;@@ -183,15 +184,15 @@ class MassController extends Controller}app('preferences')->mark();- session()->flash('success', (string) trans_choice('firefly.mass_edited_transactions_success', $count));+ session()->flash('success', (string)trans_choice('firefly.mass_edited_transactions_success', $count));// redirect to previous URL:return redirect($this->getPreviousUrl('transactions.mass-edit.url'));}/**- * @param int $journalId- * @param MassEditJournalRequest $request+ * @param int $journalId+ * @param MassEditJournalRequest $request** @throws FireflyException*/@@ -227,9 +228,9 @@ class MassController extends Controller}/**- * @param MassEditJournalRequest $request- * @param int $journalId- * @param string $key+ * @param MassEditJournalRequest $request+ * @param int $journalId+ * @param string $key** @return Carbon|null* @codeCoverageIgnore@@ -255,9 +256,9 @@ class MassController extends Controller}/**- * @param MassEditJournalRequest $request- * @param int $journalId- * @param string $string+ * @param MassEditJournalRequest $request+ * @param int $journalId+ * @param string $string** @return string|null* @codeCoverageIgnore@@ -272,13 +273,13 @@ class MassController extends Controllerreturn null;}- return (string) $value[$journalId];+ return (string)$value[$journalId];}/**- * @param MassEditJournalRequest $request- * @param int $journalId- * @param string $string+ * @param MassEditJournalRequest $request+ * @param int $journalId+ * @param string $string** @return int|null* @codeCoverageIgnore@@ -293,6 +294,6 @@ class MassController extends Controllerreturn null;}- return (int) $value[$journalId];+ return (int)$value[$journalId];}}diff --git a/app/Http/Controllers/Transaction/ShowController.php b/app/Http/Controllers/Transaction/ShowController.phpindex 08bb352938..c294ff0c7e 100644--- a/app/Http/Controllers/Transaction/ShowController.php+++ b/app/Http/Controllers/Transaction/ShowController.php@@ -41,8 +41,8 @@ use Symfony\Component\HttpFoundation\ParameterBag;*/class ShowController extends Controller{- private TransactionGroupRepositoryInterface $repository;private ALERepositoryInterface $ALERepository;+ private TransactionGroupRepositoryInterface $repository;/*** ShowController constructor.@@ -57,7 +57,7 @@ class ShowController extends Controller$this->repository = app(TransactionGroupRepositoryInterface::class);$this->ALERepository = app(ALERepositoryInterface::class);- app('view')->share('title', (string) trans('firefly.transactions'));+ app('view')->share('title', (string)trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');return $next($request);@@ -66,7 +66,7 @@ class ShowController extends Controller}/**- * @param TransactionGroup $transactionGroup+ * @param TransactionGroup $transactionGroup** @return JsonResponse*/@@ -76,8 +76,8 @@ class ShowController extends Controller}/**- * @param Request $request- * @param TransactionGroup $transactionGroup+ * @param Request $request+ * @param TransactionGroup $transactionGroup** @return Factory|View* @throws FireflyException@@ -92,7 +92,7 @@ class ShowController extends Controllerthrow new FireflyException('This transaction is broken :(.');}- $type = (string) trans(sprintf('firefly.%s', $first->transactionType->type));+ $type = (string)trans(sprintf('firefly.%s', $first->transactionType->type));$title = 1 === $splits ? $first->description : $transactionGroup->title;$subTitle = sprintf('%s: "%s"', $type, $title);@@ -140,7 +140,7 @@ class ShowController extends Controller}/**- * @param array $group+ * @param array $group** @return array*/@@ -175,7 +175,7 @@ class ShowController extends Controller}/**- * @param array $group+ * @param array $group** @return array*/@@ -188,12 +188,14 @@ class ShowController extends Controller'type' => $transaction['source_type'],'id' => $transaction['source_id'],'name' => $transaction['source_name'],- 'iban' => $transaction['source_iban']];+ 'iban' => $transaction['source_iban'],+ ];$accounts['destination'][] = ['type' => $transaction['destination_type'],'id' => $transaction['destination_id'],'name' => $transaction['destination_name'],- 'iban' => $transaction['destination_iban']];+ 'iban' => $transaction['destination_iban'],+ ];}$accounts['source'] = array_unique($accounts['source'], SORT_REGULAR);diff --git a/app/Http/Controllers/Webhooks/CreateController.php b/app/Http/Controllers/Webhooks/CreateController.phpindex daa58426f3..4bf123ef0b 100644--- a/app/Http/Controllers/Webhooks/CreateController.php+++ b/app/Http/Controllers/Webhooks/CreateController.php@@ -45,8 +45,8 @@ class CreateController extends Controllerfunction ($request, $next) {app('view')->share('mainTitleIcon', 'fa-bolt');app('view')->share('subTitleIcon', 'fa-plus');- app('view')->share('title', (string) trans('firefly.webhooks'));- app('view')->share('subTitle', (string) trans('firefly.create_new_webhook'));+ app('view')->share('title', (string)trans('firefly.webhooks'));+ app('view')->share('subTitle', (string)trans('firefly.create_new_webhook'));return $next($request);}diff --git a/app/Http/Controllers/Webhooks/DeleteController.php b/app/Http/Controllers/Webhooks/DeleteController.phpindex c3c57bfdcb..f97bee9492 100644--- a/app/Http/Controllers/Webhooks/DeleteController.php+++ b/app/Http/Controllers/Webhooks/DeleteController.php@@ -25,7 +25,6 @@ namespace FireflyIII\Http\Controllers\Webhooks;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\Webhook;-use FireflyIII\Repositories\Account\AccountRepositoryInterface;use Illuminate\Contracts\View\Factory;use Illuminate\Http\RedirectResponse;use Illuminate\Routing\Redirector;@@ -50,8 +49,8 @@ class DeleteController extends Controllerfunction ($request, $next) {app('view')->share('mainTitleIcon', 'fa-bolt');app('view')->share('subTitleIcon', 'fa-trash');- app('view')->share('title', (string) trans('firefly.webhooks'));- app('view')->share('subTitle', (string) trans('firefly.delete_webhook'));+ app('view')->share('title', (string)trans('firefly.webhooks'));+ app('view')->share('subTitle', (string)trans('firefly.delete_webhook'));return $next($request);}@@ -61,13 +60,13 @@ class DeleteController extends Controller/*** Delete account screen.*- * @param Webhook $webhook+ * @param Webhook $webhook** @return Factory|RedirectResponse|Redirector|View*/public function index(Webhook $webhook){- $subTitle = (string) trans('firefly.delete_webhook', ['title' => $webhook->name]);+ $subTitle = (string)trans('firefly.delete_webhook', ['title' => $webhook->name]);$this->rememberPreviousUrl('webhooks.delete.url');return view('webhooks.delete', compact('webhook', 'subTitle'));diff --git a/app/Http/Controllers/Webhooks/EditController.php b/app/Http/Controllers/Webhooks/EditController.phpindex f3cf0f80f2..6f630855ca 100644--- a/app/Http/Controllers/Webhooks/EditController.php+++ b/app/Http/Controllers/Webhooks/EditController.php@@ -24,12 +24,9 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Webhooks;use FireflyIII\Http\Controllers\Controller;-use FireflyIII\Models\Account;use FireflyIII\Models\Webhook;-use FireflyIII\Repositories\Account\AccountRepositoryInterface;use Illuminate\Contracts\View\Factory;use Illuminate\Http\RedirectResponse;-use Illuminate\Http\Request;use Illuminate\Routing\Redirector;use Illuminate\View\View;@@ -52,7 +49,7 @@ class EditController extends Controllerfunction ($request, $next) {app('view')->share('mainTitleIcon', 'fa-bolt');app('view')->share('subTitleIcon', 'fa-pencil');- app('view')->share('title', (string) trans('firefly.webhooks'));+ app('view')->share('title', (string)trans('firefly.webhooks'));return $next($request);}@@ -62,13 +59,13 @@ class EditController extends Controller/*** Delete account screen.*- * @param Webhook $webhook+ * @param Webhook $webhook** @return Factory|RedirectResponse|Redirector|View*/public function index(Webhook $webhook){- $subTitle = (string) trans('firefly.edit_webhook', ['title' => $webhook->title]);+ $subTitle = (string)trans('firefly.edit_webhook', ['title' => $webhook->title]);$this->rememberPreviousUrl('webhooks.delete.url');return view('webhooks.edit', compact('webhook', 'subTitle'));diff --git a/app/Http/Controllers/Webhooks/IndexController.php b/app/Http/Controllers/Webhooks/IndexController.phpindex 801201ba7f..30c1c414b5 100644--- a/app/Http/Controllers/Webhooks/IndexController.php+++ b/app/Http/Controllers/Webhooks/IndexController.php@@ -46,16 +46,17 @@ class IndexController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-bolt');- app('view')->share('title', (string) trans('firefly.webhooks'));+ app('view')->share('title', (string)trans('firefly.webhooks'));return $next($request);});}+/*** Show debug info.*- * @param Request $request+ * @param Request $request** @return Factory|View* @throws FireflyExceptiondiff --git a/app/Http/Controllers/Webhooks/ShowController.php b/app/Http/Controllers/Webhooks/ShowController.phpindex 344132dc69..236461d339 100644--- a/app/Http/Controllers/Webhooks/ShowController.php+++ b/app/Http/Controllers/Webhooks/ShowController.php@@ -24,12 +24,9 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Webhooks;use FireflyIII\Http\Controllers\Controller;-use FireflyIII\Models\Account;use FireflyIII\Models\Webhook;-use FireflyIII\Repositories\Account\AccountRepositoryInterface;use Illuminate\Contracts\View\Factory;use Illuminate\Http\RedirectResponse;-use Illuminate\Http\Request;use Illuminate\Routing\Redirector;use Illuminate\View\View;@@ -52,7 +49,7 @@ class ShowController extends Controllerfunction ($request, $next) {app('view')->share('mainTitleIcon', 'fa-bolt');app('view')->share('subTitleIcon', 'fa-bolt');- app('view')->share('title', (string) trans('firefly.webhooks'));+ app('view')->share('title', (string)trans('firefly.webhooks'));return $next($request);}@@ -62,13 +59,13 @@ class ShowController extends Controller/*** Delete account screen.*- * @param Webhook $webhook+ * @param Webhook $webhook** @return Factory|RedirectResponse|Redirector|View*/public function index(Webhook $webhook){- $subTitle = (string) trans('firefly.show_webhook', ['title' => $webhook->title]);+ $subTitle = (string)trans('firefly.show_webhook', ['title' => $webhook->title]);return view('webhooks.show', compact('webhook', 'subTitle'));}diff --git a/app/Http/Middleware/AcceptHeaders.php b/app/Http/Middleware/AcceptHeaders.phpindex 75c6eeb45e..ffbd0f77ba 100644--- a/app/Http/Middleware/AcceptHeaders.php+++ b/app/Http/Middleware/AcceptHeaders.php@@ -27,7 +27,6 @@ namespace FireflyIII\Http\Middleware;use FireflyIII\Exceptions\BadHttpHeaderException;use Illuminate\Http\Request;use Illuminate\Http\Response;-use Log;use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;/**@@ -38,8 +37,8 @@ class AcceptHeaders/*** Handle the incoming requests.*- * @param Request $request- * @param callable $next+ * @param Request $request+ * @param callable $next* @return Response* @throws BadHttpHeaderException*/@@ -50,7 +49,7 @@ class AcceptHeadersif ('GET' === $method && !$request->accepts(['application/json', 'application/vdn.api+json'])) {throw new BadHttpHeaderException('Your request must accept either application/json or application/vdn.api+json.');}- $allowed = ['application/x-www-form-urlencoded','application/json'];+ $allowed = ['application/x-www-form-urlencoded', 'application/json'];$submitted = (string)$request->header('Content-Type');if (('POST' === $method || 'PUT' === $method) && !in_array($submitted, $allowed, true)) {$error = new BadHttpHeaderException(sprintf('Content-Type cannot be "%s"', $submitted));diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.phpindex 236ac192c8..1507af86b6 100644--- a/app/Http/Middleware/Authenticate.php+++ b/app/Http/Middleware/Authenticate.php@@ -47,7 +47,7 @@ class Authenticate/*** Create a new middleware instance.*- * @param Auth $auth+ * @param Auth $auth** @return void*/@@ -59,9 +59,9 @@ class Authenticate/*** Handle an incoming request.*- * @param Request $request- * @param Closure $next- * @param string[] ...$guards+ * @param Request $request+ * @param Closure $next+ * @param string[] ...$guards** @return mixed*@@ -78,8 +78,8 @@ class Authenticate/*** Determine if the user is logged in to any of the given guards.*- * @param mixed $request- * @param array $guards+ * @param mixed $request+ * @param array $guards** @return mixed* @throws FireflyException@@ -94,10 +94,10 @@ class Authenticate// do an extra check on user object./** @var User $user */$user = $this->auth->authenticate();- if (1 === (int) $user->blocked) {- $message = (string) trans('firefly.block_account_logout');+ if (1 === (int)$user->blocked) {+ $message = (string)trans('firefly.block_account_logout');if ('email_changed' === $user->blocked_code) {- $message = (string) trans('firefly.email_changed_logout');+ $message = (string)trans('firefly.email_changed_logout');}app('session')->flash('logoutMessage', $message);$this->auth->logout();diff --git a/app/Http/Middleware/Binder.php b/app/Http/Middleware/Binder.phpindex fb5255a15d..7f8287486c 100644--- a/app/Http/Middleware/Binder.php+++ b/app/Http/Middleware/Binder.php@@ -1,4 +1,5 @@<?php+/*** Binder.php* Copyright (c) 2019 [email protected]@@ -49,7 +50,7 @@ class Binder/*** Binder constructor.*- * @param Auth $auth+ * @param Auth $auth*/public function __construct(Auth $auth){@@ -60,8 +61,8 @@ class Binder/*** Handle an incoming request.*- * @param Request $request- * @param Closure $next+ * @param Request $request+ * @param Closure $next** @return mixed*@@ -81,9 +82,9 @@ class Binder/*** Do the binding.*- * @param string $key- * @param string $value- * @param Route $route+ * @param string $key+ * @param string $value+ * @param Route $route** @return mixed*/diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.phpindex 4b3e6b0431..d0c0ba7f8e 100644--- a/app/Http/Middleware/EncryptCookies.php+++ b/app/Http/Middleware/EncryptCookies.php@@ -1,4 +1,5 @@<?php+/*** EncryptCookies.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Middleware/InstallationId.php b/app/Http/Middleware/InstallationId.phpindex 7a741e9ea6..10314bd8f6 100644--- a/app/Http/Middleware/InstallationId.php+++ b/app/Http/Middleware/InstallationId.php@@ -38,8 +38,8 @@ class InstallationId/*** Handle an incoming request.*- * @param Request $request- * @param Closure $next+ * @param Request $request+ * @param Closure $next** @return mixed*diff --git a/app/Http/Middleware/Installer.php b/app/Http/Middleware/Installer.phpindex fdfe1a723a..de0b794358 100644--- a/app/Http/Middleware/Installer.php+++ b/app/Http/Middleware/Installer.php@@ -43,8 +43,8 @@ class Installer/*** Handle an incoming request.*- * @param Request $request- * @param Closure $next+ * @param Request $request+ * @param Closure $next** @return mixed*@@ -118,7 +118,7 @@ class Installer/*** Is access denied error.*- * @param string $message+ * @param string $message** @return bool*/@@ -130,7 +130,7 @@ class Installer/*** Is no tables exist error.*- * @param string $message+ * @param string $message** @return bool*/@@ -147,8 +147,8 @@ class Installerprivate function oldDBVersion(): bool{// older version in config than database?- $configVersion = (int) config('firefly.db_version');- $dbVersion = (int) app('fireflyconfig')->getFresh('db_version', 1)->data;+ $configVersion = (int)config('firefly.db_version');+ $dbVersion = (int)app('fireflyconfig')->getFresh('db_version', 1)->data;if ($configVersion > $dbVersion) {app('log')->warning(sprintf(@@ -174,8 +174,8 @@ class Installerprivate function oldVersion(): bool{// version compare thing.- $configVersion = (string) config('firefly.version');- $dbVersion = (string) app('fireflyconfig')->getFresh('ff3_version', '1.0')->data;+ $configVersion = (string)config('firefly.version');+ $dbVersion = (string)app('fireflyconfig')->getFresh('ff3_version', '1.0')->data;if (1 === version_compare($configVersion, $dbVersion)) {app('log')->warning(sprintf(diff --git a/app/Http/Middleware/InterestingMessage.php b/app/Http/Middleware/InterestingMessage.phpindex 88759d928f..f3e264bda7 100644--- a/app/Http/Middleware/InterestingMessage.php+++ b/app/Http/Middleware/InterestingMessage.php@@ -40,8 +40,8 @@ class InterestingMessage/*** Flashes the user an interesting message if the URL parameters warrant it.*- * @param Request $request- * @param Closure $next+ * @param Request $request+ * @param Closure $next** @return mixed*@@ -82,7 +82,7 @@ class InterestingMessage}/**- * @param Request $request+ * @param Request $request** @return bool*/@@ -96,7 +96,7 @@ class InterestingMessage}/**- * @param Request $request+ * @param Request $request*/private function handleGroupMessage(Request $request): void{@@ -106,7 +106,7 @@ class InterestingMessage// send message about newly created transaction group./** @var TransactionGroup $group */- $group = auth()->user()->transactionGroups()->with(['transactionJournals', 'transactionJournals.transactionType'])->find((int) $transactionGroupId);+ $group = auth()->user()->transactionGroups()->with(['transactionJournals', 'transactionJournals.transactionType'])->find((int)$transactionGroupId);if (null === $group) {return;@@ -122,22 +122,22 @@ class InterestingMessage$title = $count > 1 ? $group->title : $journal->description;if ('created' === $message) {session()->flash('success_url', route('transactions.show', [$transactionGroupId]));- session()->flash('success', (string) trans('firefly.stored_journal', ['description' => $title]));+ session()->flash('success', (string)trans('firefly.stored_journal', ['description' => $title]));}if ('updated' === $message) {$type = strtolower($journal->transactionType->type);session()->flash('success_url', route('transactions.show', [$transactionGroupId]));- session()->flash('success', (string) trans(sprintf('firefly.updated_%s', $type), ['description' => $title]));+ session()->flash('success', (string)trans(sprintf('firefly.updated_%s', $type), ['description' => $title]));}if ('no_change' === $message) {$type = strtolower($journal->transactionType->type);session()->flash('warning_url', route('transactions.show', [$transactionGroupId]));- session()->flash('warning', (string) trans(sprintf('firefly.no_changes_%s', $type), ['description' => $title]));+ session()->flash('warning', (string)trans(sprintf('firefly.no_changes_%s', $type), ['description' => $title]));}}/**- * @param Request $request+ * @param Request $request** @return bool*/@@ -151,7 +151,7 @@ class InterestingMessage}/**- * @param Request $request+ * @param Request $request*/private function handleAccountMessage(Request $request): void{@@ -166,18 +166,18 @@ class InterestingMessagereturn;}if ('deleted' === $message) {- session()->flash('success', (string) trans('firefly.account_deleted', ['name' => $account->name]));+ session()->flash('success', (string)trans('firefly.account_deleted', ['name' => $account->name]));}if ('created' === $message) {- session()->flash('success', (string) trans('firefly.stored_new_account', ['name' => $account->name]));+ session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));}if ('updated' === $message) {- session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));+ session()->flash('success', (string)trans('firefly.updated_account', ['name' => $account->name]));}}/**- * @param Request $request+ * @param Request $request** @return bool*/@@ -189,22 +189,9 @@ class InterestingMessagereturn null !== $billId && null !== $message;}- /**- * @param Request $request- *- * @return bool- */- private function webhookMessage(Request $request): bool- {- // get parameters from request.- $billId = $request->get('webhook_id');- $message = $request->get('message');-- return null !== $billId && null !== $message;- }/**- * @param Request $request+ * @param Request $request*/private function handleBillMessage(Request $request): void{@@ -219,22 +206,36 @@ class InterestingMessagereturn;}if ('deleted' === $message) {- session()->flash('success', (string) trans('firefly.deleted_bill', ['name' => $bill->name]));+ session()->flash('success', (string)trans('firefly.deleted_bill', ['name' => $bill->name]));}if ('created' === $message) {- session()->flash('success', (string) trans('firefly.stored_new_bill', ['name' => $bill->name]));+ session()->flash('success', (string)trans('firefly.stored_new_bill', ['name' => $bill->name]));}}/**- * @param Request $request+ * @param Request $request+ *+ * @return bool*/- private function handleWebhookMessage(Request $request): void+ private function webhookMessage(Request $request): bool{// get parameters from request.- $webhookId = $request->get('webhook_id');+ $billId = $request->get('webhook_id');$message = $request->get('message');+ return null !== $billId && null !== $message;+ }++ /**+ * @param Request $request+ */+ private function handleWebhookMessage(Request $request): void+ {+ // get parameters from request.+ $webhookId = $request->get('webhook_id');+ $message = $request->get('message');+/** @var Webhook $webhook */$webhook = auth()->user()->webhooks()->withTrashed()->find($webhookId);@@ -242,13 +243,13 @@ class InterestingMessagereturn;}if ('deleted' === $message) {- session()->flash('success', (string) trans('firefly.deleted_webhook', ['title' => $webhook->title]));+ session()->flash('success', (string)trans('firefly.deleted_webhook', ['title' => $webhook->title]));}if ('updated' === $message) {- session()->flash('success', (string) trans('firefly.updated_webhook', ['title' => $webhook->title]));+ session()->flash('success', (string)trans('firefly.updated_webhook', ['title' => $webhook->title]));}if ('created' === $message) {- session()->flash('success', (string) trans('firefly.stored_new_webhook', ['title' => $webhook->title]));+ session()->flash('success', (string)trans('firefly.stored_new_webhook', ['title' => $webhook->title]));}}}diff --git a/app/Http/Middleware/IsAdmin.php b/app/Http/Middleware/IsAdmin.phpindex 8386c3fe93..32d8b04c98 100644--- a/app/Http/Middleware/IsAdmin.php+++ b/app/Http/Middleware/IsAdmin.php@@ -1,4 +1,5 @@<?php+/*** IsAdmin.php* Copyright (c) 2019 [email protected]@@ -36,9 +37,9 @@ class IsAdmin/*** Handle an incoming request. Must be admin.*- * @param Request $request- * @param Closure $next- * @param string|null $guard+ * @param Request $request+ * @param Closure $next+ * @param string|null $guard** @return mixed*/diff --git a/app/Http/Middleware/IsDemoUser.php b/app/Http/Middleware/IsDemoUser.phpindex f3d915530f..6ce1d912e2 100644--- a/app/Http/Middleware/IsDemoUser.php+++ b/app/Http/Middleware/IsDemoUser.php@@ -1,4 +1,5 @@<?php+/*** IsDemoUser.php* Copyright (c) 2019 [email protected]@@ -36,8 +37,8 @@ class IsDemoUser/*** Handle an incoming request.*- * @param Request $request- * @param Closure $next+ * @param Request $request+ * @param Closure $next** @return mixed*/@@ -53,7 +54,7 @@ class IsDemoUser$repository = app(UserRepositoryInterface::class);if ($repository->hasRole($user, 'demo')) {Log::info('User is a demo user.');- $request->session()->flash('info', (string) trans('firefly.not_available_demo_user'));+ $request->session()->flash('info', (string)trans('firefly.not_available_demo_user'));$current = $request->url();$previous = $request->session()->previousUrl();if ($current !== $previous) {diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.phpindex 8d1313f7a8..3db1a776a9 100644--- a/app/Http/Middleware/Range.php+++ b/app/Http/Middleware/Range.php@@ -1,4 +1,5 @@<?php+/*** Range.php* Copyright (c) 2019 [email protected]@@ -40,8 +41,8 @@ class Range/*** Handle an incoming request.*- * @param Request $request- * @param Closure $next+ * @param Request $request+ * @param Closure $next** @return mixed*/@@ -112,12 +113,12 @@ class Range}// save some formats:- $monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);- $dateTimeFormat = (string) trans('config.date_time_js', [], $locale);+ $monthAndDayFormat = (string)trans('config.month_and_day_js', [], $locale);+ $dateTimeFormat = (string)trans('config.date_time_js', [], $locale);$defaultCurrency = app('amount')->getDefaultCurrency();// also format for moment JS:- $madMomentJS = (string) trans('config.month_and_day_moment_js', [], $locale);+ $madMomentJS = (string)trans('config.month_and_day_moment_js', [], $locale);app('view')->share('madMomentJS', $madMomentJS);app('view')->share('monthAndDayFormat', $monthAndDayFormat);diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.phpindex 9b17c7f49a..d48dbcb893 100644--- a/app/Http/Middleware/RedirectIfAuthenticated.php+++ b/app/Http/Middleware/RedirectIfAuthenticated.php@@ -1,4 +1,5 @@<?php+/*** RedirectIfAuthenticated.php* Copyright (c) 2019 [email protected]@@ -36,9 +37,9 @@ class RedirectIfAuthenticated/*** Handle an incoming request.*- * @param Request $request- * @param Closure $next- * @param string|null $guard+ * @param Request $request+ * @param Closure $next+ * @param string|null $guard** @return mixed*/diff --git a/app/Http/Middleware/SecureHeaders.php b/app/Http/Middleware/SecureHeaders.phpindex 462c6e7ee0..443bf866c4 100644--- a/app/Http/Middleware/SecureHeaders.php+++ b/app/Http/Middleware/SecureHeaders.php@@ -36,8 +36,8 @@ class SecureHeaders/*** Handle an incoming request.*- * @param Request $request- * @param Closure $next+ * @param Request $request+ * @param Closure $next** @return mixed* @throws Exception@@ -64,8 +64,8 @@ class SecureHeaders$route = $request->route();$customUrl = '';- $authGuard = (string) config('firefly.authentication_guard');- $logoutUrl = (string) config('firefly.custom_logout_url');+ $authGuard = (string)config('firefly.authentication_guard');+ $logoutUrl = (string)config('firefly.custom_logout_url');if ('remote_user_guard' === $authGuard && '' !== $logoutUrl) {$customUrl = $logoutUrl;}@@ -115,8 +115,8 @@ class SecureHeaders*/private function getTrackingScriptSource(): string{- if ('' !== (string) config('firefly.tracker_site_id') && '' !== (string) config('firefly.tracker_url')) {- return (string) config('firefly.tracker_url');+ if ('' !== (string)config('firefly.tracker_site_id') && '' !== (string)config('firefly.tracker_url')) {+ return (string)config('firefly.tracker_url');}return '';diff --git a/app/Http/Middleware/StartFireflySession.php b/app/Http/Middleware/StartFireflySession.phpindex 20d1d7d4e6..2ae301774c 100644--- a/app/Http/Middleware/StartFireflySession.php+++ b/app/Http/Middleware/StartFireflySession.php@@ -1,4 +1,5 @@<?php+/*** StartFireflySession.php* Copyright (c) 2019 [email protected]@@ -36,8 +37,8 @@ class StartFireflySession extends StartSession/*** Store the current URL for the request if necessary.*- * @param Request $request- * @param Session $session+ * @param Request $request+ * @param Session $session*/protected function storeCurrentUrl(Request $request, $session): void{diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.phpindex 8753eaea56..fc3a8d14da 100644--- a/app/Http/Middleware/TrimStrings.php+++ b/app/Http/Middleware/TrimStrings.php@@ -1,4 +1,5 @@<?php+/*** TrimStrings.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.phpindex 022d1a1858..aaa48350c7 100644--- a/app/Http/Middleware/TrustProxies.php+++ b/app/Http/Middleware/TrustProxies.php@@ -1,4 +1,5 @@<?php+/*** TrustProxies.php* Copyright (c) 2019 [email protected]@@ -45,6 +46,6 @@ class TrustProxies extends Middleware*/public function __construct(){- $this->proxies = (string) config('firefly.trusted_proxies');+ $this->proxies = (string)config('firefly.trusted_proxies');}}diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.phpindex 195b27daaa..8f53afdccd 100644--- a/app/Http/Middleware/VerifyCsrfToken.php+++ b/app/Http/Middleware/VerifyCsrfToken.php@@ -1,4 +1,5 @@<?php+/*** VerifyCsrfToken.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.phpindex af65b69f1d..b9281b9d0a 100644--- a/app/Http/Requests/AccountFormRequest.php+++ b/app/Http/Requests/AccountFormRequest.php@@ -1,4 +1,5 @@<?php+/*** AccountFormRequest.php* Copyright (c) 2019 [email protected]@@ -107,12 +108,12 @@ class AccountFormRequest extends FormRequest'virtual_balance' => 'numeric|nullable|max:1000000000','currency_id' => 'exists:transaction_currencies,id','account_number' => 'between:1,255|uniqueAccountNumberForUser|nullable',- 'account_role' => 'in:' . $accountRoles,+ 'account_role' => 'in:'.$accountRoles,'active' => 'boolean',- 'cc_type' => 'in:' . $ccPaymentTypes,+ 'cc_type' => 'in:'.$ccPaymentTypes,'amount_currency_id_opening_balance' => 'exists:transaction_currencies,id','amount_currency_id_virtual_balance' => 'exists:transaction_currencies,id',- 'what' => 'in:' . $types,+ 'what' => 'in:'.$types,'interest_period' => 'in:daily,monthly,yearly',];$rules = Location::requestRules($rules);@@ -122,7 +123,7 @@ class AccountFormRequest extends FormRequestif (null !== $account) {// add rules:$rules['id'] = 'belongsToUser:accounts';- $rules['name'] = 'required|min:1|uniqueAccountForUser:' . $account->id;+ $rules['name'] = 'required|min:1|uniqueAccountForUser:'.$account->id;$rules['iban'] = ['iban', 'nullable', new UniqueIban($account, $account->accountType->type)];}diff --git a/app/Http/Requests/AttachmentFormRequest.php b/app/Http/Requests/AttachmentFormRequest.phpindex 11dfbcf69f..c02d58d1ca 100644--- a/app/Http/Requests/AttachmentFormRequest.php+++ b/app/Http/Requests/AttachmentFormRequest.php@@ -1,4 +1,5 @@<?php+/*** AttachmentFormRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/BillStoreRequest.php b/app/Http/Requests/BillStoreRequest.phpindex 596bff95d8..8b2ef19b54 100644--- a/app/Http/Requests/BillStoreRequest.php+++ b/app/Http/Requests/BillStoreRequest.php@@ -1,4 +1,5 @@<?php+/*** BillStoreRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/BillUpdateRequest.php b/app/Http/Requests/BillUpdateRequest.phpindex 003feec81b..d205a6d680 100644--- a/app/Http/Requests/BillUpdateRequest.php+++ b/app/Http/Requests/BillUpdateRequest.php@@ -1,4 +1,5 @@<?php+/*** BillUpdateRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/BudgetFormStoreRequest.php b/app/Http/Requests/BudgetFormStoreRequest.phpindex 4dfa42224d..3788013236 100644--- a/app/Http/Requests/BudgetFormStoreRequest.php+++ b/app/Http/Requests/BudgetFormStoreRequest.php@@ -1,4 +1,5 @@<?php+/*** BudgetFormStoreRequest.php* Copyright (c) 2019 [email protected]@@ -75,7 +76,7 @@ class BudgetFormStoreRequest extends FormRequest/*** Configure the validator instance with special rules for after the basic validation rules.*- * @param Validator $validator+ * @param Validator $validator** @return void*/diff --git a/app/Http/Requests/BudgetFormUpdateRequest.php b/app/Http/Requests/BudgetFormUpdateRequest.phpindex 68bd47144a..c4ef14971e 100644--- a/app/Http/Requests/BudgetFormUpdateRequest.php+++ b/app/Http/Requests/BudgetFormUpdateRequest.php@@ -1,4 +1,5 @@<?php+/*** BudgetFormRequest.php* Copyright (c) 2019 [email protected]@@ -69,7 +70,7 @@ class BudgetFormUpdateRequest extends FormRequest$budget = $this->route()->parameter('budget');if (null !== $budget) {- $nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,' . $budget->id;+ $nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,'.$budget->id;}return [@@ -85,7 +86,7 @@ class BudgetFormUpdateRequest extends FormRequest/*** Configure the validator instance with special rules for after the basic validation rules.*- * @param Validator $validator+ * @param Validator $validator** @return void*/diff --git a/app/Http/Requests/BudgetIncomeRequest.php b/app/Http/Requests/BudgetIncomeRequest.phpindex aa99bf336a..bc500c7e8b 100644--- a/app/Http/Requests/BudgetIncomeRequest.php+++ b/app/Http/Requests/BudgetIncomeRequest.php@@ -1,4 +1,5 @@<?php+/*** BudgetIncomeRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/BulkEditJournalRequest.php b/app/Http/Requests/BulkEditJournalRequest.phpindex 8457483917..1f8c04074e 100644--- a/app/Http/Requests/BulkEditJournalRequest.php+++ b/app/Http/Requests/BulkEditJournalRequest.php@@ -1,4 +1,5 @@<?php+/*** BulkEditJournalRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/CategoryFormRequest.php b/app/Http/Requests/CategoryFormRequest.phpindex d22cadddad..476140da26 100644--- a/app/Http/Requests/CategoryFormRequest.php+++ b/app/Http/Requests/CategoryFormRequest.php@@ -1,4 +1,5 @@<?php+/*** CategoryFormRequest.php* Copyright (c) 2019 [email protected]@@ -60,7 +61,7 @@ class CategoryFormRequest extends FormRequest$category = $this->route()->parameter('category');if (null !== $category) {- $nameRule = 'required|between:1,100|uniqueObjectForUser:categories,name,' . $category->id;+ $nameRule = 'required|between:1,100|uniqueObjectForUser:categories,name,'.$category->id;}// fixeddiff --git a/app/Http/Requests/ConfigurationRequest.php b/app/Http/Requests/ConfigurationRequest.phpindex 41dc970169..14b7267ad0 100644--- a/app/Http/Requests/ConfigurationRequest.php+++ b/app/Http/Requests/ConfigurationRequest.php@@ -1,4 +1,5 @@<?php+/*** ConfigurationRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/CurrencyFormRequest.php b/app/Http/Requests/CurrencyFormRequest.phpindex a3b50f5599..b0048f8496 100644--- a/app/Http/Requests/CurrencyFormRequest.php+++ b/app/Http/Requests/CurrencyFormRequest.php@@ -1,4 +1,5 @@<?php+/*** CurrencyFormRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/DeleteAccountFormRequest.php b/app/Http/Requests/DeleteAccountFormRequest.phpindex 8f5a9b3e39..774e81f493 100644--- a/app/Http/Requests/DeleteAccountFormRequest.php+++ b/app/Http/Requests/DeleteAccountFormRequest.php@@ -1,4 +1,5 @@<?php+/*** DeleteAccountFormRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/EmailFormRequest.php b/app/Http/Requests/EmailFormRequest.phpindex 81df95ea18..25540c62f5 100644--- a/app/Http/Requests/EmailFormRequest.php+++ b/app/Http/Requests/EmailFormRequest.php@@ -1,4 +1,5 @@<?php+/*** EmailFormRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/JournalLinkRequest.php b/app/Http/Requests/JournalLinkRequest.phpindex 52996db13b..7eb14cbee6 100644--- a/app/Http/Requests/JournalLinkRequest.php+++ b/app/Http/Requests/JournalLinkRequest.php@@ -1,4 +1,5 @@<?php+/*** JournalLinkRequest.php* Copyright (c) 2019 [email protected]@@ -45,7 +46,7 @@ class JournalLinkRequest extends FormRequest$return = [];$linkType = $this->get('link_type');$parts = explode('_', $linkType);- $return['link_type_id'] = (int) $parts[0];+ $return['link_type_id'] = (int)$parts[0];$return['transaction_journal_id'] = $this->convertInteger('opposing');$return['notes'] = $this->convertString('notes');$return['direction'] = $parts[1];diff --git a/app/Http/Requests/LinkTypeFormRequest.php b/app/Http/Requests/LinkTypeFormRequest.phpindex 3df1effbe3..d8864ba15e 100644--- a/app/Http/Requests/LinkTypeFormRequest.php+++ b/app/Http/Requests/LinkTypeFormRequest.php@@ -1,4 +1,5 @@<?php+/*** LinkTypeFormRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/MassDeleteJournalRequest.php b/app/Http/Requests/MassDeleteJournalRequest.phpindex 797b26573f..5d9e4036c1 100644--- a/app/Http/Requests/MassDeleteJournalRequest.php+++ b/app/Http/Requests/MassDeleteJournalRequest.php@@ -1,4 +1,5 @@<?php+/*** MassDeleteJournalRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/MassEditJournalRequest.php b/app/Http/Requests/MassEditJournalRequest.phpindex af3fceb33c..d02bfcd182 100644--- a/app/Http/Requests/MassEditJournalRequest.php+++ b/app/Http/Requests/MassEditJournalRequest.php@@ -1,4 +1,5 @@<?php+/*** MassEditJournalRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/NewUserFormRequest.php b/app/Http/Requests/NewUserFormRequest.phpindex d965f4bbb5..f523f7ca04 100644--- a/app/Http/Requests/NewUserFormRequest.php+++ b/app/Http/Requests/NewUserFormRequest.php@@ -1,4 +1,5 @@<?php+/*** NewUserFormRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/ObjectGroupFormRequest.php b/app/Http/Requests/ObjectGroupFormRequest.phpindex 8b6c5fa6fb..cabec0d41d 100644--- a/app/Http/Requests/ObjectGroupFormRequest.php+++ b/app/Http/Requests/ObjectGroupFormRequest.php@@ -1,4 +1,5 @@<?php+/*** ObjectGroupFormRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/PiggyBankStoreRequest.php b/app/Http/Requests/PiggyBankStoreRequest.phpindex 586f27c196..b4baa67c46 100644--- a/app/Http/Requests/PiggyBankStoreRequest.php+++ b/app/Http/Requests/PiggyBankStoreRequest.php@@ -1,4 +1,5 @@<?php+/*** PiggyBankStoreRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/PiggyBankUpdateRequest.php b/app/Http/Requests/PiggyBankUpdateRequest.phpindex df178f1ab3..7df2c58629 100644--- a/app/Http/Requests/PiggyBankUpdateRequest.php+++ b/app/Http/Requests/PiggyBankUpdateRequest.php@@ -1,4 +1,5 @@<?php+/*** PiggyBankUpdateRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/ProfileFormRequest.php b/app/Http/Requests/ProfileFormRequest.phpindex ae40c1113e..4bb3b789f4 100644--- a/app/Http/Requests/ProfileFormRequest.php+++ b/app/Http/Requests/ProfileFormRequest.php@@ -1,4 +1,5 @@<?php+/*** ProfileFormRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/RecurrenceFormRequest.php b/app/Http/Requests/RecurrenceFormRequest.phpindex b607162ca0..806e301483 100644--- a/app/Http/Requests/RecurrenceFormRequest.php+++ b/app/Http/Requests/RecurrenceFormRequest.php@@ -191,7 +191,7 @@ class RecurrenceFormRequest extends FormRequest$rules = [// mandatory info for recurrence.'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',- 'first_date' => 'required|date|after:' . $today->format('Y-m-d'),+ 'first_date' => 'required|date|after:'.$today->format('Y-m-d'),'repetition_type' => ['required', new ValidRecurrenceRepetitionValue(), new ValidRecurrenceRepetitionType(), 'between:1,20'],'skip' => 'required|numeric|integer|gte:0|lte:31',@@ -235,7 +235,7 @@ class RecurrenceFormRequest extends FormRequest// if ends at date X, set another rule.if ('until_date' === $this->convertString('repetition_end')) {- $rules['repeat_until'] = 'required|date|after:' . $tomorrow->format('Y-m-d');+ $rules['repeat_until'] = 'required|date|after:'.$tomorrow->format('Y-m-d');}// switch on type to expand rules for source and destination accounts:@@ -263,7 +263,7 @@ class RecurrenceFormRequest extends FormRequest$recurrence = $this->route()->parameter('recurrence');if ($recurrence instanceof Recurrence) {$rules['id'] = 'required|numeric|exists:recurrences,id';- $rules['title'] = 'required|between:1,255|uniqueObjectForUser:recurrences,title,' . $recurrence->id;+ $rules['title'] = 'required|between:1,255|uniqueObjectForUser:recurrences,title,'.$recurrence->id;$rules['first_date'] = 'required|date';}@@ -273,7 +273,7 @@ class RecurrenceFormRequest extends FormRequest/*** Configure the validator instance with special rules for after the basic validation rules.*- * @param Validator $validator+ * @param Validator $validator** @return void*/@@ -290,7 +290,7 @@ class RecurrenceFormRequest extends FormRequest/*** Validates the given account information. Switches on given transaction type.*- * @param Validator $validator+ * @param Validator $validator** @throws FireflyException*/@@ -314,16 +314,16 @@ class RecurrenceFormRequest extends FormRequestdefault:throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->convertString('transaction_type')));case 'withdrawal':- $sourceId = (int) $data['source_id'];- $destinationId = (int) $data['withdrawal_destination_id'];+ $sourceId = (int)$data['source_id'];+ $destinationId = (int)$data['withdrawal_destination_id'];break;case 'deposit':- $sourceId = (int) $data['deposit_source_id'];- $destinationId = (int) $data['destination_id'];+ $sourceId = (int)$data['deposit_source_id'];+ $destinationId = (int)$data['destination_id'];break;case 'transfer':- $sourceId = (int) $data['source_id'];- $destinationId = (int) $data['destination_id'];+ $sourceId = (int)$data['source_id'];+ $destinationId = (int)$data['destination_id'];break;}// validate source account.@@ -331,7 +331,7 @@ class RecurrenceFormRequest extends FormRequest// do something with result:if (false === $validSource) {- $message = (string) trans('validation.generic_invalid_source');+ $message = (string)trans('validation.generic_invalid_source');$validator->errors()->add('source_id', $message);$validator->errors()->add('deposit_source_id', $message);@@ -342,7 +342,7 @@ class RecurrenceFormRequest extends FormRequest$validDestination = $accountValidator->validateDestination(['id' => $destinationId,]);// do something with result:if (false === $validDestination) {- $message = (string) trans('validation.generic_invalid_destination');+ $message = (string)trans('validation.generic_invalid_destination');$validator->errors()->add('destination_id', $message);$validator->errors()->add('withdrawal_destination_id', $message);}diff --git a/app/Http/Requests/ReportFormRequest.php b/app/Http/Requests/ReportFormRequest.phpindex 3b5274f3cd..2fbea87a78 100644--- a/app/Http/Requests/ReportFormRequest.php+++ b/app/Http/Requests/ReportFormRequest.php@@ -1,4 +1,5 @@<?php+/*** ReportFormRequest.php* Copyright (c) 2019 [email protected]@@ -55,7 +56,7 @@ class ReportFormRequest extends FormRequest$collection = new Collection();if (is_array($set)) {foreach ($set as $accountId) {- $account = $repository->find((int) $accountId);+ $account = $repository->find((int)$accountId);if (null !== $account) {$collection->push($account);}@@ -78,7 +79,7 @@ class ReportFormRequest extends FormRequest$collection = new Collection();if (is_array($set)) {foreach ($set as $budgetId) {- $budget = $repository->find((int) $budgetId);+ $budget = $repository->find((int)$budgetId);if (null !== $budget) {$collection->push($budget);}@@ -101,7 +102,7 @@ class ReportFormRequest extends FormRequest$collection = new Collection();if (is_array($set)) {foreach ($set as $categoryId) {- $category = $repository->find((int) $categoryId);+ $category = $repository->find((int)$categoryId);if (null !== $category) {$collection->push($category);}@@ -124,7 +125,7 @@ class ReportFormRequest extends FormRequest$collection = new Collection();if (is_array($set)) {foreach ($set as $accountId) {- $account = $repository->find((int) $accountId);+ $account = $repository->find((int)$accountId);if (null !== $account) {$collection->push($account);}@@ -145,7 +146,7 @@ class ReportFormRequest extends FormRequest{$date = today(config('app.timezone'));$range = $this->get('daterange');- $parts = explode(' - ', (string) $range);+ $parts = explode(' - ', (string)$range);if (2 === count($parts)) {$string = $parts[1];// validate as date@@ -179,7 +180,7 @@ class ReportFormRequest extends FormRequest{$date = today(config('app.timezone'));$range = $this->get('daterange');- $parts = explode(' - ', (string) $range);+ $parts = explode(' - ', (string)$range);if (2 === count($parts)) {$string = $parts[0];// validate as date@@ -223,7 +224,7 @@ class ReportFormRequest extends FormRequest$collection->push($tag);continue;}- $tag = $repository->find((int) $tagTag);+ $tag = $repository->find((int)$tagTag);if (null !== $tag) {$collection->push($tag);}diff --git a/app/Http/Requests/RuleGroupFormRequest.php b/app/Http/Requests/RuleGroupFormRequest.phpindex 89b37bf34f..3b23ecc0f7 100644--- a/app/Http/Requests/RuleGroupFormRequest.php+++ b/app/Http/Requests/RuleGroupFormRequest.php@@ -1,4 +1,5 @@<?php+/*** RuleGroupFormRequest.php* Copyright (c) 2019 [email protected]@@ -68,7 +69,7 @@ class RuleGroupFormRequest extends FormRequest$ruleGroup = $this->route()->parameter('ruleGroup');if (null !== $ruleGroup) {- $titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title,' . $ruleGroup->id;+ $titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title,'.$ruleGroup->id;}return [diff --git a/app/Http/Requests/SelectTransactionsRequest.php b/app/Http/Requests/SelectTransactionsRequest.phpindex e52c1d3cfd..c7a84cd23a 100644--- a/app/Http/Requests/SelectTransactionsRequest.php+++ b/app/Http/Requests/SelectTransactionsRequest.php@@ -1,4 +1,5 @@<?php+/*** SelectTransactionsRequest.php* Copyright (c) 2019 [email protected]@@ -49,8 +50,8 @@ class SelectTransactionsRequest extends FormRequest$today = Carbon::now()->addDay()->format('Y-m-d');return [- 'start' => 'required|date|after:' . $first,- 'end' => 'required|date|before:' . $today,+ 'start' => 'required|date|after:'.$first,+ 'end' => 'required|date|before:'.$today,'accounts' => 'required','accounts.*' => 'required|exists:accounts,id|belongsToUser:accounts',];diff --git a/app/Http/Requests/TagFormRequest.php b/app/Http/Requests/TagFormRequest.phpindex f63754c9a9..25adcd9450 100644--- a/app/Http/Requests/TagFormRequest.php+++ b/app/Http/Requests/TagFormRequest.php@@ -1,4 +1,5 @@<?php+/*** TagFormRequest.php* Copyright (c) 2019 [email protected]@@ -68,7 +69,7 @@ class TagFormRequest extends FormRequest$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag';if (null !== $tag) {$idRule = 'belongsToUser:tags';- $tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,' . $tag->id;+ $tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,'.$tag->id;}$rules = [diff --git a/app/Http/Requests/TestRuleFormRequest.php b/app/Http/Requests/TestRuleFormRequest.phpindex e80042afc9..3c6d7bdf37 100644--- a/app/Http/Requests/TestRuleFormRequest.php+++ b/app/Http/Requests/TestRuleFormRequest.php@@ -1,4 +1,5 @@<?php+/*** TestRuleFormRequest.php* Copyright (c) 2019 [email protected]@@ -48,7 +49,7 @@ class TestRuleFormRequest extends FormRequest$validTriggers = $this->getTriggers();return [- 'rule-trigger.*' => 'required|min:1|in:' . implode(',', $validTriggers),+ 'rule-trigger.*' => 'required|min:1|in:'.implode(',', $validTriggers),'rule-trigger-value.*' => 'required|min:1|ruleTriggerValue',];}diff --git a/app/Http/Requests/TokenFormRequest.php b/app/Http/Requests/TokenFormRequest.phpindex e7c45ad2cc..8245fafa37 100644--- a/app/Http/Requests/TokenFormRequest.php+++ b/app/Http/Requests/TokenFormRequest.php@@ -1,4 +1,5 @@<?php+/*** TokenFormRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/TriggerRecurrenceRequest.php b/app/Http/Requests/TriggerRecurrenceRequest.phpindex 23474e9c8b..6add29444e 100644--- a/app/Http/Requests/TriggerRecurrenceRequest.php+++ b/app/Http/Requests/TriggerRecurrenceRequest.php@@ -1,4 +1,5 @@<?php+declare(strict_types=1);/** TriggerRecurrenceRequest.phpdiff --git a/app/Http/Requests/UserFormRequest.php b/app/Http/Requests/UserFormRequest.phpindex f48d0cb289..ceea33a1a9 100644--- a/app/Http/Requests/UserFormRequest.php+++ b/app/Http/Requests/UserFormRequest.php@@ -1,4 +1,5 @@<?php+/*** UserFormRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Http/Requests/UserRegistrationRequest.php b/app/Http/Requests/UserRegistrationRequest.phpindex 46d6092805..02831d3fb4 100644--- a/app/Http/Requests/UserRegistrationRequest.php+++ b/app/Http/Requests/UserRegistrationRequest.php@@ -1,4 +1,5 @@<?php+/*** UserRegistrationRequest.php* Copyright (c) 2019 [email protected]diff --git a/app/Jobs/CreateAutoBudgetLimits.php b/app/Jobs/CreateAutoBudgetLimits.phpindex 7c3f42da97..42e9af5f0e 100644--- a/app/Jobs/CreateAutoBudgetLimits.php+++ b/app/Jobs/CreateAutoBudgetLimits.php@@ -55,7 +55,7 @@ class CreateAutoBudgetLimits implements ShouldQueue** @codeCoverageIgnore*- * @param Carbon|null $date+ * @param Carbon|null $date*/public function __construct(?Carbon $date){@@ -83,7 +83,7 @@ class CreateAutoBudgetLimits implements ShouldQueue}/**- * @param AutoBudget $autoBudget+ * @param AutoBudget $autoBudget** @throws FireflyException*/@@ -133,7 +133,7 @@ class CreateAutoBudgetLimits implements ShouldQueue// find budget limit:$budgetLimit = $this->findBudgetLimit($autoBudget->budget, $start, $end);- if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_RESET === (int) $autoBudget->auto_budget_type) {+ if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_RESET === (int)$autoBudget->auto_budget_type) {// that's easy: create one.// do nothing else.$this->createBudgetLimit($autoBudget, $start, $end);@@ -142,7 +142,7 @@ class CreateAutoBudgetLimits implements ShouldQueuereturn;}- if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_ROLLOVER === (int) $autoBudget->auto_budget_type) {+ if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_ROLLOVER === (int)$autoBudget->auto_budget_type) {// budget limit exists already,$this->createRollover($autoBudget);Log::debug(sprintf('Done with auto budget #%d', $autoBudget->id));@@ -153,7 +153,7 @@ class CreateAutoBudgetLimits implements ShouldQueue}/**- * @param AutoBudget $autoBudget+ * @param AutoBudget $autoBudget** @return bool* @throws FireflyException@@ -190,9 +190,9 @@ class CreateAutoBudgetLimits implements ShouldQueue}/**- * @param Budget $budget- * @param Carbon $start- * @param Carbon $end+ * @param Budget $budget+ * @param Carbon $start+ * @param Carbon $end** @return BudgetLimit|null*/@@ -214,10 +214,10 @@ class CreateAutoBudgetLimits implements ShouldQueue}/**- * @param AutoBudget $autoBudget- * @param Carbon $start- * @param Carbon $end- * @param string|null $amount+ * @param AutoBudget $autoBudget+ * @param Carbon $start+ * @param Carbon $end+ * @param string|null $amount*/private function createBudgetLimit(AutoBudget $autoBudget, Carbon $start, Carbon $end, ?string $amount = null){@@ -239,7 +239,7 @@ class CreateAutoBudgetLimits implements ShouldQueue}/**- * @param AutoBudget $autoBudget+ * @param AutoBudget $autoBudget** @throws FireflyException*/@@ -280,7 +280,7 @@ class CreateAutoBudgetLimits implements ShouldQueue$repository = app(OperationsRepositoryInterface::class);$repository->setUser($autoBudget->budget->user);$spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection([$autoBudget->budget]), $autoBudget->transactionCurrency);- $currencyId = (int) $autoBudget->transaction_currency_id;+ $currencyId = (int)$autoBudget->transaction_currency_id;$spentAmount = $spent[$currencyId]['sum'] ?? '0';Log::debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount));@@ -304,7 +304,7 @@ class CreateAutoBudgetLimits implements ShouldQueue}/**- * @param Carbon $date+ * @param Carbon $date*/public function setDate(Carbon $date): void{diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.phpindex 04563b115a..8d7baff791 100644--- a/app/Jobs/CreateRecurringTransactions.php+++ b/app/Jobs/CreateRecurringTransactions.php@@ -61,10 +61,10 @@ class CreateRecurringTransactions implements ShouldQueueprivate Carbon $date;private bool $force;private TransactionGroupRepositoryInterface $groupRepository;+ private Collection $groups;private JournalRepositoryInterface $journalRepository;- private RecurringRepositoryInterface $repository;private Collection $recurrences;- private Collection $groups;+ private RecurringRepositoryInterface $repository;/*** Create a new job instance.@@ -97,6 +97,14 @@ class CreateRecurringTransactions implements ShouldQueueLog::debug(sprintf('Created new CreateRecurringTransactions("%s")', $this->date->format('Y-m-d')));}+ /**+ * @return Collection+ */+ public function getGroups(): Collection+ {+ return $this->groups;+ }+/*** Execute the job.*/@@ -520,12 +528,4 @@ class CreateRecurringTransactions implements ShouldQueue{$this->recurrences = $recurrences;}-- /**- * @return Collection- */- public function getGroups(): Collection- {- return $this->groups;- }}diff --git a/app/Jobs/DownloadExchangeRates.php b/app/Jobs/DownloadExchangeRates.phpindex 98e8f74260..3e47c4e045 100644--- a/app/Jobs/DownloadExchangeRates.php+++ b/app/Jobs/DownloadExchangeRates.php@@ -47,9 +47,9 @@ class DownloadExchangeRates implements ShouldQueueuse Queueable;use SerializesModels;+ private array $active;private Carbon $date;private CurrencyRepositoryInterface $repository;- private array $active;private Collection $users;/**@@ -57,7 +57,7 @@ class DownloadExchangeRates implements ShouldQueue** @codeCoverageIgnore*- * @param Carbon|null $date+ * @param Carbon|null $date*/public function __construct(?Carbon $date){@@ -92,23 +92,13 @@ class DownloadExchangeRates implements ShouldQueue}/**- * @param Carbon $date- */- public function setDate(Carbon $date): void- {- $newDate = clone $date;- $newDate->startOfDay();- $this->date = $newDate;- }-- /**- * @param TransactionCurrency $currency+ * @param TransactionCurrency $currency* @return void*/private function downloadRates(TransactionCurrency $currency): void{Log::debug(sprintf('Now downloading new exchange rates for currency %s.', $currency->code));- $base = sprintf('%s/%s/%s', (string) config('cer.url'), $this->date->year, $this->date->isoWeek);+ $base = sprintf('%s/%s/%s', (string)config('cer.url'), $this->date->year, $this->date->isoWeek);$client = new Client();$url = sprintf('%s/%s.json', $base, $currency->code);$res = $client->get($url);@@ -117,7 +107,7 @@ class DownloadExchangeRates implements ShouldQueueapp('log')->warning(sprintf('Trying to grab "%s" resulted in status code %d.', $url, $statusCode));return;}- $body = (string) $res->getBody();+ $body = (string)$res->getBody();$json = json_decode($body, true);if (false === $json || null === $json) {app('log')->warning(sprintf('Trying to grab "%s" resulted in bad JSON.', $url));@@ -128,8 +118,8 @@ class DownloadExchangeRates implements ShouldQueue}/**- * @param TransactionCurrency $currency- * @param array $rates+ * @param TransactionCurrency $currency+ * @param array $rates* @return void*/private function saveRates(TransactionCurrency $currency, Carbon $date, array $rates): void@@ -146,7 +136,7 @@ class DownloadExchangeRates implements ShouldQueue}/**- * @param string $code+ * @param string $code* @return TransactionCurrency|null*/private function getCurrency(string $code): ?TransactionCurrency@@ -185,4 +175,14 @@ class DownloadExchangeRates implements ShouldQueue}}}++ /**+ * @param Carbon $date+ */+ public function setDate(Carbon $date): void+ {+ $newDate = clone $date;+ $newDate->startOfDay();+ $this->date = $newDate;+ }}diff --git a/app/Jobs/Job.php b/app/Jobs/Job.phpindex 7562dbfa3c..05b4952226 100644--- a/app/Jobs/Job.php+++ b/app/Jobs/Job.php@@ -1,4 +1,5 @@<?php+/*** Job.php* Copyright (c) 2019 [email protected]diff --git a/app/Jobs/MailError.php b/app/Jobs/MailError.phpindex 677c24dc83..ec5d5af0b9 100644--- a/app/Jobs/MailError.php+++ b/app/Jobs/MailError.php@@ -1,4 +1,5 @@<?php+/*** MailError.php* Copyright (c) 2019 [email protected]@@ -48,10 +49,10 @@ class MailError extends Job implements ShouldQueue/*** MailError constructor.*- * @param array $userData- * @param string $destination- * @param string $ipAddress- * @param array $exceptionData+ * @param array $userData+ * @param string $destination+ * @param string $ipAddress+ * @param array $exceptionData*/public function __construct(array $userData, string $destination, string $ipAddress, array $exceptionData){@@ -70,7 +71,7 @@ class MailError extends Job implements ShouldQueue*/public function handle(){- $email = (string) config('firefly.site_owner');+ $email = (string)config('firefly.site_owner');$args = $this->exception;$args['loggedIn'] = $this->userData['id'] > 0;$args['user'] = $this->userData;@@ -83,12 +84,12 @@ class MailError extends Job implements ShouldQueue$args,function (Message $message) use ($email) {if ('[email protected]' !== $email) {- $message->to($email, $email)->subject((string) trans('email.error_subject'));+ $message->to($email, $email)->subject((string)trans('email.error_subject'));}});} catch (Exception $e) {- Log::error('Exception when mailing: ' . $e->getMessage());+ Log::error('Exception when mailing: '.$e->getMessage());}}}diff --git a/app/Jobs/SendWebhookMessage.php b/app/Jobs/SendWebhookMessage.phpindex d628f1882f..05efaeb8a2 100644--- a/app/Jobs/SendWebhookMessage.php+++ b/app/Jobs/SendWebhookMessage.php@@ -48,7 +48,7 @@ class SendWebhookMessage implements ShouldQueue/*** Create a new job instance.*- * @param WebhookMessage $message+ * @param WebhookMessage $message*/public function __construct(WebhookMessage $message){diff --git a/app/Jobs/WarnAboutBills.php b/app/Jobs/WarnAboutBills.phpindex 353cdebc05..647e3d0372 100644--- a/app/Jobs/WarnAboutBills.php+++ b/app/Jobs/WarnAboutBills.php@@ -52,7 +52,7 @@ class WarnAboutBills implements ShouldQueue** @codeCoverageIgnore*- * @param Carbon|null $date+ * @param Carbon|null $date*/public function __construct(?Carbon $date){@@ -97,7 +97,7 @@ class WarnAboutBills implements ShouldQueue}/**- * @param Bill $bill+ * @param Bill $bill* @return bool*/private function hasDateFields(Bill $bill): bool@@ -114,8 +114,8 @@ class WarnAboutBills implements ShouldQueue}/**- * @param Bill $bill- * @param string $field+ * @param Bill $bill+ * @param string $field* @return bool*/private function needsWarning(Bill $bill, string $field): bool@@ -133,8 +133,8 @@ class WarnAboutBills implements ShouldQueue}/**- * @param Bill $bill- * @param string $field+ * @param Bill $bill+ * @param string $field* @return int*/private function getDiff(Bill $bill, string $field): int@@ -145,8 +145,8 @@ class WarnAboutBills implements ShouldQueue}/**- * @param Bill $bill- * @param string $field+ * @param Bill $bill+ * @param string $field* @return void*/private function sendWarning(Bill $bill, string $field): void@@ -157,7 +157,7 @@ class WarnAboutBills implements ShouldQueue}/**- * @param Carbon $date+ * @param Carbon $date*/public function setDate(Carbon $date): void{@@ -167,7 +167,7 @@ class WarnAboutBills implements ShouldQueue}/**- * @param bool $force+ * @param bool $force*/public function setForce(bool $force): void{diff --git a/app/Mail/AccessTokenCreatedMail.php b/app/Mail/AccessTokenCreatedMail.phpindex bf7b4a4e10..40dbbe2c27 100644--- a/app/Mail/AccessTokenCreatedMail.php+++ b/app/Mail/AccessTokenCreatedMail.php@@ -53,6 +53,6 @@ class AccessTokenCreatedMail extends Mailable{return $this->markdown('emails.token-created')- ->subject((string) trans('email.access_token_created_subject'));+ ->subject((string)trans('email.access_token_created_subject'));}}diff --git a/app/Mail/AdminTestMail.php b/app/Mail/AdminTestMail.phpindex 400861d502..bcef6cda6e 100644--- a/app/Mail/AdminTestMail.php+++ b/app/Mail/AdminTestMail.php@@ -1,4 +1,5 @@<?php+/*** AdminTestMail.php* Copyright (c) 2019 [email protected]@@ -56,6 +57,6 @@ class AdminTestMail extends Mailable{return $this->markdown('emails.admin-test')- ->subject((string) trans('email.admin_test_subject'));+ ->subject((string)trans('email.admin_test_subject'));}}diff --git a/app/Mail/BillWarningMail.php b/app/Mail/BillWarningMail.phpindex 64623e5560..308d86c706 100644--- a/app/Mail/BillWarningMail.php+++ b/app/Mail/BillWarningMail.php@@ -41,9 +41,9 @@ class BillWarningMail extends Mailable/*** ConfirmEmailChangeMail constructor.*- * @param Bill $bill- * @param string $field- * @param int $diff+ * @param Bill $bill+ * @param string $field+ * @param int $diff*/public function __construct(Bill $bill, string $field, int $diff){@@ -59,9 +59,9 @@ class BillWarningMail extends Mailable*/public function build(): self{- $subject = (string) trans(sprintf('email.bill_warning_subject_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);+ $subject = (string)trans(sprintf('email.bill_warning_subject_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);if (0 === $this->diff) {- $subject = (string) trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);+ $subject = (string)trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);}return $thisdiff --git a/app/Mail/ConfirmEmailChangeMail.php b/app/Mail/ConfirmEmailChangeMail.phpindex 6bf15b5f1f..7ad5fe34ac 100644--- a/app/Mail/ConfirmEmailChangeMail.php+++ b/app/Mail/ConfirmEmailChangeMail.php@@ -1,4 +1,5 @@<?php+/*** ConfirmEmailChangeMail.php* Copyright (c) 2019 [email protected]@@ -45,9 +46,9 @@ class ConfirmEmailChangeMail extends Mailable/*** ConfirmEmailChangeMail constructor.*- * @param string $newEmail- * @param string $oldEmail- * @param string $url+ * @param string $newEmail+ * @param string $oldEmail+ * @param string $url*/public function __construct(string $newEmail, string $oldEmail, string $url){@@ -67,6 +68,6 @@ class ConfirmEmailChangeMail extends Mailable//->view('emails.confirm-email-change-html')//->text('emails.confirm-email-change-text')->markdown('emails.confirm-email-change')- ->subject((string) trans('email.email_change_subject'));+ ->subject((string)trans('email.email_change_subject'));}}diff --git a/app/Mail/InvitationMail.php b/app/Mail/InvitationMail.phpindex cd1995029b..65490d9b0f 100644--- a/app/Mail/InvitationMail.php+++ b/app/Mail/InvitationMail.php@@ -33,22 +33,22 @@ class InvitationMail extends Mailableuse Queueable;use SerializesModels;- public string $invitee;public string $admin;- public string $url;public string $host;+ public string $invitee;+ public string $url;/*** OAuthTokenCreatedMail constructor.*- * @param string $ipAddress+ * @param string $ipAddress*/public function __construct(string $invitee, string $admin, string $url){$this->invitee = $invitee;- $this->admin = $admin;- $this->url = $url;- $this->host = parse_url($url, PHP_URL_HOST);+ $this->admin = $admin;+ $this->url = $url;+ $this->host = parse_url($url, PHP_URL_HOST);}/**@@ -60,6 +60,6 @@ class InvitationMail extends Mailable{return $this->markdown('emails.invitation')- ->subject((string) trans('email.invite_user_subject'));+ ->subject((string)trans('email.invite_user_subject'));}}diff --git a/app/Mail/NewIPAddressWarningMail.php b/app/Mail/NewIPAddressWarningMail.phpindex 02297032e0..80393791c0 100644--- a/app/Mail/NewIPAddressWarningMail.php+++ b/app/Mail/NewIPAddressWarningMail.php@@ -44,7 +44,7 @@ class NewIPAddressWarningMail extends Mailable/*** OAuthTokenCreatedMail constructor.*- * @param string $ipAddress+ * @param string $ipAddress*/public function __construct(string $ipAddress){@@ -58,7 +58,7 @@ class NewIPAddressWarningMail extends Mailable*/public function build(): self{- $this->time = now(config('app.timezone'))->isoFormat((string) trans('config.date_time_js'));+ $this->time = now(config('app.timezone'))->isoFormat((string)trans('config.date_time_js'));$this->host = '';try {$hostName = gethostbyaddr($this->ipAddress);@@ -71,6 +71,6 @@ class NewIPAddressWarningMail extends Mailablereturn $this->markdown('emails.new-ip')- ->subject((string) trans('email.login_from_new_ip'));+ ->subject((string)trans('email.login_from_new_ip'));}}diff --git a/app/Mail/OAuthTokenCreatedMail.php b/app/Mail/OAuthTokenCreatedMail.phpindex 9a6bdef155..69bc8cf471 100644--- a/app/Mail/OAuthTokenCreatedMail.php+++ b/app/Mail/OAuthTokenCreatedMail.php@@ -43,7 +43,7 @@ class OAuthTokenCreatedMail extends Mailable/*** OAuthTokenCreatedMail constructor.*- * @param Client $client+ * @param Client $client*/public function __construct(Client $client){@@ -59,6 +59,6 @@ class OAuthTokenCreatedMail extends Mailable{return $this->markdown('emails.oauth-client-created')- ->subject((string) trans('email.oauth_created_subject'));+ ->subject((string)trans('email.oauth_created_subject'));}}diff --git a/app/Mail/RegisteredUser.php b/app/Mail/RegisteredUser.phpindex 81a73704e4..b68e2449b7 100644--- a/app/Mail/RegisteredUser.php+++ b/app/Mail/RegisteredUser.php@@ -44,7 +44,7 @@ class RegisteredUser extends Mailable/*** Create a new message instance.*- * @param string $address+ * @param string $address*/public function __construct(string $address){@@ -60,6 +60,6 @@ class RegisteredUser extends Mailable{return $this->markdown('emails.registered')- ->subject((string) trans('email.registered_subject'));+ ->subject((string)trans('email.registered_subject'));}}diff --git a/app/Mail/ReportNewJournalsMail.php b/app/Mail/ReportNewJournalsMail.phpindex c69ee517be..2b0154ce8d 100644--- a/app/Mail/ReportNewJournalsMail.php+++ b/app/Mail/ReportNewJournalsMail.php@@ -1,4 +1,5 @@<?php+/*** ReportNewJournalsMail.php* Copyright (c) 2019 [email protected]@@ -47,7 +48,7 @@ class ReportNewJournalsMail extends Mailable/*** ConfirmEmailChangeMail constructor.*- * @param Collection $groups+ * @param Collection $groups*/public function __construct(Collection $groups){@@ -65,7 +66,7 @@ class ReportNewJournalsMail extends Mailablereturn $this->markdown('emails.report-new-journals')- ->subject((string) trans_choice('email.new_journals_subject', $this->groups->count()));+ ->subject((string)trans_choice('email.new_journals_subject', $this->groups->count()));}private function transform(): voiddiff --git a/app/Mail/RequestedNewPassword.php b/app/Mail/RequestedNewPassword.phpindex d7dc317fa7..865280d00d 100644--- a/app/Mail/RequestedNewPassword.php+++ b/app/Mail/RequestedNewPassword.php@@ -43,7 +43,7 @@ class RequestedNewPassword extends Mailable/*** RequestedNewPassword constructor.*- * @param string $url+ * @param string $url*/public function __construct(string $url){@@ -59,6 +59,6 @@ class RequestedNewPassword extends Mailable{return $this->markdown('emails.password')- ->subject((string) trans('email.reset_pw_subject'));+ ->subject((string)trans('email.reset_pw_subject'));}}diff --git a/app/Mail/UndoEmailChangeMail.php b/app/Mail/UndoEmailChangeMail.phpindex f499314d2b..df4a5df620 100644--- a/app/Mail/UndoEmailChangeMail.php+++ b/app/Mail/UndoEmailChangeMail.php@@ -1,4 +1,5 @@<?php+/*** UndoEmailChangeMail.php* Copyright (c) 2019 [email protected]@@ -43,9 +44,9 @@ class UndoEmailChangeMail extends Mailable/*** UndoEmailChangeMail constructor.*- * @param string $newEmail- * @param string $oldEmail- * @param string $url+ * @param string $newEmail+ * @param string $oldEmail+ * @param string $url*/public function __construct(string $newEmail, string $oldEmail, string $url){@@ -63,6 +64,6 @@ class UndoEmailChangeMail extends Mailable{return $this->markdown('emails.undo-email-change')- ->subject((string) trans('email.email_change_subject'));+ ->subject((string)trans('email.email_change_subject'));}}diff --git a/app/Models/Account.php b/app/Models/Account.phpindex 14588b6f4e..8375ef8737 100644--- a/app/Models/Account.php+++ b/app/Models/Account.php@@ -1,4 +1,5 @@<?php+/*** Account.php* Copyright (c) 2019 [email protected]@@ -39,36 +40,36 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** Class Account*- * @property int $id+ * @property int $id* @property \Illuminate\Support\Carbon|null $created_at* @property \Illuminate\Support\Carbon|null $updated_at* @property \Illuminate\Support\Carbon|null $deleted_at- * @property int $user_id- * @property int $account_type_id- * @property string $name- * @property string|null $virtual_balance- * @property string|null $iban- * @property bool $active- * @property bool $encrypted- * @property int $order- * @property-read Collection|AccountMeta[] $accountMeta- * @property-read int|null $account_meta_count- * @property AccountType $accountType- * @property-read Collection|Attachment[] $attachments- * @property-read int|null $attachments_count- * @property-read string $account_number- * @property-read string $edit_name- * @property-read Collection|Location[] $locations- * @property-read int|null $locations_count- * @property-read Collection|Note[] $notes- * @property-read int|null $notes_count- * @property-read Collection|ObjectGroup[] $objectGroups- * @property-read int|null $object_groups_count- * @property-read Collection|PiggyBank[] $piggyBanks- * @property-read int|null $piggy_banks_count- * @property-read Collection|Transaction[] $transactions- * @property-read int|null $transactions_count- * @property-read User $user+ * @property int $user_id+ * @property int $account_type_id+ * @property string $name+ * @property string|null $virtual_balance+ * @property string|null $iban+ * @property bool $active+ * @property bool $encrypted+ * @property int $order+ * @property-read Collection|AccountMeta[] $accountMeta+ * @property-read int|null $account_meta_count+ * @property AccountType $accountType+ * @property-read Collection|Attachment[] $attachments+ * @property-read int|null $attachments_count+ * @property-read string $account_number+ * @property-read string $edit_name+ * @property-read Collection|Location[] $locations+ * @property-read int|null $locations_count+ * @property-read Collection|Note[] $notes+ * @property-read int|null $notes_count+ * @property-read Collection|ObjectGroup[] $objectGroups+ * @property-read int|null $object_groups_count+ * @property-read Collection|PiggyBank[] $piggyBanks+ * @property-read int|null $piggy_banks_count+ * @property-read Collection|Transaction[] $transactions+ * @property-read int|null $transactions_count+ * @property-read User $user* @method static EloquentBuilder|Account accountTypeIn($types)* @method static EloquentBuilder|Account newModelQuery()* @method static EloquentBuilder|Account newQuery()@@ -89,17 +90,17 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|Account withTrashed()* @method static Builder|Account withoutTrashed()* @mixin Eloquent- * @property Carbon $lastActivityDate- * @property string $startBalance- * @property string $endBalance- * @property string $difference- * @property string $interest- * @property string $interestPeriod- * @property string $accountTypeString- * @property string $location- * @property string $liability_direction- * @property string $current_debt- * @property int|null $user_group_id+ * @property Carbon $lastActivityDate+ * @property string $startBalance+ * @property string $endBalance+ * @property string $difference+ * @property string $interest+ * @property string $interestPeriod+ * @property string $accountTypeString+ * @property string $location+ * @property string $liability_direction+ * @property string $current_debt+ * @property int|null $user_group_id* @method static EloquentBuilder|Account whereUserGroupId($value)*/class Account extends Model@@ -124,13 +125,13 @@ class Account extends Model/** @var array Fields that can be filled */protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban'];/** @var array Hidden from view */- protected $hidden = ['encrypted'];+ protected $hidden = ['encrypted'];private bool $joinedAccountTypes = false;/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return Account* @throws NotFoundHttpException@@ -138,7 +139,7 @@ class Account extends Modelpublic static function routeBinder(string $value): Account{if (auth()->check()) {- $accountId = (int) $value;+ $accountId = (int)$value;/** @var User $user */$user = auth()->user();/** @var Account $account */@@ -150,6 +151,15 @@ class Account extends Modelthrow new NotFoundHttpException();}+ /**+ * @return BelongsTo+ * @codeCoverageIgnore+ */+ public function user(): BelongsTo+ {+ return $this->belongsTo(User::class);+ }+/*** @return BelongsTo* @codeCoverageIgnore@@ -245,8 +255,8 @@ class Account extends Model/*** @codeCoverageIgnore*- * @param EloquentBuilder $query- * @param array $types+ * @param EloquentBuilder $query+ * @param array $types*/public function scopeAccountTypeIn(EloquentBuilder $query, array $types): void{@@ -260,13 +270,13 @@ class Account extends Model/*** @codeCoverageIgnore*- * @param mixed $value+ * @param mixed $value** @codeCoverageIgnore*/public function setVirtualBalanceAttribute($value): void{- $value = (string) $value;+ $value = (string)$value;if ('' === $value) {$value = null;}@@ -281,13 +291,4 @@ class Account extends Model{return $this->hasMany(Transaction::class);}-- /**- * @return BelongsTo- * @codeCoverageIgnore- */- public function user(): BelongsTo- {- return $this->belongsTo(User::class);- }}diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.phpindex 4f41f9aaf9..1047fa1a72 100644--- a/app/Models/AccountMeta.php+++ b/app/Models/AccountMeta.php@@ -1,4 +1,5 @@<?php+/*** AccountMeta.php* Copyright (c) 2019 [email protected]@@ -32,12 +33,12 @@ use JsonException;/*** Class AccountMeta*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property int $account_id- * @property string $name- * @property mixed $data+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property int $account_id+ * @property string $name+ * @property mixed $data* @property-read Account $account* @method static Builder|AccountMeta newModelQuery()* @method static Builder|AccountMeta newQuery()@@ -77,7 +78,7 @@ class AccountMeta extends Model}/**- * @param mixed $value+ * @param mixed $value** @return mixed* @throws JsonException@@ -89,7 +90,7 @@ class AccountMeta extends Model}/**- * @param mixed $value+ * @param mixed $value** @codeCoverageIgnore*/diff --git a/app/Models/AccountType.php b/app/Models/AccountType.phpindex 00031a46fe..a3c53fdca0 100644--- a/app/Models/AccountType.php+++ b/app/Models/AccountType.php@@ -1,4 +1,5 @@<?php+/*** AccountType.php* Copyright (c) 2019 [email protected]@@ -32,12 +33,12 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\AccountType*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property string $type+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property string $type* @property-read Collection|Account[] $accounts- * @property-read int|null $accounts_count+ * @property-read int|null $accounts_count* @method static Builder|AccountType newModelQuery()* @method static Builder|AccountType newQuery()* @method static Builder|AccountType query()diff --git a/app/Models/Attachment.php b/app/Models/Attachment.phpindex 333bb794ff..6615788d3a 100644--- a/app/Models/Attachment.php+++ b/app/Models/Attachment.php@@ -1,4 +1,5 @@<?php+/*** Attachment.php* Copyright (c) 2019 [email protected]@@ -37,26 +38,26 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\Attachment*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $user_id- * @property int $attachable_id- * @property string $attachable_type- * @property bool $file_exists- * @property string $md5- * @property string $filename- * @property string|null $title- * @property string|null $description- * @property string $mime- * @property int $size- * @property bool $uploaded- * @property string $notes_text+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $user_id+ * @property int $attachable_id+ * @property string $attachable_type+ * @property bool $file_exists+ * @property string $md5+ * @property string $filename+ * @property string|null $title+ * @property string|null $description+ * @property string $mime+ * @property int $size+ * @property bool $uploaded+ * @property string $notes_text* @property-read Model|Eloquent $attachable- * @property Collection|Note[] $notes- * @property-read int|null $notes_count- * @property-read User $user+ * @property Collection|Note[] $notes+ * @property-read int|null $notes_count+ * @property-read User $user* @method static \Illuminate\Database\Eloquent\Builder|Attachment newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|Attachment newQuery()* @method static Builder|Attachment onlyTrashed()@@ -78,7 +79,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|Attachment withTrashed()* @method static Builder|Attachment withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereUserGroupId($value)*/class Attachment extends Model@@ -103,7 +104,7 @@ class Attachment extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return Attachment* @throws NotFoundHttpException@@ -111,7 +112,7 @@ class Attachment extends Modelpublic static function routeBinder(string $value): Attachment{if (auth()->check()) {- $attachmentId = (int) $value;+ $attachmentId = (int)$value;/** @var User $user */$user = auth()->user();/** @var Attachment $attachment */@@ -123,6 +124,15 @@ class Attachment extends Modelthrow new NotFoundHttpException();}+ /**+ * @codeCoverageIgnore+ * @return BelongsTo+ */+ public function user(): BelongsTo+ {+ return $this->belongsTo(User::class);+ }+/*** Get all of the owning attachable models.*@@ -143,7 +153,7 @@ class Attachment extends Model*/public function fileName(): string{- return sprintf('at-%s.data', (string) $this->id);+ return sprintf('at-%s.data', (string)$this->id);}/**@@ -154,13 +164,4 @@ class Attachment extends Model{return $this->morphMany(Note::class, 'noteable');}-- /**- * @codeCoverageIgnore- * @return BelongsTo- */- public function user(): BelongsTo- {- return $this->belongsTo(User::class);- }}diff --git a/app/Models/AuditLogEntry.php b/app/Models/AuditLogEntry.phpindex 2df014d179..86f2a94283 100644--- a/app/Models/AuditLogEntry.php+++ b/app/Models/AuditLogEntry.php@@ -24,22 +24,47 @@ declare(strict_types=1);namespace FireflyIII\Models;+use Eloquent;+use Illuminate\Database\Eloquent\Builder;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\Relations\MorphTo;use Illuminate\Database\Eloquent\SoftDeletes;+use Illuminate\Support\Carbon;/*** Class AuditLogEntry*- * @property-read Model|\Eloquent $auditable- * @property-read Model|\Eloquent $changer- * @method static \Illuminate\Database\Eloquent\Builder|AuditLogEntry newModelQuery()- * @method static \Illuminate\Database\Eloquent\Builder|AuditLogEntry newQuery()+ * @property-read Model|Eloquent $auditable+ * @property-read Model|Eloquent $changer+ * @method static Builder|AuditLogEntry newModelQuery()+ * @method static Builder|AuditLogEntry newQuery()* @method static \Illuminate\Database\Query\Builder|AuditLogEntry onlyTrashed()- * @method static \Illuminate\Database\Eloquent\Builder|AuditLogEntry query()+ * @method static Builder|AuditLogEntry query()* @method static \Illuminate\Database\Query\Builder|AuditLogEntry withTrashed()* @method static \Illuminate\Database\Query\Builder|AuditLogEntry withoutTrashed()- * @mixin \Eloquent+ * @mixin Eloquent+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $auditable_id+ * @property string $auditable_type+ * @property int $changer_id+ * @property string $changer_type+ * @property string $action+ * @property array|null $before+ * @property array|null $after+ * @method static Builder|AuditLogEntry whereAction($value)+ * @method static Builder|AuditLogEntry whereAfter($value)+ * @method static Builder|AuditLogEntry whereAuditableId($value)+ * @method static Builder|AuditLogEntry whereAuditableType($value)+ * @method static Builder|AuditLogEntry whereBefore($value)+ * @method static Builder|AuditLogEntry whereChangerId($value)+ * @method static Builder|AuditLogEntry whereChangerType($value)+ * @method static Builder|AuditLogEntry whereCreatedAt($value)+ * @method static Builder|AuditLogEntry whereDeletedAt($value)+ * @method static Builder|AuditLogEntry whereId($value)+ * @method static Builder|AuditLogEntry whereUpdatedAt($value)*/class AuditLogEntry extends Model{diff --git a/app/Models/AutoBudget.php b/app/Models/AutoBudget.phpindex 9132c39a4b..aef874b847 100644--- a/app/Models/AutoBudget.php+++ b/app/Models/AutoBudget.php@@ -34,16 +34,16 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\AutoBudget*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $budget_id- * @property int $transaction_currency_id- * @property int $auto_budget_type- * @property string $amount- * @property string $period- * @property-read Budget $budget+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $budget_id+ * @property int $transaction_currency_id+ * @property int $auto_budget_type+ * @property string $amount+ * @property string $period+ * @property-read Budget $budget* @property-read TransactionCurrency $transactionCurrency* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget newQuery()@@ -65,7 +65,8 @@ use Illuminate\Support\Carbon;class AutoBudget extends Model{use SoftDeletes;- public const AUTO_BUDGET_RESET = 1;++ public const AUTO_BUDGET_RESET = 1;public const AUTO_BUDGET_ROLLOVER = 2;/**diff --git a/app/Models/AvailableBudget.php b/app/Models/AvailableBudget.phpindex 8286c87e6d..79fd9a1607 100644--- a/app/Models/AvailableBudget.php+++ b/app/Models/AvailableBudget.php@@ -1,4 +1,5 @@<?php+/*** AvailableBudget.php* Copyright (c) 2019 [email protected]@@ -34,17 +35,17 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\AvailableBudget*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $user_id- * @property int $transaction_currency_id- * @property string $amount- * @property Carbon $start_date- * @property Carbon $end_date+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $user_id+ * @property int $transaction_currency_id+ * @property string $amount+ * @property Carbon $start_date+ * @property Carbon $end_date* @property-read TransactionCurrency $transactionCurrency- * @property-read User $user+ * @property-read User $user* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget newQuery()* @method static Builder|AvailableBudget onlyTrashed()@@ -61,7 +62,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|AvailableBudget withTrashed()* @method static Builder|AvailableBudget withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget whereUserGroupId($value)*/class AvailableBudget extends Model@@ -88,7 +89,7 @@ class AvailableBudget extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return AvailableBudget* @throws NotFoundHttpException@@ -96,7 +97,7 @@ class AvailableBudget extends Modelpublic static function routeBinder(string $value): AvailableBudget{if (auth()->check()) {- $availableBudgetId = (int) $value;+ $availableBudgetId = (int)$value;/** @var User $user */$user = auth()->user();/** @var AvailableBudget $availableBudget */@@ -112,17 +113,17 @@ class AvailableBudget extends Model* @codeCoverageIgnore* @return BelongsTo*/- public function transactionCurrency(): BelongsTo+ public function user(): BelongsTo{- return $this->belongsTo(TransactionCurrency::class);+ return $this->belongsTo(User::class);}/*** @codeCoverageIgnore* @return BelongsTo*/- public function user(): BelongsTo+ public function transactionCurrency(): BelongsTo{- return $this->belongsTo(User::class);+ return $this->belongsTo(TransactionCurrency::class);}}diff --git a/app/Models/Bill.php b/app/Models/Bill.phpindex 73dc7a0377..2e7673fcae 100644--- a/app/Models/Bill.php+++ b/app/Models/Bill.php@@ -1,4 +1,5 @@<?php+/*** Bill.php* Copyright (c) 2019 [email protected]@@ -38,36 +39,36 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\Bill*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $user_id- * @property int|null $transaction_currency_id- * @property string $name- * @property string $match- * @property string $amount_min- * @property string $amount_max- * @property Carbon $date- * @property string|null $end_date- * @property string|null $extension_date- * @property string $repeat_freq- * @property int $skip- * @property bool $automatch- * @property bool $active- * @property bool $name_encrypted- * @property bool $match_encrypted- * @property int $order- * @property-read Collection|Attachment[] $attachments- * @property-read int|null $attachments_count- * @property-read Collection|Note[] $notes- * @property-read int|null $notes_count- * @property-read Collection|ObjectGroup[] $objectGroups- * @property-read int|null $object_groups_count- * @property-read TransactionCurrency|null $transactionCurrency+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $user_id+ * @property int|null $transaction_currency_id+ * @property string $name+ * @property string $match+ * @property string $amount_min+ * @property string $amount_max+ * @property Carbon $date+ * @property string|null $end_date+ * @property string|null $extension_date+ * @property string $repeat_freq+ * @property int $skip+ * @property bool $automatch+ * @property bool $active+ * @property bool $name_encrypted+ * @property bool $match_encrypted+ * @property int $order+ * @property-read Collection|Attachment[] $attachments+ * @property-read int|null $attachments_count+ * @property-read Collection|Note[] $notes+ * @property-read int|null $notes_count+ * @property-read Collection|ObjectGroup[] $objectGroups+ * @property-read int|null $object_groups_count+ * @property-read TransactionCurrency|null $transactionCurrency* @property-read Collection|TransactionJournal[] $transactionJournals- * @property-read int|null $transaction_journals_count- * @property-read User $user+ * @property-read int|null $transaction_journals_count+ * @property-read User $user* @method static \Illuminate\Database\Eloquent\Builder|Bill newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|Bill newQuery()* @method static Builder|Bill onlyTrashed()@@ -95,7 +96,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|Bill withTrashed()* @method static Builder|Bill withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserGroupId($value)*/class Bill extends Model@@ -124,15 +125,28 @@ class Bill extends Model/** @var array Fields that can be filled */protected $fillable- = ['name', 'match', 'amount_min', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip',- 'automatch', 'active', 'transaction_currency_id', 'end_date', 'extension_date'];+ = [+ 'name',+ 'match',+ 'amount_min',+ 'user_id',+ 'amount_max',+ 'date',+ 'repeat_freq',+ 'skip',+ 'automatch',+ 'active',+ 'transaction_currency_id',+ 'end_date',+ 'extension_date',+ ];/** @var array Hidden from view */protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted'];/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return Bill* @throws NotFoundHttpException@@ -140,7 +154,7 @@ class Bill extends Modelpublic static function routeBinder(string $value): Bill{if (auth()->check()) {- $billId = (int) $value;+ $billId = (int)$value;/** @var User $user */$user = auth()->user();/** @var Bill $bill */@@ -152,6 +166,15 @@ class Bill extends Modelthrow new NotFoundHttpException();}+ /**+ * @codeCoverageIgnore+ * @return BelongsTo+ */+ public function user(): BelongsTo+ {+ return $this->belongsTo(User::class);+ }+/*** @codeCoverageIgnore* @return MorphMany@@ -181,21 +204,21 @@ class Bill extends Model/*** @codeCoverageIgnore*- * @param mixed $value+ * @param mixed $value*/public function setAmountMaxAttribute($value): void{- $this->attributes['amount_max'] = (string) $value;+ $this->attributes['amount_max'] = (string)$value;}/**- * @param mixed $value+ * @param mixed $value** @codeCoverageIgnore*/public function setAmountMinAttribute($value): void{- $this->attributes['amount_min'] = (string) $value;+ $this->attributes['amount_min'] = (string)$value;}/**@@ -216,15 +239,6 @@ class Bill extends Modelreturn $this->hasMany(TransactionJournal::class);}- /**- * @codeCoverageIgnore- * @return BelongsTo- */- public function user(): BelongsTo- {- return $this->belongsTo(User::class);- }-/*** Get the max amount*@@ -233,7 +247,7 @@ class Bill extends Modelprotected function amountMax(): Attribute{return Attribute::make(- get: fn ($value) => (string) $value,+ get: fn ($value) => (string)$value,);}@@ -245,7 +259,7 @@ class Bill extends Modelprotected function amountMin(): Attribute{return Attribute::make(- get: fn ($value) => (string) $value,+ get: fn ($value) => (string)$value,);}}diff --git a/app/Models/Budget.php b/app/Models/Budget.phpindex fc5f6a7c11..6b260adb25 100644--- a/app/Models/Budget.php+++ b/app/Models/Budget.php@@ -1,4 +1,5 @@<?php+/*** Budget.php* Copyright (c) 2019 [email protected]@@ -38,26 +39,26 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\Budget*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $user_id- * @property string $name- * @property bool $active- * @property bool $encrypted- * @property int $order- * @property-read Collection|Attachment[] $attachments- * @property-read int|null $attachments_count- * @property-read Collection|AutoBudget[] $autoBudgets- * @property-read int|null $auto_budgets_count- * @property-read Collection|BudgetLimit[] $budgetlimits- * @property-read int|null $budgetlimits_count- * @property-read Collection|TransactionJournal[] $transactionJournals- * @property-read int|null $transaction_journals_count- * @property-read Collection|Transaction[] $transactions- * @property-read int|null $transactions_count- * @property-read User $user+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $user_id+ * @property string $name+ * @property bool $active+ * @property bool $encrypted+ * @property int $order+ * @property-read Collection|Attachment[] $attachments+ * @property-read int|null $attachments_count+ * @property-read Collection|AutoBudget[] $autoBudgets+ * @property-read int|null $auto_budgets_count+ * @property-read Collection|BudgetLimit[] $budgetlimits+ * @property-read int|null $budgetlimits_count+ * @property-read Collection|TransactionJournal[] $transactionJournals+ * @property-read int|null $transaction_journals_count+ * @property-read Collection|Transaction[] $transactions+ * @property-read int|null $transactions_count+ * @property-read User $user* @method static \Illuminate\Database\Eloquent\Builder|Budget newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|Budget newQuery()* @method static Builder|Budget onlyTrashed()@@ -74,11 +75,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|Budget withTrashed()* @method static Builder|Budget withoutTrashed()* @mixin Eloquent- * @property string $email- * @property int|null $user_group_id+ * @property string $email+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|Budget whereUserGroupId($value)* @property-read Collection|Note[] $notes- * @property-read int|null $notes_count+ * @property-read int|null $notes_count*/class Budget extends Model{@@ -105,7 +106,7 @@ class Budget extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return Budget* @throws NotFoundHttpException@@ -113,7 +114,7 @@ class Budget extends Modelpublic static function routeBinder(string $value): Budget{if (auth()->check()) {- $budgetId = (int) $value;+ $budgetId = (int)$value;/** @var User $user */$user = auth()->user();/** @var Budget $budget */@@ -125,6 +126,15 @@ class Budget extends Modelthrow new NotFoundHttpException();}+ /**+ * @codeCoverageIgnore+ * @return BelongsTo+ */+ public function user(): BelongsTo+ {+ return $this->belongsTo(User::class);+ }+/*** @codeCoverageIgnore* @return MorphMany@@ -178,13 +188,4 @@ class Budget extends Model{return $this->belongsToMany(Transaction::class, 'budget_transaction', 'budget_id');}-- /**- * @codeCoverageIgnore- * @return BelongsTo- */- public function user(): BelongsTo- {- return $this->belongsTo(User::class);- }}diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.phpindex e2671ae380..fdb0c43cac 100644--- a/app/Models/BudgetLimit.php+++ b/app/Models/BudgetLimit.php@@ -1,4 +1,5 @@<?php+/*** BudgetLimit.php* Copyright (c) 2019 [email protected]@@ -33,18 +34,18 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\BudgetLimit*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property int $budget_id- * @property int|null $transaction_currency_id- * @property Carbon $start_date- * @property Carbon|null $end_date- * @property string $amount- * @property string $spent- * @property string|null $period- * @property int $generated- * @property-read Budget $budget+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property int $budget_id+ * @property int|null $transaction_currency_id+ * @property Carbon $start_date+ * @property Carbon|null $end_date+ * @property string $amount+ * @property string $spent+ * @property string|null $period+ * @property int $generated+ * @property-read Budget $budget* @property-read TransactionCurrency|null $transactionCurrency* @method static Builder|BudgetLimit newModelQuery()* @method static Builder|BudgetLimit newQuery()@@ -83,7 +84,7 @@ class BudgetLimit extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return BudgetLimit* @throws NotFoundHttpException@@ -91,7 +92,7 @@ class BudgetLimit extends Modelpublic static function routeBinder(string $value): BudgetLimit{if (auth()->check()) {- $budgetLimitId = (int) $value;+ $budgetLimitId = (int)$value;$budgetLimit = self::where('budget_limits.id', $budgetLimitId)->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')->where('budgets.user_id', auth()->user()->id)@@ -129,7 +130,7 @@ class BudgetLimit extends Modelprotected function amount(): Attribute{return Attribute::make(- get: fn ($value) => (string) $value,+ get: fn ($value) => (string)$value,);}}diff --git a/app/Models/Category.php b/app/Models/Category.phpindex e2ddee7726..24a9e2038f 100644--- a/app/Models/Category.php+++ b/app/Models/Category.php@@ -38,23 +38,23 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\Category*- * @property int $id- * @property \Illuminate\Support\Carbon|null $created_at- * @property \Illuminate\Support\Carbon|null $updated_at- * @property \Illuminate\Support\Carbon|null $deleted_at- * @property int $user_id- * @property string $name- * @property Carbon $lastActivity- * @property bool $encrypted- * @property-read Collection|Attachment[] $attachments- * @property-read int|null $attachments_count- * @property-read Collection|Note[] $notes- * @property-read int|null $notes_count+ * @property int $id+ * @property \Illuminate\Support\Carbon|null $created_at+ * @property \Illuminate\Support\Carbon|null $updated_at+ * @property \Illuminate\Support\Carbon|null $deleted_at+ * @property int $user_id+ * @property string $name+ * @property Carbon $lastActivity+ * @property bool $encrypted+ * @property-read Collection|Attachment[] $attachments+ * @property-read int|null $attachments_count+ * @property-read Collection|Note[] $notes+ * @property-read int|null $notes_count* @property-read Collection|TransactionJournal[] $transactionJournals- * @property-read int|null $transaction_journals_count- * @property-read Collection|Transaction[] $transactions- * @property-read int|null $transactions_count- * @property-read User $user+ * @property-read int|null $transaction_journals_count+ * @property-read Collection|Transaction[] $transactions+ * @property-read int|null $transactions_count+ * @property-read User $user* @method static \Illuminate\Database\Eloquent\Builder|Category newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|Category newQuery()* @method static Builder|Category onlyTrashed()@@ -69,7 +69,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|Category withTrashed()* @method static Builder|Category withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|Category whereUserGroupId($value)*/class Category extends Model@@ -96,7 +96,7 @@ class Category extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return Category* @throws NotFoundHttpException@@ -104,7 +104,7 @@ class Category extends Modelpublic static function routeBinder(string $value): Category{if (auth()->check()) {- $categoryId = (int) $value;+ $categoryId = (int)$value;/** @var User $user */$user = auth()->user();/** @var Category $category */@@ -116,6 +116,15 @@ class Category extends Modelthrow new NotFoundHttpException();}+ /**+ * @codeCoverageIgnore+ * @return BelongsTo+ */+ public function user(): BelongsTo+ {+ return $this->belongsTo(User::class);+ }+/*** @codeCoverageIgnore* @return MorphMany@@ -151,13 +160,4 @@ class Category extends Model{return $this->belongsToMany(Transaction::class, 'category_transaction', 'category_id');}-- /**- * @codeCoverageIgnore- * @return BelongsTo- */- public function user(): BelongsTo- {- return $this->belongsTo(User::class);- }}diff --git a/app/Models/Configuration.php b/app/Models/Configuration.phpindex ee887f0227..ec88f81842 100644--- a/app/Models/Configuration.php+++ b/app/Models/Configuration.php@@ -1,4 +1,5 @@<?php+/*** Configuration.php* Copyright (c) 2019 [email protected]@@ -31,12 +32,12 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\Configuration*- * @property int $id+ * @property int $id* @property Carbon|null $created_at* @property Carbon|null $updated_at* @property Carbon|null $deleted_at- * @property string $name- * @property mixed $data+ * @property string $name+ * @property mixed $data* @method static \Illuminate\Database\Eloquent\Builder|Configuration newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|Configuration newQuery()* @method static Builder|Configuration onlyTrashed()@@ -74,7 +75,7 @@ class Configuration extends Model** @codeCoverageIgnore*- * @param mixed $value+ * @param mixed $value** @return mixed*/@@ -86,7 +87,7 @@ class Configuration extends Model/*** @codeCoverageIgnore*- * @param mixed $value+ * @param mixed $value*/public function setDataAttribute($value): void{diff --git a/app/Models/CurrencyExchangeRate.php b/app/Models/CurrencyExchangeRate.phpindex 7605110b26..d5e059a39a 100644--- a/app/Models/CurrencyExchangeRate.php+++ b/app/Models/CurrencyExchangeRate.php@@ -1,4 +1,5 @@<?php+/*** CurrencyExchangeRate.php* Copyright (c) 2019 [email protected]@@ -24,39 +25,43 @@ namespace FireflyIII\Models;use Eloquent;use FireflyIII\User;+use Illuminate\Database\Eloquent\Builder;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\Relations\BelongsTo;+use Illuminate\Support\Carbon;/*** Class CurrencyExchangeRate** @property int $id- * @property \Illuminate\Support\Carbon|null $created_at- * @property \Illuminate\Support\Carbon|null $updated_at+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at* @property string|null $deleted_at* @property int $user_id* @property int $from_currency_id* @property int $to_currency_id- * @property \Illuminate\Support\Carbon $date+ * @property Carbon $date* @property string $rate* @property string|null $user_rate- * @property-read \FireflyIII\Models\TransactionCurrency $fromCurrency- * @property-read \FireflyIII\Models\TransactionCurrency $toCurrency+ * @property-read TransactionCurrency $fromCurrency+ * @property-read TransactionCurrency $toCurrency* @property-read User $user- * @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate newModelQuery()- * @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate newQuery()- * @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate query()- * @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereCreatedAt($value)- * @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereDate($value)- * @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereDeletedAt($value)- * @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereFromCurrencyId($value)- * @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereId($value)- * @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereRate($value)- * @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereToCurrencyId($value)- * @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereUpdatedAt($value)- * @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereUserId($value)- * @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereUserRate($value)+ * @method static Builder|CurrencyExchangeRate newModelQuery()+ * @method static Builder|CurrencyExchangeRate newQuery()+ * @method static Builder|CurrencyExchangeRate query()+ * @method static Builder|CurrencyExchangeRate whereCreatedAt($value)+ * @method static Builder|CurrencyExchangeRate whereDate($value)+ * @method static Builder|CurrencyExchangeRate whereDeletedAt($value)+ * @method static Builder|CurrencyExchangeRate whereFromCurrencyId($value)+ * @method static Builder|CurrencyExchangeRate whereId($value)+ * @method static Builder|CurrencyExchangeRate whereRate($value)+ * @method static Builder|CurrencyExchangeRate whereToCurrencyId($value)+ * @method static Builder|CurrencyExchangeRate whereUpdatedAt($value)+ * @method static Builder|CurrencyExchangeRate whereUserId($value)+ * @method static Builder|CurrencyExchangeRate whereUserRate($value)* @mixin Eloquent+ * @property int|null $user_group_id+ * @method static Builder|CurrencyExchangeRate whereUserGroupId($value)*/class CurrencyExchangeRate extends Model{diff --git a/app/Models/GroupMembership.php b/app/Models/GroupMembership.phpindex 1af5447862..e872ad78f0 100644--- a/app/Models/GroupMembership.php+++ b/app/Models/GroupMembership.php@@ -34,16 +34,16 @@ use Illuminate\Support\Carbon;/*** Class GroupMembership*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property string|null $deleted_at- * @property int $user_id- * @property int $user_group_id- * @property int $user_role_id- * @property-read User $user+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property string|null $deleted_at+ * @property int $user_id+ * @property int $user_group_id+ * @property int $user_role_id+ * @property-read User $user* @property-read UserGroup $userGroup- * @property-read UserRole $userRole+ * @property-read UserRole $userRole* @method static Builder|GroupMembership newModelQuery()* @method static Builder|GroupMembership newQuery()* @method static Builder|GroupMembership query()diff --git a/app/Models/InvitedUser.php b/app/Models/InvitedUser.phpindex 20b4f8cdfd..6525b735f4 100644--- a/app/Models/InvitedUser.php+++ b/app/Models/InvitedUser.php@@ -24,28 +24,46 @@ declare(strict_types=1);namespace FireflyIII\Models;+use Eloquent;use FireflyIII\User;+use Illuminate\Database\Eloquent\Builder;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\Relations\BelongsTo;+use Illuminate\Support\Carbon;/*** Class InvitedUser** @property-read User $user- * @method static \Illuminate\Database\Eloquent\Builder|InvitedUser newModelQuery()- * @method static \Illuminate\Database\Eloquent\Builder|InvitedUser newQuery()- * @method static \Illuminate\Database\Eloquent\Builder|InvitedUser query()- * @mixin \Eloquent+ * @method static Builder|InvitedUser newModelQuery()+ * @method static Builder|InvitedUser newQuery()+ * @method static Builder|InvitedUser query()+ * @mixin Eloquent+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property int $user_id+ * @property string $email+ * @property string $invite_code+ * @property Carbon $expires+ * @property bool $redeemed+ * @method static Builder|InvitedUser whereCreatedAt($value)+ * @method static Builder|InvitedUser whereEmail($value)+ * @method static Builder|InvitedUser whereExpires($value)+ * @method static Builder|InvitedUser whereId($value)+ * @method static Builder|InvitedUser whereInviteCode($value)+ * @method static Builder|InvitedUser whereRedeemed($value)+ * @method static Builder|InvitedUser whereUpdatedAt($value)+ * @method static Builder|InvitedUser whereUserId($value)*/class InvitedUser extends Model{- protected $fillable = ['user_id', 'email', 'invite_code', 'expires', 'redeemed'];-protected $casts= ['expires' => 'datetime','redeemed' => 'boolean',];+ protected $fillable = ['user_id', 'email', 'invite_code', 'expires', 'redeemed'];/*** @codeCoverageIgnorediff --git a/app/Models/LinkType.php b/app/Models/LinkType.phpindex 65bd060832..e05e7d8263 100644--- a/app/Models/LinkType.php+++ b/app/Models/LinkType.php@@ -1,4 +1,5 @@<?php+/*** LinkType.php* Copyright (c) 2019 [email protected]@@ -34,17 +35,17 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\LinkType*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property string $name- * @property string $outward- * @property string $inward- * @property int $journalCount- * @property bool $editable+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property string $name+ * @property string $outward+ * @property string $inward+ * @property int $journalCount+ * @property bool $editable* @property-read Collection|TransactionJournalLink[] $transactionJournalLinks- * @property-read int|null $transaction_journal_links_count+ * @property-read int|null $transaction_journal_links_count* @method static \Illuminate\Database\Eloquent\Builder|LinkType newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|LinkType newQuery()* @method static Builder|LinkType onlyTrashed()@@ -84,7 +85,7 @@ class LinkType extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return LinkType*@@ -93,7 +94,7 @@ class LinkType extends Modelpublic static function routeBinder(string $value): LinkType{if (auth()->check()) {- $linkTypeId = (int) $value;+ $linkTypeId = (int)$value;$linkType = self::find($linkTypeId);if (null !== $linkType) {return $linkType;diff --git a/app/Models/Location.php b/app/Models/Location.phpindex 720fcf02bb..47520351cf 100644--- a/app/Models/Location.php+++ b/app/Models/Location.php@@ -35,18 +35,18 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\Location*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $locatable_id- * @property string $locatable_type- * @property float|null $latitude- * @property float|null $longitude- * @property int|null $zoom_level+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $locatable_id+ * @property string $locatable_type+ * @property float|null $latitude+ * @property float|null $longitude+ * @property int|null $zoom_level* @property-read Collection|Account[] $accounts- * @property-read int|null $accounts_count- * @property-read Model|Eloquent $locatable+ * @property-read int|null $accounts_count+ * @property-read Model|Eloquent $locatable* @method static Builder|Location newModelQuery()* @method static Builder|Location newQuery()* @method static Builder|Location query()@@ -83,7 +83,7 @@ class Location extends Model/*** Add rules for locations.*- * @param array $rules+ * @param array $rules** @return array*/diff --git a/app/Models/Note.php b/app/Models/Note.phpindex 59e03f4501..92c83528ec 100644--- a/app/Models/Note.php+++ b/app/Models/Note.php@@ -1,4 +1,5 @@<?php+/*** Note.php* Copyright (c) 2019 [email protected]@@ -32,14 +33,14 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\Note*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $noteable_id- * @property string $noteable_type- * @property string|null $title- * @property string|null $text+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $noteable_id+ * @property string $noteable_type+ * @property string|null $title+ * @property string|null $text* @property-read Model|Eloquent $noteable* @method static \Illuminate\Database\Eloquent\Builder|Note newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|Note newQuery()diff --git a/app/Models/ObjectGroup.php b/app/Models/ObjectGroup.phpindex 020b20c60c..eb20e51e90 100644--- a/app/Models/ObjectGroup.php+++ b/app/Models/ObjectGroup.php@@ -37,20 +37,20 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\ObjectGroup*- * @property int $id- * @property int $user_id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property string $title- * @property int $order- * @property-read Collection|Account[] $accounts- * @property-read int|null $accounts_count- * @property-read Collection|Bill[] $bills- * @property-read int|null $bills_count+ * @property int $id+ * @property int $user_id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property string $title+ * @property int $order+ * @property-read Collection|Account[] $accounts+ * @property-read int|null $accounts_count+ * @property-read Collection|Bill[] $bills+ * @property-read int|null $bills_count* @property-read Collection|PiggyBank[] $piggyBanks- * @property-read int|null $piggy_banks_count- * @property-read User $user+ * @property-read int|null $piggy_banks_count+ * @property-read User $user* @method static Builder|ObjectGroup newModelQuery()* @method static Builder|ObjectGroup newQuery()* @method static Builder|ObjectGroup query()@@ -82,7 +82,7 @@ class ObjectGroup extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return ObjectGroup* @throws NotFoundHttpException@@ -90,7 +90,7 @@ class ObjectGroup extends Modelpublic static function routeBinder(string $value): ObjectGroup{if (auth()->check()) {- $objectGroupId = (int) $value;+ $objectGroupId = (int)$value;/** @var ObjectGroup $objectGroup */$objectGroup = self::where('object_groups.id', $objectGroupId)->where('object_groups.user_id', auth()->user()->id)->first();@@ -101,6 +101,15 @@ class ObjectGroup extends Modelthrow new NotFoundHttpException();}+ /**+ * @return BelongsTo+ * @codeCoverageIgnore+ */+ public function user(): BelongsTo+ {+ return $this->belongsTo(User::class);+ }+/*** @return MorphToMany*/@@ -124,13 +133,4 @@ class ObjectGroup extends Model{return $this->morphedByMany(PiggyBank::class, 'object_groupable');}-- /**- * @return BelongsTo- * @codeCoverageIgnore- */- public function user(): BelongsTo- {- return $this->belongsTo(User::class);- }}diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.phpindex 5e4c7e6eaa..b497fd1791 100644--- a/app/Models/PiggyBank.php+++ b/app/Models/PiggyBank.php@@ -1,4 +1,5 @@<?php+/*** PiggyBank.php* Copyright (c) 2019 [email protected]@@ -37,29 +38,29 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\PiggyBank*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $account_id- * @property string $name- * @property string $targetamount- * @property Carbon|null $startdate- * @property Carbon|null $targetdate- * @property int $order- * @property bool $active- * @property bool $encrypted- * @property-read Account $account- * @property-read Collection|Attachment[] $attachments- * @property-read int|null $attachments_count- * @property-read Collection|Note[] $notes- * @property-read int|null $notes_count- * @property-read Collection|ObjectGroup[] $objectGroups- * @property-read int|null $object_groups_count- * @property-read Collection|PiggyBankEvent[] $piggyBankEvents- * @property-read int|null $piggy_bank_events_count+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $account_id+ * @property string $name+ * @property string $targetamount+ * @property Carbon|null $startdate+ * @property Carbon|null $targetdate+ * @property int $order+ * @property bool $active+ * @property bool $encrypted+ * @property-read Account $account+ * @property-read Collection|Attachment[] $attachments+ * @property-read int|null $attachments_count+ * @property-read Collection|Note[] $notes+ * @property-read int|null $notes_count+ * @property-read Collection|ObjectGroup[] $objectGroups+ * @property-read int|null $object_groups_count+ * @property-read Collection|PiggyBankEvent[] $piggyBankEvents+ * @property-read int|null $piggy_bank_events_count* @property-read Collection|PiggyBankRepetition[] $piggyBankRepetitions- * @property-read int|null $piggy_bank_repetitions_count+ * @property-read int|null $piggy_bank_repetitions_count* @method static \Illuminate\Database\Eloquent\Builder|PiggyBank newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|PiggyBank newQuery()* @method static Builder|PiggyBank onlyTrashed()@@ -108,7 +109,7 @@ class PiggyBank extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return PiggyBank* @throws NotFoundHttpException@@ -116,7 +117,7 @@ class PiggyBank extends Modelpublic static function routeBinder(string $value): PiggyBank{if (auth()->check()) {- $piggyBankId = (int) $value;+ $piggyBankId = (int)$value;$piggyBank = self::where('piggy_banks.id', $piggyBankId)->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', auth()->user()->id)->first(['piggy_banks.*']);@@ -183,11 +184,11 @@ class PiggyBank extends Model/*** @codeCoverageIgnore*- * @param mixed $value+ * @param mixed $value*/public function setTargetamountAttribute($value): void{- $this->attributes['targetamount'] = (string) $value;+ $this->attributes['targetamount'] = (string)$value;}/**@@ -198,7 +199,7 @@ class PiggyBank extends Modelprotected function targetamount(): Attribute{return Attribute::make(- get: fn ($value) => (string) $value,+ get: fn ($value) => (string)$value,);}}diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.phpindex 4562d27dab..592810edcf 100644--- a/app/Models/PiggyBankEvent.php+++ b/app/Models/PiggyBankEvent.php@@ -1,4 +1,5 @@<?php+/*** PiggyBankEvent.php* Copyright (c) 2019 [email protected]@@ -32,14 +33,14 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\PiggyBankEvent*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property int $piggy_bank_id- * @property int|null $transaction_journal_id- * @property Carbon $date- * @property string $amount- * @property PiggyBank $piggyBank+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property int $piggy_bank_id+ * @property int|null $transaction_journal_id+ * @property Carbon $date+ * @property string $amount+ * @property PiggyBank $piggyBank* @property-read TransactionJournal|null $transactionJournal* @method static Builder|PiggyBankEvent newModelQuery()* @method static Builder|PiggyBankEvent newQuery()@@ -83,11 +84,11 @@ class PiggyBankEvent extends Model/*** @codeCoverageIgnore*- * @param mixed $value+ * @param mixed $value*/public function setAmountAttribute($value): void{- $this->attributes['amount'] = (string) $value;+ $this->attributes['amount'] = (string)$value;}/**@@ -107,7 +108,7 @@ class PiggyBankEvent extends Modelprotected function amount(): Attribute{return Attribute::make(- get: fn ($value) => (string) $value,+ get: fn ($value) => (string)$value,);}}diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.phpindex 55f5ebf5e9..f7394bbf90 100644--- a/app/Models/PiggyBankRepetition.php+++ b/app/Models/PiggyBankRepetition.php@@ -1,4 +1,5 @@<?php+/*** PiggyBankRepetition.php* Copyright (c) 2019 [email protected]@@ -32,14 +33,14 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;/*** FireflyIII\Models\PiggyBankRepetition*- * @property int $id+ * @property int $id* @property \Illuminate\Support\Carbon|null $created_at* @property \Illuminate\Support\Carbon|null $updated_at- * @property int $piggy_bank_id+ * @property int $piggy_bank_id* @property \Illuminate\Support\Carbon|null $startdate* @property \Illuminate\Support\Carbon|null $targetdate- * @property string $currentamount- * @property-read PiggyBank $piggyBank+ * @property string $currentamount+ * @property-read PiggyBank $piggyBank* @method static EloquentBuilder|PiggyBankRepetition newModelQuery()* @method static EloquentBuilder|PiggyBankRepetition newQuery()* @method static EloquentBuilder|PiggyBankRepetition onDates(Carbon $start, Carbon $target)@@ -83,9 +84,9 @@ class PiggyBankRepetition extends Model/*** @codeCoverageIgnore*- * @param EloquentBuilder $query- * @param Carbon $start- * @param Carbon $target+ * @param EloquentBuilder $query+ * @param Carbon $start+ * @param Carbon $target** @return EloquentBuilder*/@@ -97,8 +98,8 @@ class PiggyBankRepetition extends Model/*** @codeCoverageIgnore*- * @param EloquentBuilder $query- * @param Carbon $date+ * @param EloquentBuilder $query+ * @param Carbon $date** @return EloquentBuilder*/@@ -121,11 +122,11 @@ class PiggyBankRepetition extends Model/*** @codeCoverageIgnore*- * @param mixed $value+ * @param mixed $value*/public function setCurrentamountAttribute($value): void{- $this->attributes['currentamount'] = (string) $value;+ $this->attributes['currentamount'] = (string)$value;}/**@@ -136,7 +137,7 @@ class PiggyBankRepetition extends Modelprotected function currentamount(): Attribute{return Attribute::make(- get: fn ($value) => (string) $value,+ get: fn ($value) => (string)$value,);}}diff --git a/app/Models/Preference.php b/app/Models/Preference.phpindex 7b1440cee1..daf12690a7 100644--- a/app/Models/Preference.php+++ b/app/Models/Preference.php@@ -1,4 +1,5 @@<?php+/*** Preference.php* Copyright (c) 2019 [email protected]@@ -33,13 +34,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\Preference*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property int $user_id- * @property string $name+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property int $user_id+ * @property string $name* @property int|string|array|null $data- * @property-read User $user+ * @property-read User $user* @method static Builder|Preference newModelQuery()* @method static Builder|Preference newQuery()* @method static Builder|Preference query()@@ -71,7 +72,7 @@ class Preference extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return Preference* @throws NotFoundHttpException@@ -84,7 +85,7 @@ class Preference extends Model/** @var Preference|null $preference */$preference = $user->preferences()->where('name', $value)->first();if (null === $preference) {- $preference = $user->preferences()->where('id', (int) $value)->first();+ $preference = $user->preferences()->where('id', (int)$value)->first();}if (null !== $preference) {return $preference;diff --git a/app/Models/Recurrence.php b/app/Models/Recurrence.phpindex 0df6d7bbd3..b1415f8333 100644--- a/app/Models/Recurrence.php+++ b/app/Models/Recurrence.php@@ -38,33 +38,33 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\Recurrence*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $user_id- * @property int $transaction_type_id- * @property string $title- * @property string $description- * @property Carbon $first_date- * @property Carbon|null $repeat_until- * @property Carbon|null $latest_date- * @property int $repetitions- * @property bool $apply_rules- * @property bool $active- * @property-read Collection|Attachment[] $attachments- * @property-read int|null $attachments_count- * @property-read Collection|Note[] $notes- * @property-read int|null $notes_count- * @property-read Collection|RecurrenceMeta[] $recurrenceMeta- * @property-read int|null $recurrence_meta_count- * @property-read Collection|RecurrenceRepetition[] $recurrenceRepetitions- * @property-read int|null $recurrence_repetitions_count+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $user_id+ * @property int $transaction_type_id+ * @property string $title+ * @property string $description+ * @property Carbon $first_date+ * @property Carbon|null $repeat_until+ * @property Carbon|null $latest_date+ * @property int $repetitions+ * @property bool $apply_rules+ * @property bool $active+ * @property-read Collection|Attachment[] $attachments+ * @property-read int|null $attachments_count+ * @property-read Collection|Note[] $notes+ * @property-read int|null $notes_count+ * @property-read Collection|RecurrenceMeta[] $recurrenceMeta+ * @property-read int|null $recurrence_meta_count+ * @property-read Collection|RecurrenceRepetition[] $recurrenceRepetitions+ * @property-read int|null $recurrence_repetitions_count* @property-read Collection|RecurrenceTransaction[] $recurrenceTransactions- * @property-read int|null $recurrence_transactions_count- * @property-read TransactionCurrency $transactionCurrency- * @property-read TransactionType $transactionType- * @property-read User $user+ * @property-read int|null $recurrence_transactions_count+ * @property-read TransactionCurrency $transactionCurrency+ * @property-read TransactionType $transactionType+ * @property-read User $user* @method static \Illuminate\Database\Eloquent\Builder|Recurrence newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|Recurrence newQuery()* @method static Builder|Recurrence onlyTrashed()@@ -86,7 +86,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|Recurrence withTrashed()* @method static Builder|Recurrence withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|Recurrence whereUserGroupId($value)*/class Recurrence extends Model@@ -122,7 +122,7 @@ class Recurrence extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return Recurrence* @throws NotFoundHttpException@@ -130,7 +130,7 @@ class Recurrence extends Modelpublic static function routeBinder(string $value): Recurrence{if (auth()->check()) {- $recurrenceId = (int) $value;+ $recurrenceId = (int)$value;/** @var User $user */$user = auth()->user();/** @var Recurrence $recurrence */@@ -142,6 +142,15 @@ class Recurrence extends Modelthrow new NotFoundHttpException();}+ /**+ * @codeCoverageIgnore+ * @return BelongsTo+ */+ public function user(): BelongsTo+ {+ return $this->belongsTo(User::class);+ }+/*** @codeCoverageIgnore* @return MorphMany@@ -204,13 +213,4 @@ class Recurrence extends Model{return $this->belongsTo(TransactionType::class);}-- /**- * @codeCoverageIgnore- * @return BelongsTo- */- public function user(): BelongsTo- {- return $this->belongsTo(User::class);- }}diff --git a/app/Models/RecurrenceMeta.php b/app/Models/RecurrenceMeta.phpindex 1037b6ccb3..516ff62ed5 100644--- a/app/Models/RecurrenceMeta.php+++ b/app/Models/RecurrenceMeta.php@@ -33,13 +33,13 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\RecurrenceMeta*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $recurrence_id- * @property string $name- * @property mixed $value+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $recurrence_id+ * @property string $name+ * @property mixed $value* @property-read Recurrence $recurrence* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceMeta newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceMeta newQuery()diff --git a/app/Models/RecurrenceRepetition.php b/app/Models/RecurrenceRepetition.phpindex 3061ad67f6..156dbaf01a 100644--- a/app/Models/RecurrenceRepetition.php+++ b/app/Models/RecurrenceRepetition.php@@ -33,15 +33,15 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\RecurrenceRepetition*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $recurrence_id- * @property string $repetition_type- * @property string $repetition_moment- * @property int $repetition_skip- * @property int $weekend+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $recurrence_id+ * @property string $repetition_type+ * @property string $repetition_moment+ * @property int $repetition_skip+ * @property int $weekend* @property-read Recurrence $recurrence* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition newQuery()@@ -63,6 +63,7 @@ use Illuminate\Support\Carbon;class RecurrenceRepetition extends Model{use SoftDeletes;+public const WEEKEND_DO_NOTHING = 1;public const WEEKEND_SKIP_CREATION = 2;public const WEEKEND_TO_FRIDAY = 3;diff --git a/app/Models/RecurrenceTransaction.php b/app/Models/RecurrenceTransaction.phpindex 9617e13a2b..3bf47ab78c 100644--- a/app/Models/RecurrenceTransaction.php+++ b/app/Models/RecurrenceTransaction.php@@ -35,25 +35,25 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\RecurrenceTransaction*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $recurrence_id- * @property int $transaction_currency_id- * @property int|null $foreign_currency_id- * @property int $source_id- * @property int $destination_id- * @property string $amount- * @property string|null $foreign_amount- * @property string $description- * @property-read Account $destinationAccount- * @property-read TransactionCurrency|null $foreignCurrency- * @property-read Recurrence $recurrence+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $recurrence_id+ * @property int $transaction_currency_id+ * @property int|null $foreign_currency_id+ * @property int $source_id+ * @property int $destination_id+ * @property string $amount+ * @property string|null $foreign_amount+ * @property string $description+ * @property-read Account $destinationAccount+ * @property-read TransactionCurrency|null $foreignCurrency+ * @property-read Recurrence $recurrence* @property-read Collection|RecurrenceTransactionMeta[] $recurrenceTransactionMeta- * @property-read int|null $recurrence_transaction_meta_count- * @property-read Account $sourceAccount- * @property-read TransactionCurrency $transactionCurrency+ * @property-read int|null $recurrence_transaction_meta_count+ * @property-read Account $sourceAccount+ * @property-read TransactionCurrency $transactionCurrency* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction newQuery()* @method static Builder|RecurrenceTransaction onlyTrashed()@@ -73,9 +73,9 @@ use Illuminate\Support\Carbon;* @method static Builder|RecurrenceTransaction withTrashed()* @method static Builder|RecurrenceTransaction withoutTrashed()* @mixin Eloquent- * @property int|null $transaction_type_id+ * @property int|null $transaction_type_id* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction whereTransactionTypeId($value)- * @property-read TransactionType|null $transactionType+ * @property-read TransactionType|null $transactionType*/class RecurrenceTransaction extends Model{@@ -97,8 +97,16 @@ class RecurrenceTransaction extends Model];/** @var array Fields that can be filled */protected $fillable- = ['recurrence_id', 'transaction_currency_id', 'foreign_currency_id', 'source_id', 'destination_id', 'amount', 'foreign_amount',- 'description'];+ = [+ 'recurrence_id',+ 'transaction_currency_id',+ 'foreign_currency_id',+ 'source_id',+ 'destination_id',+ 'amount',+ 'foreign_amount',+ 'description',+ ];/** @var string The table to store the data in */protected $table = 'recurrences_transactions';diff --git a/app/Models/RecurrenceTransactionMeta.php b/app/Models/RecurrenceTransactionMeta.phpindex 0ca31628e5..a5e1bd9fc0 100644--- a/app/Models/RecurrenceTransactionMeta.php+++ b/app/Models/RecurrenceTransactionMeta.php@@ -33,13 +33,13 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\RecurrenceTransactionMeta*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $rt_id- * @property string $name- * @property mixed $value+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $rt_id+ * @property string $name+ * @property mixed $value* @property-read RecurrenceTransaction $recurrenceTransaction* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransactionMeta newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransactionMeta newQuery()diff --git a/app/Models/Role.php b/app/Models/Role.phpindex 1462fb2e30..75befaabe5 100644--- a/app/Models/Role.php+++ b/app/Models/Role.php@@ -1,4 +1,5 @@<?php+/*** Role.php* Copyright (c) 2019 [email protected]@@ -33,14 +34,14 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\Role*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property string $name- * @property string|null $display_name- * @property string|null $description+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property string $name+ * @property string|null $display_name+ * @property string|null $description* @property-read Collection|User[] $users- * @property-read int|null $users_count+ * @property-read int|null $users_count* @method static Builder|Role newModelQuery()* @method static Builder|Role newQuery()* @method static Builder|Role query()diff --git a/app/Models/Rule.php b/app/Models/Rule.phpindex a0a5b88f5d..cda09fb731 100644--- a/app/Models/Rule.php+++ b/app/Models/Rule.php@@ -1,4 +1,5 @@<?php+/*** Rule.php* Copyright (c) 2019 [email protected]@@ -36,25 +37,25 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\Rule*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $user_id- * @property int $rule_group_id- * @property string $title- * @property string|null $description- * @property int $order- * @property bool $active- * @property bool $stop_processing- * @property bool $strict- * @property-read string $action_value+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $user_id+ * @property int $rule_group_id+ * @property string $title+ * @property string|null $description+ * @property int $order+ * @property bool $active+ * @property bool $stop_processing+ * @property bool $strict+ * @property-read string $action_value* @property-read Collection|RuleAction[] $ruleActions- * @property-read int|null $rule_actions_count- * @property-read RuleGroup $ruleGroup- * @property Collection|RuleTrigger[] $ruleTriggers- * @property-read int|null $rule_triggers_count- * @property-read User $user+ * @property-read int|null $rule_actions_count+ * @property-read RuleGroup $ruleGroup+ * @property Collection|RuleTrigger[] $ruleTriggers+ * @property-read int|null $rule_triggers_count+ * @property-read User $user* @method static \Illuminate\Database\Eloquent\Builder|Rule newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|Rule newQuery()* @method static Builder|Rule onlyTrashed()@@ -74,7 +75,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|Rule withTrashed()* @method static Builder|Rule withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|Rule whereUserGroupId($value)*/class Rule extends Model@@ -103,7 +104,7 @@ class Rule extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return Rule* @throws NotFoundHttpException@@ -111,7 +112,7 @@ class Rule extends Modelpublic static function routeBinder(string $value): Rule{if (auth()->check()) {- $ruleId = (int) $value;+ $ruleId = (int)$value;/** @var User $user */$user = auth()->user();/** @var Rule $rule */@@ -123,6 +124,15 @@ class Rule extends Modelthrow new NotFoundHttpException();}+ /**+ * @codeCoverageIgnore+ * @return BelongsTo+ */+ public function user(): BelongsTo+ {+ return $this->belongsTo(User::class);+ }+/*** @codeCoverageIgnore* @return HasMany@@ -151,7 +161,7 @@ class Rule extends Model}/**- * @param mixed $value+ * @param mixed $value** @codeCoverageIgnore*/@@ -159,13 +169,4 @@ class Rule extends Model{$this->attributes['description'] = e($value);}-- /**- * @codeCoverageIgnore- * @return BelongsTo- */- public function user(): BelongsTo- {- return $this->belongsTo(User::class);- }}diff --git a/app/Models/RuleAction.php b/app/Models/RuleAction.phpindex 922c4445c1..a80ccb1523 100644--- a/app/Models/RuleAction.php+++ b/app/Models/RuleAction.php@@ -1,4 +1,5 @@<?php+/*** RuleAction.php* Copyright (c) 2019 [email protected]@@ -31,16 +32,16 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\RuleAction*- * @property int $id+ * @property int $id* @property Carbon|null $created_at* @property Carbon|null $updated_at- * @property int $rule_id- * @property string $action_type- * @property string $action_value- * @property int $order- * @property bool $active- * @property bool $stop_processing- * @property-read Rule $rule+ * @property int $rule_id+ * @property string $action_type+ * @property string $action_value+ * @property int $order+ * @property bool $active+ * @property bool $stop_processing+ * @property-read Rule $rule* @method static Builder|RuleAction newModelQuery()* @method static Builder|RuleAction newQuery()* @method static Builder|RuleAction query()diff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.phpindex 448acd5466..cd9ea245df 100644--- a/app/Models/RuleGroup.php+++ b/app/Models/RuleGroup.php@@ -1,4 +1,5 @@<?php+/*** RuleGroup.php* Copyright (c) 2019 [email protected]@@ -36,19 +37,19 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\RuleGroup*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $user_id- * @property string $title- * @property string|null $description- * @property int $order- * @property bool $active- * @property bool $stop_processing+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $user_id+ * @property string $title+ * @property string|null $description+ * @property int $order+ * @property bool $active+ * @property bool $stop_processing* @property Collection|Rule[] $rules- * @property-read int|null $rules_count- * @property-read User $user+ * @property-read int|null $rules_count+ * @property-read User $user* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup newQuery()* @method static Builder|RuleGroup onlyTrashed()@@ -66,7 +67,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|RuleGroup withTrashed()* @method static Builder|RuleGroup withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereUserGroupId($value)*/class RuleGroup extends Model@@ -94,7 +95,7 @@ class RuleGroup extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return RuleGroup* @throws NotFoundHttpException@@ -102,7 +103,7 @@ class RuleGroup extends Modelpublic static function routeBinder(string $value): RuleGroup{if (auth()->check()) {- $ruleGroupId = (int) $value;+ $ruleGroupId = (int)$value;/** @var User $user */$user = auth()->user();/** @var RuleGroup $ruleGroup */@@ -116,19 +117,19 @@ class RuleGroup extends Model/*** @codeCoverageIgnore- * @return HasMany+ * @return BelongsTo*/- public function rules(): HasMany+ public function user(): BelongsTo{- return $this->hasMany(Rule::class);+ return $this->belongsTo(User::class);}/*** @codeCoverageIgnore- * @return BelongsTo+ * @return HasMany*/- public function user(): BelongsTo+ public function rules(): HasMany{- return $this->belongsTo(User::class);+ return $this->hasMany(Rule::class);}}diff --git a/app/Models/RuleTrigger.php b/app/Models/RuleTrigger.phpindex 234e1feefa..2e0fb6543a 100644--- a/app/Models/RuleTrigger.php+++ b/app/Models/RuleTrigger.php@@ -1,4 +1,5 @@<?php+/*** RuleTrigger.php* Copyright (c) 2019 [email protected]@@ -31,16 +32,16 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\RuleTrigger*- * @property int $id+ * @property int $id* @property Carbon|null $created_at* @property Carbon|null $updated_at- * @property int $rule_id- * @property string $trigger_type- * @property string $trigger_value- * @property int $order- * @property bool $active- * @property bool $stop_processing- * @property-read Rule $rule+ * @property int $rule_id+ * @property string $trigger_type+ * @property string $trigger_value+ * @property int $order+ * @property bool $active+ * @property bool $stop_processing+ * @property-read Rule $rule* @method static Builder|RuleTrigger newModelQuery()* @method static Builder|RuleTrigger newQuery()* @method static Builder|RuleTrigger query()diff --git a/app/Models/Tag.php b/app/Models/Tag.phpindex a33d0d0cc1..ce0c944fb4 100644--- a/app/Models/Tag.php+++ b/app/Models/Tag.php@@ -1,4 +1,5 @@<?php+/*** Tag.php* Copyright (c) 2019 [email protected]@@ -37,25 +38,25 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\Tag*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $user_id- * @property string $tag- * @property string $tagMode- * @property Carbon|null $date- * @property string|null $description- * @property float|null $latitude- * @property float|null $longitude- * @property int|null $zoomLevel- * @property-read Collection|Attachment[] $attachments- * @property-read int|null $attachments_count- * @property-read Collection|Location[] $locations- * @property-read int|null $locations_count+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $user_id+ * @property string $tag+ * @property string $tagMode+ * @property Carbon|null $date+ * @property string|null $description+ * @property float|null $latitude+ * @property float|null $longitude+ * @property int|null $zoomLevel+ * @property-read Collection|Attachment[] $attachments+ * @property-read int|null $attachments_count+ * @property-read Collection|Location[] $locations+ * @property-read int|null $locations_count* @property-read Collection|TransactionJournal[] $transactionJournals- * @property-read int|null $transaction_journals_count- * @property-read User $user+ * @property-read int|null $transaction_journals_count+ * @property-read User $user* @method static \Illuminate\Database\Eloquent\Builder|Tag newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|Tag newQuery()* @method static Builder|Tag onlyTrashed()@@ -75,7 +76,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|Tag withTrashed()* @method static Builder|Tag withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|Tag whereUserGroupId($value)*/class Tag extends Model@@ -105,7 +106,7 @@ class Tag extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return Tag* @throws NotFoundHttpException@@ -113,7 +114,7 @@ class Tag extends Modelpublic static function routeBinder(string $value): Tag{if (auth()->check()) {- $tagId = (int) $value;+ $tagId = (int)$value;/** @var User $user */$user = auth()->user();/** @var Tag $tag */@@ -125,6 +126,15 @@ class Tag extends Modelthrow new NotFoundHttpException();}+ /**+ * @codeCoverageIgnore+ * @return BelongsTo+ */+ public function user(): BelongsTo+ {+ return $this->belongsTo(User::class);+ }+/*** @codeCoverageIgnore* @return MorphMany@@ -151,13 +161,4 @@ class Tag extends Model{return $this->belongsToMany(TransactionJournal::class);}-- /**- * @codeCoverageIgnore- * @return BelongsTo- */- public function user(): BelongsTo- {- return $this->belongsTo(User::class);- }}diff --git a/app/Models/Transaction.php b/app/Models/Transaction.phpindex b65007574c..03e90a0203 100644--- a/app/Models/Transaction.php+++ b/app/Models/Transaction.php@@ -1,4 +1,5 @@<?php+/*** Transaction.php* Copyright (c) 2019 [email protected]@@ -36,31 +37,31 @@ use Illuminate\Database\Eloquent\SoftDeletes;/*** FireflyIII\Models\Transaction*- * @property int $id+ * @property int $id* @property \Illuminate\Support\Carbon|null $created_at* @property \Illuminate\Support\Carbon|null $updated_at* @property \Illuminate\Support\Carbon|null $deleted_at- * @property bool $reconciled- * @property int $account_id- * @property int $transaction_journal_id- * @property string|null $description- * @property int|null $transaction_currency_id- * @property string $modified- * @property string $modified_foreign- * @property string $date- * @property string $max_date- * @property string $amount- * @property string|null $foreign_amount- * @property int|null $foreign_currency_id- * @property int $identifier- * @property-read Account $account- * @property-read Collection|Budget[] $budgets- * @property-read int|null $budgets_count- * @property-read Collection|Category[] $categories- * @property-read int|null $categories_count- * @property-read TransactionCurrency|null $foreignCurrency- * @property-read TransactionCurrency|null $transactionCurrency- * @property-read TransactionJournal $transactionJournal+ * @property bool $reconciled+ * @property int $account_id+ * @property int $transaction_journal_id+ * @property string|null $description+ * @property int|null $transaction_currency_id+ * @property string $modified+ * @property string $modified_foreign+ * @property string $date+ * @property string $max_date+ * @property string $amount+ * @property string|null $foreign_amount+ * @property int|null $foreign_currency_id+ * @property int $identifier+ * @property-read Account $account+ * @property-read Collection|Budget[] $budgets+ * @property-read int|null $budgets_count+ * @property-read Collection|Category[] $categories+ * @property-read int|null $categories_count+ * @property-read TransactionCurrency|null $foreignCurrency+ * @property-read TransactionCurrency|null $transactionCurrency+ * @property-read TransactionJournal $transactionJournal* @method static Builder|Transaction after(Carbon $date)* @method static Builder|Transaction before(Carbon $date)* @method static Builder|Transaction newModelQuery()@@ -84,7 +85,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;* @method static \Illuminate\Database\Query\Builder|Transaction withTrashed()* @method static \Illuminate\Database\Query\Builder|Transaction withoutTrashed()* @mixin Eloquent- * @property int $the_count+ * @property int $the_count*/class Transaction extends Model{@@ -108,8 +109,17 @@ class Transaction extends Model];/** @var array Fields that can be filled */protected $fillable- = ['account_id', 'transaction_journal_id', 'description', 'amount', 'identifier', 'transaction_currency_id', 'foreign_currency_id',- 'foreign_amount', 'reconciled'];+ = [+ 'account_id',+ 'transaction_journal_id',+ 'description',+ 'amount',+ 'identifier',+ 'transaction_currency_id',+ 'foreign_currency_id',+ 'foreign_amount',+ 'reconciled',+ ];/** @var array Hidden from view */protected $hidden = ['encrypted'];@@ -162,8 +172,8 @@ class Transaction extends Model** @codeCoverageIgnore*- * @param Builder $query- * @param Carbon $date+ * @param Builder $query+ * @param Carbon $date*/public function scopeAfter(Builder $query, Carbon $date): void{@@ -176,8 +186,8 @@ class Transaction extends Model/*** Check if a table is joined.*- * @param Builder $query- * @param string $table+ * @param Builder $query+ * @param string $table** @return bool* @codeCoverageIgnore@@ -202,8 +212,8 @@ class Transaction extends Model** @codeCoverageIgnore*- * @param Builder $query- * @param Carbon $date+ * @param Builder $query+ * @param Carbon $date*/public function scopeBefore(Builder $query, Carbon $date): void{@@ -216,8 +226,8 @@ class Transaction extends Model/*** @codeCoverageIgnore*- * @param Builder $query- * @param array $types+ * @param Builder $query+ * @param array $types*/public function scopeTransactionTypes(Builder $query, array $types): void{@@ -234,11 +244,11 @@ class Transaction extends Model/*** @codeCoverageIgnore*- * @param mixed $value+ * @param mixed $value*/public function setAmountAttribute($value): void{- $this->attributes['amount'] = (string) $value;+ $this->attributes['amount'] = (string)$value;}/**@@ -267,7 +277,7 @@ class Transaction extends Modelprotected function amount(): Attribute{return Attribute::make(- get: fn ($value) => (string) $value,+ get: fn ($value) => (string)$value,);}@@ -279,7 +289,7 @@ class Transaction extends Modelprotected function foreignAmount(): Attribute{return Attribute::make(- get: fn ($value) => (string) $value,+ get: fn ($value) => (string)$value,);}}diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.phpindex 6d00964384..1196f7a8e3 100644--- a/app/Models/TransactionCurrency.php+++ b/app/Models/TransactionCurrency.php@@ -1,4 +1,5 @@<?php+/*** TransactionCurrency.php* Copyright (c) 2019 [email protected]@@ -34,21 +35,21 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\TransactionCurrency*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property bool $enabled- * @property string $code- * @property string $name- * @property string $symbol- * @property int $decimal_places- * @property-read Collection|BudgetLimit[] $budgetLimits- * @property-read int|null $budget_limits_count+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property bool $enabled+ * @property string $code+ * @property string $name+ * @property string $symbol+ * @property int $decimal_places+ * @property-read Collection|BudgetLimit[] $budgetLimits+ * @property-read int|null $budget_limits_count* @property-read Collection|TransactionJournal[] $transactionJournals- * @property-read int|null $transaction_journals_count- * @property-read Collection|Transaction[] $transactions- * @property-read int|null $transactions_count+ * @property-read int|null $transaction_journals_count+ * @property-read Collection|Transaction[] $transactions+ * @property-read int|null $transactions_count* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency newQuery()* @method static Builder|TransactionCurrency onlyTrashed()@@ -89,7 +90,7 @@ class TransactionCurrency extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return TransactionCurrency* @throws NotFoundHttpException@@ -97,7 +98,7 @@ class TransactionCurrency extends Modelpublic static function routeBinder(string $value): TransactionCurrency{if (auth()->check()) {- $currencyId = (int) $value;+ $currencyId = (int)$value;$currency = self::find($currencyId);if (null !== $currency) {return $currency;diff --git a/app/Models/TransactionGroup.php b/app/Models/TransactionGroup.phpindex a22763c667..627f5c756d 100644--- a/app/Models/TransactionGroup.php+++ b/app/Models/TransactionGroup.php@@ -1,4 +1,5 @@<?php+/*** TransactionGroup.php* Copyright (c) 2019 [email protected]@@ -36,15 +37,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\TransactionGroup*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $user_id- * @property string|null $title+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $user_id+ * @property string|null $title* @property-read Collection|TransactionJournal[] $transactionJournals- * @property-read int|null $transaction_journals_count- * @property-read User $user+ * @property-read int|null $transaction_journals_count+ * @property-read User $user* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup newQuery()* @method static Builder|TransactionGroup onlyTrashed()@@ -58,7 +59,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|TransactionGroup withTrashed()* @method static Builder|TransactionGroup withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup whereUserGroupId($value)*/class TransactionGroup extends Model@@ -86,7 +87,7 @@ class TransactionGroup extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return TransactionGroup* @throws NotFoundHttpException@@ -94,7 +95,7 @@ class TransactionGroup extends Modelpublic static function routeBinder(string $value): TransactionGroup{if (auth()->check()) {- $groupId = (int) $value;+ $groupId = (int)$value;/** @var User $user */$user = auth()->user();/** @var TransactionGroup $group */@@ -111,19 +112,19 @@ class TransactionGroup extends Model/*** @codeCoverageIgnore- * @return HasMany+ * @return BelongsTo*/- public function transactionJournals(): HasMany+ public function user(): BelongsTo{- return $this->hasMany(TransactionJournal::class);+ return $this->belongsTo(User::class);}/*** @codeCoverageIgnore- * @return BelongsTo+ * @return HasMany*/- public function user(): BelongsTo+ public function transactionJournals(): HasMany{- return $this->belongsTo(User::class);+ return $this->hasMany(TransactionJournal::class);}}diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.phpindex a1541e13e3..03fe540362 100644--- a/app/Models/TransactionJournal.php+++ b/app/Models/TransactionJournal.php@@ -1,4 +1,5 @@<?php+/*** TransactionJournal.php* Copyright (c) 2019 [email protected]@@ -40,50 +41,50 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\TransactionJournal*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $user_id- * @property int $transaction_type_id- * @property int|null $transaction_group_id- * @property int|null $bill_id- * @property int|null $transaction_currency_id- * @property string $description- * @property Carbon $date- * @property Carbon|null $interest_date- * @property Carbon|null $book_date- * @property Carbon|null $process_date- * @property int $order- * @property int $tag_count- * @property string $transaction_type_type- * @property bool $encrypted- * @property bool $completed- * @property-read Collection|Attachment[] $attachments- * @property-read int|null $attachments_count- * @property-read Bill|null $bill- * @property-read Collection|Budget[] $budgets- * @property-read int|null $budgets_count- * @property-read Collection|Category[] $categories- * @property-read int|null $categories_count+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $user_id+ * @property int $transaction_type_id+ * @property int|null $transaction_group_id+ * @property int|null $bill_id+ * @property int|null $transaction_currency_id+ * @property string $description+ * @property Carbon $date+ * @property Carbon|null $interest_date+ * @property Carbon|null $book_date+ * @property Carbon|null $process_date+ * @property int $order+ * @property int $tag_count+ * @property string $transaction_type_type+ * @property bool $encrypted+ * @property bool $completed+ * @property-read Collection|Attachment[] $attachments+ * @property-read int|null $attachments_count+ * @property-read Bill|null $bill+ * @property-read Collection|Budget[] $budgets+ * @property-read int|null $budgets_count+ * @property-read Collection|Category[] $categories+ * @property-read int|null $categories_count* @property-read Collection|TransactionJournalLink[] $destJournalLinks- * @property-read int|null $dest_journal_links_count- * @property-read Collection|Note[] $notes- * @property-read int|null $notes_count- * @property-read Collection|PiggyBankEvent[] $piggyBankEvents- * @property-read int|null $piggy_bank_events_count+ * @property-read int|null $dest_journal_links_count+ * @property-read Collection|Note[] $notes+ * @property-read int|null $notes_count+ * @property-read Collection|PiggyBankEvent[] $piggyBankEvents+ * @property-read int|null $piggy_bank_events_count* @property-read Collection|TransactionJournalLink[] $sourceJournalLinks- * @property-read int|null $source_journal_links_count- * @property-read Collection|Tag[] $tags- * @property-read int|null $tags_count- * @property-read TransactionCurrency|null $transactionCurrency- * @property-read TransactionGroup|null $transactionGroup+ * @property-read int|null $source_journal_links_count+ * @property-read Collection|Tag[] $tags+ * @property-read int|null $tags_count+ * @property-read TransactionCurrency|null $transactionCurrency+ * @property-read TransactionGroup|null $transactionGroup* @property-read Collection|TransactionJournalMeta[] $transactionJournalMeta- * @property-read int|null $transaction_journal_meta_count- * @property-read TransactionType $transactionType- * @property-read Collection|Transaction[] $transactions- * @property-read int|null $transactions_count- * @property-read User $user+ * @property-read int|null $transaction_journal_meta_count+ * @property-read TransactionType $transactionType+ * @property-read Collection|Transaction[] $transactions+ * @property-read int|null $transactions_count+ * @property-read User $user* @method static EloquentBuilder|TransactionJournal after(Carbon $date)* @method static EloquentBuilder|TransactionJournal before(Carbon $date)* @method static EloquentBuilder|TransactionJournal newModelQuery()@@ -112,10 +113,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static \Illuminate\Database\Query\Builder|TransactionJournal withTrashed()* @method static \Illuminate\Database\Query\Builder|TransactionJournal withoutTrashed()* @mixin Eloquent- * @property-read Collection|Location[] $locations- * @property-read int|null $locations_count- * @property int $the_count- * @property int|null $user_group_id+ * @property-read Collection|Location[] $locations+ * @property-read int|null $locations_count+ * @property int $the_count+ * @property int|null $user_group_id* @method static EloquentBuilder|TransactionJournal whereUserGroupId($value)*/class TransactionJournal extends Model@@ -145,15 +146,24 @@ class TransactionJournal extends Model/** @var array Fields that can be filled */protected $fillable- = ['user_id', 'transaction_type_id', 'bill_id', 'tag_count', 'transaction_currency_id', 'description', 'completed', 'order',- 'date'];+ = [+ 'user_id',+ 'transaction_type_id',+ 'bill_id',+ 'tag_count',+ 'transaction_currency_id',+ 'description',+ 'completed',+ 'order',+ 'date',+ ];/** @var array Hidden from view */protected $hidden = ['encrypted'];/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return TransactionJournal* @throws NotFoundHttpException@@ -161,7 +171,7 @@ class TransactionJournal extends Modelpublic static function routeBinder(string $value): TransactionJournal{if (auth()->check()) {- $journalId = (int) $value;+ $journalId = (int)$value;/** @var User $user */$user = auth()->user();/** @var TransactionJournal $journal */@@ -174,6 +184,15 @@ class TransactionJournal extends Modelthrow new NotFoundHttpException();}+ /**+ * @codeCoverageIgnore+ * @return BelongsTo+ */+ public function user(): BelongsTo+ {+ return $this->belongsTo(User::class);+ }+/*** @codeCoverageIgnore* @return MorphMany@@ -262,8 +281,8 @@ class TransactionJournal extends Model/*** @codeCoverageIgnore*- * @param EloquentBuilder $query- * @param Carbon $date+ * @param EloquentBuilder $query+ * @param Carbon $date** @return EloquentBuilder*/@@ -275,8 +294,8 @@ class TransactionJournal extends Model/*** @codeCoverageIgnore*- * @param EloquentBuilder $query- * @param Carbon $date+ * @param EloquentBuilder $query+ * @param Carbon $date** @return EloquentBuilder*/@@ -288,8 +307,8 @@ class TransactionJournal extends Model/*** @codeCoverageIgnore*- * @param EloquentBuilder $query- * @param array $types+ * @param EloquentBuilder $query+ * @param array $types*/public function scopeTransactionTypes(EloquentBuilder $query, array $types): void{@@ -306,8 +325,8 @@ class TransactionJournal extends Model** @codeCoverageIgnore*- * @param Builder $query- * @param string $table+ * @param Builder $query+ * @param string $table** @return bool*/@@ -388,13 +407,4 @@ class TransactionJournal extends Model{return $this->hasMany(Transaction::class);}-- /**- * @codeCoverageIgnore- * @return BelongsTo- */- public function user(): BelongsTo- {- return $this->belongsTo(User::class);- }}diff --git a/app/Models/TransactionJournalLink.php b/app/Models/TransactionJournalLink.phpindex 34e819a2d8..937acf1713 100644--- a/app/Models/TransactionJournalLink.php+++ b/app/Models/TransactionJournalLink.php@@ -1,4 +1,5 @@<?php+/*** TransactionJournalLink.php* Copyright (c) 2019 [email protected]@@ -34,20 +35,20 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\TransactionJournalLink*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property int $link_type_id- * @property int $source_id- * @property int $destination_id- * @property string|null $comment+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property int $link_type_id+ * @property int $source_id+ * @property int $destination_id+ * @property string|null $comment* @property-read TransactionJournal $destination- * @property-read LinkType $linkType- * @property-read Collection|Note[] $notes- * @property-read int|null $notes_count+ * @property-read LinkType $linkType+ * @property-read Collection|Note[] $notes+ * @property-read int|null $notes_count* @property-read TransactionJournal $source- * @property-read string $inward- * @property-read string $outward+ * @property-read string $inward+ * @property-read string $outward* @method static Builder|TransactionJournalLink newModelQuery()* @method static Builder|TransactionJournalLink newQuery()* @method static Builder|TransactionJournalLink query()@@ -78,7 +79,7 @@ class TransactionJournalLink extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return TransactionJournalLink*@@ -87,7 +88,7 @@ class TransactionJournalLink extends Modelpublic static function routeBinder(string $value): TransactionJournalLink{if (auth()->check()) {- $linkId = (int) $value;+ $linkId = (int)$value;$link = self::where('journal_links.id', $linkId)->leftJoin('transaction_journals as t_a', 't_a.id', '=', 'source_id')->leftJoin('transaction_journals as t_b', 't_b.id', '=', 'destination_id')diff --git a/app/Models/TransactionJournalMeta.php b/app/Models/TransactionJournalMeta.phpindex 94a9feba64..823bcb01a6 100644--- a/app/Models/TransactionJournalMeta.php+++ b/app/Models/TransactionJournalMeta.php@@ -1,4 +1,5 @@<?php+/*** TransactionJournalMeta.php* Copyright (c) 2019 [email protected]@@ -32,14 +33,14 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\TransactionJournalMeta*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property int $transaction_journal_id- * @property string $name- * @property mixed $data- * @property string $hash- * @property Carbon|null $deleted_at+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property int $transaction_journal_id+ * @property string $name+ * @property mixed $data+ * @property string $hash+ * @property Carbon|null $deleted_at* @property-read TransactionJournal $transactionJournal* @method static \Illuminate\Database\Eloquent\Builder|TransactionJournalMeta newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|TransactionJournalMeta newQuery()@@ -80,7 +81,7 @@ class TransactionJournalMeta extends Model/*** @codeCoverageIgnore*- * @param mixed $value+ * @param mixed $value** @return mixed*/@@ -92,7 +93,7 @@ class TransactionJournalMeta extends Model/*** @codeCoverageIgnore*- * @param mixed $value+ * @param mixed $value*/public function setDataAttribute($value): void{diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.phpindex 989cb92575..b39832d757 100644--- a/app/Models/TransactionType.php+++ b/app/Models/TransactionType.php@@ -1,4 +1,5 @@<?php+/*** TransactionType.php* Copyright (c) 2019 [email protected]@@ -34,13 +35,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\TransactionType*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property string $type+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property string $type* @property-read Collection|TransactionJournal[] $transactionJournals- * @property-read int|null $transaction_journals_count+ * @property-read int|null $transaction_journals_count* @method static \Illuminate\Database\Eloquent\Builder|TransactionType newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|TransactionType newQuery()* @method static Builder|TransactionType onlyTrashed()@@ -57,6 +58,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;class TransactionType extends Model{use SoftDeletes;+public const DEPOSIT = 'Deposit';public const INVALID = 'Invalid';public const LIABILITY_CREDIT = 'Liability credit';@@ -76,7 +78,7 @@ class TransactionType extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $type+ * @param string $type** @return TransactionType* @throws NotFoundHttpExceptiondiff --git a/app/Models/UserGroup.php b/app/Models/UserGroup.phpindex 4ebc662242..f5bbe869f8 100644--- a/app/Models/UserGroup.php+++ b/app/Models/UserGroup.php@@ -34,13 +34,13 @@ use Illuminate\Support\Carbon;/*** Class UserGroup*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property string|null $deleted_at- * @property string $title+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property string|null $deleted_at+ * @property string $title* @property-read Collection|GroupMembership[] $groupMemberships- * @property-read int|null $group_memberships_count+ * @property-read int|null $group_memberships_count* @method static Builder|UserGroup newModelQuery()* @method static Builder|UserGroup newQuery()* @method static Builder|UserGroup query()diff --git a/app/Models/UserRole.php b/app/Models/UserRole.phpindex 2ba67bca33..0247c4ca58 100644--- a/app/Models/UserRole.php+++ b/app/Models/UserRole.php@@ -34,13 +34,13 @@ use Illuminate\Support\Carbon;/*** Class UserRole*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property string|null $deleted_at- * @property string $title+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property string|null $deleted_at+ * @property string $title* @property-read Collection|GroupMembership[] $groupMemberships- * @property-read int|null $group_memberships_count+ * @property-read int|null $group_memberships_count* @method static Builder|UserRole newModelQuery()* @method static Builder|UserRole newQuery()* @method static Builder|UserRole query()@@ -57,9 +57,9 @@ class UserRole extends Modelpublic const CHANGE_REPETITIONS = 'change_reps';public const CHANGE_RULES = 'change_rules';public const CHANGE_TRANSACTIONS = 'change_tx';- public const MANAGE_WEBHOOKS = 'manage_webhooks';- public const MANAGE_CURRENCIES = 'manage_currencies';public const FULL = 'full';+ public const MANAGE_CURRENCIES = 'manage_currencies';+ public const MANAGE_WEBHOOKS = 'manage_webhooks';public const OWNER = 'owner';public const READ_ONLY = 'ro';public const VIEW_REPORTS = 'view_reports';diff --git a/app/Models/Webhook.php b/app/Models/Webhook.phpindex d3176266e6..bf38d394b7 100644--- a/app/Models/Webhook.php+++ b/app/Models/Webhook.php@@ -40,19 +40,19 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\Webhook*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $user_id- * @property bool $active- * @property int $trigger- * @property int $response- * @property int $delivery- * @property string $url- * @property-read User $user+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $user_id+ * @property bool $active+ * @property int $trigger+ * @property int $response+ * @property int $delivery+ * @property string $url+ * @property-read User $user* @property-read Collection|WebhookMessage[] $webhookMessages- * @property-read int|null $webhook_messages_count+ * @property-read int|null $webhook_messages_count* @method static Builder|Webhook newModelQuery()* @method static Builder|Webhook newQuery()* @method static \Illuminate\Database\Query\Builder|Webhook onlyTrashed()@@ -70,11 +70,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static \Illuminate\Database\Query\Builder|Webhook withTrashed()* @method static \Illuminate\Database\Query\Builder|Webhook withoutTrashed()* @mixin Eloquent- * @property string $title- * @property string $secret+ * @property string $title+ * @property string $secret* @method static Builder|Webhook whereSecret($value)* @method static Builder|Webhook whereTitle($value)- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static Builder|Webhook whereUserGroupId($value)*/class Webhook extends Model@@ -90,54 +90,13 @@ class Webhook extends Model];protected $fillable = ['active', 'trigger', 'response', 'delivery', 'user_id', 'url', 'title', 'secret'];- /**- * Route binder. Converts the key in the URL to the specified object (or throw 404).- *- * @param string $value- *- * @return Webhook- * @throws NotFoundHttpException- */- public static function routeBinder(string $value): Webhook- {- if (auth()->check()) {- $webhookId = (int) $value;- /** @var User $user */- $user = auth()->user();- /** @var Webhook $webhook */- $webhook = $user->webhooks()->find($webhookId);- if (null !== $webhook) {- return $webhook;- }- }- throw new NotFoundHttpException();- }-- /**- * @codeCoverageIgnore- * @return BelongsTo- */- public function user(): BelongsTo- {- return $this->belongsTo(User::class);- }-- /**- * @codeCoverageIgnore- * @return HasMany- */- public function webhookMessages(): HasMany- {- return $this->hasMany(WebhookMessage::class);- }-/*** @return array*/- public static function getTriggers(): array+ public static function getDeliveries(): array{$array = [];- $set = WebhookTrigger::cases();+ $set = WebhookDelivery::cases();foreach ($set as $item) {$array[$item->value] = $item->name;}@@ -147,12 +106,12 @@ class Webhook extends Model/*** @return array*/- public static function getTriggersForValidation(): array+ public static function getDeliveriesForValidation(): array{$array = [];- $set = WebhookTrigger::cases();+ $set = WebhookDelivery::cases();foreach ($set as $item) {- $array[$item->name] = $item->value;+ $array[$item->name] = $item->value;$array[$item->value] = $item->value;}return $array;@@ -161,13 +120,12 @@ class Webhook extends Model/*** @return array*/- public static function getResponsesForValidation(): array+ public static function getResponses(): array{$array = [];$set = WebhookResponse::cases();foreach ($set as $item) {- $array[$item->name] = $item->value;- $array[$item->value] = $item->value;+ $array[$item->value] = $item->name;}return $array;}@@ -175,12 +133,12 @@ class Webhook extends Model/*** @return array*/- public static function getDeliveriesForValidation(): array+ public static function getResponsesForValidation(): array{$array = [];- $set = WebhookDelivery::cases();+ $set = WebhookResponse::cases();foreach ($set as $item) {- $array[$item->name] = $item->value;+ $array[$item->name] = $item->value;$array[$item->value] = $item->value;}return $array;@@ -189,10 +147,10 @@ class Webhook extends Model/*** @return array*/- public static function getResponses(): array+ public static function getTriggers(): array{$array = [];- $set = WebhookResponse::cases();+ $set = WebhookTrigger::cases();foreach ($set as $item) {$array[$item->value] = $item->name;}@@ -202,13 +160,55 @@ class Webhook extends Model/*** @return array*/- public static function getDeliveries(): array+ public static function getTriggersForValidation(): array{$array = [];- $set = WebhookDelivery::cases();+ $set = WebhookTrigger::cases();foreach ($set as $item) {- $array[$item->value] = $item->name;+ $array[$item->name] = $item->value;+ $array[$item->value] = $item->value;}return $array;}++ /**+ * Route binder. Converts the key in the URL to the specified object (or throw 404).+ *+ * @param string $value+ *+ * @return Webhook+ * @throws NotFoundHttpException+ */+ public static function routeBinder(string $value): Webhook+ {+ if (auth()->check()) {+ $webhookId = (int)$value;+ /** @var User $user */+ $user = auth()->user();+ /** @var Webhook $webhook */+ $webhook = $user->webhooks()->find($webhookId);+ if (null !== $webhook) {+ return $webhook;+ }+ }+ throw new NotFoundHttpException();+ }++ /**+ * @codeCoverageIgnore+ * @return BelongsTo+ */+ public function user(): BelongsTo+ {+ return $this->belongsTo(User::class);+ }++ /**+ * @codeCoverageIgnore+ * @return HasMany+ */+ public function webhookMessages(): HasMany+ {+ return $this->hasMany(WebhookMessage::class);+ }}diff --git a/app/Models/WebhookAttempt.php b/app/Models/WebhookAttempt.phpindex 97538899aa..9d1c296626 100644--- a/app/Models/WebhookAttempt.php+++ b/app/Models/WebhookAttempt.php@@ -35,14 +35,14 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** Class WebhookAttempt*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property string|null $deleted_at- * @property int $webhook_message_id- * @property int $status_code- * @property string|null $logs- * @property string|null $response+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property string|null $deleted_at+ * @property int $webhook_message_id+ * @property int $status_code+ * @property string|null $logs+ * @property string|null $response* @property-read WebhookMessage $webhookMessage* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt newQuery()@@ -67,7 +67,7 @@ class WebhookAttempt extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return WebhookAttempt* @throws NotFoundHttpException@@ -75,7 +75,7 @@ class WebhookAttempt extends Modelpublic static function routeBinder(string $value): WebhookAttempt{if (auth()->check()) {- $attemptId = (int) $value;+ $attemptId = (int)$value;/** @var User $user */$user = auth()->user();/** @var WebhookAttempt $attempt */diff --git a/app/Models/WebhookMessage.php b/app/Models/WebhookMessage.phpindex 03a740e4ec..19d62f451a 100644--- a/app/Models/WebhookMessage.php+++ b/app/Models/WebhookMessage.php@@ -36,18 +36,18 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\WebhookMessage*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property string|null $deleted_at- * @property int $webhook_id- * @property bool $sent- * @property bool $errored- * @property int $attempts- * @property string $uuid- * @property array $message- * @property array|null $logs- * @property-read Webhook $webhook+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property string|null $deleted_at+ * @property int $webhook_id+ * @property bool $sent+ * @property bool $errored+ * @property int $attempts+ * @property string $uuid+ * @property array $message+ * @property array|null $logs+ * @property-read Webhook $webhook* @method static Builder|WebhookMessage newModelQuery()* @method static Builder|WebhookMessage newQuery()* @method static Builder|WebhookMessage query()@@ -64,7 +64,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|WebhookMessage whereWebhookId($value)* @mixin Eloquent* @property-read Collection|WebhookAttempt[] $webhookAttempts- * @property-read int|null $webhook_attempts_count+ * @property-read int|null $webhook_attempts_count*/class WebhookMessage extends Model{@@ -80,7 +80,7 @@ class WebhookMessage extends Model/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*- * @param string $value+ * @param string $value** @return WebhookMessage* @throws NotFoundHttpException@@ -88,7 +88,7 @@ class WebhookMessage extends Modelpublic static function routeBinder(string $value): WebhookMessage{if (auth()->check()) {- $messageId = (int) $value;+ $messageId = (int)$value;/** @var User $user */$user = auth()->user();/** @var WebhookMessage $message */diff --git a/app/Notifications/Admin/TestNotification.php b/app/Notifications/Admin/TestNotification.phpindex 99d8437c87..ad21a8d2d7 100644--- a/app/Notifications/Admin/TestNotification.php+++ b/app/Notifications/Admin/TestNotification.php@@ -49,50 +49,50 @@ class TestNotification extends Notification}/**- * Get the notification's delivery channels.+ * Get the array representation of the notification.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return array*/- public function via($notifiable)+ public function toArray($notifiable){- return ['mail', 'slack'];+ return [+ //+ ];}/*** Get the mail representation of the notification.*- * @param mixed $notifiable- * @return \Illuminate\Notifications\Messages\MailMessage+ * @param mixed $notifiable+ * @return MailMessage*/public function toMail($notifiable){return (new MailMessage())->markdown('emails.admin-test', ['email' => $this->address])- ->subject((string) trans('email.admin_test_subject'));+ ->subject((string)trans('email.admin_test_subject'));}/*** Get the Slack representation of the notification.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return SlackMessage*/public function toSlack($notifiable){- return (new SlackMessage())->content((string) trans('email.admin_test_subject'));+ return (new SlackMessage())->content((string)trans('email.admin_test_subject'));}/**- * Get the array representation of the notification.+ * Get the notification's delivery channels.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return array*/- public function toArray($notifiable)+ public function via($notifiable){- return [- //- ];+ return ['mail', 'slack'];}}diff --git a/app/Notifications/Admin/UserInvitation.php b/app/Notifications/Admin/UserInvitation.phpindex cfc2af2ea5..5b17c60412 100644--- a/app/Notifications/Admin/UserInvitation.php+++ b/app/Notifications/Admin/UserInvitation.php@@ -50,50 +50,52 @@ class UserInvitation extends Notification}/**- * Get the notification's delivery channels.+ * Get the array representation of the notification.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return array*/- public function via($notifiable)+ public function toArray($notifiable){- return ['mail', 'slack'];+ return [+ //+ ];}/*** Get the mail representation of the notification.*- * @param mixed $notifiable- * @return \Illuminate\Notifications\Messages\MailMessage+ * @param mixed $notifiable+ * @return MailMessage*/public function toMail($notifiable){return (new MailMessage())->markdown('emails.invitation-created', ['email' => $this->invitee->user->email, 'invitee' => $this->invitee->email])- ->subject((string) trans('email.invitation_created_subject'));+ ->subject((string)trans('email.invitation_created_subject'));}/*** Get the Slack representation of the notification.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return SlackMessage*/public function toSlack($notifiable){- return (new SlackMessage())->content((string) trans('email.invitation_created_body', ['email' => $this->invitee->user->email, 'invitee' => $this->invitee->email]));+ return (new SlackMessage())->content(+ (string)trans('email.invitation_created_body', ['email' => $this->invitee->user->email, 'invitee' => $this->invitee->email])+ );}/**- * Get the array representation of the notification.+ * Get the notification's delivery channels.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return array*/- public function toArray($notifiable)+ public function via($notifiable){- return [- //- ];+ return ['mail', 'slack'];}}diff --git a/app/Notifications/Admin/UserRegistration.php b/app/Notifications/Admin/UserRegistration.phpindex 16f4b517fa..a9636020a9 100644--- a/app/Notifications/Admin/UserRegistration.php+++ b/app/Notifications/Admin/UserRegistration.php@@ -50,50 +50,50 @@ class UserRegistration extends Notification}/**- * Get the notification's delivery channels.+ * Get the array representation of the notification.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return array*/- public function via($notifiable)+ public function toArray($notifiable){- return ['mail', 'slack'];+ return [+ //+ ];}/*** Get the mail representation of the notification.*- * @param mixed $notifiable- * @return \Illuminate\Notifications\Messages\MailMessage+ * @param mixed $notifiable+ * @return MailMessage*/public function toMail($notifiable){return (new MailMessage())->markdown('emails.registered-admin', ['email' => $this->user->email, 'id' => $this->user->id])- ->subject((string) trans('email.registered_subject_admin'));+ ->subject((string)trans('email.registered_subject_admin'));}/*** Get the Slack representation of the notification.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return SlackMessage*/public function toSlack($notifiable){- return (new SlackMessage())->content((string) trans('email.admin_new_user_registered', ['email' => $this->user->email, 'id' => $this->user->id]));+ return (new SlackMessage())->content((string)trans('email.admin_new_user_registered', ['email' => $this->user->email, 'id' => $this->user->id]));}/**- * Get the array representation of the notification.+ * Get the notification's delivery channels.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return array*/- public function toArray($notifiable)+ public function via($notifiable){- return [- //- ];+ return ['mail', 'slack'];}}diff --git a/app/Notifications/Admin/VersionCheckResult.php b/app/Notifications/Admin/VersionCheckResult.phpindex 1cd56c1b33..a8d3ce7f1a 100644--- a/app/Notifications/Admin/VersionCheckResult.php+++ b/app/Notifications/Admin/VersionCheckResult.php@@ -50,53 +50,53 @@ class VersionCheckResult extends Notification}/**- * Get the notification's delivery channels.+ * Get the array representation of the notification.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return array*/- public function via($notifiable)+ public function toArray($notifiable){- return ['mail', 'slack'];+ return [+ //+ ];}/*** Get the mail representation of the notification.*- * @param mixed $notifiable- * @return \Illuminate\Notifications\Messages\MailMessage+ * @param mixed $notifiable+ * @return MailMessage*/public function toMail($notifiable){return (new MailMessage())->markdown('emails.new-version', ['message' => $this->message])- ->subject((string) trans('email.new_version_email_subject'));+ ->subject((string)trans('email.new_version_email_subject'));}/*** Get the Slack representation of the notification.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return SlackMessage*/public function toSlack($notifiable){return (new SlackMessage())->content($this->message)- ->attachment(function ($attachment) {- $attachment->title('Firefly III @ GitHub', 'https://github.com/firefly-iii/firefly-iii/releases');- });+ ->attachment(function ($attachment) {+ $attachment->title('Firefly III @ GitHub', 'https://github.com/firefly-iii/firefly-iii/releases');+ });}/**- * Get the array representation of the notification.+ * Get the notification's delivery channels.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return array*/- public function toArray($notifiable)+ public function via($notifiable){- return [- //- ];+ return ['mail', 'slack'];}}diff --git a/app/Notifications/User/BillReminder.php b/app/Notifications/User/BillReminder.phpindex d17b8f775f..677dd6fa47 100644--- a/app/Notifications/User/BillReminder.php+++ b/app/Notifications/User/BillReminder.php@@ -38,8 +38,8 @@ class BillReminder extends Notificationuse Queueable;private Bill $bill;- private string $field;private int $diff;+ private string $field;/*** Create a new notification instance.@@ -54,27 +54,29 @@ class BillReminder extends Notification}/**- * Get the notification's delivery channels.+ * Get the array representation of the notification.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return array*/- public function via($notifiable)+ public function toArray($notifiable){- return ['mail', 'slack'];+ return [+ //+ ];}/*** Get the mail representation of the notification.*- * @param mixed $notifiable- * @return \Illuminate\Notifications\Messages\MailMessage+ * @param mixed $notifiable+ * @return MailMessage*/public function toMail($notifiable){- $subject = (string) trans(sprintf('email.bill_warning_subject_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);+ $subject = (string)trans(sprintf('email.bill_warning_subject_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);if (0 === $this->diff) {- $subject = (string) trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);+ $subject = (string)trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);}return (new MailMessage())@@ -85,35 +87,33 @@ class BillReminder extends Notification/*** Get the Slack representation of the notification.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return SlackMessage*/public function toSlack($notifiable){- $message = (string) trans(sprintf('email.bill_warning_subject_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);+ $message = (string)trans(sprintf('email.bill_warning_subject_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);if (0 === $this->diff) {- $message = (string) trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);+ $message = (string)trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);}$bill = $this->bill;$url = route('bills.show', [$bill->id]);return (new SlackMessage())->warning()->attachment(function ($attachment) use ($bill, $url) {- $attachment->title((string) trans('firefly.visit_bill', ['name' => $bill->name]), $url);+ $attachment->title((string)trans('firefly.visit_bill', ['name' => $bill->name]), $url);})->content($message);}/**- * Get the array representation of the notification.+ * Get the notification's delivery channels.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return array*/- public function toArray($notifiable)+ public function via($notifiable){- return [- //- ];+ return ['mail', 'slack'];}}diff --git a/app/Notifications/User/NewAccessToken.php b/app/Notifications/User/NewAccessToken.phpindex d70919de2c..867c3fd4b9 100644--- a/app/Notifications/User/NewAccessToken.php+++ b/app/Notifications/User/NewAccessToken.php@@ -43,49 +43,50 @@ class NewAccessToken extends Notification}/**- * Get the notification's delivery channels.+ * Get the array representation of the notification.** @param mixed $notifiable* @return array*/- public function via($notifiable)+ public function toArray($notifiable){- return ['mail', 'slack'];+ return [+ //+ ];}/*** Get the mail representation of the notification.** @param mixed $notifiable- * @return \Illuminate\Notifications\Messages\MailMessage+ * @return MailMessage*/public function toMail($notifiable){return (new MailMessage())->markdown('emails.token-created')- ->subject((string) trans('email.access_token_created_subject'));+ ->subject((string)trans('email.access_token_created_subject'));}+/*** Get the Slack representation of the notification.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return SlackMessage*/public function toSlack($notifiable){- return (new SlackMessage())->content((string) trans('email.access_token_created_body'));+ return (new SlackMessage())->content((string)trans('email.access_token_created_body'));}/**- * Get the array representation of the notification.+ * Get the notification's delivery channels.** @param mixed $notifiable* @return array*/- public function toArray($notifiable)+ public function via($notifiable){- return [- //- ];+ return ['mail', 'slack'];}}diff --git a/app/Notifications/User/TransactionCreation.php b/app/Notifications/User/TransactionCreation.phpindex 7dea4fcbbb..102ab79087 100644--- a/app/Notifications/User/TransactionCreation.php+++ b/app/Notifications/User/TransactionCreation.php@@ -27,7 +27,6 @@ namespace FireflyIII\Notifications\User;use Illuminate\Bus\Queueable;use Illuminate\Notifications\Messages\MailMessage;use Illuminate\Notifications\Notification;-use Illuminate\Support\Collection;class TransactionCreation extends Notification{@@ -46,39 +45,39 @@ class TransactionCreation extends Notification}/**- * Get the notification's delivery channels.+ * Get the array representation of the notification.** @param mixed $notifiable* @return array*/- public function via($notifiable)+ public function toArray($notifiable){- return ['mail'];+ return [+ //+ ];}/*** Get the mail representation of the notification.** @param mixed $notifiable- * @return \Illuminate\Notifications\Messages\MailMessage+ * @return MailMessage*/public function toMail($notifiable){return (new MailMessage())->markdown('emails.report-new-journals', ['transformed' => $this->collection])- ->subject((string) trans_choice('email.new_journals_subject', count($this->collection)));+ ->subject((string)trans_choice('email.new_journals_subject', count($this->collection)));}/**- * Get the array representation of the notification.+ * Get the notification's delivery channels.** @param mixed $notifiable* @return array*/- public function toArray($notifiable)+ public function via($notifiable){- return [- //- ];+ return ['mail'];}}diff --git a/app/Notifications/User/UserLogin.php b/app/Notifications/User/UserLogin.phpindex 263cc7db90..9ec2a5bc35 100644--- a/app/Notifications/User/UserLogin.php+++ b/app/Notifications/User/UserLogin.php@@ -47,25 +47,27 @@ class UserLogin extends Notification}/**- * Get the notification's delivery channels.+ * Get the array representation of the notification.** @param mixed $notifiable* @return array*/- public function via($notifiable)+ public function toArray($notifiable){- return ['mail', 'slack'];+ return [+ //+ ];}/*** Get the mail representation of the notification.** @param mixed $notifiable- * @return \Illuminate\Notifications\Messages\MailMessage+ * @return MailMessage*/public function toMail($notifiable){- $time = now(config('app.timezone'))->isoFormat((string) trans('config.date_time_js'));+ $time = now(config('app.timezone'))->isoFormat((string)trans('config.date_time_js'));$host = '';try {$hostName = gethostbyaddr($this->ip);@@ -78,13 +80,13 @@ class UserLogin extends Notificationreturn (new MailMessage())->markdown('emails.new-ip', ['time' => $time, 'ipAddress' => $this->ip, 'host' => $host])- ->subject((string) trans('email.login_from_new_ip'));+ ->subject((string)trans('email.login_from_new_ip'));}/*** Get the Slack representation of the notification.*- * @param mixed $notifiable+ * @param mixed $notifiable* @return SlackMessage*/public function toSlack($notifiable)@@ -99,19 +101,17 @@ class UserLogin extends Notification$host = $hostName;}- return (new SlackMessage())->content((string) trans('email.slack_login_from_new_ip', ['host' => $host, 'ip' => $this->ip]));+ return (new SlackMessage())->content((string)trans('email.slack_login_from_new_ip', ['host' => $host, 'ip' => $this->ip]));}/**- * Get the array representation of the notification.+ * Get the notification's delivery channels.** @param mixed $notifiable* @return array*/- public function toArray($notifiable)+ public function via($notifiable){- return [- //- ];+ return ['mail', 'slack'];}}diff --git a/app/Notifications/User/UserNewPassword.php b/app/Notifications/User/UserNewPassword.phpindex 2141a634cc..48f14421b1 100644--- a/app/Notifications/User/UserNewPassword.php+++ b/app/Notifications/User/UserNewPassword.php@@ -45,39 +45,39 @@ class UserNewPassword extends Notification}/**- * Get the notification's delivery channels.+ * Get the array representation of the notification.** @param mixed $notifiable* @return array*/- public function via($notifiable)+ public function toArray($notifiable){- return ['mail'];+ return [+ //+ ];}/*** Get the mail representation of the notification.** @param mixed $notifiable- * @return \Illuminate\Notifications\Messages\MailMessage+ * @return MailMessage*/public function toMail($notifiable){return (new MailMessage())->markdown('emails.password', ['url' => $this->url])- ->subject((string) trans('email.reset_pw_subject'));+ ->subject((string)trans('email.reset_pw_subject'));}/**- * Get the array representation of the notification.+ * Get the notification's delivery channels.** @param mixed $notifiable* @return array*/- public function toArray($notifiable)+ public function via($notifiable){- return [- //- ];+ return ['mail'];}}diff --git a/app/Notifications/User/UserRegistration.php b/app/Notifications/User/UserRegistration.phpindex 0c30634939..ba5e39348a 100644--- a/app/Notifications/User/UserRegistration.php+++ b/app/Notifications/User/UserRegistration.php@@ -42,39 +42,39 @@ class UserRegistration extends Notification}/**- * Get the notification's delivery channels.+ * Get the array representation of the notification.** @param mixed $notifiable* @return array*/- public function via($notifiable)+ public function toArray($notifiable){- return ['mail'];+ return [+ //+ ];}/*** Get the mail representation of the notification.** @param mixed $notifiable- * @return \Illuminate\Notifications\Messages\MailMessage+ * @return MailMessage*/public function toMail($notifiable){return (new MailMessage())->markdown('emails.registered', ['address' => route('index')])- ->subject((string) trans('email.registered_subject'));+ ->subject((string)trans('email.registered_subject'));}/**- * Get the array representation of the notification.+ * Get the notification's delivery channels.** @param mixed $notifiable* @return array*/- public function toArray($notifiable)+ public function via($notifiable){- return [- //- ];+ return ['mail'];}}diff --git a/app/Providers/AccountServiceProvider.php b/app/Providers/AccountServiceProvider.phpindex c87627d280..ae57518c7b 100644--- a/app/Providers/AccountServiceProvider.php+++ b/app/Providers/AccountServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** AccountServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/AdminServiceProvider.php b/app/Providers/AdminServiceProvider.phpindex 1eb49323db..5e72a7b9e5 100644--- a/app/Providers/AdminServiceProvider.php+++ b/app/Providers/AdminServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** AdminServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.phpindex 9ceb51dd63..d622e55553 100644--- a/app/Providers/AppServiceProvider.php+++ b/app/Providers/AppServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** AppServiceProvider.php* Copyright (c) 2019 [email protected]@@ -22,12 +23,12 @@ declare(strict_types=1);namespace FireflyIII\Providers;+use Illuminate\Support\Facades\Response;use Illuminate\Support\Facades\Schema;use Illuminate\Support\ServiceProvider;use Laravel\Passport\Passport;use Laravel\Sanctum\Sanctum;use URL;-use Illuminate\Support\Facades\Response;/*** @codeCoverageIgnore@@ -49,9 +50,9 @@ class AppServiceProvider extends ServiceProviderResponse::macro('api', function (array $value) {$headers = [- 'Cache-Control' => 'no-store'+ 'Cache-Control' => 'no-store',];- $uuid = (string) request()->header('X-Trace-Id');+ $uuid = (string)request()->header('X-Trace-Id');if ('' !== trim($uuid) && (preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', trim($uuid)) === 1)) {$headers['X-Trace-Id'] = $uuid;}diff --git a/app/Providers/AttachmentServiceProvider.php b/app/Providers/AttachmentServiceProvider.phpindex 94e3052727..712f631a73 100644--- a/app/Providers/AttachmentServiceProvider.php+++ b/app/Providers/AttachmentServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** AttachmentServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.phpindex 124d56fed6..09dddfdcf2 100644--- a/app/Providers/AuthServiceProvider.php+++ b/app/Providers/AuthServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** AuthServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/BillServiceProvider.php b/app/Providers/BillServiceProvider.phpindex 7190f26798..ea3def27f9 100644--- a/app/Providers/BillServiceProvider.php+++ b/app/Providers/BillServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** BillServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.phpindex 99b4a17e1f..58e9475c01 100644--- a/app/Providers/BroadcastServiceProvider.php+++ b/app/Providers/BroadcastServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** BroadcastServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/BudgetServiceProvider.php b/app/Providers/BudgetServiceProvider.phpindex a2c5dd7a7b..6b9ebe6369 100644--- a/app/Providers/BudgetServiceProvider.php+++ b/app/Providers/BudgetServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** BudgetServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/CategoryServiceProvider.php b/app/Providers/CategoryServiceProvider.phpindex af3679b08f..131e9c8a1d 100644--- a/app/Providers/CategoryServiceProvider.php+++ b/app/Providers/CategoryServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** CategoryServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/CurrencyServiceProvider.php b/app/Providers/CurrencyServiceProvider.phpindex 0e4eafb253..442877d21f 100644--- a/app/Providers/CurrencyServiceProvider.php+++ b/app/Providers/CurrencyServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** CurrencyServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.phpindex a69a9ac361..e76b2af4e9 100644--- a/app/Providers/EventServiceProvider.php+++ b/app/Providers/EventServiceProvider.php@@ -172,6 +172,23 @@ class EventServiceProvider extends ServiceProvider$this->registerBudgetEvents();}+ /**+ * TODO needs a dedicated (static) method.+ */+ protected function registerCreateEvents(): void+ {+ PiggyBank::created(+ static function (PiggyBank $piggyBank) {+ $repetition = new PiggyBankRepetition();+ $repetition->piggyBank()->associate($piggyBank);+ $repetition->startdate = $piggyBank->startdate;+ $repetition->targetdate = $piggyBank->targetdate;+ $repetition->currentamount = 0;+ $repetition->save();+ }+ );+ }+/*** TODO needs a dedicated method.*/@@ -224,21 +241,4 @@ class EventServiceProvider extends ServiceProviderBudgetLimit::created($func);BudgetLimit::updated($func);}-- /**- * TODO needs a dedicated (static) method.- */- protected function registerCreateEvents(): void- {- PiggyBank::created(- static function (PiggyBank $piggyBank) {- $repetition = new PiggyBankRepetition();- $repetition->piggyBank()->associate($piggyBank);- $repetition->startdate = $piggyBank->startdate;- $repetition->targetdate = $piggyBank->targetdate;- $repetition->currentamount = 0;- $repetition->save();- }- );- }}diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.phpindex 9e96be7b62..8bc336d545 100644--- a/app/Providers/FireflyServiceProvider.php+++ b/app/Providers/FireflyServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** FireflyServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/FireflySessionProvider.php b/app/Providers/FireflySessionProvider.phpindex 6021e5d9ba..2d95dc0181 100644--- a/app/Providers/FireflySessionProvider.php+++ b/app/Providers/FireflySessionProvider.php@@ -1,4 +1,5 @@<?php+/*** FireflySessionProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/JournalServiceProvider.php b/app/Providers/JournalServiceProvider.phpindex cf8eb35024..d0ae1c155c 100644--- a/app/Providers/JournalServiceProvider.php+++ b/app/Providers/JournalServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** JournalServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/PiggyBankServiceProvider.php b/app/Providers/PiggyBankServiceProvider.phpindex d7e511f78c..54c1132ec1 100644--- a/app/Providers/PiggyBankServiceProvider.php+++ b/app/Providers/PiggyBankServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** PiggyBankServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/RecurringServiceProvider.php b/app/Providers/RecurringServiceProvider.phpindex 9d86053b47..b6d096a81c 100644--- a/app/Providers/RecurringServiceProvider.php+++ b/app/Providers/RecurringServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** RecurringServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.phpindex a6600f04a7..e72bf5eb69 100644--- a/app/Providers/RouteServiceProvider.php+++ b/app/Providers/RouteServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** RouteServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/RuleGroupServiceProvider.php b/app/Providers/RuleGroupServiceProvider.phpindex 19b9eceb78..2fbde7d142 100644--- a/app/Providers/RuleGroupServiceProvider.php+++ b/app/Providers/RuleGroupServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** RuleGroupServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/RuleServiceProvider.php b/app/Providers/RuleServiceProvider.phpindex 5215fd7a4d..c384faf0b3 100644--- a/app/Providers/RuleServiceProvider.php+++ b/app/Providers/RuleServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** RuleServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/SearchServiceProvider.php b/app/Providers/SearchServiceProvider.phpindex 1aa5941516..c47e7688eb 100644--- a/app/Providers/SearchServiceProvider.php+++ b/app/Providers/SearchServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** SearchServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/SessionServiceProvider.php b/app/Providers/SessionServiceProvider.phpindex 183b4a48e5..e02f8eda08 100644--- a/app/Providers/SessionServiceProvider.php+++ b/app/Providers/SessionServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** SessionServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Providers/TagServiceProvider.php b/app/Providers/TagServiceProvider.phpindex 64b9b3cf29..e8b7a063fd 100644--- a/app/Providers/TagServiceProvider.php+++ b/app/Providers/TagServiceProvider.php@@ -1,4 +1,5 @@<?php+/*** TagServiceProvider.php* Copyright (c) 2019 [email protected]diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex 6dc64a5187..caf53bfffb 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -1,4 +1,5 @@<?php+/*** AccountRepository.php* Copyright (c) 2019 [email protected]@@ -52,21 +53,11 @@ class AccountRepository implements AccountRepositoryInterface{private User $user;- /**- * @param array $types- *- * @return int- */- public function count(array $types): int- {- return $this->user->accounts()->accountTypeIn($types)->count();- }-/*** Moved here from account CRUD.*- * @param Account $account- * @param Account|null $moveTo+ * @param Account $account+ * @param Account|null $moveTo** @return bool*@@ -84,7 +75,7 @@ class AccountRepository implements AccountRepositoryInterface/*** Find account with same name OR same IBAN or both, but not the same type or ID.*- * @param Collection $accounts+ * @param Collection $accounts** @return Collection*/@@ -115,16 +106,6 @@ class AccountRepository implements AccountRepositoryInterfacereturn $result;}- /**- * @param int $accountId- *- * @return Account|null- */- public function find(int $accountId): ?Account- {- return $this->user->accounts()->find($accountId);- }-/*** @inheritDoc*/@@ -151,8 +132,8 @@ class AccountRepository implements AccountRepositoryInterface}/**- * @param string $iban- * @param array $types+ * @param string $iban+ * @param array $types** @return Account|null*/@@ -169,8 +150,8 @@ class AccountRepository implements AccountRepositoryInterface}/**- * @param string $name- * @param array $types+ * @param string $name+ * @param array $types** @return Account|null*/@@ -200,7 +181,7 @@ class AccountRepository implements AccountRepositoryInterface/*** Return account type or null if not found.*- * @param string $type+ * @param string $type** @return AccountType|null*/@@ -210,7 +191,7 @@ class AccountRepository implements AccountRepositoryInterface}/**- * @param array $accountIds+ * @param array $accountIds** @return Collection*/@@ -229,16 +210,19 @@ class AccountRepository implements AccountRepositoryInterface}/**- * @param array $types+ * @param array $types** @return Collection*/public function getActiveAccountsByType(array $types): Collection{$query = $this->user->accounts()->with(- ['accountmeta' => function (HasMany $query) {- $query->where('name', 'account_role');- }, 'attachments']+ [+ 'accountmeta' => function (HasMany $query) {+ $query->where('name', 'account_role');+ },+ 'attachments',+ ]);if (0 !== count($types)) {$query->accountTypeIn($types);@@ -288,15 +272,23 @@ class AccountRepository implements AccountRepositoryInterfacereturn $factory->findOrCreate('Cash account', $type->type);}+ /**+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }+/*** @inheritDoc*/public function getCreditTransactionGroup(Account $account): ?TransactionGroup{$journal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')- ->where('transactions.account_id', $account->id)- ->transactionTypes([TransactionType::LIABILITY_CREDIT])- ->first(['transaction_journals.*']);+ ->where('transactions.account_id', $account->id)+ ->transactionTypes([TransactionType::LIABILITY_CREDIT])+ ->first(['transaction_journals.*']);if (null === $journal) {return null;}@@ -305,16 +297,18 @@ class AccountRepository implements AccountRepositoryInterface}/**- * @param array $types+ * @param array $types** @return Collection*/public function getInactiveAccountsByType(array $types): Collection{$query = $this->user->accounts()->with(- ['accountmeta' => function (HasMany $query) {- $query->where('name', 'account_role');- }]+ [+ 'accountmeta' => function (HasMany $query) {+ $query->where('name', 'account_role');+ },+ ]);if (0 !== count($types)) {$query->accountTypeIn($types);@@ -338,7 +332,7 @@ class AccountRepository implements AccountRepositoryInterface/*** Get note text or null.*- * @param Account $account+ * @param Account $account** @return null|string*/@@ -356,7 +350,7 @@ class AccountRepository implements AccountRepositoryInterface/*** Returns the amount of the opening balance for this account.*- * @param Account $account+ * @param Account $account** @return string|null*/@@ -374,13 +368,13 @@ class AccountRepository implements AccountRepositoryInterfacereturn null;}- return (string) $transaction->amount;+ return (string)$transaction->amount;}/*** Return date of opening balance as string or null.*- * @param Account $account+ * @param Account $account** @return null|string*/@@ -398,7 +392,7 @@ class AccountRepository implements AccountRepositoryInterface}/**- * @param Account $account+ * @param Account $account** @return TransactionGroup|null*/@@ -410,20 +404,20 @@ class AccountRepository implements AccountRepositoryInterface}/**- * @param Account $account+ * @param Account $account** @return TransactionJournal|null*/public function getOpeningBalance(Account $account): ?TransactionJournal{return TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')- ->where('transactions.account_id', $account->id)- ->transactionTypes([TransactionType::OPENING_BALANCE])- ->first(['transaction_journals.*']);+ ->where('transactions.account_id', $account->id)+ ->transactionTypes([TransactionType::OPENING_BALANCE])+ ->first(['transaction_journals.*']);}/**- * @param Account $account+ * @param Account $account** @return Collection*/@@ -433,7 +427,7 @@ class AccountRepository implements AccountRepositoryInterface}/**- * @param Account $account+ * @param Account $account** @return Account|null*@@ -476,7 +470,7 @@ class AccountRepository implements AccountRepositoryInterface}/**- * @param Account $account+ * @param Account $account** @return TransactionCurrency|null*/@@ -489,7 +483,7 @@ class AccountRepository implements AccountRepositoryInterfaceif (!in_array($type, $list, true)) {return null;}- $currencyId = (int) $this->getMetaValue($account, 'currency_id');+ $currencyId = (int)$this->getMetaValue($account, 'currency_id');if ($currencyId > 0) {return TransactionCurrency::find($currencyId);}@@ -500,8 +494,8 @@ class AccountRepository implements AccountRepositoryInterface/*** Return meta value for account. Null if not found.*- * @param Account $account- * @param string $field+ * @param Account $account+ * @param string $field** @return null|string*/@@ -516,12 +510,32 @@ class AccountRepository implements AccountRepositoryInterfacereturn null;}if (1 === $result->count()) {- return (string) $result->first()->data;+ return (string)$result->first()->data;}return null;}+ /**+ * @param array $types+ *+ * @return int+ */+ public function count(array $types): int+ {+ return $this->user->accounts()->accountTypeIn($types)->count();+ }++ /**+ * @param int $accountId+ *+ * @return Account|null+ */+ public function find(int $accountId): ?Account+ {+ return $this->user->accounts()->find($accountId);+ }+/*** @inheritDoc*/@@ -530,8 +544,8 @@ class AccountRepository implements AccountRepositoryInterface$info = $account->transactions()->get(['transaction_currency_id', 'foreign_currency_id'])->toArray();$currencyIds = [];foreach ($info as $entry) {- $currencyIds[] = (int) $entry['transaction_currency_id'];- $currencyIds[] = (int) $entry['foreign_currency_id'];+ $currencyIds[] = (int)$entry['transaction_currency_id'];+ $currencyIds[] = (int)$entry['foreign_currency_id'];}$currencyIds = array_unique($currencyIds);@@ -539,7 +553,7 @@ class AccountRepository implements AccountRepositoryInterface}/**- * @param Account $account+ * @param Account $account** @return bool*/@@ -562,22 +576,22 @@ class AccountRepository implements AccountRepositoryInterfaceAccountType::MORTGAGE => [AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE],];if (array_key_exists(ucfirst($type), $sets)) {- $order = (int) $this->getAccountsByType($sets[ucfirst($type)])->max('order');+ $order = (int)$this->getAccountsByType($sets[ucfirst($type)])->max('order');Log::debug(sprintf('Return max order of "%s" set: %d', $type, $order));return $order;}$specials = [AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION];- $order = (int) $this->getAccountsByType($specials)->max('order');+ $order = (int)$this->getAccountsByType($specials)->max('order');Log::debug(sprintf('Return max order of "%s" set (specials!): %d', $type, $order));return $order;}/**- * @param array $types- * @param array|null $sort+ * @param array $types+ * @param array|null $sort** @return Collection*/@@ -610,7 +624,7 @@ class AccountRepository implements AccountRepositoryInterface/*** Returns the date of the very first transaction in this account.*- * @param Account $account+ * @param Account $account** @return Carbon|null*/@@ -624,7 +638,7 @@ class AccountRepository implements AccountRepositoryInterface/*** Returns the date of the very first transaction in this account.*- * @param Account $account+ * @param Account $account** @return TransactionJournal|null*/@@ -638,7 +652,7 @@ class AccountRepository implements AccountRepositoryInterface->orderBy('transaction_journals.id', 'ASC')->first(['transaction_journals.id']);if (null !== $first) {- return TransactionJournal::find((int) $first->id);+ return TransactionJournal::find((int)$first->id);}return null;@@ -665,7 +679,7 @@ class AccountRepository implements AccountRepositoryInterface$account->order = 0;continue;}- if ($index !== (int) $account->order) {+ if ($index !== (int)$account->order) {Log::debug(sprintf('Account #%d ("%s"): order should %d be but is %d.', $account->id, $account->name, $index, $account->order));$account->order = $index;$account->save();@@ -676,9 +690,9 @@ class AccountRepository implements AccountRepositoryInterface}/**- * @param string $query- * @param array $types- * @param int $limit+ * @param string $query+ * @param array $types+ * @param int $limit** @return Collection*/@@ -745,15 +759,7 @@ class AccountRepository implements AccountRepositoryInterface}/**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }-- /**- * @param array $data+ * @param array $data** @return Account* @throws FireflyException@@ -769,8 +775,8 @@ class AccountRepository implements AccountRepositoryInterface}/**- * @param Account $account- * @param array $data+ * @param Account $account+ * @param array $data** @return Account* @throws FireflyExceptiondiff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.phpindex 8f585ad173..85b26128aa 100644--- a/app/Repositories/Account/AccountRepositoryInterface.php+++ b/app/Repositories/Account/AccountRepositoryInterface.php@@ -1,4 +1,5 @@<?php+/*** AccountRepositoryInterface.php* Copyright (c) 2019 [email protected]@@ -40,7 +41,7 @@ interface AccountRepositoryInterface/*** Moved here from account CRUD.*- * @param array $types+ * @param array $types** @return int*/@@ -50,8 +51,8 @@ interface AccountRepositoryInterface/*** Moved here from account CRUD.*- * @param Account $account- * @param Account|null $moveTo+ * @param Account $account+ * @param Account|null $moveTo** @return bool*/@@ -60,45 +61,45 @@ interface AccountRepositoryInterface/*** Find account with same name OR same IBAN or both, but not the same type or ID.*- * @param Collection $accounts+ * @param Collection $accounts** @return Collection*/public function expandWithDoubles(Collection $accounts): Collection;/**- * @param int $accountId+ * @param int $accountId** @return Account|null*/public function find(int $accountId): ?Account;/**- * @param string $number- * @param array $types+ * @param string $number+ * @param array $types** @return Account|null*/public function findByAccountNumber(string $number, array $types): ?Account;/**- * @param string $iban- * @param array $types+ * @param string $iban+ * @param array $types** @return Account|null*/public function findByIbanNull(string $iban, array $types): ?Account;/**- * @param string $name- * @param array $types+ * @param string $name+ * @param array $types** @return Account|null*/public function findByName(string $name, array $types): ?Account;/**- * @param Account $account+ * @param Account $account** @return TransactionCurrency|null*/@@ -107,36 +108,36 @@ interface AccountRepositoryInterface/*** Return account type or null if not found.*- * @param string $type+ * @param string $type** @return AccountType|null*/public function getAccountTypeByType(string $type): ?AccountType;/**- * @param array $accountIds+ * @param array $accountIds** @return Collection*/public function getAccountsById(array $accountIds): Collection;/**- * @param array $types- * @param array|null $sort+ * @param array $types+ * @param array|null $sort** @return Collection*/public function getAccountsByType(array $types, ?array $sort = []): Collection;/**- * @param array $types+ * @param array $types** @return Collection*/public function getActiveAccountsByType(array $types): Collection;/**- * @param Account $account+ * @param Account $account** @return Collection*/@@ -148,14 +149,14 @@ interface AccountRepositoryInterfacepublic function getCashAccount(): Account;/**- * @param Account $account+ * @param Account $account** @return TransactionGroup|null*/public function getCreditTransactionGroup(Account $account): ?TransactionGroup;/**- * @param array $types+ * @param array $types** @return Collection*/@@ -164,7 +165,7 @@ interface AccountRepositoryInterface/*** Get account location, if any.*- * @param Account $account+ * @param Account $account** @return Location|null*/@@ -173,8 +174,8 @@ interface AccountRepositoryInterface/*** Return meta value for account. Null if not found.*- * @param Account $account- * @param string $field+ * @param Account $account+ * @param string $field** @return null|string*/@@ -183,14 +184,14 @@ interface AccountRepositoryInterface/*** Get note text or null.*- * @param Account $account+ * @param Account $account** @return null|string*/public function getNoteText(Account $account): ?string;/**- * @param Account $account+ * @param Account $account** @return TransactionJournal|null*@@ -200,7 +201,7 @@ interface AccountRepositoryInterface/*** Returns the amount of the opening balance for this account.*- * @param Account $account+ * @param Account $account** @return string|null*/@@ -209,21 +210,21 @@ interface AccountRepositoryInterface/*** Return date of opening balance as string or null.*- * @param Account $account+ * @param Account $account** @return null|string*/public function getOpeningBalanceDate(Account $account): ?string;/**- * @param Account $account+ * @param Account $account** @return TransactionGroup|null*/public function getOpeningBalanceGroup(Account $account): ?TransactionGroup;/**- * @param Account $account+ * @param Account $account** @return Collection*/@@ -232,28 +233,28 @@ interface AccountRepositoryInterface/*** Find or create the opposing reconciliation account.*- * @param Account $account+ * @param Account $account** @return Account|null*/public function getReconciliation(Account $account): ?Account;/**- * @param Account $account+ * @param Account $account** @return Collection*/public function getUsedCurrencies(Account $account): Collection;/**- * @param Account $account+ * @param Account $account** @return bool*/public function isLiability(Account $account): bool;/**- * @param string $type+ * @param string $type** @return int*/@@ -262,7 +263,7 @@ interface AccountRepositoryInterface/*** Returns the date of the very first transaction in this account.*- * @param Account $account+ * @param Account $account** @return TransactionJournal|null*/@@ -271,7 +272,7 @@ interface AccountRepositoryInterface/*** Returns the date of the very first transaction in this account.*- * @param Account $account+ * @param Account $account** @return Carbon|null*/@@ -283,38 +284,38 @@ interface AccountRepositoryInterfacepublic function resetAccountOrder(): void;/**- * @param string $query- * @param array $types- * @param int $limit+ * @param string $query+ * @param array $types+ * @param int $limit** @return Collection*/public function searchAccount(string $query, array $types, int $limit): Collection;/**- * @param string $query- * @param array $types- * @param int $limit+ * @param string $query+ * @param array $types+ * @param int $limit** @return Collection*/public function searchAccountNr(string $query, array $types, int $limit): Collection;/**- * @param User $user+ * @param User $user*/public function setUser(User $user);/**- * @param array $data+ * @param array $data** @return Account*/public function store(array $data): Account;/**- * @param Account $account- * @param array $data+ * @param Account $account+ * @param array $data** @return Account*/diff --git a/app/Repositories/Account/AccountTasker.php b/app/Repositories/Account/AccountTasker.phpindex 37df7a76df..931fb680ee 100644--- a/app/Repositories/Account/AccountTasker.php+++ b/app/Repositories/Account/AccountTasker.php@@ -1,4 +1,5 @@<?php+/*** AccountTasker.php* Copyright (c) 2019 [email protected]@@ -23,12 +24,14 @@ declare(strict_types=1);namespace FireflyIII\Repositories\Account;use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Helpers\Collector\GroupCollectorInterface;use FireflyIII\Models\Account;use FireflyIII\Models\TransactionType;use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;use FireflyIII\User;use Illuminate\Support\Collection;+use JsonException;use Log;/**@@ -40,13 +43,13 @@ class AccountTasker implements AccountTaskerInterfaceprivate $user;/**- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return array- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/public function getAccountReport(Collection $accounts, Carbon $start, Carbon $end): array{@@ -70,14 +73,15 @@ class AccountTasker implements AccountTaskerInterface$id = $account->id;$currency = $repository->getAccountCurrency($account) ?? $defaultCurrency;$return['sums'][$currency->id] = $return['sums'][$currency->id] ?? [- 'start' => '0',- 'end' => '0',- 'difference' => '0',- 'currency_id' => $currency->id,- 'currency_code' => $currency->code,- 'currency_symbol' => $currency->symbol,- 'currency_name' => $currency->name,- 'currency_decimal_places' => $currency->decimal_places,];+ 'start' => '0',+ 'end' => '0',+ 'difference' => '0',+ 'currency_id' => $currency->id,+ 'currency_code' => $currency->code,+ 'currency_symbol' => $currency->symbol,+ 'currency_name' => $currency->name,+ 'currency_decimal_places' => $currency->decimal_places,+ ];$entry = ['name' => $account->name,'id' => $account->id,@@ -114,9 +118,9 @@ class AccountTasker implements AccountTaskerInterface}/**- * @param Carbon $start- * @param Carbon $end- * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection $accounts** @return array*/@@ -140,7 +144,7 @@ class AccountTasker implements AccountTaskerInterface// Obtain a list of columns$sum = [];foreach ($report['accounts'] as $accountId => $row) {- $sum[$accountId] = (float) $row['sum']; // intentional float+ $sum[$accountId] = (float)$row['sum']; // intentional float}array_multisort($sum, SORT_ASC, $report['accounts']);@@ -149,11 +153,11 @@ class AccountTasker implements AccountTaskerInterface}/**- * @param array $array+ * @param array $array** @return array- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/private function groupExpenseByDestination(array $array): array{@@ -168,22 +172,22 @@ class AccountTasker implements AccountTaskerInterface/** @var array $journal */foreach ($array as $journal) {- $sourceId = (int) $journal['destination_account_id'];- $currencyId = (int) $journal['currency_id'];+ $sourceId = (int)$journal['destination_account_id'];+ $currencyId = (int)$journal['currency_id'];$key = sprintf('%s-%s', $sourceId, $currencyId);$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->find($currencyId);$report['accounts'][$key] = $report['accounts'][$key] ?? [- 'id' => $sourceId,- 'name' => $journal['destination_account_name'],- 'sum' => '0',- 'average' => '0',- 'count' => 0,- 'currency_id' => $currencies[$currencyId]->id,- 'currency_name' => $currencies[$currencyId]->name,- 'currency_symbol' => $currencies[$currencyId]->symbol,- 'currency_code' => $currencies[$currencyId]->code,- 'currency_decimal_places' => $currencies[$currencyId]->decimal_places,- ];+ 'id' => $sourceId,+ 'name' => $journal['destination_account_name'],+ 'sum' => '0',+ 'average' => '0',+ 'count' => 0,+ 'currency_id' => $currencies[$currencyId]->id,+ 'currency_name' => $currencies[$currencyId]->name,+ 'currency_symbol' => $currencies[$currencyId]->symbol,+ 'currency_code' => $currencies[$currencyId]->code,+ 'currency_decimal_places' => $currencies[$currencyId]->decimal_places,+ ];$report['accounts'][$key]['sum'] = bcadd($report['accounts'][$key]['sum'], $journal['amount']);Log::debug(sprintf('Sum for %s is now %s', $journal['destination_account_name'], $report['accounts'][$key]['sum']));@@ -194,17 +198,17 @@ class AccountTasker implements AccountTaskerInterface// do averages and sums.foreach (array_keys($report['accounts']) as $key) {if ($report['accounts'][$key]['count'] > 1) {- $report['accounts'][$key]['average'] = bcdiv($report['accounts'][$key]['sum'], (string) $report['accounts'][$key]['count']);+ $report['accounts'][$key]['average'] = bcdiv($report['accounts'][$key]['sum'], (string)$report['accounts'][$key]['count']);}$currencyId = $report['accounts'][$key]['currency_id'];$report['sums'][$currencyId] = $report['sums'][$currencyId] ?? [- 'sum' => '0',- 'currency_id' => $report['accounts'][$key]['currency_id'],- 'currency_name' => $report['accounts'][$key]['currency_name'],- 'currency_symbol' => $report['accounts'][$key]['currency_symbol'],- 'currency_code' => $report['accounts'][$key]['currency_code'],- 'currency_decimal_places' => $report['accounts'][$key]['currency_decimal_places'],- ];+ 'sum' => '0',+ 'currency_id' => $report['accounts'][$key]['currency_id'],+ 'currency_name' => $report['accounts'][$key]['currency_name'],+ 'currency_symbol' => $report['accounts'][$key]['currency_symbol'],+ 'currency_code' => $report['accounts'][$key]['currency_code'],+ 'currency_decimal_places' => $report['accounts'][$key]['currency_decimal_places'],+ ];$report['sums'][$currencyId]['sum'] = bcadd($report['sums'][$currencyId]['sum'], $report['accounts'][$key]['sum']);}@@ -212,9 +216,9 @@ class AccountTasker implements AccountTaskerInterface}/**- * @param Carbon $start- * @param Carbon $end- * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection $accounts** @return array*/@@ -235,7 +239,7 @@ class AccountTasker implements AccountTaskerInterface// Obtain a list of columns$sum = [];foreach ($report['accounts'] as $accountId => $row) {- $sum[$accountId] = (float) $row['sum']; // intentional float+ $sum[$accountId] = (float)$row['sum']; // intentional float}array_multisort($sum, SORT_DESC, $report['accounts']);@@ -244,11 +248,11 @@ class AccountTasker implements AccountTaskerInterface}/**- * @param array $array+ * @param array $array** @return array- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/private function groupIncomeBySource(array $array): array{@@ -263,8 +267,8 @@ class AccountTasker implements AccountTaskerInterface/** @var array $journal */foreach ($array as $journal) {- $sourceId = (int) $journal['source_account_id'];- $currencyId = (int) $journal['currency_id'];+ $sourceId = (int)$journal['source_account_id'];+ $currencyId = (int)$journal['currency_id'];$key = sprintf('%s-%s', $sourceId, $currencyId);if (!array_key_exists($key, $report['accounts'])) {$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->find($currencyId);@@ -288,17 +292,17 @@ class AccountTasker implements AccountTaskerInterface// do averages and sums.foreach (array_keys($report['accounts']) as $key) {if ($report['accounts'][$key]['count'] > 1) {- $report['accounts'][$key]['average'] = bcdiv($report['accounts'][$key]['sum'], (string) $report['accounts'][$key]['count']);+ $report['accounts'][$key]['average'] = bcdiv($report['accounts'][$key]['sum'], (string)$report['accounts'][$key]['count']);}$currencyId = $report['accounts'][$key]['currency_id'];$report['sums'][$currencyId] = $report['sums'][$currencyId] ?? [- 'sum' => '0',- 'currency_id' => $report['accounts'][$key]['currency_id'],- 'currency_name' => $report['accounts'][$key]['currency_name'],- 'currency_symbol' => $report['accounts'][$key]['currency_symbol'],- 'currency_code' => $report['accounts'][$key]['currency_code'],- 'currency_decimal_places' => $report['accounts'][$key]['currency_decimal_places'],- ];+ 'sum' => '0',+ 'currency_id' => $report['accounts'][$key]['currency_id'],+ 'currency_name' => $report['accounts'][$key]['currency_name'],+ 'currency_symbol' => $report['accounts'][$key]['currency_symbol'],+ 'currency_code' => $report['accounts'][$key]['currency_code'],+ 'currency_decimal_places' => $report['accounts'][$key]['currency_decimal_places'],+ ];$report['sums'][$currencyId]['sum'] = bcadd($report['sums'][$currencyId]['sum'], $report['accounts'][$key]['sum']);}@@ -306,7 +310,7 @@ class AccountTasker implements AccountTaskerInterface}/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void{diff --git a/app/Repositories/Account/AccountTaskerInterface.php b/app/Repositories/Account/AccountTaskerInterface.phpindex cc6f68eed7..d7ff2c184d 100644--- a/app/Repositories/Account/AccountTaskerInterface.php+++ b/app/Repositories/Account/AccountTaskerInterface.php@@ -1,4 +1,5 @@<?php+/*** AccountTaskerInterface.php* Copyright (c) 2019 [email protected]@@ -32,34 +33,34 @@ use Illuminate\Support\Collection;interface AccountTaskerInterface{/**- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return array*/public function getAccountReport(Collection $accounts, Carbon $start, Carbon $end): array;/**- * @param Carbon $start- * @param Carbon $end- * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection $accounts** @return array*/public function getExpenseReport(Carbon $start, Carbon $end, Collection $accounts): array;/**- * @param Carbon $start- * @param Carbon $end- * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection $accounts** @return array*/public function getIncomeReport(Carbon $start, Carbon $end, Collection $accounts): array;/**- * @param User $user+ * @param User $user*/public function setUser(User $user);}diff --git a/app/Repositories/Account/OperationsRepository.php b/app/Repositories/Account/OperationsRepository.phpindex 471204162c..c6524f02e5 100644--- a/app/Repositories/Account/OperationsRepository.php+++ b/app/Repositories/Account/OperationsRepository.php@@ -43,9 +43,9 @@ class OperationsRepository implements OperationsRepositoryInterface* which have the specified accounts. It's grouped per currency, with as few details in the array* as possible. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection $accounts** @return array*/@@ -59,10 +59,10 @@ class OperationsRepository implements OperationsRepositoryInterface/*** Collect transactions with some parameters*- * @param Carbon $start- * @param Carbon $end- * @param Collection $accounts- * @param string $type+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection $accounts+ * @param string $type** @return array*/@@ -78,8 +78,16 @@ class OperationsRepository implements OperationsRepositoryInterface}/**- * @param array $journals- * @param string $direction+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }++ /**+ * @param array $journals+ * @param string $direction** @return array*/@@ -87,20 +95,20 @@ class OperationsRepository implements OperationsRepositoryInterface{$array = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];- $journalId = (int) $journal['transaction_journal_id'];+ $currencyId = (int)$journal['currency_id'];+ $journalId = (int)$journal['transaction_journal_id'];$array[$currencyId] = $array[$currencyId] ?? [- 'currency_id' => $journal['currency_id'],- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- 'transaction_journals' => [],- ];+ 'currency_id' => $journal['currency_id'],+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ 'transaction_journals' => [],+ ];$array[$currencyId]['transaction_journals'][$journalId] = [- 'amount' => app('steam')->$direction((string) $journal['amount']),+ 'amount' => app('steam')->$direction((string)$journal['amount']),'date' => $journal['date'],'transaction_journal_id' => $journalId,'budget_name' => $journal['budget_name'],@@ -125,9 +133,9 @@ class OperationsRepository implements OperationsRepositoryInterface* which have the specified accounts. It's grouped per currency, with as few details in the array* as possible. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts** @return array*/@@ -138,14 +146,6 @@ class OperationsRepository implements OperationsRepositoryInterfacereturn $this->sortByCurrency($journals, 'positive');}- /**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }-/*** @inheritDoc*/@@ -162,12 +162,12 @@ class OperationsRepository implements OperationsRepositoryInterface}/**- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $opposing- * @param TransactionCurrency|null $currency- * @param string $type+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $opposing+ * @param TransactionCurrency|null $currency+ * @param string $type** @return array*/@@ -246,8 +246,8 @@ class OperationsRepository implements OperationsRepositoryInterface}/**- * @param array $journals- * @param string $direction+ * @param array $journals+ * @param string $direction** @return array*/@@ -256,28 +256,28 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$array[$currencyId] = $array[$currencyId] ?? [- 'sum' => '0',- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'sum' => '0',+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->$direction($journal['amount']));// also do foreign amount:- $foreignId = (int) $journal['foreign_currency_id'];+ $foreignId = (int)$journal['foreign_currency_id'];if (0 !== $foreignId) {$array[$foreignId] = $array[$foreignId] ?? [- 'sum' => '0',- 'currency_id' => $foreignId,- 'currency_name' => $journal['foreign_currency_name'],- 'currency_symbol' => $journal['foreign_currency_symbol'],- 'currency_code' => $journal['foreign_currency_code'],- 'currency_decimal_places' => $journal['foreign_currency_decimal_places'],- ];+ 'sum' => '0',+ 'currency_id' => $foreignId,+ 'currency_name' => $journal['foreign_currency_name'],+ 'currency_symbol' => $journal['foreign_currency_symbol'],+ 'currency_code' => $journal['foreign_currency_code'],+ 'currency_decimal_places' => $journal['foreign_currency_decimal_places'],+ ];$array[$foreignId]['sum'] = bcadd($array[$foreignId]['sum'], app('steam')->$direction($journal['foreign_amount']));}}@@ -301,9 +301,9 @@ class OperationsRepository implements OperationsRepositoryInterface}/**- * @param array $journals- * @param string $direction- * @param string $method+ * @param array $journals+ * @param string $direction+ * @param string $method** @return array*/@@ -316,31 +316,31 @@ class OperationsRepository implements OperationsRepositoryInterfaceforeach ($journals as $journal) {$key = sprintf('%s-%s', $journal[$idKey], $journal['currency_id']);$array[$key] = $array[$key] ?? [- 'id' => $journal[$idKey],- 'name' => $journal[$nameKey],- 'sum' => '0',- 'currency_id' => $journal['currency_id'],- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];- $array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->$method((string) $journal['amount']));+ 'id' => $journal[$idKey],+ 'name' => $journal[$nameKey],+ 'sum' => '0',+ 'currency_id' => $journal['currency_id'],+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];+ $array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->$method((string)$journal['amount']));// also do foreign amount:- if (0 !== (int) $journal['foreign_currency_id']) {+ if (0 !== (int)$journal['foreign_currency_id']) {$key = sprintf('%s-%s', $journal[$idKey], $journal['foreign_currency_id']);$array[$key] = $array[$key] ?? [- 'id' => $journal[$idKey],- 'name' => $journal[$nameKey],- 'sum' => '0',- 'currency_id' => $journal['foreign_currency_id'],- 'currency_name' => $journal['foreign_currency_name'],- 'currency_symbol' => $journal['foreign_currency_symbol'],- 'currency_code' => $journal['foreign_currency_code'],- 'currency_decimal_places' => $journal['foreign_currency_decimal_places'],- ];- $array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->$method((string) $journal['foreign_amount']));+ 'id' => $journal[$idKey],+ 'name' => $journal[$nameKey],+ 'sum' => '0',+ 'currency_id' => $journal['foreign_currency_id'],+ 'currency_name' => $journal['foreign_currency_name'],+ 'currency_symbol' => $journal['foreign_currency_symbol'],+ 'currency_code' => $journal['foreign_currency_code'],+ 'currency_decimal_places' => $journal['foreign_currency_decimal_places'],+ ];+ $array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->$method((string)$journal['foreign_amount']));}}@@ -418,7 +418,7 @@ class OperationsRepository implements OperationsRepositoryInterface}/**- * @param array $journals+ * @param array $journals** @return array*/@@ -431,9 +431,9 @@ class OperationsRepository implements OperationsRepositoryInterface}$final = [];foreach ($return as $array) {- $array['difference_float'] = (float) $array['difference'];- $array['in_float'] = (float) $array['in'];- $array['out_float'] = (float) $array['out'];+ $array['difference_float'] = (float)$array['difference'];+ $array['in_float'] = (float)$array['in'];+ $array['out_float'] = (float)$array['out'];$final[] = $array;}@@ -441,8 +441,8 @@ class OperationsRepository implements OperationsRepositoryInterface}/**- * @param array $return- * @param array $journal+ * @param array $return+ * @param array $journal** @return array*/@@ -457,31 +457,31 @@ class OperationsRepository implements OperationsRepositoryInterface// source first$return[$sourceKey] = $return[$sourceKey] ?? [- 'id' => (string) $sourceId,- 'name' => $journal['source_account_name'],- 'difference' => '0',- 'difference_float' => 0,- 'in' => '0',- 'in_float' => 0,- 'out' => '0',- 'out_float' => 0,- 'currency_id' => (string) $currencyId,- 'currency_code' => $journal['currency_code'],- ];+ 'id' => (string)$sourceId,+ 'name' => $journal['source_account_name'],+ 'difference' => '0',+ 'difference_float' => 0,+ 'in' => '0',+ 'in_float' => 0,+ 'out' => '0',+ 'out_float' => 0,+ 'currency_id' => (string)$currencyId,+ 'currency_code' => $journal['currency_code'],+ ];// dest next:$return[$destKey] = $return[$destKey] ?? [- 'id' => (string) $destinationId,- 'name' => $journal['destination_account_name'],- 'difference' => '0',- 'difference_float' => 0,- 'in' => '0',- 'in_float' => 0,- 'out' => '0',- 'out_float' => 0,- 'currency_id' => (string) $currencyId,- 'currency_code' => $journal['currency_code'],- ];+ 'id' => (string)$destinationId,+ 'name' => $journal['destination_account_name'],+ 'difference' => '0',+ 'difference_float' => 0,+ 'in' => '0',+ 'in_float' => 0,+ 'out' => '0',+ 'out_float' => 0,+ 'currency_id' => (string)$currencyId,+ 'currency_code' => $journal['currency_code'],+ ];// source account? money goes out!$return[$sourceKey]['out'] = bcadd($return[$sourceKey]['out'], app('steam')->negative($amount));@@ -501,31 +501,31 @@ class OperationsRepository implements OperationsRepositoryInterface// same as above:// source first$return[$sourceKey] = $return[$sourceKey] ?? [- 'id' => (string) $sourceId,- 'name' => $journal['source_account_name'],- 'difference' => '0',- 'difference_float' => 0,- 'in' => '0',- 'in_float' => 0,- 'out' => '0',- 'out_float' => 0,- 'currency_id' => (string) $currencyId,- 'currency_code' => $journal['foreign_currency_code'],- ];+ 'id' => (string)$sourceId,+ 'name' => $journal['source_account_name'],+ 'difference' => '0',+ 'difference_float' => 0,+ 'in' => '0',+ 'in_float' => 0,+ 'out' => '0',+ 'out_float' => 0,+ 'currency_id' => (string)$currencyId,+ 'currency_code' => $journal['foreign_currency_code'],+ ];// dest next:$return[$destKey] = $return[$destKey] ?? [- 'id' => (string) $destinationId,- 'name' => $journal['destination_account_name'],- 'difference' => '0',- 'difference_float' => 0,- 'in' => '0',- 'in_float' => 0,- 'out' => '0',- 'out_float' => 0,- 'currency_id' => (string) $currencyId,- 'currency_code' => $journal['foreign_currency_code'],- ];+ 'id' => (string)$destinationId,+ 'name' => $journal['destination_account_name'],+ 'difference' => '0',+ 'difference_float' => 0,+ 'in' => '0',+ 'in_float' => 0,+ 'out' => '0',+ 'out_float' => 0,+ 'currency_id' => (string)$currencyId,+ 'currency_code' => $journal['foreign_currency_code'],+ ];// source account? money goes out! (same as above)$return[$sourceKey]['out'] = bcadd($return[$sourceKey]['out'], app('steam')->negative($amount));$return[$sourceKey]['difference'] = bcadd($return[$sourceKey]['out'], $return[$sourceKey]['in']);diff --git a/app/Repositories/Account/OperationsRepositoryInterface.php b/app/Repositories/Account/OperationsRepositoryInterface.phpindex cd16d830c8..e70e27f4a4 100644--- a/app/Repositories/Account/OperationsRepositoryInterface.php+++ b/app/Repositories/Account/OperationsRepositoryInterface.php@@ -38,9 +38,9 @@ interface OperationsRepositoryInterface* which have the specified accounts. It's grouped per currency, with as few details in the array* as possible. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection $accounts** @return array*/@@ -51,27 +51,27 @@ interface OperationsRepositoryInterface* which have the specified accounts. It's grouped per currency, with as few details in the array* as possible. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts** @return array*/public function listIncome(Carbon $start, Carbon $end, ?Collection $accounts = null): array;/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void;/*** Sum of withdrawal journals in period for a set of accounts, grouped per currency. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $expense- * @param TransactionCurrency|null $currency+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $expense+ * @param TransactionCurrency|null $currency** @return array*/@@ -86,11 +86,11 @@ interface OperationsRepositoryInterface/*** Sum of withdrawal journals in period for a set of accounts, grouped per destination / currency. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $expense- * @param TransactionCurrency|null $currency+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $expense+ * @param TransactionCurrency|null $currency** @return array*/@@ -105,11 +105,11 @@ interface OperationsRepositoryInterface/*** Sum of withdrawal journals in period for a set of accounts, grouped per source / currency. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $expense- * @param TransactionCurrency|null $currency+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $expense+ * @param TransactionCurrency|null $currency** @return array*/@@ -124,11 +124,11 @@ interface OperationsRepositoryInterface/*** Sum of income journals in period for a set of accounts, grouped per currency. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $revenue- * @param TransactionCurrency|null $currency+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $revenue+ * @param TransactionCurrency|null $currency** @return array*/@@ -143,16 +143,16 @@ interface OperationsRepositoryInterface/*** Sum of income journals in period for a set of accounts, grouped per destination + currency. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $revenue- * @param TransactionCurrency|null $currency+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $revenue+ * @param TransactionCurrency|null $currency** @return array*/public function sumIncomeByDestination(- Carbon $start,+ Carbon $start,Carbon $end,?Collection $accounts = null,?Collection $revenue = null,@@ -162,16 +162,16 @@ interface OperationsRepositoryInterface/*** Sum of income journals in period for a set of accounts, grouped per source + currency. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $revenue- * @param TransactionCurrency|null $currency+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $revenue+ * @param TransactionCurrency|null $currency** @return array*/public function sumIncomeBySource(- Carbon $start,+ Carbon $start,Carbon $end,?Collection $accounts = null,?Collection $revenue = null,@@ -181,10 +181,10 @@ interface OperationsRepositoryInterface/*** Sum of transfers in period for a set of accounts, grouped per currency. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param TransactionCurrency|null $currency+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param TransactionCurrency|null $currency** @return array*/diff --git a/app/Repositories/Attachment/AttachmentRepository.php b/app/Repositories/Attachment/AttachmentRepository.phpindex b0e79c31d1..5fde3a1261 100644--- a/app/Repositories/Attachment/AttachmentRepository.php+++ b/app/Repositories/Attachment/AttachmentRepository.php@@ -1,4 +1,5 @@<?php+/*** AttachmentRepository.php* Copyright (c) 2019 [email protected]@@ -44,7 +45,7 @@ class AttachmentRepository implements AttachmentRepositoryInterfaceprivate $user;/**- * @param Attachment $attachment+ * @param Attachment $attachment** @return bool* @throws Exception@@ -66,28 +67,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface}/**- * @param Attachment $attachment- *- * @return bool- */- public function exists(Attachment $attachment): bool- {- /** @var Storage $disk */- $disk = Storage::disk('upload');-- return $disk->exists($attachment->fileName());- }-- /**- * @return Collection- */- public function get(): Collection- {- return $this->user->attachments()->get();- }-- /**- * @param Attachment $attachment+ * @param Attachment $attachment** @return string*/@@ -99,7 +79,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface$unencryptedContent = '';if ($disk->exists($file)) {- $encryptedContent = (string) $disk->get($file);+ $encryptedContent = (string)$disk->get($file);try {$unencryptedContent = Crypt::decrypt($encryptedContent); // verified@@ -111,10 +91,31 @@ class AttachmentRepository implements AttachmentRepositoryInterfacereturn $unencryptedContent;}+ /**+ * @param Attachment $attachment+ *+ * @return bool+ */+ public function exists(Attachment $attachment): bool+ {+ /** @var Storage $disk */+ $disk = Storage::disk('upload');++ return $disk->exists($attachment->fileName());+ }++ /**+ * @return Collection+ */+ public function get(): Collection+ {+ return $this->user->attachments()->get();+ }+/*** Get attachment note text or empty string.*- * @param Attachment $attachment+ * @param Attachment $attachment** @return string|null*/@@ -122,22 +123,14 @@ class AttachmentRepository implements AttachmentRepositoryInterface{$note = $attachment->notes()->first();if (null !== $note) {- return (string) $note->text;+ return (string)$note->text;}return null;}/**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }-- /**- * @param array $data+ * @param array $data** @return Attachment* @throws FireflyException@@ -156,8 +149,16 @@ class AttachmentRepository implements AttachmentRepositoryInterface}/**- * @param Attachment $attachment- * @param array $data+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }++ /**+ * @param Attachment $attachment+ * @param array $data** @return Attachment* @throws Exception@@ -168,28 +169,28 @@ class AttachmentRepository implements AttachmentRepositoryInterface$attachment->title = $data['title'];}- if (array_key_exists('filename', $data) && '' !== (string) $data['filename'] && $data['filename'] !== $attachment->filename) {+ if (array_key_exists('filename', $data) && '' !== (string)$data['filename'] && $data['filename'] !== $attachment->filename) {$attachment->filename = $data['filename'];}// update model (move attachment)// should be validated already:if (array_key_exists('attachable_type', $data) && array_key_exists('attachable_id', $data)) {- $attachment->attachable_id = (int) $data['attachable_id'];+ $attachment->attachable_id = (int)$data['attachable_id'];$attachment->attachable_type = sprintf('FireflyIII\\Models\\%s', $data['attachable_type']);}$attachment->save();$attachment->refresh();if (array_key_exists('notes', $data)) {- $this->updateNote($attachment, (string) $data['notes']);+ $this->updateNote($attachment, (string)$data['notes']);}return $attachment;}/**- * @param Attachment $attachment- * @param string $note+ * @param Attachment $attachment+ * @param string $note** @return bool* @throws Exceptiondiff --git a/app/Repositories/Attachment/AttachmentRepositoryInterface.php b/app/Repositories/Attachment/AttachmentRepositoryInterface.phpindex 0b64420736..50d2d3b8a9 100644--- a/app/Repositories/Attachment/AttachmentRepositoryInterface.php+++ b/app/Repositories/Attachment/AttachmentRepositoryInterface.php@@ -1,4 +1,5 @@<?php+/*** AttachmentRepositoryInterface.php* Copyright (c) 2019 [email protected]@@ -33,14 +34,14 @@ use Illuminate\Support\Collection;interface AttachmentRepositoryInterface{/**- * @param Attachment $attachment+ * @param Attachment $attachment** @return bool*/public function destroy(Attachment $attachment): bool;/**- * @param Attachment $attachment+ * @param Attachment $attachment** @return bool*/@@ -52,7 +53,7 @@ interface AttachmentRepositoryInterfacepublic function get(): Collection;/**- * @param Attachment $attachment+ * @param Attachment $attachment** @return string*/@@ -61,19 +62,19 @@ interface AttachmentRepositoryInterface/*** Get attachment note text or empty string.*- * @param Attachment $attachment+ * @param Attachment $attachment** @return string|null*/public function getNoteText(Attachment $attachment): ?string;/**- * @param User $user+ * @param User $user*/public function setUser(User $user);/**- * @param array $data+ * @param array $data** @return Attachment* @throws FireflyException@@ -81,8 +82,8 @@ interface AttachmentRepositoryInterfacepublic function store(array $data): Attachment;/**- * @param Attachment $attachment- * @param array $attachmentData+ * @param Attachment $attachment+ * @param array $attachmentData** @return Attachment*/diff --git a/app/Repositories/AuditLogEntry/ALERepository.php b/app/Repositories/AuditLogEntry/ALERepository.phpindex 12177e7e1a..9832b8c001 100644--- a/app/Repositories/AuditLogEntry/ALERepository.php+++ b/app/Repositories/AuditLogEntry/ALERepository.php@@ -33,6 +33,14 @@ use Illuminate\Support\Collection;*/class ALERepository implements ALERepositoryInterface{+ /**+ * @inheritDoc+ */+ public function getForObject(Model $model): Collection+ {+ return AuditLogEntry::where('auditable_id', $model->id)->where('auditable_type', get_class($model))->get();+ }+/*** @inheritDoc*/@@ -48,12 +56,4 @@ class ALERepository implements ALERepositoryInterface$auditLogEntry->save();return $auditLogEntry;}-- /**- * @inheritDoc- */- public function getForObject(Model $model): Collection- {- return AuditLogEntry::where('auditable_id', $model->id)->where('auditable_type', get_class($model))->get();- }}diff --git a/app/Repositories/AuditLogEntry/ALERepositoryInterface.php b/app/Repositories/AuditLogEntry/ALERepositoryInterface.phpindex 052ca28d4e..26117f8457 100644--- a/app/Repositories/AuditLogEntry/ALERepositoryInterface.php+++ b/app/Repositories/AuditLogEntry/ALERepositoryInterface.php@@ -34,14 +34,14 @@ use Illuminate\Support\Collection;interface ALERepositoryInterface{/**- * @param array $data- * @return AuditLogEntry+ * @param Model $model+ * @return Collection*/- public function store(array $data): AuditLogEntry;+ public function getForObject(Model $model): Collection;/**- * @param Model $model- * @return Collection+ * @param array $data+ * @return AuditLogEntry*/- public function getForObject(Model $model): Collection;+ public function store(array $data): AuditLogEntry;}diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.phpindex 59671f0298..462101a871 100644--- a/app/Repositories/Bill/BillRepository.php+++ b/app/Repositories/Bill/BillRepository.php@@ -1,4 +1,5 @@<?php+/*** BillRepository.php* Copyright (c) 2019 [email protected]@@ -106,6 +107,104 @@ class BillRepository implements BillRepositoryInterfacereturn $bills;}+ /**+ * @return Collection+ */+ public function getActiveBills(): Collection+ {+ return $this->user->bills()+ ->where('active', true)+ ->orderBy('bills.name', 'ASC')+ ->get(['bills.*', DB::raw('((bills.amount_min + bills.amount_max) / 2) AS expectedAmount'),]);+ }++ /**+ * Between start and end, tells you on which date(s) the bill is expected to hit.+ *+ * @param Bill $bill+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return Collection+ */+ public function getPayDatesInRange(Bill $bill, Carbon $start, Carbon $end): Collection+ {+ $set = new Collection();+ $currentStart = clone $start;+ //Log::debug(sprintf('Now at bill "%s" (%s)', $bill->name, $bill->repeat_freq));+ //Log::debug(sprintf('First currentstart is %s', $currentStart->format('Y-m-d')));++ while ($currentStart <= $end) {+ //Log::debug(sprintf('Currentstart is now %s.', $currentStart->format('Y-m-d')));+ $nextExpectedMatch = $this->nextDateMatch($bill, $currentStart);+ //Log::debug(sprintf('Next Date match after %s is %s', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d')));+ if ($nextExpectedMatch > $end) {// If nextExpectedMatch is after end, we continue+ break;+ }+ $set->push(clone $nextExpectedMatch);+ //Log::debug(sprintf('Now %d dates in set.', $set->count()));+ $nextExpectedMatch->addDay();++ //Log::debug(sprintf('Currentstart (%s) has become %s.', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d')));++ $currentStart = clone $nextExpectedMatch;+ }++ return $set;+ }++ /**+ * Given a bill and a date, this method will tell you at which moment this bill expects its next+ * transaction. Whether or not it is there already, is not relevant.+ *+ * @param Bill $bill+ * @param Carbon $date+ *+ * @return Carbon+ */+ public function nextDateMatch(Bill $bill, Carbon $date): Carbon+ {+ $cache = new CacheProperties();+ $cache->addProperty($bill->id);+ $cache->addProperty('nextDateMatch');+ $cache->addProperty($date);+ if ($cache->has()) {+ return $cache->get();+ }+ // find the most recent date for this bill NOT in the future. Cache this date:+ $start = clone $bill->date;++ while ($start < $date) {+ $start = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip);+ }+ $cache->store($start);++ return $start;+ }++ /**+ * @param array $data+ *+ * @return Bill+ * @throws FireflyException+ */+ public function store(array $data): Bill+ {+ /** @var BillFactory $factory */+ $factory = app(BillFactory::class);+ $factory->setUser($this->user);++ return $factory->create($data);+ }++ /**+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }+/*** Correct order of piggies in case of issues.*/@@ -114,7 +213,7 @@ class BillRepository implements BillRepositoryInterface$set = $this->user->bills()->orderBy('order', 'ASC')->get();$current = 1;foreach ($set as $bill) {- if ((int) $bill->order !== $current) {+ if ((int)$bill->order !== $current) {$bill->order = $current;$bill->save();}@@ -123,7 +222,7 @@ class BillRepository implements BillRepositoryInterface}/**- * @param Bill $bill+ * @param Bill $bill** @return bool*@@ -149,15 +248,15 @@ class BillRepository implements BillRepositoryInterface/*** Find bill by parameters.*- * @param int|null $billId- * @param string|null $billName+ * @param int|null $billId+ * @param string|null $billName** @return Bill|null*/public function findBill(?int $billId, ?string $billName): ?Bill{if (null !== $billId) {- $searchResult = $this->find((int) $billId);+ $searchResult = $this->find((int)$billId);if (null !== $searchResult) {Log::debug(sprintf('Found bill based on #%d, will return it.', $billId));@@ -165,7 +264,7 @@ class BillRepository implements BillRepositoryInterface}}if (null !== $billName) {- $searchResult = $this->findByName((string) $billName);+ $searchResult = $this->findByName((string)$billName);if (null !== $searchResult) {Log::debug(sprintf('Found bill based on "%s", will return it.', $billName));@@ -180,7 +279,7 @@ class BillRepository implements BillRepositoryInterface/*** Find a bill by ID.*- * @param int $billId+ * @param int $billId** @return Bill|null*/@@ -192,7 +291,7 @@ class BillRepository implements BillRepositoryInterface/*** Find a bill by name.*- * @param string $name+ * @param string $name** @return Bill|null*/@@ -204,7 +303,7 @@ class BillRepository implements BillRepositoryInterface/*** Get all attachments.*- * @param Bill $bill+ * @param Bill $bill** @return Collection*/@@ -238,14 +337,28 @@ class BillRepository implements BillRepositoryInterface}/**- * @param Collection $accounts+ * @param Collection $accounts** @return Collection*/public function getBillsForAccounts(Collection $accounts): Collection{- $fields = ['bills.id', 'bills.created_at', 'bills.updated_at', 'bills.deleted_at', 'bills.user_id', 'bills.name', 'bills.amount_min',- 'bills.amount_max', 'bills.date', 'bills.transaction_currency_id', 'bills.repeat_freq', 'bills.skip', 'bills.automatch', 'bills.active',];+ $fields = [+ 'bills.id',+ 'bills.created_at',+ 'bills.updated_at',+ 'bills.deleted_at',+ 'bills.user_id',+ 'bills.name',+ 'bills.amount_min',+ 'bills.amount_max',+ 'bills.date',+ 'bills.transaction_currency_id',+ 'bills.repeat_freq',+ 'bills.skip',+ 'bills.automatch',+ 'bills.active',+ ];$ids = $accounts->pluck('id')->toArray();return $this->user->bills()@@ -274,8 +387,8 @@ class BillRepository implements BillRepositoryInterface* This amount will be negative (they're expenses). This method is equal to* getBillsUnpaidInRange. So the debug comments are gone.*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end* @return string* @deprecated*/@@ -289,7 +402,7 @@ class BillRepository implements BillRepositoryInterface$set = $bill->transactionJournals()->after($start)->before($end)->get(['transaction_journals.*']);if ($set->count() > 0) {$journalIds = $set->pluck('id')->toArray();- $amount = (string) Transaction::whereIn('transaction_journal_id', $journalIds)->where('amount', '<', 0)->sum('amount');+ $amount = (string)Transaction::whereIn('transaction_journal_id', $journalIds)->where('amount', '<', 0)->sum('amount');$sum = bcadd($sum, $amount);//Log::debug(sprintf('Total > 0, so add to sum %f, which becomes %f', $amount, $sum));}@@ -298,22 +411,11 @@ class BillRepository implements BillRepositoryInterfacereturn $sum;}- /**- * @return Collection- */- public function getActiveBills(): Collection- {- return $this->user->bills()- ->where('active', true)- ->orderBy('bills.name', 'ASC')- ->get(['bills.*', DB::raw('((bills.amount_min + bills.amount_max) / 2) AS expectedAmount'),]);- }-/*** Get the total amount of money paid for the users active bills in the date range given,* grouped per currency.- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return array* @deprecated@@ -326,10 +428,10 @@ class BillRepository implements BillRepositoryInterfaceforeach ($bills as $bill) {/** @var Collection $set */$set = $bill->transactionJournals()->after($start)->before($end)->get(['transaction_journals.*']);- $currencyId = (int) $bill->transaction_currency_id;+ $currencyId = (int)$bill->transaction_currency_id;if ($set->count() > 0) {$journalIds = $set->pluck('id')->toArray();- $amount = (string) Transaction::whereIn('transaction_journal_id', $journalIds)->where('amount', '<', 0)->sum('amount');+ $amount = (string)Transaction::whereIn('transaction_journal_id', $journalIds)->where('amount', '<', 0)->sum('amount');$return[$currencyId] = $return[$currencyId] ?? '0';$return[$currencyId] = bcadd($amount, $return[$currencyId]);//Log::debug(sprintf('Total > 0, so add to sum %f, which becomes %f (currency %d)', $amount, $return[$currencyId], $currencyId));@@ -342,8 +444,8 @@ class BillRepository implements BillRepositoryInterface/*** Get the total amount of money due for the users active bills in the date range given. This amount will be positive.*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end* @return string* @deprecated*/@@ -362,7 +464,7 @@ class BillRepository implements BillRepositoryInterfaceif ($total > 0) {$average = bcdiv(bcadd($bill->amount_max, $bill->amount_min), '2');- $multi = bcmul($average, (string) $total);+ $multi = bcmul($average, (string)$total);$sum = bcadd($sum, $multi);//Log::debug(sprintf('Total > 0, so add to sum %f, which becomes %f', $multi, $sum));}@@ -371,75 +473,11 @@ class BillRepository implements BillRepositoryInterfacereturn $sum;}- /**- * Between start and end, tells you on which date(s) the bill is expected to hit.- *- * @param Bill $bill- * @param Carbon $start- * @param Carbon $end- *- * @return Collection- */- public function getPayDatesInRange(Bill $bill, Carbon $start, Carbon $end): Collection- {- $set = new Collection();- $currentStart = clone $start;- //Log::debug(sprintf('Now at bill "%s" (%s)', $bill->name, $bill->repeat_freq));- //Log::debug(sprintf('First currentstart is %s', $currentStart->format('Y-m-d')));-- while ($currentStart <= $end) {- //Log::debug(sprintf('Currentstart is now %s.', $currentStart->format('Y-m-d')));- $nextExpectedMatch = $this->nextDateMatch($bill, $currentStart);- //Log::debug(sprintf('Next Date match after %s is %s', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d')));- if ($nextExpectedMatch > $end) {// If nextExpectedMatch is after end, we continue- break;- }- $set->push(clone $nextExpectedMatch);- //Log::debug(sprintf('Now %d dates in set.', $set->count()));- $nextExpectedMatch->addDay();-- //Log::debug(sprintf('Currentstart (%s) has become %s.', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d')));-- $currentStart = clone $nextExpectedMatch;- }-- return $set;- }-- /**- * Given a bill and a date, this method will tell you at which moment this bill expects its next- * transaction. Whether or not it is there already, is not relevant.- *- * @param Bill $bill- * @param Carbon $date- *- * @return Carbon- */- public function nextDateMatch(Bill $bill, Carbon $date): Carbon- {- $cache = new CacheProperties();- $cache->addProperty($bill->id);- $cache->addProperty('nextDateMatch');- $cache->addProperty($date);- if ($cache->has()) {- return $cache->get();- }- // find the most recent date for this bill NOT in the future. Cache this date:- $start = clone $bill->date;-- while ($start < $date) {- $start = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip);- }- $cache->store($start);-- return $start;- }-/*** Get the total amount of money due for the users active bills in the date range given.*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end* @return array* @deprecated*/@@ -453,13 +491,13 @@ class BillRepository implements BillRepositoryInterface$dates = $this->getPayDatesInRange($bill, $start, $end);$count = $bill->transactionJournals()->after($start)->before($end)->count();$total = $dates->count() - $count;- $currencyId = (int) $bill->transaction_currency_id;+ $currencyId = (int)$bill->transaction_currency_id;//Log::debug(sprintf('Dates = %d, journalCount = %d, total = %d', $dates->count(), $count, $total));if ($total > 0) {- $average = bcdiv(bcadd((string) $bill->amount_max, (string) $bill->amount_min), '2');- $multi = bcmul($average, (string) $total);+ $average = bcdiv(bcadd((string)$bill->amount_max, (string)$bill->amount_min), '2');+ $multi = bcmul($average, (string)$total);$return[$currencyId] = $return[$currencyId] ?? '0';$return[$currencyId] = bcadd($return[$currencyId], $multi);//Log::debug(sprintf('Total > 0, so add to sum %f, which becomes %f (for currency %d)', $multi, $return[$currencyId], $currencyId));@@ -469,70 +507,10 @@ class BillRepository implements BillRepositoryInterfacereturn $return;}- /**- * @inheritDoc- */- public function sumUnpaidInRange(Carbon $start, Carbon $end): array- {- $bills = $this->getActiveBills();- $return = [];- /** @var Bill $bill */- foreach ($bills as $bill) {- $dates = $this->getPayDatesInRange($bill, $start, $end);- $count = $bill->transactionJournals()->after($start)->before($end)->count();- $total = $dates->count() - $count;-- if ($total > 0) {- $currency = $bill->transactionCurrency;- $average = bcdiv(bcadd($bill->amount_max, $bill->amount_min), '2');- $return[$currency->id] = $return[$currency->id] ?? [- 'id' => (string) $currency->id,- 'name' => $currency->name,- 'symbol' => $currency->symbol,- 'code' => $currency->code,- 'decimal_places' => $currency->decimal_places,- 'sum' => '0',- ];- $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], bcmul($average, (string) $total));- }- }-- return $return;- }-- /**- * @inheritDoc- */- public function sumPaidInRange(Carbon $start, Carbon $end): array- {- $bills = $this->getActiveBills();- $return = [];- /** @var Bill $bill */- foreach ($bills as $bill) {- /** @var Collection $set */- $set = $bill->transactionJournals()->after($start)->before($end)->get(['transaction_journals.*']);- $currency = $bill->transactionCurrency;- if ($set->count() > 0) {- $journalIds = $set->pluck('id')->toArray();- $amount = (string) Transaction::whereIn('transaction_journal_id', $journalIds)->where('amount', '<', 0)->sum('amount');- $return[$currency->id] = $return[$currency->id] ?? [- 'id' => (string) $currency->id,- 'name' => $currency->name,- 'symbol' => $currency->symbol,- 'code' => $currency->code,- 'decimal_places' => $currency->decimal_places,- 'sum' => '0',- ];- $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $amount);- }- }- return $return;- }-/*** Get all bills with these ID's.*- * @param array $billIds+ * @param array $billIds** @return Collection*/@@ -544,7 +522,7 @@ class BillRepository implements BillRepositoryInterface/*** Get text or return empty string.*- * @param Bill $bill+ * @param Bill $bill** @return string*/@@ -553,14 +531,14 @@ class BillRepository implements BillRepositoryInterface/** @var Note $note */$note = $bill->notes()->first();if (null !== $note) {- return (string) $note->text;+ return (string)$note->text;}return '';}/**- * @param Bill $bill+ * @param Bill $bill** @return array*/@@ -578,35 +556,35 @@ class BillRepository implements BillRepositoryInterfaceforeach ($journals as $journal) {/** @var Transaction $transaction */$transaction = $journal->transactions()->where('amount', '<', 0)->first();- $currencyId = (int) $journal->transaction_currency_id;+ $currencyId = (int)$journal->transaction_currency_id;$currency = $journal->transactionCurrency;$result[$currencyId] = $result[$currencyId] ?? [- 'sum' => '0',- 'count' => 0,- 'avg' => '0',- 'currency_id' => $currency->id,- 'currency_code' => $currency->code,- 'currency_symbol' => $currency->symbol,- 'currency_decimal_places' => $currency->decimal_places,- ];+ 'sum' => '0',+ 'count' => 0,+ 'avg' => '0',+ 'currency_id' => $currency->id,+ 'currency_code' => $currency->code,+ 'currency_symbol' => $currency->symbol,+ 'currency_decimal_places' => $currency->decimal_places,+ ];$result[$currencyId]['sum'] = bcadd($result[$currencyId]['sum'], $transaction->amount);$result[$currencyId]['count']++;}// after loop, re-loop for avg./**- * @var int $currencyId+ * @var int $currencyId* @var array $arr*/foreach ($result as $currencyId => $arr) {- $result[$currencyId]['avg'] = bcdiv($arr['sum'], (string) $arr['count']);+ $result[$currencyId]['avg'] = bcdiv($arr['sum'], (string)$arr['count']);}return $result;}/**- * @param int $size+ * @param int $size** @return LengthAwarePaginator*/@@ -620,9 +598,9 @@ class BillRepository implements BillRepositoryInterface/*** The "paid dates" list is a list of dates of transaction journals that are linked to this bill.*- * @param Bill $bill- * @param Carbon $start- * @param Carbon $end+ * @param Bill $bill+ * @param Carbon $start+ * @param Carbon $end** @return Collection*/@@ -633,7 +611,8 @@ class BillRepository implements BillRepositoryInterfacereturn $bill->transactionJournals()->before($end)->after($start)->get([- 'transaction_journals.id', 'transaction_journals.date',+ 'transaction_journals.id',+ 'transaction_journals.date','transaction_journals.transaction_group_id',]);@@ -642,7 +621,7 @@ class BillRepository implements BillRepositoryInterface/*** Return all rules for one bill*- * @param Bill $bill+ * @param Bill $bill** @return Collection*/@@ -661,7 +640,7 @@ class BillRepository implements BillRepositoryInterface** 5 => [['id' => 1, 'title' => 'Some rule'],['id' => 2, 'title' => 'Some other rule']]*- * @param Collection $collection+ * @param Collection $collection** @return array*/@@ -686,8 +665,8 @@ class BillRepository implements BillRepositoryInterface}/**- * @param Bill $bill- * @param Carbon $date+ * @param Bill $bill+ * @param Carbon $date** @return array*/@@ -701,8 +680,8 @@ class BillRepository implements BillRepositoryInterface$result = [];$journals = $bill->transactionJournals()- ->where('date', '>=', $date->year . '-01-01 00:00:00')- ->where('date', '<=', $date->year . '-12-31 23:59:59')+ ->where('date', '>=', $date->year.'-01-01 00:00:00')+ ->where('date', '<=', $date->year.'-12-31 23:59:59')->get();/** @var TransactionJournal $journal */@@ -712,28 +691,28 @@ class BillRepository implements BillRepositoryInterfaceif (null === $transaction) {continue;}- $currencyId = (int) $journal->transaction_currency_id;+ $currencyId = (int)$journal->transaction_currency_id;$currency = $journal->transactionCurrency;$result[$currencyId] = $result[$currencyId] ?? [- 'sum' => '0',- 'count' => 0,- 'avg' => '0',- 'currency_id' => $currency->id,- 'currency_code' => $currency->code,- 'currency_symbol' => $currency->symbol,- 'currency_decimal_places' => $currency->decimal_places,- ];+ 'sum' => '0',+ 'count' => 0,+ 'avg' => '0',+ 'currency_id' => $currency->id,+ 'currency_code' => $currency->code,+ 'currency_symbol' => $currency->symbol,+ 'currency_decimal_places' => $currency->decimal_places,+ ];$result[$currencyId]['sum'] = bcadd($result[$currencyId]['sum'], $transaction->amount);$result[$currencyId]['count']++;}// after loop, re-loop for avg./**- * @var int $currencyId+ * @var int $currencyId* @var array $arr*/foreach ($result as $currencyId => $arr) {- $result[$currencyId]['avg'] = bcdiv($arr['sum'], (string) $arr['count']);+ $result[$currencyId]['avg'] = bcdiv($arr['sum'], (string)$arr['count']);}return $result;@@ -742,14 +721,14 @@ class BillRepository implements BillRepositoryInterface/*** Link a set of journals to a bill.*- * @param Bill $bill- * @param array $transactions+ * @param Bill $bill+ * @param array $transactions*/public function linkCollectionToBill(Bill $bill, array $transactions): void{/** @var Transaction $transaction */foreach ($transactions as $transaction) {- $journal = $bill->user->transactionJournals()->find((int) $transaction['transaction_journal_id']);+ $journal = $bill->user->transactionJournals()->find((int)$transaction['transaction_journal_id']);$journal->bill_id = $bill->id;$journal->save();Log::debug(sprintf('Linked journal #%d to bill #%d', $journal->id, $bill->id));@@ -759,8 +738,8 @@ class BillRepository implements BillRepositoryInterface/*** Given the date in $date, this method will return a moment in the future where the bill is expected to be paid.*- * @param Bill $bill- * @param Carbon $date+ * @param Bill $bill+ * @param Carbon $date** @return Carbon* @throws JsonException@@ -776,12 +755,12 @@ class BillRepository implements BillRepositoryInterface}// find the most recent date for this bill NOT in the future. Cache this date:$start = clone $bill->date;- Log::debug('nextExpectedMatch: Start is ' . $start->format('Y-m-d'));+ Log::debug('nextExpectedMatch: Start is '.$start->format('Y-m-d'));while ($start < $date) {Log::debug(sprintf('$start (%s) < $date (%s)', $start->format('Y-m-d'), $date->format('Y-m-d')));$start = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip);- Log::debug('Start is now ' . $start->format('Y-m-d'));+ Log::debug('Start is now '.$start->format('Y-m-d'));}$end = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip);@@ -795,8 +774,8 @@ class BillRepository implements BillRepositoryInterface$start = clone $end;$end = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip);}- Log::debug('nextExpectedMatch: Final start is ' . $start->format('Y-m-d'));- Log::debug('nextExpectedMatch: Matching end is ' . $end->format('Y-m-d'));+ Log::debug('nextExpectedMatch: Final start is '.$start->format('Y-m-d'));+ Log::debug('nextExpectedMatch: Matching end is '.$end->format('Y-m-d'));$cache->store($start);@@ -814,8 +793,8 @@ class BillRepository implements BillRepositoryInterface}/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/@@ -849,30 +828,67 @@ class BillRepository implements BillRepositoryInterface}/**- * @param User $user+ * @inheritDoc*/- public function setUser(User $user): void+ public function sumPaidInRange(Carbon $start, Carbon $end): array{- $this->user = $user;+ $bills = $this->getActiveBills();+ $return = [];+ /** @var Bill $bill */+ foreach ($bills as $bill) {+ /** @var Collection $set */+ $set = $bill->transactionJournals()->after($start)->before($end)->get(['transaction_journals.*']);+ $currency = $bill->transactionCurrency;+ if ($set->count() > 0) {+ $journalIds = $set->pluck('id')->toArray();+ $amount = (string)Transaction::whereIn('transaction_journal_id', $journalIds)->where('amount', '<', 0)->sum('amount');+ $return[$currency->id] = $return[$currency->id] ?? [+ 'id' => (string)$currency->id,+ 'name' => $currency->name,+ 'symbol' => $currency->symbol,+ 'code' => $currency->code,+ 'decimal_places' => $currency->decimal_places,+ 'sum' => '0',+ ];+ $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $amount);+ }+ }+ return $return;}/**- * @param array $data- *- * @return Bill- * @throws FireflyException+ * @inheritDoc*/- public function store(array $data): Bill+ public function sumUnpaidInRange(Carbon $start, Carbon $end): array{- /** @var BillFactory $factory */- $factory = app(BillFactory::class);- $factory->setUser($this->user);+ $bills = $this->getActiveBills();+ $return = [];+ /** @var Bill $bill */+ foreach ($bills as $bill) {+ $dates = $this->getPayDatesInRange($bill, $start, $end);+ $count = $bill->transactionJournals()->after($start)->before($end)->count();+ $total = $dates->count() - $count;- return $factory->create($data);+ if ($total > 0) {+ $currency = $bill->transactionCurrency;+ $average = bcdiv(bcadd($bill->amount_max, $bill->amount_min), '2');+ $return[$currency->id] = $return[$currency->id] ?? [+ 'id' => (string)$currency->id,+ 'name' => $currency->name,+ 'symbol' => $currency->symbol,+ 'code' => $currency->code,+ 'decimal_places' => $currency->decimal_places,+ 'sum' => '0',+ ];+ $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], bcmul($average, (string)$total));+ }+ }++ return $return;}/**- * @param Bill $bill+ * @param Bill $bill*/public function unlinkAll(Bill $bill): void{@@ -880,8 +896,8 @@ class BillRepository implements BillRepositoryInterface}/**- * @param Bill $bill- * @param array $data+ * @param Bill $bill+ * @param array $data** @return Bill*/diff --git a/app/Repositories/Bill/BillRepositoryInterface.php b/app/Repositories/Bill/BillRepositoryInterface.phpindex 4b6cfbb125..372d2da8b1 100644--- a/app/Repositories/Bill/BillRepositoryInterface.php+++ b/app/Repositories/Bill/BillRepositoryInterface.php@@ -1,4 +1,5 @@<?php+/*** BillRepositoryInterface.php* Copyright (c) 2019 [email protected]@@ -35,34 +36,16 @@ use Illuminate\Support\Collection;interface BillRepositoryInterface{/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/public function billEndsWith(string $query, int $limit): Collection;/**- * Collect multi-currency of sum of bills yet to pay.- *- * @param Carbon $start- * @param Carbon $end- * @return array- */- public function sumUnpaidInRange(Carbon $start, Carbon $end): array;-- /**- * Collect multi-currency of sum of bills already paid.- *- * @param Carbon $start- * @param Carbon $end- * @return array- */- public function sumPaidInRange(Carbon $start, Carbon $end): array;-- /**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/@@ -71,10 +54,10 @@ interface BillRepositoryInterface/*** Get the total amount of money due for the users active bills in the date range given.*- * @param Carbon $start- * @param Carbon $end- * @deprecated+ * @param Carbon $start+ * @param Carbon $end* @return Collection+ * @deprecated*/public function collectBillsUnpaidInRange(Carbon $start, Carbon $end): Collection;@@ -84,7 +67,7 @@ interface BillRepositoryInterfacepublic function correctOrder(): void;/**- * @param Bill $bill+ * @param Bill $bill** @return bool*/@@ -98,7 +81,7 @@ interface BillRepositoryInterface/*** Find a bill by ID.*- * @param int $billId+ * @param int $billId** @return Bill|null*/@@ -107,8 +90,8 @@ interface BillRepositoryInterface/*** Find bill by parameters.*- * @param int|null $billId- * @param string|null $billName+ * @param int|null $billId+ * @param string|null $billName** @return Bill|null*/@@ -117,7 +100,7 @@ interface BillRepositoryInterface/*** Find a bill by name.*- * @param string $name+ * @param string $name** @return Bill|null*/@@ -131,7 +114,7 @@ interface BillRepositoryInterface/*** Get all attachments.*- * @param Bill $bill+ * @param Bill $bill** @return Collection*/@@ -145,7 +128,7 @@ interface BillRepositoryInterface/*** Gets the bills which have some kind of relevance to the accounts mentioned.*- * @param Collection $accounts+ * @param Collection $accounts** @return Collection*/@@ -153,8 +136,8 @@ interface BillRepositoryInterface/*** Get the total amount of money paid for the users active bills in the date range given.- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return string* @deprecated@@ -164,8 +147,8 @@ interface BillRepositoryInterface/*** Get the total amount of money paid for the users active bills in the date range given,* grouped per currency.- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return array* @deprecated@@ -174,8 +157,8 @@ interface BillRepositoryInterface/*** Get the total amount of money due for the users active bills in the date range given.- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return string* @deprecated@@ -184,8 +167,8 @@ interface BillRepositoryInterface/*** Get the total amount of money due for the users active bills in the date range given.- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return array* @deprecated@@ -195,7 +178,7 @@ interface BillRepositoryInterface/*** Get all bills with these ID's.*- * @param array $billIds+ * @param array $billIds** @return Collection*/@@ -204,30 +187,30 @@ interface BillRepositoryInterface/*** Get text or return empty string.*- * @param Bill $bill+ * @param Bill $bill** @return string*/public function getNoteText(Bill $bill): string;/**- * @param Bill $bill+ * @param Bill $bill** @return array*/public function getOverallAverage(Bill $bill): array;/**- * @param int $size+ * @param int $size** @return LengthAwarePaginator*/public function getPaginator(int $size): LengthAwarePaginator;/**- * @param Bill $bill- * @param Carbon $start- * @param Carbon $end+ * @param Bill $bill+ * @param Carbon $start+ * @param Carbon $end** @return Collection*/@@ -236,9 +219,9 @@ interface BillRepositoryInterface/*** Between start and end, tells you on which date(s) the bill is expected to hit.*- * @param Bill $bill- * @param Carbon $start- * @param Carbon $end+ * @param Bill $bill+ * @param Carbon $start+ * @param Carbon $end** @return Collection*/@@ -247,7 +230,7 @@ interface BillRepositoryInterface/*** Return all rules for one bill*- * @param Bill $bill+ * @param Bill $bill** @return Collection*/@@ -259,15 +242,15 @@ interface BillRepositoryInterface** 5 => [['id' => 1, 'title' => 'Some rule'],['id' => 2, 'title' => 'Some other rule']]*- * @param Collection $collection+ * @param Collection $collection** @return array*/public function getRulesForBills(Collection $collection): array;/**- * @param Bill $bill- * @param Carbon $date+ * @param Bill $bill+ * @param Carbon $date** @return array*/@@ -276,8 +259,8 @@ interface BillRepositoryInterface/*** Link a set of journals to a bill.*- * @param Bill $bill- * @param array $transactions+ * @param Bill $bill+ * @param array $transactions*/public function linkCollectionToBill(Bill $bill, array $transactions): void;@@ -285,39 +268,39 @@ interface BillRepositoryInterface* Given a bill and a date, this method will tell you at which moment this bill expects its next* transaction. Whether or not it is there already, is not relevant.*- * @param Bill $bill- * @param Carbon $date+ * @param Bill $bill+ * @param Carbon $date** @return Carbon*/public function nextDateMatch(Bill $bill, Carbon $date): Carbon;/**- * @param Bill $bill- * @param Carbon $date+ * @param Bill $bill+ * @param Carbon $date** @return Carbon*/public function nextExpectedMatch(Bill $bill, Carbon $date): Carbon;/**- * @param Bill $bill+ * @param Bill $bill** @return Bill*/public function removeObjectGroup(Bill $bill): Bill;/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/public function searchBill(string $query, int $limit): Collection;/**- * @param Bill $bill- * @param string $objectGroupTitle+ * @param Bill $bill+ * @param string $objectGroupTitle** @return Bill*/@@ -326,18 +309,18 @@ interface BillRepositoryInterface/*** Set specific piggy bank to specific order.*- * @param Bill $bill- * @param int $order+ * @param Bill $bill+ * @param int $order*/public function setOrder(Bill $bill, int $order): void;/**- * @param User $user+ * @param User $user*/public function setUser(User $user);/**- * @param array $data+ * @param array $data** @return Bill* @throws FireflyException@@ -345,13 +328,31 @@ interface BillRepositoryInterfacepublic function store(array $data): Bill;/**- * @param Bill $bill+ * Collect multi-currency of sum of bills already paid.+ *+ * @param Carbon $start+ * @param Carbon $end+ * @return array+ */+ public function sumPaidInRange(Carbon $start, Carbon $end): array;++ /**+ * Collect multi-currency of sum of bills yet to pay.+ *+ * @param Carbon $start+ * @param Carbon $end+ * @return array+ */+ public function sumUnpaidInRange(Carbon $start, Carbon $end): array;++ /**+ * @param Bill $bill*/public function unlinkAll(Bill $bill): void;/**- * @param Bill $bill- * @param array $data+ * @param Bill $bill+ * @param array $data** @return Bill*/diff --git a/app/Repositories/Budget/AvailableBudgetRepository.php b/app/Repositories/Budget/AvailableBudgetRepository.phpindex 57820051d3..62983b91c1 100644--- a/app/Repositories/Budget/AvailableBudgetRepository.php+++ b/app/Repositories/Budget/AvailableBudgetRepository.php@@ -48,7 +48,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface}/**- * @param AvailableBudget $availableBudget+ * @param AvailableBudget $availableBudget*/public function destroyAvailableBudget(AvailableBudget $availableBudget): void{@@ -59,24 +59,6 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface}}- /**- * Find existing AB.- *- * @param TransactionCurrency $currency- * @param Carbon $start- * @param Carbon $end- *- * @return AvailableBudget|null- */- public function find(TransactionCurrency $currency, Carbon $start, Carbon $end): ?AvailableBudget- {- return $this->user->availableBudgets()- ->where('transaction_currency_id', $currency->id)- ->where('start_date', $start->format('Y-m-d'))- ->where('end_date', $end->format('Y-m-d'))- ->first();- }-/*** @inheritDoc*/@@ -86,32 +68,27 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface}/**- * Return a list of all available budgets (in all currencies) (for the selected period).+ * Find existing AB.*- * @param Carbon|null $start- * @param Carbon|null $end+ * @param TransactionCurrency $currency+ * @param Carbon $start+ * @param Carbon $end*- * @return Collection+ * @return AvailableBudget|null*/- public function get(?Carbon $start = null, ?Carbon $end = null): Collection+ public function find(TransactionCurrency $currency, Carbon $start, Carbon $end): ?AvailableBudget{- $query = $this->user->availableBudgets()->with(['transactionCurrency']);- if (null !== $start && null !== $end) {- $query->where(- static function (Builder $q1) use ($start, $end) {- $q1->where('start_date', '=', $start->format('Y-m-d'));- $q1->where('end_date', '=', $end->format('Y-m-d'));- }- );- }-- return $query->get(['available_budgets.*']);+ return $this->user->availableBudgets()+ ->where('transaction_currency_id', $currency->id)+ ->where('start_date', $start->format('Y-m-d'))+ ->where('end_date', $end->format('Y-m-d'))+ ->first();}/**- * @param TransactionCurrency $currency- * @param Carbon $start- * @param Carbon $end+ * @param TransactionCurrency $currency+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -123,15 +100,15 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface->where('start_date', $start->format('Y-m-d'))->where('end_date', $end->format('Y-m-d'))->first();if (null !== $availableBudget) {- $amount = (string) $availableBudget->amount;+ $amount = (string)$availableBudget->amount;}return $amount;}/**- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return array*/@@ -149,10 +126,33 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterfacereturn $return;}+ /**+ * Return a list of all available budgets (in all currencies) (for the selected period).+ *+ * @param Carbon|null $start+ * @param Carbon|null $end+ *+ * @return Collection+ */+ public function get(?Carbon $start = null, ?Carbon $end = null): Collection+ {+ $query = $this->user->availableBudgets()->with(['transactionCurrency']);+ if (null !== $start && null !== $end) {+ $query->where(+ static function (Builder $q1) use ($start, $end) {+ $q1->where('start_date', '=', $start->format('Y-m-d'));+ $q1->where('end_date', '=', $end->format('Y-m-d'));+ }+ );+ }++ return $query->get(['available_budgets.*']);+ }+/*** Returns all available budget objects.*- * @param TransactionCurrency $currency+ * @param TransactionCurrency $currency** @return Collection*/@@ -164,8 +164,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface/*** Returns all available budget objects.*- * @param Carbon|null $start- * @param Carbon|null $end+ * @param Carbon|null $start+ * @param Carbon|null $end** @return Collection*@@ -197,10 +197,10 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface}/**- * @param TransactionCurrency $currency- * @param Carbon $start- * @param Carbon $end- * @param string $amount+ * @param TransactionCurrency $currency+ * @param Carbon $start+ * @param Carbon $end+ * @param string $amount** @return AvailableBudget* @deprecated@@ -225,7 +225,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface}/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void{@@ -233,7 +233,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface}/**- * @param array $data+ * @param array $data** @return AvailableBudget|null*/@@ -261,8 +261,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface}/**- * @param AvailableBudget $availableBudget- * @param array $data+ * @param AvailableBudget $availableBudget+ * @param array $data** @return AvailableBudget*/@@ -277,8 +277,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface}/**- * @param AvailableBudget $availableBudget- * @param array $data+ * @param AvailableBudget $availableBudget+ * @param array $data** @return AvailableBudget*/diff --git a/app/Repositories/Budget/AvailableBudgetRepositoryInterface.php b/app/Repositories/Budget/AvailableBudgetRepositoryInterface.phpindex 7a4cc93b24..7537291f96 100644--- a/app/Repositories/Budget/AvailableBudgetRepositoryInterface.php+++ b/app/Repositories/Budget/AvailableBudgetRepositoryInterface.php@@ -40,23 +40,23 @@ interface AvailableBudgetRepositoryInterfacepublic function destroyAll(): void;/**- * @param AvailableBudget $availableBudget+ * @param AvailableBudget $availableBudget*/public function destroyAvailableBudget(AvailableBudget $availableBudget): void;/*** Find existing AB.*- * @param TransactionCurrency $currency- * @param Carbon $start- * @param Carbon $end+ * @param TransactionCurrency $currency+ * @param Carbon $start+ * @param Carbon $end** @return AvailableBudget|null*/public function find(TransactionCurrency $currency, Carbon $start, Carbon $end): ?AvailableBudget;/**- * @param int $id+ * @param int $id** @return AvailableBudget|null*/@@ -65,17 +65,17 @@ interface AvailableBudgetRepositoryInterface/*** Return a list of all available budgets (in all currencies) (for the selected period).*- * @param Carbon|null $start- * @param Carbon|null $end+ * @param Carbon|null $start+ * @param Carbon|null $end** @return Collection*/public function get(?Carbon $start = null, ?Carbon $end = null): Collection;/**- * @param TransactionCurrency $currency- * @param Carbon $start- * @param Carbon $end+ * @param TransactionCurrency $currency+ * @param Carbon $start+ * @param Carbon $end** @return string* @deprecated@@ -83,8 +83,8 @@ interface AvailableBudgetRepositoryInterfacepublic function getAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end): string;/**- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return array*/@@ -93,7 +93,7 @@ interface AvailableBudgetRepositoryInterface/*** Returns all available budget objects.*- * @param TransactionCurrency $currency+ * @param TransactionCurrency $currency** @return Collection*/@@ -102,8 +102,8 @@ interface AvailableBudgetRepositoryInterface/*** Returns all available budget objects.*- * @param Carbon|null $start- * @param Carbon|null $end+ * @param Carbon|null $start+ * @param Carbon|null $end** @return Collection*@@ -113,19 +113,19 @@ interface AvailableBudgetRepositoryInterface/*** Get by transaction currency and date. Should always result in one entry or NULL.*- * @param Carbon $start- * @param Carbon $end- * @param TransactionCurrency $currency+ * @param Carbon $start+ * @param Carbon $end+ * @param TransactionCurrency $currency** @return null|AvailableBudget*/public function getByCurrencyDate(Carbon $start, Carbon $end, TransactionCurrency $currency): ?AvailableBudget;/**- * @param TransactionCurrency $currency- * @param Carbon $start- * @param Carbon $end- * @param string $amount+ * @param TransactionCurrency $currency+ * @param Carbon $start+ * @param Carbon $end+ * @param string $amount** @return AvailableBudget* @deprecated@@ -133,28 +133,28 @@ interface AvailableBudgetRepositoryInterfacepublic function setAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end, string $amount): AvailableBudget;/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void;/**- * @param array $data+ * @param array $data** @return AvailableBudget|null*/public function store(array $data): ?AvailableBudget;/**- * @param AvailableBudget $availableBudget- * @param array $data+ * @param AvailableBudget $availableBudget+ * @param array $data** @return AvailableBudget*/public function update(AvailableBudget $availableBudget, array $data): AvailableBudget;/**- * @param AvailableBudget $availableBudget- * @param array $data+ * @param AvailableBudget $availableBudget+ * @param array $data** @return AvailableBudget*/diff --git a/app/Repositories/Budget/BudgetLimitRepository.php b/app/Repositories/Budget/BudgetLimitRepository.phpindex 43fb51fb02..e314f23551 100644--- a/app/Repositories/Budget/BudgetLimitRepository.php+++ b/app/Repositories/Budget/BudgetLimitRepository.php@@ -48,10 +48,10 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface* Tells you which amount has been budgeted (for the given budgets)* in the selected query. Returns a positive amount as a string.*- * @param Carbon $start- * @param Carbon $end- * @param TransactionCurrency $currency- * @param Collection|null $budgets+ * @param Carbon $start+ * @param Carbon $end+ * @param TransactionCurrency $currency+ * @param Collection|null $budgets** @return string*/@@ -60,37 +60,37 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface$query = BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')// same complex where query as below.- ->where(- static function (Builder $q5) use ($start, $end) {- $q5->where(- static function (Builder $q1) use ($start, $end) {- $q1->where(- static function (Builder $q2) use ($start, $end) {- $q2->where('budget_limits.end_date', '>=', $start->format('Y-m-d'));- $q2->where('budget_limits.end_date', '<=', $end->format('Y-m-d'));+ ->where(+ static function (Builder $q5) use ($start, $end) {+ $q5->where(+ static function (Builder $q1) use ($start, $end) {+ $q1->where(+ static function (Builder $q2) use ($start, $end) {+ $q2->where('budget_limits.end_date', '>=', $start->format('Y-m-d'));+ $q2->where('budget_limits.end_date', '<=', $end->format('Y-m-d'));+ }+ )+ ->orWhere(+ static function (Builder $q3) use ($start, $end) {+ $q3->where('budget_limits.start_date', '>=', $start->format('Y-m-d'));+ $q3->where('budget_limits.start_date', '<=', $end->format('Y-m-d'));+ }+ );+ }+ )+ ->orWhere(+ static function (Builder $q4) use ($start, $end) {+ // or start is before start AND end is after end.+ $q4->where('budget_limits.start_date', '<=', $start->format('Y-m-d'));+ $q4->where('budget_limits.end_date', '>=', $end->format('Y-m-d'));+ }+ );})- ->orWhere(- static function (Builder $q3) use ($start, $end) {- $q3->where('budget_limits.start_date', '>=', $start->format('Y-m-d'));- $q3->where('budget_limits.start_date', '<=', $end->format('Y-m-d'));- }- );- }- )- ->orWhere(- static function (Builder $q4) use ($start, $end) {- // or start is before start AND end is after end.- $q4->where('budget_limits.start_date', '<=', $start->format('Y-m-d'));- $q4->where('budget_limits.end_date', '>=', $end->format('Y-m-d'));- }- );- }- )- ->where('budget_limits.transaction_currency_id', $currency->id)- ->whereNull('budgets.deleted_at')- ->where('budgets.active', true)- ->where('budgets.user_id', $this->user->id);+ ->where('budget_limits.transaction_currency_id', $currency->id)+ ->whereNull('budgets.deleted_at')+ ->where('budgets.active', true)+ ->where('budgets.user_id', $this->user->id);if (null !== $budgets && $budgets->count() > 0) {$query->whereIn('budget_limits.budget_id', $budgets->pluck('id')->toArray());}@@ -120,7 +120,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface/*** Destroy a budget limit.*- * @param BudgetLimit $budgetLimit+ * @param BudgetLimit $budgetLimit*/public function destroyBudgetLimit(BudgetLimit $budgetLimit): void{@@ -132,25 +132,9 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface}/**- * @param Budget $budget- * @param TransactionCurrency $currency- * @param Carbon $start- * @param Carbon $end- *- * @return BudgetLimit|null- */- public function find(Budget $budget, TransactionCurrency $currency, Carbon $start, Carbon $end): ?BudgetLimit- {- return $budget->budgetlimits()- ->where('transaction_currency_id', $currency->id)- ->where('start_date', $start->format('Y-m-d'))- ->where('end_date', $end->format('Y-m-d'))->first();- }-- /**- * @param TransactionCurrency $currency- * @param Carbon|null $start- * @param Carbon|null $end+ * @param TransactionCurrency $currency+ * @param Carbon|null $start+ * @param Carbon|null $end** @return Collection*/@@ -164,8 +148,8 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface}/**- * @param Carbon|null $start- * @param Carbon|null $end+ * @param Carbon|null $start+ * @param Carbon|null $end** @return Collection*/@@ -232,9 +216,9 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface}/**- * @param Budget $budget- * @param Carbon|null $start- * @param Carbon|null $end+ * @param Budget $budget+ * @param Carbon|null $start+ * @param Carbon|null $end** @return Collection*/@@ -292,7 +276,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface}/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void{@@ -300,7 +284,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface}/**- * @param array $data+ * @param array $data** @return BudgetLimit* @throws FireflyException@@ -319,7 +303,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface$currency->save();// find the budget:- $budget = $this->user->budgets()->find((int) $data['budget_id']);+ $budget = $this->user->budgets()->find((int)$data['budget_id']);if (null === $budget) {throw new FireflyException('200004: Budget does not exist.');}@@ -349,8 +333,24 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface}/**- * @param BudgetLimit $budgetLimit- * @param array $data+ * @param Budget $budget+ * @param TransactionCurrency $currency+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return BudgetLimit|null+ */+ public function find(Budget $budget, TransactionCurrency $currency, Carbon $start, Carbon $end): ?BudgetLimit+ {+ return $budget->budgetlimits()+ ->where('transaction_currency_id', $currency->id)+ ->where('start_date', $start->format('Y-m-d'))+ ->where('end_date', $end->format('Y-m-d'))->first();+ }++ /**+ * @param BudgetLimit $budgetLimit+ * @param array $data** @return BudgetLimit* @throws FireflyException@@ -386,10 +386,10 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface}/**- * @param Budget $budget- * @param Carbon $start- * @param Carbon $end- * @param string $amount+ * @param Budget $budget+ * @param Carbon $start+ * @param Carbon $end+ * @param string $amount** @return BudgetLimit|null*diff --git a/app/Repositories/Budget/BudgetLimitRepositoryInterface.php b/app/Repositories/Budget/BudgetLimitRepositoryInterface.phpindex ae7adc15b5..3c6c914c8a 100644--- a/app/Repositories/Budget/BudgetLimitRepositoryInterface.php+++ b/app/Repositories/Budget/BudgetLimitRepositoryInterface.php@@ -39,10 +39,10 @@ interface BudgetLimitRepositoryInterface* Tells you which amount has been budgeted (for the given budgets)* in the selected query. Returns a positive amount as a string.*- * @param Carbon $start- * @param Carbon $end- * @param TransactionCurrency $currency- * @param Collection|null $budgets+ * @param Carbon $start+ * @param Carbon $end+ * @param TransactionCurrency $currency+ * @param Collection|null $budgets** @return string*/@@ -56,15 +56,15 @@ interface BudgetLimitRepositoryInterface/*** Destroy a budget limit.*- * @param BudgetLimit $budgetLimit+ * @param BudgetLimit $budgetLimit*/public function destroyBudgetLimit(BudgetLimit $budgetLimit): void;/**- * @param Budget $budget- * @param TransactionCurrency $currency- * @param Carbon $start- * @param Carbon $end+ * @param Budget $budget+ * @param TransactionCurrency $currency+ * @param Carbon $start+ * @param Carbon $end** @return BudgetLimit|null*/@@ -73,56 +73,56 @@ interface BudgetLimitRepositoryInterface/*** TODO this method is not multi currency aware.*- * @param Carbon|null $start- * @param Carbon|null $end+ * @param Carbon|null $start+ * @param Carbon|null $end** @return Collection*/public function getAllBudgetLimits(Carbon $start = null, Carbon $end = null): Collection;/**- * @param TransactionCurrency $currency- * @param Carbon|null $start- * @param Carbon|null $end+ * @param TransactionCurrency $currency+ * @param Carbon|null $start+ * @param Carbon|null $end** @return Collection*/public function getAllBudgetLimitsByCurrency(TransactionCurrency $currency, Carbon $start = null, Carbon $end = null): Collection;/**- * @param Budget $budget- * @param Carbon|null $start- * @param Carbon|null $end+ * @param Budget $budget+ * @param Carbon|null $start+ * @param Carbon|null $end** @return Collection*/public function getBudgetLimits(Budget $budget, Carbon $start = null, Carbon $end = null): Collection;/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void;/**- * @param array $data+ * @param array $data** @return BudgetLimit*/public function store(array $data): BudgetLimit;/**- * @param BudgetLimit $budgetLimit- * @param array $data+ * @param BudgetLimit $budgetLimit+ * @param array $data** @return BudgetLimit*/public function update(BudgetLimit $budgetLimit, array $data): BudgetLimit;/**- * @param Budget $budget- * @param Carbon $start- * @param Carbon $end- * @param string $amount+ * @param Budget $budget+ * @param Carbon $start+ * @param Carbon $end+ * @param string $amount** @return BudgetLimit|null*/diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.phpindex c5586f8297..549d7487b9 100644--- a/app/Repositories/Budget/BudgetRepository.php+++ b/app/Repositories/Budget/BudgetRepository.php@@ -1,4 +1,5 @@<?php+/*** BudgetRepository.php* Copyright (c) 2019 [email protected]@@ -105,42 +106,52 @@ class BudgetRepository implements BudgetRepositoryInterfaceLog::debug(sprintf('Budget limit #%d', $limit->id));$currency = $limit->transactionCurrency;$return[$currency->id] = $return[$currency->id] ?? [- 'id' => (string) $currency->id,- 'name' => $currency->name,- 'symbol' => $currency->symbol,- 'code' => $currency->code,- 'decimal_places' => $currency->decimal_places,- 'sum' => '0',- ];+ 'id' => (string)$currency->id,+ 'name' => $currency->name,+ 'symbol' => $currency->symbol,+ 'code' => $currency->code,+ 'decimal_places' => $currency->decimal_places,+ 'sum' => '0',+ ];// same periodif ($limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end)) {- $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string) $limit->amount);+ $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string)$limit->amount);Log::debug(sprintf('Add full amount [1]: %s', $limit->amount));continue;}// limit is inside of date rangeif ($start->lte($limit->start_date) && $end->gte($limit->end_date)) {- $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string) $limit->amount);+ $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string)$limit->amount);Log::debug(sprintf('Add full amount [2]: %s', $limit->amount));continue;}$total = $limit->start_date->diffInDays($limit->end_date) + 1; // include the day itself.$days = $this->daysInOverlap($limit, $start, $end);- $amount = bcmul(bcdiv((string) $limit->amount, (string) $total), (string) $days);+ $amount = bcmul(bcdiv((string)$limit->amount, (string)$total), (string)$days);$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $amount);- Log::debug(sprintf(- 'Amount per day: %s (%s over %d days). Total amount for %d days: %s',- bcdiv((string) $limit->amount, (string) $total),- $limit->amount,- $total,- $days,- $amount- ));+ Log::debug(+ sprintf(+ 'Amount per day: %s (%s over %d days). Total amount for %d days: %s',+ bcdiv((string)$limit->amount, (string)$total),+ $limit->amount,+ $total,+ $days,+ $amount+ )+ );}}return $return;}+ /**+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }+/*** @return Collection*/@@ -155,9 +166,9 @@ class BudgetRepository implements BudgetRepositoryInterface/*** How many days of this budget limit are between start and end?*- * @param BudgetLimit $limit- * @param Carbon $start- * @param Carbon $end+ * @param BudgetLimit $limit+ * @param Carbon $start+ * @param Carbon $end* @return int*/private function daysInOverlap(BudgetLimit $limit, Carbon $start, Carbon $end): int@@ -203,7 +214,7 @@ class BudgetRepository implements BudgetRepositoryInterface}$budgets = $this->getActiveBudgets();/**- * @var int $index+ * @var int $index* @var Budget $budget*/foreach ($budgets as $index => $budget) {@@ -217,7 +228,193 @@ class BudgetRepository implements BudgetRepositoryInterface}/**- * @param Budget $budget+ * @param Budget $budget+ * @param array $data+ *+ * @return Budget+ */+ public function update(Budget $budget, array $data): Budget+ {+ Log::debug('Now in update()');++ $oldName = $budget->name;+ if (array_key_exists('name', $data)) {+ $budget->name = $data['name'];+ $this->updateRuleActions($oldName, $budget->name);+ $this->updateRuleTriggers($oldName, $budget->name);+ }+ if (array_key_exists('active', $data)) {+ $budget->active = $data['active'];+ }+ if (array_key_exists('notes', $data)) {+ $this->setNoteText($budget, (string)$data['notes']);+ }+ $budget->save();++ // update or create auto-budget:+ $autoBudget = $this->getAutoBudget($budget);++ // first things first: delete when no longer required:+ $autoBudgetType = array_key_exists('auto_budget_type', $data) ? $data['auto_budget_type'] : null;++ if (0 === $autoBudgetType && null !== $autoBudget) {+ // delete!+ $autoBudget->delete();++ return $budget;+ }+ if (0 === $autoBudgetType && null === $autoBudget) {+ return $budget;+ }+ if (null === $autoBudgetType && null === $autoBudget) {+ return $budget;+ }+ $this->updateAutoBudget($budget, $data);++ return $budget;+ }++ /**+ * @param string $oldName+ * @param string $newName+ */+ private function updateRuleActions(string $oldName, string $newName): void+ {+ $types = ['set_budget',];+ $actions = RuleAction::leftJoin('rules', 'rules.id', '=', 'rule_actions.rule_id')+ ->where('rules.user_id', $this->user->id)+ ->whereIn('rule_actions.action_type', $types)+ ->where('rule_actions.action_value', $oldName)+ ->get(['rule_actions.*']);+ Log::debug(sprintf('Found %d actions to update.', $actions->count()));+ /** @var RuleAction $action */+ foreach ($actions as $action) {+ $action->action_value = $newName;+ $action->save();+ Log::debug(sprintf('Updated action %d: %s', $action->id, $action->action_value));+ }+ }++ /**+ * @param string $oldName+ * @param string $newName+ */+ private function updateRuleTriggers(string $oldName, string $newName): void+ {+ $types = ['budget_is',];+ $triggers = RuleTrigger::leftJoin('rules', 'rules.id', '=', 'rule_triggers.rule_id')+ ->where('rules.user_id', $this->user->id)+ ->whereIn('rule_triggers.trigger_type', $types)+ ->where('rule_triggers.trigger_value', $oldName)+ ->get(['rule_triggers.*']);+ Log::debug(sprintf('Found %d triggers to update.', $triggers->count()));+ /** @var RuleTrigger $trigger */+ foreach ($triggers as $trigger) {+ $trigger->trigger_value = $newName;+ $trigger->save();+ Log::debug(sprintf('Updated trigger %d: %s', $trigger->id, $trigger->trigger_value));+ }+ }++ /**+ * @param Budget $budget+ * @param string $text+ * @return void+ */+ private function setNoteText(Budget $budget, string $text): void+ {+ $dbNote = $budget->notes()->first();+ if ('' !== $text) {+ if (null === $dbNote) {+ $dbNote = new Note();+ $dbNote->noteable()->associate($budget);+ }+ $dbNote->text = trim($text);+ $dbNote->save();++ return;+ }+ if (null !== $dbNote) {+ try {+ $dbNote->delete();+ } catch (Exception $e) {+ // @ignoreException+ }+ }+ }++ /**+ * @inheritDoc+ */+ public function getAutoBudget(Budget $budget): ?AutoBudget+ {+ return $budget->autoBudgets()->first();+ }++ /**+ * @param Budget $budget+ * @param array $data+ * @throws FireflyException+ * @throws JsonException+ */+ private function updateAutoBudget(Budget $budget, array $data): void+ {+ // update or create auto-budget:+ $autoBudget = $this->getAutoBudget($budget);++ // grab default currency:+ $currency = app('amount')->getDefaultCurrencyByUser($this->user);++ if (null === $autoBudget) {+ // at this point it's a blind assumption auto_budget_type is 1 or 2.+ $autoBudget = new AutoBudget();+ $autoBudget->auto_budget_type = $data['auto_budget_type'];+ $autoBudget->budget_id = $budget->id;+ $autoBudget->transaction_currency_id = $currency->id;+ }++ // set or update the currency.+ if (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {+ $repos = app(CurrencyRepositoryInterface::class);+ $currencyId = (int)($data['currency_id'] ?? 0);+ $currencyCode = (string)($data['currency_code'] ?? '');+ $currency = $repos->find($currencyId);+ if (null === $currency) {+ $currency = $repos->findByCodeNull($currencyCode);+ }+ if (null !== $currency) {+ $autoBudget->transaction_currency_id = $currency->id;+ }+ }++ // change values if submitted or presented:+ if (array_key_exists('auto_budget_type', $data)) {+ $autoBudget->auto_budget_type = $data['auto_budget_type'];+ }+ if (array_key_exists('auto_budget_amount', $data)) {+ $autoBudget->amount = $data['auto_budget_amount'];+ }+ if (array_key_exists('auto_budget_period', $data)) {+ $autoBudget->period = $data['auto_budget_period'];+ }++ $autoBudget->save();+ }++ /**+ * Find a budget or return NULL+ *+ * @param int|null $budgetId |null+ *+ * @return Budget|null+ */+ public function find(int $budgetId = null): ?Budget+ {+ return $this->user->budgets()->find($budgetId);+ }++ /**+ * @param Budget $budget** @return bool*/@@ -238,10 +435,10 @@ class BudgetRepository implements BudgetRepositoryInterface$budgets = $this->getBudgets();/** @var Budget $budget */foreach ($budgets as $budget) {- DB::table('budget_transaction')->where('budget_id', (int) $budget->id)->delete();- DB::table('budget_transaction_journal')->where('budget_id', (int) $budget->id)->delete();- RecurrenceTransactionMeta::where('name', 'budget_id')->where('value', (string) $budget->id)->delete();- RuleAction::where('action_type', 'set_budget')->where('action_value', (string) $budget->id)->delete();+ DB::table('budget_transaction')->where('budget_id', (int)$budget->id)->delete();+ DB::table('budget_transaction_journal')->where('budget_id', (int)$budget->id)->delete();+ RecurrenceTransactionMeta::where('name', 'budget_id')->where('value', (string)$budget->id)->delete();+ RuleAction::where('action_type', 'set_budget')->where('action_value', (string)$budget->id)->delete();$budget->delete();}}@@ -267,8 +464,8 @@ class BudgetRepository implements BudgetRepositoryInterface}/**- * @param int|null $budgetId- * @param string|null $budgetName+ * @param int|null $budgetId+ * @param string|null $budgetName** @return Budget|null*/@@ -276,10 +473,10 @@ class BudgetRepository implements BudgetRepositoryInterface{Log::debug('Now in findBudget()');Log::debug(sprintf('Searching for budget with ID #%d...', $budgetId));- $result = $this->find((int) $budgetId);+ $result = $this->find((int)$budgetId);if (null === $result && null !== $budgetName && '' !== $budgetName) {Log::debug(sprintf('Searching for budget with name %s...', $budgetName));- $result = $this->findByName((string) $budgetName);+ $result = $this->findByName((string)$budgetName);}if (null !== $result) {Log::debug(sprintf('Found budget #%d: %s', $result->id, $result->name));@@ -289,22 +486,10 @@ class BudgetRepository implements BudgetRepositoryInterfacereturn $result;}- /**- * Find a budget or return NULL- *- * @param int|null $budgetId |null- *- * @return Budget|null- */- public function find(int $budgetId = null): ?Budget- {- return $this->user->budgets()->find($budgetId);- }-/*** Find budget by name.*- * @param string|null $name+ * @param string|null $name** @return Budget|null*/@@ -322,7 +507,7 @@ class BudgetRepository implements BudgetRepositoryInterface* This method returns the oldest journal or transaction date known to this budget.* Will cache result.*- * @param Budget $budget+ * @param Budget $budget** @return Carbon|null*/@@ -360,7 +545,7 @@ class BudgetRepository implements BudgetRepositoryInterface/*** Get all budgets with these ID's.*- * @param array $budgetIds+ * @param array $budgetIds** @return Collection*/@@ -393,8 +578,8 @@ class BudgetRepository implements BudgetRepositoryInterface}/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/@@ -411,8 +596,8 @@ class BudgetRepository implements BudgetRepositoryInterface}/**- * @param Budget $budget- * @param int $order+ * @param Budget $budget+ * @param int $order*/public function setBudgetOrder(Budget $budget, int $order): void{@@ -420,14 +605,6 @@ class BudgetRepository implements BudgetRepositoryInterface$budget->save();}- /**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }-/*** @inheritDoc*/@@ -462,28 +639,28 @@ class BudgetRepository implements BudgetRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$array[$currencyId] = $array[$currencyId] ?? [- 'id' => (string) $currencyId,- 'name' => $journal['currency_name'],- 'symbol' => $journal['currency_symbol'],- 'code' => $journal['currency_code'],- 'decimal_places' => $journal['currency_decimal_places'],- 'sum' => '0',- ];+ 'id' => (string)$currencyId,+ 'name' => $journal['currency_name'],+ 'symbol' => $journal['currency_symbol'],+ 'code' => $journal['currency_code'],+ 'decimal_places' => $journal['currency_decimal_places'],+ 'sum' => '0',+ ];$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->negative($journal['amount']));// also do foreign amount:- $foreignId = (int) $journal['foreign_currency_id'];+ $foreignId = (int)$journal['foreign_currency_id'];if (0 !== $foreignId) {$array[$foreignId] = $array[$foreignId] ?? [- 'id' => (string) $foreignId,- 'name' => $journal['foreign_currency_name'],- 'symbol' => $journal['foreign_currency_symbol'],- 'code' => $journal['foreign_currency_code'],- 'decimal_places' => $journal['foreign_currency_decimal_places'],- 'sum' => '0',- ];+ 'id' => (string)$foreignId,+ 'name' => $journal['foreign_currency_name'],+ 'symbol' => $journal['foreign_currency_symbol'],+ 'code' => $journal['foreign_currency_code'],+ 'decimal_places' => $journal['foreign_currency_decimal_places'],+ 'sum' => '0',+ ];$array[$foreignId]['sum'] = bcadd($array[$foreignId]['sum'], app('steam')->negative($journal['foreign_amount']));}}@@ -492,7 +669,7 @@ class BudgetRepository implements BudgetRepositoryInterface}/**- * @param array $data+ * @param array $data** @return Budget* @throws FireflyException@@ -518,7 +695,7 @@ class BudgetRepository implements BudgetRepositoryInterface// set notesif (array_key_exists('notes', $data)) {- $this->setNoteText($newBudget, (string) $data['notes']);+ $this->setNoteText($newBudget, (string)$data['notes']);}if (!array_key_exists('auto_budget_type', $data) || !array_key_exists('auto_budget_amount', $data) || !array_key_exists('auto_budget_period', $data)) {@@ -542,10 +719,10 @@ class BudgetRepository implements BudgetRepositoryInterface$repos = app(CurrencyRepositoryInterface::class);$currency = null;if (array_key_exists('currency_id', $data)) {- $currency = $repos->find((int) $data['currency_id']);+ $currency = $repos->find((int)$data['currency_id']);}if (array_key_exists('currency_code', $data)) {- $currency = $repos->findByCode((string) $data['currency_code']);+ $currency = $repos->findByCode((string)$data['currency_code']);}if (null === $currency) {$currency = app('amount')->getDefaultCurrencyByUser($this->user);@@ -581,180 +758,6 @@ class BudgetRepository implements BudgetRepositoryInterfacepublic function getMaxOrder(): int{- return (int) $this->user->budgets()->max('order');- }-- /**- * @param Budget $budget- * @param string $text- * @return void- */- private function setNoteText(Budget $budget, string $text): void- {- $dbNote = $budget->notes()->first();- if ('' !== $text) {- if (null === $dbNote) {- $dbNote = new Note();- $dbNote->noteable()->associate($budget);- }- $dbNote->text = trim($text);- $dbNote->save();-- return;- }- if (null !== $dbNote) {- try {- $dbNote->delete();- } catch (Exception $e) {- // @ignoreException- }- }- }-- /**- * @param Budget $budget- * @param array $data- *- * @return Budget- */- public function update(Budget $budget, array $data): Budget- {- Log::debug('Now in update()');-- $oldName = $budget->name;- if (array_key_exists('name', $data)) {- $budget->name = $data['name'];- $this->updateRuleActions($oldName, $budget->name);- $this->updateRuleTriggers($oldName, $budget->name);- }- if (array_key_exists('active', $data)) {- $budget->active = $data['active'];- }- if (array_key_exists('notes', $data)) {- $this->setNoteText($budget, (string) $data['notes']);- }- $budget->save();-- // update or create auto-budget:- $autoBudget = $this->getAutoBudget($budget);-- // first things first: delete when no longer required:- $autoBudgetType = array_key_exists('auto_budget_type', $data) ? $data['auto_budget_type'] : null;-- if (0 === $autoBudgetType && null !== $autoBudget) {- // delete!- $autoBudget->delete();-- return $budget;- }- if (0 === $autoBudgetType && null === $autoBudget) {- return $budget;- }- if (null === $autoBudgetType && null === $autoBudget) {- return $budget;- }- $this->updateAutoBudget($budget, $data);-- return $budget;- }-- /**- * @param string $oldName- * @param string $newName- */- private function updateRuleActions(string $oldName, string $newName): void- {- $types = ['set_budget',];- $actions = RuleAction::leftJoin('rules', 'rules.id', '=', 'rule_actions.rule_id')- ->where('rules.user_id', $this->user->id)- ->whereIn('rule_actions.action_type', $types)- ->where('rule_actions.action_value', $oldName)- ->get(['rule_actions.*']);- Log::debug(sprintf('Found %d actions to update.', $actions->count()));- /** @var RuleAction $action */- foreach ($actions as $action) {- $action->action_value = $newName;- $action->save();- Log::debug(sprintf('Updated action %d: %s', $action->id, $action->action_value));- }- }-- /**- * @param string $oldName- * @param string $newName- */- private function updateRuleTriggers(string $oldName, string $newName): void- {- $types = ['budget_is',];- $triggers = RuleTrigger::leftJoin('rules', 'rules.id', '=', 'rule_triggers.rule_id')- ->where('rules.user_id', $this->user->id)- ->whereIn('rule_triggers.trigger_type', $types)- ->where('rule_triggers.trigger_value', $oldName)- ->get(['rule_triggers.*']);- Log::debug(sprintf('Found %d triggers to update.', $triggers->count()));- /** @var RuleTrigger $trigger */- foreach ($triggers as $trigger) {- $trigger->trigger_value = $newName;- $trigger->save();- Log::debug(sprintf('Updated trigger %d: %s', $trigger->id, $trigger->trigger_value));- }- }-- /**- * @inheritDoc- */- public function getAutoBudget(Budget $budget): ?AutoBudget- {- return $budget->autoBudgets()->first();- }-- /**- * @param Budget $budget- * @param array $data- * @throws FireflyException- * @throws JsonException- */- private function updateAutoBudget(Budget $budget, array $data): void- {- // update or create auto-budget:- $autoBudget = $this->getAutoBudget($budget);-- // grab default currency:- $currency = app('amount')->getDefaultCurrencyByUser($this->user);-- if (null === $autoBudget) {- // at this point it's a blind assumption auto_budget_type is 1 or 2.- $autoBudget = new AutoBudget();- $autoBudget->auto_budget_type = $data['auto_budget_type'];- $autoBudget->budget_id = $budget->id;- $autoBudget->transaction_currency_id = $currency->id;- }-- // set or update the currency.- if (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {- $repos = app(CurrencyRepositoryInterface::class);- $currencyId = (int) ($data['currency_id'] ?? 0);- $currencyCode = (string) ($data['currency_code'] ?? '');- $currency = $repos->find($currencyId);- if (null === $currency) {- $currency = $repos->findByCodeNull($currencyCode);- }- if (null !== $currency) {- $autoBudget->transaction_currency_id = $currency->id;- }- }-- // change values if submitted or presented:- if (array_key_exists('auto_budget_type', $data)) {- $autoBudget->auto_budget_type = $data['auto_budget_type'];- }- if (array_key_exists('auto_budget_amount', $data)) {- $autoBudget->amount = $data['auto_budget_amount'];- }- if (array_key_exists('auto_budget_period', $data)) {- $autoBudget->period = $data['auto_budget_period'];- }-- $autoBudget->save();+ return (int)$this->user->budgets()->max('order');}}diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.phpindex d40d4ad76a..9441b3b76a 100644--- a/app/Repositories/Budget/BudgetRepositoryInterface.php+++ b/app/Repositories/Budget/BudgetRepositoryInterface.php@@ -1,4 +1,5 @@<?php+/*** BudgetRepositoryInterface.php* Copyright (c) 2019 [email protected]@@ -35,16 +36,16 @@ use Illuminate\Support\Collection;interface BudgetRepositoryInterface{/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/public function budgetEndsWith(string $query, int $limit): Collection;/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/@@ -53,8 +54,8 @@ interface BudgetRepositoryInterface/*** Returns the amount that is budgeted in a period.*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end* @return array*/public function budgetedInPeriod(Carbon $start, Carbon $end): array;@@ -65,7 +66,7 @@ interface BudgetRepositoryInterfacepublic function cleanupBudgets(): bool;/**- * @param Budget $budget+ * @param Budget $budget** @return bool*/@@ -77,21 +78,21 @@ interface BudgetRepositoryInterfacepublic function destroyAll(): void;/**- * @param Budget $budget+ * @param Budget $budget*/public function destroyAutoBudget(Budget $budget): void;/***- * @param int|null $budgetId+ * @param int|null $budgetId** @return Budget|null*/public function find(int $budgetId = null): ?Budget;/**- * @param int|null $budgetId- * @param string|null $budgetName+ * @param int|null $budgetId+ * @param string|null $budgetName** @return Budget|null*/@@ -100,7 +101,7 @@ interface BudgetRepositoryInterface/*** Find budget by name.*- * @param string|null $name+ * @param string|null $name** @return Budget|null*/@@ -110,7 +111,7 @@ interface BudgetRepositoryInterface* This method returns the oldest journal or transaction date known to this budget.* Will cache result.*- * @param Budget $budget+ * @param Budget $budget** @return Carbon|null*/@@ -122,14 +123,14 @@ interface BudgetRepositoryInterfacepublic function getActiveBudgets(): Collection;/**- * @param Budget $budget+ * @param Budget $budget** @return Collection*/public function getAttachments(Budget $budget): Collection;/**- * @param Budget $budget+ * @param Budget $budget** @return AutoBudget|null*/@@ -143,7 +144,7 @@ interface BudgetRepositoryInterface/*** Get all budgets with these ID's.*- * @param array $budgetIds+ * @param array $budgetIds** @return Collection*/@@ -160,42 +161,42 @@ interface BudgetRepositoryInterfacepublic function getMaxOrder(): int;/**- * @param Budget $budget+ * @param Budget $budget* @return string|null*/public function getNoteText(Budget $budget): ?string;/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/public function searchBudget(string $query, int $limit): Collection;/**- * @param Budget $budget- * @param int $order+ * @param Budget $budget+ * @param int $order*/public function setBudgetOrder(Budget $budget, int $order): void;/**- * @param User $user+ * @param User $user*/public function setUser(User $user);/*** Used in the v2 API to calculate the amount of money spent in all active budgets.*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return array*/public function spentInPeriod(Carbon $start, Carbon $end): array;/**- * @param array $data+ * @param array $data** @return Budget* @throws FireflyException@@ -203,8 +204,8 @@ interface BudgetRepositoryInterfacepublic function store(array $data): Budget;/**- * @param Budget $budget- * @param array $data+ * @param Budget $budget+ * @param array $data** @return Budget*/diff --git a/app/Repositories/Budget/NoBudgetRepository.php b/app/Repositories/Budget/NoBudgetRepository.phpindex 6e223b5e0b..83e099d858 100644--- a/app/Repositories/Budget/NoBudgetRepository.php+++ b/app/Repositories/Budget/NoBudgetRepository.php@@ -40,9 +40,9 @@ class NoBudgetRepository implements NoBudgetRepositoryInterfaceprivate $user;/**- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return array*/@@ -61,19 +61,19 @@ class NoBudgetRepository implements NoBudgetRepositoryInterface/** @var array $journal */foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$data[$currencyId] = $data[$currencyId] ?? [- 'id' => 0,- 'name' => sprintf('%s (%s)', trans('firefly.no_budget'), $journal['currency_name']),- 'sum' => '0',- 'currency_id' => $currencyId,- 'currency_code' => $journal['currency_code'],- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- 'entries' => [],- ];+ 'id' => 0,+ 'name' => sprintf('%s (%s)', trans('firefly.no_budget'), $journal['currency_name']),+ 'sum' => '0',+ 'currency_id' => $currencyId,+ 'currency_code' => $journal['currency_code'],+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ 'entries' => [],+ ];$date = $journal['date']->format($carbonFormat);if (!array_key_exists($date, $data[$currencyId]['entries'])) {@@ -86,17 +86,9 @@ class NoBudgetRepository implements NoBudgetRepositoryInterface}/**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }-- /**- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return array* @deprecated@@ -133,7 +125,7 @@ class NoBudgetRepository implements NoBudgetRepositoryInterface/** @var TransactionCurrency $currency */$currency = $currencies[$code];$return[] = [- 'currency_id' => (string) $currency['id'],+ 'currency_id' => (string)$currency['id'],'currency_code' => $code,'currency_name' => $currency['name'],'currency_symbol' => $currency['symbol'],@@ -145,14 +137,22 @@ class NoBudgetRepository implements NoBudgetRepositoryInterfacereturn $return;}+ /**+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }+/*** TODO this method does not include multi currency. It just counts.* TODO this probably also applies to the other "sumExpenses" methods.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param TransactionCurrency|null $currency+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param TransactionCurrency|null $currency** @return array*/@@ -174,15 +174,15 @@ class NoBudgetRepository implements NoBudgetRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$array[$currencyId] = $array[$currencyId] ?? [- 'sum' => '0',- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'sum' => '0',+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->negative($journal['amount']));}diff --git a/app/Repositories/Budget/NoBudgetRepositoryInterface.php b/app/Repositories/Budget/NoBudgetRepositoryInterface.phpindex bfe8c83661..f431b59522 100644--- a/app/Repositories/Budget/NoBudgetRepositoryInterface.php+++ b/app/Repositories/Budget/NoBudgetRepositoryInterface.php@@ -34,9 +34,9 @@ use Illuminate\Support\Collection;interface NoBudgetRepositoryInterface{/**- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return array* @deprecated@@ -44,14 +44,14 @@ interface NoBudgetRepositoryInterfacepublic function getNoBudgetPeriodReport(Collection $accounts, Carbon $start, Carbon $end): array;/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void;/**- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return array* @deprecated@@ -59,10 +59,10 @@ interface NoBudgetRepositoryInterfacepublic function spentInPeriodWoBudgetMc(Collection $accounts, Carbon $start, Carbon $end): array;/**- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param TransactionCurrency|null $currency+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param TransactionCurrency|null $currency** @return array*/diff --git a/app/Repositories/Budget/OperationsRepository.php b/app/Repositories/Budget/OperationsRepository.phpindex b3281a3685..84092ab31b 100644--- a/app/Repositories/Budget/OperationsRepository.php+++ b/app/Repositories/Budget/OperationsRepository.php@@ -46,7 +46,7 @@ class OperationsRepository implements OperationsRepositoryInterface* A method that returns the amount of money budgeted per day for this budget,* on average.*- * @param Budget $budget+ * @param Budget $budget** @return string*/@@ -58,15 +58,15 @@ class OperationsRepository implements OperationsRepositoryInterfaceforeach ($budget->budgetlimits as $limit) {$diff = $limit->start_date->diffInDays($limit->end_date);$diff = 0 === $diff ? 1 : $diff;- $amount = (string) $limit->amount;- $perDay = bcdiv($amount, (string) $diff);+ $amount = (string)$limit->amount;+ $perDay = bcdiv($amount, (string)$diff);$total = bcadd($total, $perDay);$count++;Log::debug(sprintf('Found %d budget limits. Per day is %s, total is %s', $count, $perDay, $total));}$avg = $total;if ($count > 0) {- $avg = bcdiv($total, (string) $count);+ $avg = bcdiv($total, (string)$count);}Log::debug(sprintf('%s / %d = %s = average.', $total, $count, $avg));@@ -77,10 +77,10 @@ class OperationsRepository implements OperationsRepositoryInterface* This method is being used to generate the budget overview in the year/multi-year report. Its used* in both the year/multi-year budget overview AND in the accompanying chart.*- * @param Collection $budgets- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $budgets+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return array* @deprecated@@ -100,22 +100,22 @@ class OperationsRepository implements OperationsRepositoryInterface/** @var array $journal */foreach ($journals as $journal) {// prep data array for currency:- $budgetId = (int) $journal['budget_id'];+ $budgetId = (int)$journal['budget_id'];$budgetName = $journal['budget_name'];- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$key = sprintf('%d-%d', $budgetId, $currencyId);$data[$key] = $data[$key] ?? [- 'id' => $budgetId,- 'name' => sprintf('%s (%s)', $budgetName, $journal['currency_name']),- 'sum' => '0',- 'currency_id' => $currencyId,- 'currency_code' => $journal['currency_code'],- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- 'entries' => [],- ];+ 'id' => $budgetId,+ 'name' => sprintf('%s (%s)', $budgetName, $journal['currency_name']),+ 'sum' => '0',+ 'currency_id' => $currencyId,+ 'currency_code' => $journal['currency_code'],+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ 'entries' => [],+ ];$date = $journal['date']->format($carbonFormat);$data[$key]['entries'][$date] = bcadd($data[$budgetId]['entries'][$date] ?? '0', $journal['amount']);}@@ -128,10 +128,10 @@ class OperationsRepository implements OperationsRepositoryInterface* which have the specified budget set to them. It's grouped per currency, with as few details in the array* as possible. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $budgets+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $budgets** @return array*/@@ -154,9 +154,9 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];- $budgetId = (int) $journal['budget_id'];- $budgetName = (string) $journal['budget_name'];+ $currencyId = (int)$journal['currency_id'];+ $budgetId = (int)$journal['budget_id'];+ $budgetName = (string)$journal['budget_name'];// catch "no category" entries.if (0 === $budgetId) {@@ -165,24 +165,24 @@ class OperationsRepository implements OperationsRepositoryInterface// info about the currency:$array[$currencyId] = $array[$currencyId] ?? [- 'budgets' => [],- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'budgets' => [],+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];// info about the categories:$array[$currencyId]['budgets'][$budgetId] = $array[$currencyId]['budgets'][$budgetId] ?? [- 'id' => $budgetId,- 'name' => $budgetName,- 'transaction_journals' => [],- ];+ 'id' => $budgetId,+ 'name' => $budgetName,+ 'transaction_journals' => [],+ ];// add journal to array:// only a subset of the fields.- $journalId = (int) $journal['transaction_journal_id'];+ $journalId = (int)$journal['transaction_journal_id'];$array[$currencyId]['budgets'][$budgetId]['transaction_journals'][$journalId] = ['amount' => app('steam')->negative($journal['amount']),'destination_account_id' => $journal['destination_account_id'],@@ -199,6 +199,14 @@ class OperationsRepository implements OperationsRepositoryInterfacereturn $array;}+ /**+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }+/*** @return Collection*/@@ -210,20 +218,11 @@ class OperationsRepository implements OperationsRepositoryInterfacereturn $repos->getActiveBudgets();}-- /**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }-/**- * @param Collection $budgets- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $budgets+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return array* @deprecated@@ -268,7 +267,7 @@ class OperationsRepository implements OperationsRepositoryInterface/** @var TransactionCurrency $currency */$currency = $currencies[$code];$return[] = [- 'currency_id' => (string) $currency['id'],+ 'currency_id' => (string)$currency['id'],'currency_code' => $code,'currency_name' => $currency['name'],'currency_symbol' => $currency['symbol'],@@ -281,13 +280,13 @@ class OperationsRepository implements OperationsRepositoryInterface}/**- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $budgets- * @param TransactionCurrency|null $currency- * @deprecated+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $budgets+ * @param TransactionCurrency|null $currency* @return array+ * @deprecated*/public function sumExpenses(Carbon $start,@@ -355,28 +354,28 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$array[$currencyId] = $array[$currencyId] ?? [- 'sum' => '0',- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'sum' => '0',+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->negative($journal['amount']));// also do foreign amount:- $foreignId = (int) $journal['foreign_currency_id'];+ $foreignId = (int)$journal['foreign_currency_id'];if (0 !== $foreignId) {$array[$foreignId] = $array[$foreignId] ?? [- 'sum' => '0',- 'currency_id' => $foreignId,- 'currency_name' => $journal['foreign_currency_name'],- 'currency_symbol' => $journal['foreign_currency_symbol'],- 'currency_code' => $journal['foreign_currency_code'],- 'currency_decimal_places' => $journal['foreign_currency_decimal_places'],- ];+ 'sum' => '0',+ 'currency_id' => $foreignId,+ 'currency_name' => $journal['foreign_currency_name'],+ 'currency_symbol' => $journal['foreign_currency_symbol'],+ 'currency_code' => $journal['foreign_currency_code'],+ 'currency_decimal_places' => $journal['foreign_currency_decimal_places'],+ ];$array[$foreignId]['sum'] = bcadd($array[$foreignId]['sum'], app('steam')->negative($journal['foreign_amount']));}}@@ -388,9 +387,9 @@ class OperationsRepository implements OperationsRepositoryInterface* For now, simply refer to whichever repository holds this function.* TODO perhaps better in the future.*- * @param Budget $budget- * @param Carbon|null $start- * @param Carbon|null $end+ * @param Budget $budget+ * @param Carbon|null $start+ * @param Carbon|null $end** @return Collection*/diff --git a/app/Repositories/Budget/OperationsRepositoryInterface.php b/app/Repositories/Budget/OperationsRepositoryInterface.phpindex 317b8fdb8a..42d25221c1 100644--- a/app/Repositories/Budget/OperationsRepositoryInterface.php+++ b/app/Repositories/Budget/OperationsRepositoryInterface.php@@ -38,17 +38,17 @@ interface OperationsRepositoryInterface* A method that returns the amount of money budgeted per day for this budget,* on average.*- * @param Budget $budget+ * @param Budget $budget** @return string*/public function budgetedPerDay(Budget $budget): string;/**- * @param Collection $budgets- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $budgets+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return array* @deprecated@@ -60,17 +60,17 @@ interface OperationsRepositoryInterface* which have the specified budget set to them. It's grouped per currency, with as few details in the array* as possible. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $budgets+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $budgets** @return array*/public function listExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $budgets = null): array;/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void;@@ -78,10 +78,10 @@ interface OperationsRepositoryInterface/*** Return multi-currency spent information.*- * @param Collection $budgets- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $budgets+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return array* @deprecated@@ -89,14 +89,14 @@ interface OperationsRepositoryInterfacepublic function spentInPeriodMc(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): array;/**- * @deprecated- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $budgets- * @param TransactionCurrency|null $currency+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $budgets+ * @param TransactionCurrency|null $currency** @return array+ * @deprecated*/public function sumExpenses(Carbon $start,diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.phpindex e8120221c6..cbfd18453e 100644--- a/app/Repositories/Category/CategoryRepository.php+++ b/app/Repositories/Category/CategoryRepository.php@@ -1,4 +1,5 @@<?php+/*** CategoryRepository.php* Copyright (c) 2019 [email protected]@@ -73,7 +74,7 @@ class CategoryRepository implements CategoryRepositoryInterface}/**- * @param Category $category+ * @param Category $category** @return bool*@@ -115,8 +116,8 @@ class CategoryRepository implements CategoryRepositoryInterface}/**- * @param int|null $categoryId- * @param string|null $categoryName+ * @param int|null $categoryId+ * @param string|null $categoryName** @return Category|null* @throws FireflyException@@ -125,11 +126,11 @@ class CategoryRepository implements CategoryRepositoryInterface{Log::debug('Now in findCategory()');Log::debug(sprintf('Searching for category with ID #%d...', $categoryId));- $result = $this->find((int) $categoryId);+ $result = $this->find((int)$categoryId);if (null === $result) {Log::debug(sprintf('Searching for category with name %s...', $categoryName));- $result = $this->findByName((string) $categoryName);- if (null === $result && '' !== (string) $categoryName) {+ $result = $this->findByName((string)$categoryName);+ if (null === $result && '' !== (string)$categoryName) {// create it!$result = $this->store(['name' => $categoryName]);}@@ -145,7 +146,7 @@ class CategoryRepository implements CategoryRepositoryInterface/*** Find a category or return NULL*- * @param int $categoryId+ * @param int $categoryId** @return Category|null*/@@ -157,7 +158,7 @@ class CategoryRepository implements CategoryRepositoryInterface/*** Find a category.*- * @param string $name+ * @param string $name** @return Category|null*/@@ -167,7 +168,7 @@ class CategoryRepository implements CategoryRepositoryInterface}/**- * @param array $data+ * @param array $data** @return Category* @throws FireflyException@@ -195,7 +196,15 @@ class CategoryRepository implements CategoryRepositoryInterface}/**- * @param Category $category+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }++ /**+ * @param Category $category*/public function removeNotes(Category $category): void{@@ -217,7 +226,7 @@ class CategoryRepository implements CategoryRepositoryInterface}/**- * @param Category $category+ * @param Category $category** @return Carbon|null*@@ -245,7 +254,7 @@ class CategoryRepository implements CategoryRepositoryInterface}/**- * @param Category $category+ * @param Category $category** @return Carbon|null*/@@ -262,7 +271,7 @@ class CategoryRepository implements CategoryRepositoryInterface}/**- * @param Category $category+ * @param Category $category** @return Carbon|null*/@@ -305,7 +314,7 @@ class CategoryRepository implements CategoryRepositoryInterface/*** Get all categories with ID's.*- * @param array $categoryIds+ * @param array $categoryIds** @return Collection*/@@ -328,8 +337,8 @@ class CategoryRepository implements CategoryRepositoryInterface}/**- * @param Category $category- * @param Collection $accounts+ * @param Category $category+ * @param Collection $accounts** @return Carbon|null* @throws Exception@@ -357,8 +366,8 @@ class CategoryRepository implements CategoryRepositoryInterface}/**- * @param Category $category- * @param Collection $accounts+ * @param Category $category+ * @param Collection $accounts** @return Carbon|null*/@@ -381,8 +390,8 @@ class CategoryRepository implements CategoryRepositoryInterface}/**- * @param Category $category- * @param Collection $accounts+ * @param Category $category+ * @param Collection $accounts** @return Carbon|null* @throws Exception@@ -407,8 +416,8 @@ class CategoryRepository implements CategoryRepositoryInterface}/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/@@ -423,16 +432,8 @@ class CategoryRepository implements CategoryRepositoryInterface}/**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }-- /**- * @param Category $category- * @param array $data+ * @param Category $category+ * @param array $data** @return Category* @throws Exceptiondiff --git a/app/Repositories/Category/CategoryRepositoryInterface.php b/app/Repositories/Category/CategoryRepositoryInterface.phpindex 924e3b46cf..b660fe9332 100644--- a/app/Repositories/Category/CategoryRepositoryInterface.php+++ b/app/Repositories/Category/CategoryRepositoryInterface.php@@ -1,4 +1,5 @@<?php+/*** CategoryRepositoryInterface.php* Copyright (c) 2019 [email protected]@@ -34,23 +35,23 @@ use Illuminate\Support\Collection;interface CategoryRepositoryInterface{/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/public function categoryEndsWith(string $query, int $limit): Collection;/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/public function categoryStartsWith(string $query, int $limit): Collection;/**- * @param Category $category+ * @param Category $category** @return bool*/@@ -64,7 +65,7 @@ interface CategoryRepositoryInterface/*** Find a category or return NULL*- * @param int $categoryId+ * @param int $categoryId** @return Category|null*/@@ -73,29 +74,29 @@ interface CategoryRepositoryInterface/*** Find a category.*- * @param string $name+ * @param string $name** @return Category|null*/public function findByName(string $name): ?Category;/**- * @param int|null $categoryId- * @param string|null $categoryName+ * @param int|null $categoryId+ * @param string|null $categoryName** @return Category|null*/public function findCategory(?int $categoryId, ?string $categoryName): ?Category;/**- * @param Category $category+ * @param Category $category** @return Carbon|null*/public function firstUseDate(Category $category): ?Carbon;/**- * @param Category $category+ * @param Category $category** @return Collection*/@@ -104,7 +105,7 @@ interface CategoryRepositoryInterface/*** Get all categories with ID's.*- * @param array $categoryIds+ * @param array $categoryIds** @return Collection*/@@ -118,7 +119,7 @@ interface CategoryRepositoryInterfacepublic function getCategories(): Collection;/**- * @param Category $category+ * @param Category $category** @return string|null*/@@ -127,8 +128,8 @@ interface CategoryRepositoryInterface/*** Return most recent transaction(journal) date or null when never used before.*- * @param Category $category- * @param Collection $accounts+ * @param Category $category+ * @param Collection $accounts** @return Carbon|null*/@@ -137,25 +138,25 @@ interface CategoryRepositoryInterface/*** Remove notes.*- * @param Category $category+ * @param Category $category*/public function removeNotes(Category $category): void;/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/public function searchCategory(string $query, int $limit): Collection;/**- * @param User $user+ * @param User $user*/public function setUser(User $user);/**- * @param array $data+ * @param array $data** @return Category* @throws FireflyException@@ -163,16 +164,16 @@ interface CategoryRepositoryInterfacepublic function store(array $data): Category;/**- * @param Category $category- * @param array $data+ * @param Category $category+ * @param array $data** @return Category*/public function update(Category $category, array $data): Category;/**- * @param Category $category- * @param string $notes+ * @param Category $category+ * @param string $notes*/public function updateNotes(Category $category, string $notes): void;}diff --git a/app/Repositories/Category/NoCategoryRepository.php b/app/Repositories/Category/NoCategoryRepository.phpindex 51c766f2d2..0e1845ff67 100644--- a/app/Repositories/Category/NoCategoryRepository.php+++ b/app/Repositories/Category/NoCategoryRepository.php@@ -42,9 +42,9 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface* which have no category set to them. It's grouped per currency, with as few details in the array* as possible. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts** @return array*/@@ -60,25 +60,25 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$array[$currencyId] = $array[$currencyId] ?? [- 'categories' => [],- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'categories' => [],+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];// info about the non-existent category:$array[$currencyId]['categories'][0] = $array[$currencyId]['categories'][0] ?? [- 'id' => 0,- 'name' => (string) trans('firefly.noCategory'),- 'transaction_journals' => [],- ];+ 'id' => 0,+ 'name' => (string)trans('firefly.noCategory'),+ 'transaction_journals' => [],+ ];// add journal to array:// only a subset of the fields.- $journalId = (int) $journal['transaction_journal_id'];+ $journalId = (int)$journal['transaction_journal_id'];$array[$currencyId]['categories'][0]['transaction_journals'][$journalId]= ['amount' => app('steam')->negative($journal['amount']),@@ -89,14 +89,22 @@ class NoCategoryRepository implements NoCategoryRepositoryInterfacereturn $array;}+ /**+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }+/*** This method returns a list of all the deposit transaction journals (as arrays) set in that period* which have no category set to them. It's grouped per currency, with as few details in the array* as possible. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts** @return array*/@@ -112,25 +120,25 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$array[$currencyId] = $array[$currencyId] ?? [- 'categories' => [],- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'categories' => [],+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];// info about the non-existent category:$array[$currencyId]['categories'][0] = $array[$currencyId]['categories'][0] ?? [- 'id' => 0,- 'name' => (string) trans('firefly.noCategory'),- 'transaction_journals' => [],- ];+ 'id' => 0,+ 'name' => (string)trans('firefly.noCategory'),+ 'transaction_journals' => [],+ ];// add journal to array:// only a subset of the fields.- $journalId = (int) $journal['transaction_journal_id'];+ $journalId = (int)$journal['transaction_journal_id'];$array[$currencyId]['categories'][0]['transaction_journals'][$journalId]= ['amount' => app('steam')->positive($journal['amount']),@@ -141,20 +149,12 @@ class NoCategoryRepository implements NoCategoryRepositoryInterfacereturn $array;}- /**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }-/*** Sum of withdrawal journals in period without a category, grouped per currency. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts** @return array*/@@ -171,15 +171,15 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$array[$currencyId] = $array[$currencyId] ?? [- 'sum' => '0',- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'sum' => '0',+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->negative($journal['amount'] ?? '0'));}@@ -189,9 +189,9 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface/*** Sum of income journals in period without a category, grouped per currency. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts** @return array*/@@ -208,15 +208,15 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$array[$currencyId] = $array[$currencyId] ?? [- 'sum' => '0',- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'sum' => '0',+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->positive($journal['amount']));}@@ -239,15 +239,15 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$array[$currencyId] = $array[$currencyId] ?? [- 'sum' => '0',- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'sum' => '0',+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->positive($journal['amount']));}diff --git a/app/Repositories/Category/NoCategoryRepositoryInterface.php b/app/Repositories/Category/NoCategoryRepositoryInterface.phpindex c1835114b5..483f3f505d 100644--- a/app/Repositories/Category/NoCategoryRepositoryInterface.php+++ b/app/Repositories/Category/NoCategoryRepositoryInterface.php@@ -38,9 +38,9 @@ interface NoCategoryRepositoryInterface* which have no category set to them. It's grouped per currency, with as few details in the array* as possible. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts** @return array*/@@ -51,25 +51,25 @@ interface NoCategoryRepositoryInterface* which have no category set to them. It's grouped per currency, with as few details in the array* as possible. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts** @return array*/public function listIncome(Carbon $start, Carbon $end, ?Collection $accounts = null): array;/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void;/*** Sum of withdrawal journals in period without a category, grouped per currency. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts** @return array*/@@ -78,9 +78,9 @@ interface NoCategoryRepositoryInterface/*** Sum of income journals in period without a category, grouped per currency. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts** @return array*/@@ -89,9 +89,9 @@ interface NoCategoryRepositoryInterface/*** Sum of transfers in period without a category, grouped per currency. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts** @return array*/diff --git a/app/Repositories/Category/OperationsRepository.php b/app/Repositories/Category/OperationsRepository.phpindex 146c02c418..a2dabc2a7d 100644--- a/app/Repositories/Category/OperationsRepository.php+++ b/app/Repositories/Category/OperationsRepository.php@@ -44,10 +44,10 @@ class OperationsRepository implements OperationsRepositoryInterface** First currency, then categories.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $categories+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $categories** @return array*/@@ -70,9 +70,9 @@ class OperationsRepository implements OperationsRepositoryInterface$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) {@@ -81,24 +81,24 @@ class OperationsRepository implements OperationsRepositoryInterface// info about the currency:$array[$currencyId] = $array[$currencyId] ?? [- 'categories' => [],- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'categories' => [],+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];// info about the categories:$array[$currencyId]['categories'][$categoryId] = $array[$currencyId]['categories'][$categoryId] ?? [- 'id' => $categoryId,- 'name' => $categoryName,- 'transaction_journals' => [],- ];+ 'id' => $categoryId,+ 'name' => $categoryName,+ 'transaction_journals' => [],+ ];// add journal to array:// only a subset of the fields.- $journalId = (int) $journal['transaction_journal_id'];+ $journalId = (int)$journal['transaction_journal_id'];$array[$currencyId]['categories'][$categoryId]['transaction_journals'][$journalId] = ['amount' => app('steam')->negative($journal['amount']),'date' => $journal['date'],@@ -115,6 +115,14 @@ class OperationsRepository implements OperationsRepositoryInterfacereturn $array;}+ /**+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }+/*** Returns a list of all the categories belonging to a user.*@@ -130,10 +138,10 @@ class OperationsRepository implements OperationsRepositoryInterface* which have the specified category set to them. It's grouped per currency, with as few details in the array* as possible. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $categories+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $categories** @return array*/@@ -156,35 +164,35 @@ class OperationsRepository implements OperationsRepositoryInterface$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) {- $categoryName = (string) trans('firefly.no_category');+ $categoryName = (string)trans('firefly.no_category');}// info about the currency:$array[$currencyId] = $array[$currencyId] ?? [- 'categories' => [],- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'categories' => [],+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];// info about the categories:$array[$currencyId]['categories'][$categoryId] = $array[$currencyId]['categories'][$categoryId] ?? [- 'id' => $categoryId,- 'name' => $categoryName,- 'transaction_journals' => [],- ];+ 'id' => $categoryId,+ 'name' => $categoryName,+ 'transaction_journals' => [],+ ];// add journal to array:// only a subset of the fields.- $journalId = (int) $journal['transaction_journal_id'];+ $journalId = (int)$journal['transaction_journal_id'];$array[$currencyId]['categories'][$categoryId]['transaction_journals'][$journalId] = ['amount' => app('steam')->positive($journal['amount']),'date' => $journal['date'],@@ -220,9 +228,9 @@ class OperationsRepository implements OperationsRepositoryInterface$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) {@@ -231,24 +239,24 @@ class OperationsRepository implements OperationsRepositoryInterface// info about the currency:$array[$currencyId] = $array[$currencyId] ?? [- 'categories' => [],- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'categories' => [],+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];// info about the categories:$array[$currencyId]['categories'][$categoryId] = $array[$currencyId]['categories'][$categoryId] ?? [- 'id' => $categoryId,- 'name' => $categoryName,- 'transaction_journals' => [],- ];+ 'id' => $categoryId,+ 'name' => $categoryName,+ 'transaction_journals' => [],+ ];// add journal to array:// only a subset of the fields.- $journalId = (int) $journal['transaction_journal_id'];+ $journalId = (int)$journal['transaction_journal_id'];$array[$currencyId]['categories'][$categoryId]['transaction_journals'][$journalId] = ['amount' => app('steam')->positive($journal['amount']),'date' => $journal['date'],@@ -285,9 +293,9 @@ class OperationsRepository implements OperationsRepositoryInterface$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) {@@ -296,24 +304,24 @@ class OperationsRepository implements OperationsRepositoryInterface// info about the currency:$array[$currencyId] = $array[$currencyId] ?? [- 'categories' => [],- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'categories' => [],+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];// info about the categories:$array[$currencyId]['categories'][$categoryId] = $array[$currencyId]['categories'][$categoryId] ?? [- 'id' => $categoryId,- 'name' => $categoryName,- 'transaction_journals' => [],- ];+ 'id' => $categoryId,+ 'name' => $categoryName,+ 'transaction_journals' => [],+ ];// add journal to array:// only a subset of the fields.- $journalId = (int) $journal['transaction_journal_id'];+ $journalId = (int)$journal['transaction_journal_id'];$array[$currencyId]['categories'][$categoryId]['transaction_journals'][$journalId] = ['amount' => app('steam')->negative($journal['amount']),'date' => $journal['date'],@@ -330,21 +338,13 @@ class OperationsRepository implements OperationsRepositoryInterfacereturn $array;}- /**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }-/*** Sum of withdrawal journals in period for a set of categories, grouped per currency. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $categories+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $categories** @return array*/@@ -367,15 +367,15 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$array[$currencyId] = $array[$currencyId] ?? [- 'sum' => '0',- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => (int) $journal['currency_decimal_places'],- ];+ 'sum' => '0',+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => (int)$journal['currency_decimal_places'],+ ];$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->negative($journal['amount']));}@@ -385,10 +385,10 @@ class OperationsRepository implements OperationsRepositoryInterface/*** Sum of income journals in period for a set of categories, grouped per currency. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $categories+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $categories** @return array*/@@ -410,15 +410,15 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$array[$currencyId] = $array[$currencyId] ?? [- 'sum' => '0',- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'sum' => '0',+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->positive($journal['amount']));}@@ -428,10 +428,10 @@ class OperationsRepository implements OperationsRepositoryInterface/*** Sum of income journals in period for a set of categories, grouped per currency. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $categories+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $categories** @return array*/@@ -453,15 +453,15 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$array[$currencyId] = $array[$currencyId] ?? [- 'sum' => '0',- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'sum' => '0',+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->positive($journal['amount']));}diff --git a/app/Repositories/Category/OperationsRepositoryInterface.php b/app/Repositories/Category/OperationsRepositoryInterface.phpindex 0f24e11ad5..1a30eee764 100644--- a/app/Repositories/Category/OperationsRepositoryInterface.php+++ b/app/Repositories/Category/OperationsRepositoryInterface.php@@ -38,10 +38,10 @@ interface OperationsRepositoryInterface* which have the specified category set to them. It's grouped per currency, with as few details in the array* as possible. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $categories+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $categories** @return array*/@@ -52,10 +52,10 @@ interface OperationsRepositoryInterface* which have the specified category set to them. It's grouped per currency, with as few details in the array* as possible. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $categories+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $categories** @return array*/@@ -67,10 +67,10 @@ interface OperationsRepositoryInterface* It excludes any transfers between the listed accounts.* It's grouped per currency, with as few details in the array as possible. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection $accounts- * @param Collection|null $categories+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection $accounts+ * @param Collection|null $categories** @return array*/@@ -82,27 +82,27 @@ interface OperationsRepositoryInterface* It excludes any transfers between the listed accounts.* It's grouped per currency, with as few details in the array as possible. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection $accounts- * @param Collection|null $categories+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection $accounts+ * @param Collection|null $categories** @return array*/public function listTransferredOut(Carbon $start, Carbon $end, Collection $accounts, ?Collection $categories = null): array;/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void;/*** Sum of withdrawal journals in period for a set of categories, grouped per currency. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $categories+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $categories** @return array*/@@ -111,10 +111,10 @@ interface OperationsRepositoryInterface/*** Sum of income journals in period for a set of categories, grouped per currency. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $categories+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $categories** @return array*/@@ -123,10 +123,10 @@ interface OperationsRepositoryInterface/*** Sum of transfers in period for a set of categories, grouped per currency. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $categories+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $categories** @return array*/diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.phpindex 93f5d22678..96ff6e83a1 100644--- a/app/Repositories/Currency/CurrencyRepository.php+++ b/app/Repositories/Currency/CurrencyRepository.php@@ -1,4 +1,5 @@<?php+/*** CurrencyRepository.php* Copyright (c) 2019 [email protected]@@ -50,7 +51,7 @@ class CurrencyRepository implements CurrencyRepositoryInterfaceprivate User $user;/**- * @param TransactionCurrency $currency+ * @param TransactionCurrency $currency** @return bool* @throws FireflyException@@ -63,7 +64,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface}/**- * @param TransactionCurrency $currency+ * @param TransactionCurrency $currency** @return string|null* @throws FireflyException@@ -86,7 +87,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface}// is being used in accounts:- $meta = AccountMeta::where('name', 'currency_id')->where('data', json_encode((string) $currency->id))->count();+ $meta = AccountMeta::where('name', 'currency_id')->where('data', json_encode((string)$currency->id))->count();if ($meta > 0) {Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));@@ -113,8 +114,8 @@ class CurrencyRepository implements CurrencyRepositoryInterface// is being used in accounts (as integer)$meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')- ->whereNull('accounts.deleted_at')- ->where('account_meta.name', 'currency_id')->where('account_meta.data', json_encode((int) $currency->id))->count();+ ->whereNull('accounts.deleted_at')+ ->where('account_meta.name', 'currency_id')->where('account_meta.data', json_encode((int)$currency->id))->count();if ($meta > 0) {Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));@@ -151,7 +152,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface}/**- * @param TransactionCurrency $currency+ * @param TransactionCurrency $currency** @return int*/@@ -172,7 +173,15 @@ class CurrencyRepository implements CurrencyRepositoryInterface}/**- * @param TransactionCurrency $currency+ * @return Collection+ */+ public function get(): Collection+ {+ return TransactionCurrency::where('enabled', true)->orderBy('code', 'ASC')->get();+ }++ /**+ * @param TransactionCurrency $currency** @return bool*/@@ -192,7 +201,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface/*** Disables a currency*- * @param TransactionCurrency $currency+ * @param TransactionCurrency $currency*/public function disable(TransactionCurrency $currency): void{@@ -219,11 +228,21 @@ class CurrencyRepository implements CurrencyRepositoryInterface}}+ /**+ * @param TransactionCurrency $currency+ * Enables a currency+ */+ public function enable(TransactionCurrency $currency): void+ {+ $currency->enabled = true;+ $currency->save();+ }+/*** Find by currency code, return NULL if unfound.* Used in Import Currency!*- * @param string $currencyCode+ * @param string $currencyCode** @return TransactionCurrency|null* @deprecated@@ -236,7 +255,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface/*** Find by currency name.*- * @param string $currencyName+ * @param string $currencyName** @return TransactionCurrency|null*/@@ -249,7 +268,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface* Find by currency name or return null.* Used in Import Currency!*- * @param string $currencyName+ * @param string $currencyName** @return TransactionCurrency|null* @deprecated@@ -262,7 +281,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface/*** Find by currency symbol.*- * @param string $currencySymbol+ * @param string $currencySymbol** @return TransactionCurrency|null*/@@ -275,7 +294,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface* Find by currency symbol or return NULL* Used in Import Currency!*- * @param string $currencySymbol+ * @param string $currencySymbol** @return TransactionCurrency|null* @deprecated@@ -288,8 +307,8 @@ class CurrencyRepository implements CurrencyRepositoryInterface/*** Find by object, ID or code. Returns user default or system default.*- * @param int|null $currencyId- * @param string|null $currencyCode+ * @param int|null $currencyId+ * @param string|null $currencyCode** @return TransactionCurrency* @throws FireflyException@@ -320,18 +339,18 @@ class CurrencyRepository implements CurrencyRepositoryInterface/*** Find by object, ID or code. Returns NULL if nothing found.*- * @param int|null $currencyId- * @param string|null $currencyCode+ * @param int|null $currencyId+ * @param string|null $currencyCode** @return TransactionCurrency|null*/public function findCurrencyNull(?int $currencyId, ?string $currencyCode): ?TransactionCurrency{Log::debug('Now in findCurrencyNull()');- $result = $this->find((int) $currencyId);+ $result = $this->find((int)$currencyId);if (null === $result) {Log::debug(sprintf('Searching for currency with code %s...', $currencyCode));- $result = $this->findByCode((string) $currencyCode);+ $result = $this->findByCode((string)$currencyCode);}if (null !== $result && false === $result->enabled) {Log::debug(sprintf('Also enabled currency %s', $result->code));@@ -344,7 +363,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface/*** Find by ID, return NULL if not found.*- * @param int $currencyId+ * @param int $currencyId** @return TransactionCurrency|null*/@@ -356,7 +375,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface/*** Find by currency code, return NULL if unfound.*- * @param string $currencyCode+ * @param string $currencyCode** @return TransactionCurrency|null*/@@ -366,25 +385,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface}/**- * @param TransactionCurrency $currency- * Enables a currency- */- public function enable(TransactionCurrency $currency): void- {- $currency->enabled = true;- $currency->save();- }-- /**- * @return Collection- */- public function get(): Collection- {- return TransactionCurrency::where('enabled', true)->orderBy('code', 'ASC')->get();- }-- /**- * @param array $ids+ * @param array $ids** @return Collection*/@@ -394,7 +395,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface}/**- * @param Preference $preference+ * @param Preference $preference** @return TransactionCurrency*/@@ -411,9 +412,9 @@ class CurrencyRepository implements CurrencyRepositoryInterface/*** Get currency exchange rate.*- * @param TransactionCurrency $fromCurrency- * @param TransactionCurrency $toCurrency- * @param Carbon $date+ * @param TransactionCurrency $fromCurrency+ * @param TransactionCurrency $toCurrency+ * @param Carbon $date** @return CurrencyExchangeRate|null*/@@ -440,27 +441,6 @@ class CurrencyRepository implements CurrencyRepositoryInterfacereturn null;}- /**- * TODO must be a factory- * @param TransactionCurrency $fromCurrency- * @param TransactionCurrency $toCurrency- * @param Carbon $date- * @param float $rate- * @return CurrencyExchangeRate- */- public function setExchangeRate(TransactionCurrency $fromCurrency, TransactionCurrency $toCurrency, Carbon $date, float $rate): CurrencyExchangeRate- {- return CurrencyExchangeRate::create(- [- 'user_id' => $this->user->id,- 'from_currency_id' => $fromCurrency->id,- 'to_currency_id' => $toCurrency->id,- 'date' => $date,- 'rate' => $rate,- ]- );- }-/*** @inheritDoc*/@@ -470,8 +450,8 @@ class CurrencyRepository implements CurrencyRepositoryInterface}/**- * @param string $search- * @param int $limit+ * @param string $search+ * @param int $limit** @return Collection*/@@ -486,7 +466,28 @@ class CurrencyRepository implements CurrencyRepositoryInterface}/**- * @param User $user+ * TODO must be a factory+ * @param TransactionCurrency $fromCurrency+ * @param TransactionCurrency $toCurrency+ * @param Carbon $date+ * @param float $rate+ * @return CurrencyExchangeRate+ */+ public function setExchangeRate(TransactionCurrency $fromCurrency, TransactionCurrency $toCurrency, Carbon $date, float $rate): CurrencyExchangeRate+ {+ return CurrencyExchangeRate::create(+ [+ 'user_id' => $this->user->id,+ 'from_currency_id' => $fromCurrency->id,+ 'to_currency_id' => $toCurrency->id,+ 'date' => $date,+ 'rate' => $rate,+ ]+ );+ }++ /**+ * @param User $user*/public function setUser(User $user): void{@@ -494,7 +495,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface}/**- * @param array $data+ * @param array $data** @return TransactionCurrency* @throws FireflyException@@ -513,8 +514,8 @@ class CurrencyRepository implements CurrencyRepositoryInterface}/**- * @param TransactionCurrency $currency- * @param array $data+ * @param TransactionCurrency $currency+ * @param array $data** @return TransactionCurrency*/diff --git a/app/Repositories/Currency/CurrencyRepositoryInterface.php b/app/Repositories/Currency/CurrencyRepositoryInterface.phpindex e1c0e6c3ca..7c45bf9e27 100644--- a/app/Repositories/Currency/CurrencyRepositoryInterface.php+++ b/app/Repositories/Currency/CurrencyRepositoryInterface.php@@ -1,4 +1,5 @@<?php+/*** CurrencyRepositoryInterface.php* Copyright (c) 2019 [email protected]@@ -36,14 +37,14 @@ use Illuminate\Support\Collection;interface CurrencyRepositoryInterface{/**- * @param TransactionCurrency $currency+ * @param TransactionCurrency $currency** @return int*/public function countJournals(TransactionCurrency $currency): int;/**- * @param TransactionCurrency $currency+ * @param TransactionCurrency $currency** @return bool*/@@ -52,14 +53,14 @@ interface CurrencyRepositoryInterface/*** Currency is in use where exactly.*- * @param TransactionCurrency $currency+ * @param TransactionCurrency $currency** @return string|null*/public function currencyInUseAt(TransactionCurrency $currency): ?string;/**- * @param TransactionCurrency $currency+ * @param TransactionCurrency $currency** @return bool*/@@ -68,14 +69,14 @@ interface CurrencyRepositoryInterface/*** Disables a currency*- * @param TransactionCurrency $currency+ * @param TransactionCurrency $currency*/public function disable(TransactionCurrency $currency): void;/*** Enables a currency*- * @param TransactionCurrency $currency+ * @param TransactionCurrency $currency*/public function enable(TransactionCurrency $currency): void;@@ -87,7 +88,7 @@ interface CurrencyRepositoryInterface/*** Find by ID, return NULL if not found.*- * @param int $currencyId+ * @param int $currencyId** @return TransactionCurrency|null*/@@ -96,7 +97,7 @@ interface CurrencyRepositoryInterface/*** Find by currency code, return NULL if unfound.*- * @param string $currencyCode+ * @param string $currencyCode** @return TransactionCurrency|null*/@@ -105,7 +106,7 @@ interface CurrencyRepositoryInterface/*** Find by currency code, return NULL if unfound.*- * @param string $currencyCode+ * @param string $currencyCode** @return TransactionCurrency|null*/@@ -114,7 +115,7 @@ interface CurrencyRepositoryInterface/*** Find by currency name.*- * @param string $currencyName+ * @param string $currencyName** @return TransactionCurrency|null*/@@ -123,7 +124,7 @@ interface CurrencyRepositoryInterface/*** Find by currency name.*- * @param string $currencyName+ * @param string $currencyName** @return TransactionCurrency|null*/@@ -132,7 +133,7 @@ interface CurrencyRepositoryInterface/*** Find by currency symbol.*- * @param string $currencySymbol+ * @param string $currencySymbol** @return TransactionCurrency|null*/@@ -141,7 +142,7 @@ interface CurrencyRepositoryInterface/*** Find by currency symbol.*- * @param string $currencySymbol+ * @param string $currencySymbol** @return TransactionCurrency|null*/@@ -150,8 +151,8 @@ interface CurrencyRepositoryInterface/*** Find by object, ID or code. Returns user default or system default.*- * @param int|null $currencyId- * @param string|null $currencyCode+ * @param int|null $currencyId+ * @param string|null $currencyCode** @return TransactionCurrency*/@@ -160,8 +161,8 @@ interface CurrencyRepositoryInterface/*** Find by object, ID or code. Returns NULL if nothing found.*- * @param int|null $currencyId- * @param string|null $currencyCode+ * @param int|null $currencyId+ * @param string|null $currencyCode** @return TransactionCurrency|null*/@@ -178,14 +179,14 @@ interface CurrencyRepositoryInterfacepublic function getAll(): Collection;/**- * @param array $ids+ * @param array $ids** @return Collection*/public function getByIds(array $ids): Collection;/**- * @param Preference $preference+ * @param Preference $preference** @return TransactionCurrency*/@@ -194,46 +195,46 @@ interface CurrencyRepositoryInterface/*** Get currency exchange rate.*- * @param TransactionCurrency $fromCurrency- * @param TransactionCurrency $toCurrency- * @param Carbon $date+ * @param TransactionCurrency $fromCurrency+ * @param TransactionCurrency $toCurrency+ * @param Carbon $date** @return CurrencyExchangeRate|null*/public function getExchangeRate(TransactionCurrency $fromCurrency, TransactionCurrency $toCurrency, Carbon $date): ?CurrencyExchangeRate;/**- * TODO must be a factory- * @param TransactionCurrency $fromCurrency- * @param TransactionCurrency $toCurrency- * @param Carbon $date- * @param float $rate- * @return CurrencyExchangeRate- */- public function setExchangeRate(TransactionCurrency $fromCurrency, TransactionCurrency $toCurrency, Carbon $date, float $rate): CurrencyExchangeRate;-- /**- * @param TransactionCurrency $currency+ * @param TransactionCurrency $currency** @return bool*/public function isFallbackCurrency(TransactionCurrency $currency): bool;/**- * @param string $search- * @param int $limit+ * @param string $search+ * @param int $limit** @return Collection*/public function searchCurrency(string $search, int $limit): Collection;/**- * @param User $user+ * TODO must be a factory+ * @param TransactionCurrency $fromCurrency+ * @param TransactionCurrency $toCurrency+ * @param Carbon $date+ * @param float $rate+ * @return CurrencyExchangeRate+ */+ public function setExchangeRate(TransactionCurrency $fromCurrency, TransactionCurrency $toCurrency, Carbon $date, float $rate): CurrencyExchangeRate;++ /**+ * @param User $user*/public function setUser(User $user);/**- * @param array $data+ * @param array $data** @return TransactionCurrency* @throws FireflyException@@ -241,8 +242,8 @@ interface CurrencyRepositoryInterfacepublic function store(array $data): TransactionCurrency;/**- * @param TransactionCurrency $currency- * @param array $data+ * @param TransactionCurrency $currency+ * @param array $data** @return TransactionCurrency*/diff --git a/app/Repositories/Journal/JournalAPIRepository.php b/app/Repositories/Journal/JournalAPIRepository.phpindex ea86e6f1e2..16553eed5a 100644--- a/app/Repositories/Journal/JournalAPIRepository.php+++ b/app/Repositories/Journal/JournalAPIRepository.php@@ -41,7 +41,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface/*** Returns transaction by ID. Used to validate attachments.*- * @param int $transactionId+ * @param int $transactionId** @return Transaction|null*/@@ -56,7 +56,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface/*** Return all attachments for journal.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return Collection*/@@ -91,7 +91,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface/*** Get all piggy bank events for a journal.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return Collection*/@@ -108,7 +108,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface}/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void{diff --git a/app/Repositories/Journal/JournalAPIRepositoryInterface.php b/app/Repositories/Journal/JournalAPIRepositoryInterface.phpindex ad6e372987..16dd484b79 100644--- a/app/Repositories/Journal/JournalAPIRepositoryInterface.php+++ b/app/Repositories/Journal/JournalAPIRepositoryInterface.php@@ -36,7 +36,7 @@ interface JournalAPIRepositoryInterface/*** Returns transaction by ID. Used to validate attachments.*- * @param int $transactionId+ * @param int $transactionId** @return Transaction|null*/@@ -45,7 +45,7 @@ interface JournalAPIRepositoryInterface/*** Return all attachments for journal.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return Collection*/@@ -54,7 +54,7 @@ interface JournalAPIRepositoryInterface/*** Return all journal links for journal.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return Collection*/@@ -63,14 +63,14 @@ interface JournalAPIRepositoryInterface/*** Get all piggy bank events for a journal.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return Collection*/public function getPiggyBankEvents(TransactionJournal $journal): Collection;/**- * @param User $user+ * @param User $user*/public function setUser(User $user);}diff --git a/app/Repositories/Journal/JournalCLIRepository.php b/app/Repositories/Journal/JournalCLIRepository.phpindex 82d92685e1..3395fe3d66 100644--- a/app/Repositories/Journal/JournalCLIRepository.php+++ b/app/Repositories/Journal/JournalCLIRepository.php@@ -30,7 +30,6 @@ use FireflyIII\Models\TransactionJournal;use FireflyIII\Support\CacheProperties;use FireflyIII\User;use Illuminate\Support\Collection;-use JsonException;use stdClass;/**@@ -44,22 +43,22 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface/*** Get all transaction journals with a specific type, regardless of user.*- * @param array $types+ * @param array $types** @return Collection*/public function getAllJournals(array $types): Collection{return TransactionJournal::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')- ->whereIn('transaction_types.type', $types)- ->with(['user', 'transactionType', 'transactionCurrency', 'transactions', 'transactions.account'])- ->get(['transaction_journals.*']);+ ->whereIn('transaction_types.type', $types)+ ->with(['user', 'transactionType', 'transactionCurrency', 'transactions', 'transactions.account'])+ ->get(['transaction_journals.*']);}/*** Return the ID of the budget linked to the journal (if any) or the transactions (if any).*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return int*/@@ -80,7 +79,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface/*** Return the ID of the category linked to the journal (if any) or to the transactions (if any).*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return int*/@@ -111,8 +110,8 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface/*** Return Carbon value of a meta field (or NULL).*- * @param TransactionJournal $journal- * @param string $field+ * @param TransactionJournal $journal+ * @param string $field** @return null|Carbon*/@@ -154,8 +153,8 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface/*** Return value of a meta field (or NULL) as a string.*- * @param TransactionJournal $journal- * @param string $field+ * @param TransactionJournal $journal+ * @param string $field** @return null|string*/@@ -185,7 +184,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface}// return when something else:- $return = (string) $value;+ $return = (string)$value;try {$cache->store($return);} catch (Exception $e) {@@ -198,7 +197,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface/*** Return text of a note attached to journal, or NULL*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return string|null*/@@ -221,25 +220,25 @@ class JournalCLIRepository implements JournalCLIRepositoryInterfacepublic function getSplitJournals(): Collection{$query = TransactionJournal::leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->groupBy('transaction_journals.id');+ ->groupBy('transaction_journals.id');$result = $query->get(['transaction_journals.id as id', DB::raw('count(transactions.id) as transaction_count')]);$journalIds = [];/** @var stdClass $row */foreach ($result as $row) {- if ((int) $row->transaction_count > 2) {- $journalIds[] = (int) $row->id;+ if ((int)$row->transaction_count > 2) {+ $journalIds[] = (int)$row->id;}}$journalIds = array_unique($journalIds);return TransactionJournal::with(['transactions'])- ->whereIn('id', $journalIds)->get();+ ->whereIn('id', $journalIds)->get();}/*** Return all tags as strings in an array.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return array*/@@ -249,7 +248,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface}/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void{diff --git a/app/Repositories/Journal/JournalCLIRepositoryInterface.php b/app/Repositories/Journal/JournalCLIRepositoryInterface.phpindex cec8ec564d..b226973bda 100644--- a/app/Repositories/Journal/JournalCLIRepositoryInterface.php+++ b/app/Repositories/Journal/JournalCLIRepositoryInterface.php@@ -36,7 +36,7 @@ interface JournalCLIRepositoryInterface/*** Get all transaction journals with a specific type, regardless of user.*- * @param array $types+ * @param array $types** @return Collection*/@@ -45,7 +45,7 @@ interface JournalCLIRepositoryInterface/*** Return the ID of the budget linked to the journal (if any) or the transactions (if any).*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return int*/@@ -54,7 +54,7 @@ interface JournalCLIRepositoryInterface/*** Return the ID of the category linked to the journal (if any) or to the transactions (if any).*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return int*/@@ -70,8 +70,8 @@ interface JournalCLIRepositoryInterface/*** Return Carbon value of a meta field (or NULL).*- * @param TransactionJournal $journal- * @param string $field+ * @param TransactionJournal $journal+ * @param string $field** @return null|Carbon*/@@ -80,8 +80,8 @@ interface JournalCLIRepositoryInterface/*** Return value of a meta field (or NULL).*- * @param TransactionJournal $journal- * @param string $field+ * @param TransactionJournal $journal+ * @param string $field** @return null|string*/@@ -90,7 +90,7 @@ interface JournalCLIRepositoryInterface/*** Return text of a note attached to journal, or NULL*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return string|null*/@@ -107,14 +107,14 @@ interface JournalCLIRepositoryInterface/*** Return all tags as strings in an array.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return array*/public function getTags(TransactionJournal $journal): array;/**- * @param User $user+ * @param User $user*/public function setUser(User $user);}diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.phpindex 750bd295b5..b48ed7fc75 100644--- a/app/Repositories/Journal/JournalRepository.php+++ b/app/Repositories/Journal/JournalRepository.php@@ -1,4 +1,5 @@<?php+/*** JournalRepository.php* Copyright (c) 2019 [email protected]@@ -37,7 +38,6 @@ use FireflyIII\Services\Internal\Update\JournalUpdateService;use FireflyIII\Support\CacheProperties;use FireflyIII\User;use Illuminate\Support\Collection;-use JsonException;/*** Class JournalRepository.@@ -48,7 +48,7 @@ class JournalRepository implements JournalRepositoryInterfaceprivate $user;/**- * @param TransactionGroup $transactionGroup+ * @param TransactionGroup $transactionGroup**/public function destroyGroup(TransactionGroup $transactionGroup): void@@ -59,7 +59,7 @@ class JournalRepository implements JournalRepositoryInterface}/**- * @param TransactionJournal $journal+ * @param TransactionJournal $journal**/public function destroyJournal(TransactionJournal $journal): void@@ -69,18 +69,6 @@ class JournalRepository implements JournalRepositoryInterface$service->destroy($journal);}- /**- * Find a specific journal.- *- * @param int $journalId- *- * @return TransactionJournal|null- */- public function find(int $journalId): ?TransactionJournal- {- return $this->user->transactionJournals()->find($journalId);- }-/*** @inheritDoc*/@@ -127,7 +115,7 @@ class JournalRepository implements JournalRepositoryInterface/*** Return total amount of journal. Is always positive.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return string*/@@ -142,7 +130,7 @@ class JournalRepository implements JournalRepositoryInterface// saves on queries:$amount = $journal->transactions()->where('amount', '>', 0)->get()->sum('amount');- $amount = (string) $amount;+ $amount = (string)$amount;$cache->store($amount);return $amount;@@ -164,7 +152,7 @@ class JournalRepository implements JournalRepositoryInterface}/**- * @param TransactionJournalLink $link+ * @param TransactionJournalLink $link** @return string*/@@ -182,8 +170,8 @@ class JournalRepository implements JournalRepositoryInterface/*** Return Carbon value of a meta field (or NULL).*- * @param int $journalId- * @param string $field+ * @param int $journalId+ * @param string $field** @return null|Carbon*/@@ -223,7 +211,7 @@ class JournalRepository implements JournalRepositoryInterface}/**- * @param int $journalId+ * @param int $journalId*/public function reconcileById(int $journalId): void{@@ -232,11 +220,23 @@ class JournalRepository implements JournalRepositoryInterface$journal?->transactions()->update(['reconciled' => true]);}+ /**+ * Find a specific journal.+ *+ * @param int $journalId+ *+ * @return TransactionJournal|null+ */+ public function find(int $journalId): ?TransactionJournal+ {+ return $this->user->transactionJournals()->find($journalId);+ }+/*** Search in journal descriptions.*- * @param string $search- * @param int $limit+ * @param string $search+ * @param int $limit** @return Collection*/@@ -252,7 +252,7 @@ class JournalRepository implements JournalRepositoryInterface}/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void{@@ -262,8 +262,8 @@ class JournalRepository implements JournalRepositoryInterface/*** Update budget for a journal.*- * @param TransactionJournal $journal- * @param int $budgetId+ * @param TransactionJournal $journal+ * @param int $budgetId** @return TransactionJournal*/@@ -287,8 +287,8 @@ class JournalRepository implements JournalRepositoryInterface/*** Update category for a journal.*- * @param TransactionJournal $journal- * @param string $category+ * @param TransactionJournal $journal+ * @param string $category** @return TransactionJournal*/@@ -311,8 +311,8 @@ class JournalRepository implements JournalRepositoryInterface/*** Update tag(s) for a journal.*- * @param TransactionJournal $journal- * @param array $tags+ * @param TransactionJournal $journal+ * @param array $tags** @return TransactionJournal*/diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.phpindex 523ab22637..2dac2b5d3d 100644--- a/app/Repositories/Journal/JournalRepositoryInterface.php+++ b/app/Repositories/Journal/JournalRepositoryInterface.php@@ -1,4 +1,5 @@<?php+/*** JournalRepositoryInterface.php* Copyright (c) 2019 [email protected]@@ -39,28 +40,28 @@ interface JournalRepositoryInterface/*** Deletes a transaction group.*- * @param TransactionGroup $transactionGroup+ * @param TransactionGroup $transactionGroup*/public function destroyGroup(TransactionGroup $transactionGroup): void;/*** Deletes a journal.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal*/public function destroyJournal(TransactionJournal $journal): void;/*** Find a specific journal.*- * @param int $journalId+ * @param int $journalId** @return TransactionJournal|null*/public function find(int $journalId): ?TransactionJournal;/**- * @param array $types+ * @param array $types** @return Collection*/@@ -76,7 +77,7 @@ interface JournalRepositoryInterface/*** Returns the destination account of the journal.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return Account* @throws FireflyException@@ -86,7 +87,7 @@ interface JournalRepositoryInterface/*** Return total amount of journal. Is always positive.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return string*/@@ -98,7 +99,7 @@ interface JournalRepositoryInterfacepublic function getLast(): ?TransactionJournal;/**- * @param TransactionJournalLink $link+ * @param TransactionJournalLink $link** @return string*/@@ -107,8 +108,8 @@ interface JournalRepositoryInterface/*** Return Carbon value of a meta field (or NULL).*- * @param int $journalId- * @param string $field+ * @param int $journalId+ * @param string $field** @return null|Carbon*/@@ -117,7 +118,7 @@ interface JournalRepositoryInterface/*** Returns the source account of the journal.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return Account* @throws FireflyException@@ -127,30 +128,30 @@ interface JournalRepositoryInterface/*** TODO Maybe to account repository? Do this wen reconcile is API only.*- * @param int $journalId+ * @param int $journalId*/public function reconcileById(int $journalId): void;/*** Search in journal descriptions.*- * @param string $search- * @param int $limit+ * @param string $search+ * @param int $limit** @return Collection*/public function searchJournalDescriptions(string $search, int $limit): Collection;/**- * @param User $user+ * @param User $user*/public function setUser(User $user);/*** Update budget for a journal.*- * @param TransactionJournal $journal- * @param int $budgetId+ * @param TransactionJournal $journal+ * @param int $budgetId** @return TransactionJournal*/@@ -159,8 +160,8 @@ interface JournalRepositoryInterface/*** Update category for a journal.*- * @param TransactionJournal $journal- * @param string $category+ * @param TransactionJournal $journal+ * @param string $category** @return TransactionJournal*/@@ -169,8 +170,8 @@ interface JournalRepositoryInterface/*** Update tag(s) for a journal.*- * @param TransactionJournal $journal- * @param array $tags+ * @param TransactionJournal $journal+ * @param array $tags** @return TransactionJournal*/diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.phpindex ca5220d960..2ed6402451 100644--- a/app/Repositories/LinkType/LinkTypeRepository.php+++ b/app/Repositories/LinkType/LinkTypeRepository.php@@ -1,4 +1,5 @@<?php+/*** LinkTypeRepository.php* Copyright (c) 2019 [email protected]@@ -41,7 +42,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterfaceprivate User $user;/**- * @param LinkType $linkType+ * @param LinkType $linkType** @return int*/@@ -51,8 +52,8 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface}/**- * @param LinkType $linkType- * @param LinkType|null $moveTo+ * @param LinkType $linkType+ * @param LinkType|null $moveTo** @return bool*/@@ -67,7 +68,29 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface}/**- * @param TransactionJournalLink $link+ * @param LinkType $linkType+ * @param array $data+ *+ * @return LinkType+ */+ public function update(LinkType $linkType, array $data): LinkType+ {+ if (array_key_exists('name', $data) && '' !== (string)$data['name']) {+ $linkType->name = $data['name'];+ }+ if (array_key_exists('inward', $data) && '' !== (string)$data['inward']) {+ $linkType->inward = $data['inward'];+ }+ if (array_key_exists('outward', $data) && '' !== (string)$data['outward']) {+ $linkType->outward = $data['outward'];+ }+ $linkType->save();++ return $linkType;+ }++ /**+ * @param TransactionJournalLink $link** @return bool* @throws Exception@@ -83,8 +106,8 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface/*** Check if link exists between journals.*- * @param TransactionJournal $one- * @param TransactionJournal $two+ * @param TransactionJournal $one+ * @param TransactionJournal $two** @return bool*/@@ -97,18 +120,10 @@ class LinkTypeRepository implements LinkTypeRepositoryInterfacereturn $count + $opposingCount > 0;}- /**- * @return Collection- */- public function get(): Collection- {- return LinkType::orderBy('name', 'ASC')->get();- }-/*** Return array of all journal ID's for this type of link.*- * @param LinkType $linkType+ * @param LinkType $linkType** @return array*/@@ -121,22 +136,30 @@ class LinkTypeRepository implements LinkTypeRepositoryInterfacereturn array_unique(array_merge($sources, $destinations));}+ /**+ * @return Collection+ */+ public function get(): Collection+ {+ return LinkType::orderBy('name', 'ASC')->get();+ }+/*** Returns all the journal links (of a specific type).*- * @param LinkType|null $linkType+ * @param LinkType|null $linkType** @return Collection*/public function getJournalLinks(LinkType $linkType = null): Collection{$query = TransactionJournalLink::with(['source', 'destination'])- ->leftJoin('transaction_journals as source_journals', 'journal_links.source_id', '=', 'source_journals.id')- ->leftJoin('transaction_journals as dest_journals', 'journal_links.destination_id', '=', 'dest_journals.id')- ->where('source_journals.user_id', $this->user->id)- ->where('dest_journals.user_id', $this->user->id)- ->whereNull('source_journals.deleted_at')- ->whereNull('dest_journals.deleted_at');+ ->leftJoin('transaction_journals as source_journals', 'journal_links.source_id', '=', 'source_journals.id')+ ->leftJoin('transaction_journals as dest_journals', 'journal_links.destination_id', '=', 'dest_journals.id')+ ->where('source_journals.user_id', $this->user->id)+ ->where('dest_journals.user_id', $this->user->id)+ ->whereNull('source_journals.deleted_at')+ ->whereNull('dest_journals.deleted_at');if (null !== $linkType) {$query->where('journal_links.link_type_id', $linkType->id);@@ -158,7 +181,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface/*** Return list of existing connections.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return Collection*/@@ -176,7 +199,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface}/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void{@@ -184,7 +207,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface}/**- * @param array $data+ * @param array $data** @return LinkType*/@@ -203,16 +226,16 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface/*** Store link between two journals.*- * @param array $information- * @param TransactionJournal $inward- * @param TransactionJournal $outward+ * @param array $information+ * @param TransactionJournal $inward+ * @param TransactionJournal $outward** @return TransactionJournalLink|null* @throws Exception*/public function storeLink(array $information, TransactionJournal $inward, TransactionJournal $outward): ?TransactionJournalLink{- $linkType = $this->find((int) ($information['link_type_id'] ?? 0));+ $linkType = $this->find((int)($information['link_type_id'] ?? 0));if (null === $linkType) {$linkType = $this->findByName($information['link_type_name']);@@ -244,13 +267,13 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface$link->save();// make note in noteable:- $this->setNoteText($link, (string) $information['notes']);+ $this->setNoteText($link, (string)$information['notes']);return $link;}/**- * @param int $linkTypeId+ * @param int $linkTypeId** @return LinkType|null*/@@ -260,7 +283,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface}/**- * @param string|null $name+ * @param string|null $name** @return LinkType|null*/@@ -276,22 +299,22 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface/*** See if such a link already exists (and get it).*- * @param LinkType $linkType- * @param TransactionJournal $inward- * @param TransactionJournal $outward+ * @param LinkType $linkType+ * @param TransactionJournal $inward+ * @param TransactionJournal $outward** @return TransactionJournalLink|null*/public function findSpecificLink(LinkType $linkType, TransactionJournal $inward, TransactionJournal $outward): ?TransactionJournalLink{return TransactionJournalLink::where('link_type_id', $linkType->id)- ->where('source_id', $inward->id)- ->where('destination_id', $outward->id)->first();+ ->where('source_id', $inward->id)+ ->where('destination_id', $outward->id)->first();}/**- * @param TransactionJournalLink $link- * @param string $text+ * @param TransactionJournalLink $link+ * @param string $text** @throws Exception*/@@ -332,7 +355,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface}/**- * @param TransactionJournalLink $link+ * @param TransactionJournalLink $link** @return bool*/@@ -346,33 +369,11 @@ class LinkTypeRepository implements LinkTypeRepositoryInterfacereturn true;}- /**- * @param LinkType $linkType- * @param array $data- *- * @return LinkType- */- public function update(LinkType $linkType, array $data): LinkType- {- if (array_key_exists('name', $data) && '' !== (string) $data['name']) {- $linkType->name = $data['name'];- }- if (array_key_exists('inward', $data) && '' !== (string) $data['inward']) {- $linkType->inward = $data['inward'];- }- if (array_key_exists('outward', $data) && '' !== (string) $data['outward']) {- $linkType->outward = $data['outward'];- }- $linkType->save();-- return $linkType;- }-/*** Update an existing transaction journal link.*- * @param TransactionJournalLink $journalLink- * @param array $data+ * @param TransactionJournalLink $journalLink+ * @param array $data** @return TransactionJournalLink* @throws Exceptiondiff --git a/app/Repositories/LinkType/LinkTypeRepositoryInterface.php b/app/Repositories/LinkType/LinkTypeRepositoryInterface.phpindex 2898350046..9c3c9f338a 100644--- a/app/Repositories/LinkType/LinkTypeRepositoryInterface.php+++ b/app/Repositories/LinkType/LinkTypeRepositoryInterface.php@@ -1,4 +1,5 @@<?php+/*** LinkTypeRepositoryInterface.php* Copyright (c) 2019 [email protected]@@ -34,29 +35,29 @@ use Illuminate\Support\Collection;interface LinkTypeRepositoryInterface{/**- * @param LinkType $linkType+ * @param LinkType $linkType** @return int*/public function countJournals(LinkType $linkType): int;/**- * @param LinkType $linkType- * @param LinkType|null $moveTo+ * @param LinkType $linkType+ * @param LinkType|null $moveTo** @return bool*/public function destroy(LinkType $linkType, LinkType $moveTo = null): bool;/**- * @param TransactionJournalLink $link+ * @param TransactionJournalLink $link** @return bool*/public function destroyLink(TransactionJournalLink $link): bool;/**- * @param int $linkTypeId+ * @param int $linkTypeId** @return LinkType|null*/@@ -65,7 +66,7 @@ interface LinkTypeRepositoryInterface/*** Find link type by name.*- * @param string|null $name+ * @param string|null $name** @return LinkType|null*/@@ -74,8 +75,8 @@ interface LinkTypeRepositoryInterface/*** Check if link exists between journals.*- * @param TransactionJournal $one- * @param TransactionJournal $two+ * @param TransactionJournal $one+ * @param TransactionJournal $two** @return bool*/@@ -84,9 +85,9 @@ interface LinkTypeRepositoryInterface/*** See if such a link already exists (and get it).*- * @param LinkType $linkType- * @param TransactionJournal $inward- * @param TransactionJournal $outward+ * @param LinkType $linkType+ * @param TransactionJournal $inward+ * @param TransactionJournal $outward** @return TransactionJournalLink|null*/@@ -100,14 +101,14 @@ interface LinkTypeRepositoryInterface/*** Return array of all journal ID's for this type of link.*- * @param LinkType $linkType+ * @param LinkType $linkType** @return array*/public function getJournalIds(LinkType $linkType): array;/**- * @param LinkType|null $linkType+ * @param LinkType|null $linkType** @return Collection*/@@ -116,7 +117,7 @@ interface LinkTypeRepositoryInterface/*** Return list of existing connections.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return Collection*/@@ -125,12 +126,12 @@ interface LinkTypeRepositoryInterface/*** Set the user for this instance.*- * @param User $user+ * @param User $user*/public function setUser(User $user): void;/**- * @param array $data+ * @param array $data** @return LinkType*/@@ -139,31 +140,31 @@ interface LinkTypeRepositoryInterface/*** Store link between two journals.*- * @param array $information- * @param TransactionJournal $inward- * @param TransactionJournal $outward+ * @param array $information+ * @param TransactionJournal $inward+ * @param TransactionJournal $outward** @return TransactionJournalLink|null*/public function storeLink(array $information, TransactionJournal $inward, TransactionJournal $outward): ?TransactionJournalLink;/**- * @param TransactionJournalLink $link+ * @param TransactionJournalLink $link** @return bool*/public function switchLink(TransactionJournalLink $link): bool;/**- * @param int $linkId+ * @param int $linkId** @return bool*/public function switchLinkById(int $linkId): bool;/**- * @param LinkType $linkType- * @param array $data+ * @param LinkType $linkType+ * @param array $data** @return LinkType*/@@ -172,8 +173,8 @@ interface LinkTypeRepositoryInterface/*** Update an existing transaction journal link.*- * @param TransactionJournalLink $journalLink- * @param array $data+ * @param TransactionJournalLink $journalLink+ * @param array $data** @return TransactionJournalLink*/diff --git a/app/Repositories/ObjectGroup/CreatesObjectGroups.php b/app/Repositories/ObjectGroup/CreatesObjectGroups.phpindex da4f22897b..14761dcb0e 100644--- a/app/Repositories/ObjectGroup/CreatesObjectGroups.php+++ b/app/Repositories/ObjectGroup/CreatesObjectGroups.php@@ -32,7 +32,7 @@ use FireflyIII\Models\ObjectGroup;trait CreatesObjectGroups{/**- * @param int $groupId+ * @param int $groupId** @return ObjectGroup|null*/@@ -42,7 +42,7 @@ trait CreatesObjectGroups}/**- * @param string $title+ * @param string $title** @return ObjectGroup|null*/@@ -67,11 +67,11 @@ trait CreatesObjectGroups*/protected function getObjectGroupMaxOrder(): int{- return (int) $this->user->objectGroups()->max('order');+ return (int)$this->user->objectGroups()->max('order');}/**- * @param string $title+ * @param string $title** @return bool*/@@ -81,7 +81,7 @@ trait CreatesObjectGroups}/**- * @param string $title+ * @param string $title** @return null|ObjectGroup*/diff --git a/app/Repositories/ObjectGroup/ObjectGroupRepository.php b/app/Repositories/ObjectGroup/ObjectGroupRepository.phpindex 958c8d69b2..35a42991fa 100644--- a/app/Repositories/ObjectGroup/ObjectGroupRepository.php+++ b/app/Repositories/ObjectGroup/ObjectGroupRepository.php@@ -118,7 +118,7 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface$index = 1;/** @var ObjectGroup $objectGroup */foreach ($list as $objectGroup) {- if ($index !== (int) $objectGroup->order) {+ if ($index !== (int)$objectGroup->order) {Log::debug(sprintf('objectGroup #%d ("%s"): order should %d be but is %d.', $objectGroup->id, $objectGroup->title, $index, $objectGroup->order));@@ -130,8 +130,8 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface}/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/@@ -151,7 +151,7 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface}/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void{@@ -168,7 +168,7 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface}if (array_key_exists('order', $data)) {- $this->setOrder($objectGroup, (int) $data['order']);+ $this->setOrder($objectGroup, (int)$data['order']);}$objectGroup->save();@@ -181,7 +181,7 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface*/public function setOrder(ObjectGroup $objectGroup, int $newOrder): ObjectGroup{- $oldOrder = (int) $objectGroup->order;+ $oldOrder = (int)$objectGroup->order;if ($newOrder > $oldOrder) {$this->user->objectGroups()->where('object_groups.order', '<=', $newOrder)->where('object_groups.order', '>', $oldOrder)diff --git a/app/Repositories/ObjectGroup/ObjectGroupRepositoryInterface.php b/app/Repositories/ObjectGroup/ObjectGroupRepositoryInterface.phpindex cf70d8b912..2a5b2c44e7 100644--- a/app/Repositories/ObjectGroup/ObjectGroupRepositoryInterface.php+++ b/app/Repositories/ObjectGroup/ObjectGroupRepositoryInterface.php@@ -44,7 +44,7 @@ interface ObjectGroupRepositoryInterfacepublic function deleteEmpty(): void;/**- * @param ObjectGroup $objectGroup+ * @param ObjectGroup $objectGroup*/public function destroy(ObjectGroup $objectGroup): void;@@ -54,14 +54,14 @@ interface ObjectGroupRepositoryInterfacepublic function get(): Collection;/**- * @param ObjectGroup $objectGroup+ * @param ObjectGroup $objectGroup** @return Collection*/public function getBills(ObjectGroup $objectGroup): Collection;/**- * @param ObjectGroup $objectGroup+ * @param ObjectGroup $objectGroup** @return Collection*/@@ -73,29 +73,29 @@ interface ObjectGroupRepositoryInterfacepublic function resetOrder(): void;/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/public function search(string $query, int $limit): Collection;/**- * @param ObjectGroup $objectGroup- * @param int $newOrder+ * @param ObjectGroup $objectGroup+ * @param int $newOrder** @return ObjectGroup*/public function setOrder(ObjectGroup $objectGroup, int $newOrder): ObjectGroup;/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void;/**- * @param ObjectGroup $objectGroup- * @param array $data+ * @param ObjectGroup $objectGroup+ * @param array $data** @return ObjectGroup*/diff --git a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php b/app/Repositories/PiggyBank/ModifiesPiggyBanks.phpindex 9565808176..dff0581e6f 100644--- a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php+++ b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php@@ -42,45 +42,66 @@ trait ModifiesPiggyBanks{use CreatesObjectGroups;+ /**+ * @param PiggyBankRepetition $repetition+ * @param string $amount+ *+ * @return void+ */+ public function addAmountToRepetition(PiggyBankRepetition $repetition, string $amount, TransactionJournal $journal): void+ {+ Log::debug(sprintf('addAmountToRepetition: %s', $amount));+ if (-1 === bccomp($amount, '0')) {+ Log::debug('Remove amount.');+ $this->removeAmount($repetition->piggyBank, bcmul($amount, '-1'), $journal);+ }+ if (1 === bccomp($amount, '0')) {+ Log::debug('Add amount.');+ $this->addAmount($repetition->piggyBank, $amount, $journal);+ }+ }+/*** @param PiggyBank $piggyBank* @param string $amount- * @param TransactionJournal|null $journal+ ** @return bool*/- public function addAmount(PiggyBank $piggyBank, string $amount, ?TransactionJournal $journal = null): bool+ public function removeAmount(PiggyBank $piggyBank, string $amount, ?TransactionJournal $journal = null): bool{$repetition = $this->getRepetition($piggyBank);if (null === $repetition) {return false;}- $currentAmount = $repetition->currentamount ?? '0';- $repetition->currentamount = bcadd($currentAmount, $amount);+ $repetition->currentamount = bcsub($repetition->currentamount, $amount);$repetition->save();- Log::debug('addAmount: Trigger change for positive amount.');- event(new ChangedPiggyBankAmount($piggyBank, $amount, $journal, null));+ Log::debug('addAmount: Trigger change for negative amount.');+ event(new ChangedPiggyBankAmount($piggyBank, bcmul($amount, '-1'), $journal, null));return true;}/**- * @param PiggyBankRepetition $repetition+ * @param PiggyBank $piggyBank* @param string $amount- *- * @return void+ * @param TransactionJournal|null $journal+ * @return bool*/- public function addAmountToRepetition(PiggyBankRepetition $repetition, string $amount, TransactionJournal $journal): void+ public function addAmount(PiggyBank $piggyBank, string $amount, ?TransactionJournal $journal = null): bool{- Log::debug(sprintf('addAmountToRepetition: %s', $amount));- if (-1 === bccomp($amount, '0')) {- Log::debug('Remove amount.');- $this->removeAmount($repetition->piggyBank, bcmul($amount, '-1'), $journal);- }- if (1 === bccomp($amount, '0')) {- Log::debug('Add amount.');- $this->addAmount($repetition->piggyBank, $amount, $journal);+ $repetition = $this->getRepetition($piggyBank);+ if (null === $repetition) {+ return false;}+ $currentAmount = $repetition->currentamount ?? '0';+ $repetition->currentamount = bcadd($currentAmount, $amount);+ $repetition->save();++ Log::debug('addAmount: Trigger change for positive amount.');+ event(new ChangedPiggyBankAmount($piggyBank, $amount, $journal, null));++ return true;}/**@@ -144,27 +165,6 @@ trait ModifiesPiggyBanksreturn true;}- /**- * @param PiggyBank $piggyBank- * @param string $amount- *- * @return bool- */- public function removeAmount(PiggyBank $piggyBank, string $amount, ?TransactionJournal $journal = null): bool- {- $repetition = $this->getRepetition($piggyBank);- if (null === $repetition) {- return false;- }- $repetition->currentamount = bcsub($repetition->currentamount, $amount);- $repetition->save();-- Log::debug('addAmount: Trigger change for negative amount.');- event(new ChangedPiggyBankAmount($piggyBank, bcmul($amount, '-1'), $journal, null));-- return true;- }-/*** @inheritDoc*/diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.phpindex b34a7d29c7..221d15ae87 100644--- a/app/Repositories/PiggyBank/PiggyBankRepository.php+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php@@ -1,4 +1,5 @@<?php+/*** PiggyBankRepository.php* Copyright (c) 2019 [email protected]@@ -23,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Repositories\PiggyBank;use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Attachment;use FireflyIII\Models\Note;use FireflyIII\Models\PiggyBank;@@ -33,6 +35,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Repositories\Journal\JournalRepositoryInterface;use FireflyIII\User;use Illuminate\Support\Collection;+use JsonException;use Log;use Storage;@@ -55,8 +58,8 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface}/**- * @param int|null $piggyBankId- * @param string|null $piggyBankName+ * @param int|null $piggyBankId+ * @param string|null $piggyBankName** @return PiggyBank|null*/@@ -65,7 +68,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterfaceLog::debug('Searching for piggy information.');if (null !== $piggyBankId) {- $searchResult = $this->find((int) $piggyBankId);+ $searchResult = $this->find((int)$piggyBankId);if (null !== $searchResult) {Log::debug(sprintf('Found piggy based on #%d, will return it.', $piggyBankId));@@ -73,7 +76,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface}}if (null !== $piggyBankName) {- $searchResult = $this->findByName((string) $piggyBankName);+ $searchResult = $this->findByName((string)$piggyBankName);if (null !== $searchResult) {Log::debug(sprintf('Found piggy based on "%s", will return it.', $piggyBankName));@@ -86,7 +89,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface}/**- * @param int $piggyBankId+ * @param int $piggyBankId** @return PiggyBank|null*/@@ -98,7 +101,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface/*** Find by name or return NULL.*- * @param string $name+ * @param string $name** @return PiggyBank|null*/@@ -131,7 +134,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface/*** Get current amount saved in piggy bank.*- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return string*/@@ -142,11 +145,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterfacereturn '0';}- return (string) $rep->currentamount;+ return (string)$rep->currentamount;}/**- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return PiggyBankRepetition|null*/@@ -156,7 +159,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface}/**- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return Collection*/@@ -168,13 +171,13 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface/*** Used for connecting to a piggy bank.*- * @param PiggyBank $piggyBank- * @param PiggyBankRepetition $repetition- * @param TransactionJournal $journal+ * @param PiggyBank $piggyBank+ * @param PiggyBankRepetition $repetition+ * @param TransactionJournal $journal** @return string- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/public function getExactAmount(PiggyBank $piggyBank, PiggyBankRepetition $repetition, TransactionJournal $journal): string{@@ -221,11 +224,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface// currency of the account + the piggy bank currency are almost the same.// which amount from the transaction matches?$amount = null;- if ((int) $source->transaction_currency_id === (int) $currency->id) {+ if ((int)$source->transaction_currency_id === (int)$currency->id) {Log::debug('Use normal amount');$amount = app('steam')->$operator($source->amount);}- if ((int) $source->foreign_currency_id === (int) $currency->id) {+ if ((int)$source->foreign_currency_id === (int)$currency->id) {Log::debug('Use foreign amount');$amount = app('steam')->$operator($source->foreign_amount);}@@ -236,10 +239,10 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface}Log::debug(sprintf('The currency is %s and the amount is %s', $currency->code, $amount));- $room = bcsub((string) $piggyBank->targetamount, (string) $repetition->currentamount);+ $room = bcsub((string)$piggyBank->targetamount, (string)$repetition->currentamount);$compare = bcmul($repetition->currentamount, '-1');- if (bccomp((string) $piggyBank->targetamount, '0') === 0) {+ if (bccomp((string)$piggyBank->targetamount, '0') === 0) {// amount is zero? then the "room" is positive amount of we wish to add or remove.$room = app('steam')->positive($amount);Log::debug(sprintf('Room is now %s', $room));@@ -266,7 +269,15 @@ class PiggyBankRepository implements PiggyBankRepositoryInterfacereturn $compare;}- return (string) $amount;+ return (string)$amount;+ }++ /**+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;}/**@@ -274,13 +285,13 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface*/public function getMaxOrder(): int{- return (int) $this->user->piggyBanks()->max('piggy_banks.order');+ return (int)$this->user->piggyBanks()->max('piggy_banks.order');}/*** Return note for piggy bank.*- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return string*/@@ -309,7 +320,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface/** @var PiggyBank $piggy */foreach ($set as $piggy) {$currentAmount = $this->getRepetition($piggy)->currentamount ?? '0';- $piggy->name = $piggy->name . ' (' . app('amount')->formatAnything($currency, $currentAmount, false) . ')';+ $piggy->name = $piggy->name.' ('.app('amount')->formatAnything($currency, $currentAmount, false).')';}return $set;@@ -326,7 +337,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface/*** Returns the suggested amount the user should save per month, or "".*- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return string*@@ -346,7 +357,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface// more than 1 month to go and still need money to save:if ($diffInMonths > 0 && 1 === bccomp($remainingAmount, '0')) {- $savePerMonth = bcdiv($remainingAmount, (string) $diffInMonths);+ $savePerMonth = bcdiv($remainingAmount, (string)$diffInMonths);}// less than 1 month to go but still need money to save:@@ -361,11 +372,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface/*** Get for piggy account what is left to put in piggies.*- * @param PiggyBank $piggyBank- * @param Carbon $date+ * @param PiggyBank $piggyBank+ * @param Carbon $date** @return string- * @throws \JsonException+ * @throws JsonException*/public function leftOnAccount(PiggyBank $piggyBank, Carbon $date): string{@@ -399,12 +410,4 @@ class PiggyBankRepository implements PiggyBankRepositoryInterfacereturn $search->take($limit)->get();}-- /**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }}diff --git a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.phpindex e3b83132b2..d786a77364 100644--- a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php+++ b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php@@ -1,4 +1,5 @@<?php+/*** PiggyBankRepositoryInterface.php* Copyright (c) 2019 [email protected]@@ -25,7 +26,6 @@ namespace FireflyIII\Repositories\PiggyBank;use Carbon\Carbon;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\PiggyBank;-use FireflyIII\Models\PiggyBankEvent;use FireflyIII\Models\PiggyBankRepetition;use FireflyIII\Models\TransactionJournal;use FireflyIII\User;@@ -45,22 +45,22 @@ interface PiggyBankRepositoryInterfacepublic function addAmount(PiggyBank $piggyBank, string $amount, ?TransactionJournal $journal = null): bool;/**- * @param PiggyBankRepetition $repetition- * @param string $amount+ * @param PiggyBankRepetition $repetition+ * @param string $amount*/public function addAmountToRepetition(PiggyBankRepetition $repetition, string $amount, TransactionJournal $journal): void;/**- * @param PiggyBank $piggyBank- * @param string $amount+ * @param PiggyBank $piggyBank+ * @param string $amount** @return bool*/public function canAddAmount(PiggyBank $piggyBank, string $amount): bool;/**- * @param PiggyBank $piggyBank- * @param string $amount+ * @param PiggyBank $piggyBank+ * @param string $amount** @return bool*/@@ -69,7 +69,7 @@ interface PiggyBankRepositoryInterface/*** Destroy piggy bank.*- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return bool*/@@ -81,7 +81,7 @@ interface PiggyBankRepositoryInterfacepublic function destroyAll(): void;/**- * @param int $piggyBankId+ * @param int $piggyBankId** @return PiggyBank|null*/@@ -90,22 +90,22 @@ interface PiggyBankRepositoryInterface/*** Find by name or return NULL.*- * @param string $name+ * @param string $name** @return PiggyBank|null*/public function findByName(string $name): ?PiggyBank;/**- * @param int|null $piggyBankId- * @param string|null $piggyBankName+ * @param int|null $piggyBankId+ * @param string|null $piggyBankName** @return PiggyBank|null*/public function findPiggyBank(?int $piggyBankId, ?string $piggyBankName): ?PiggyBank;/**- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return Collection*/@@ -114,7 +114,7 @@ interface PiggyBankRepositoryInterface/*** Get current amount saved in piggy bank.*- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return string*/@@ -123,7 +123,7 @@ interface PiggyBankRepositoryInterface/*** Get all events.*- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return Collection*/@@ -132,9 +132,9 @@ interface PiggyBankRepositoryInterface/*** Used for connecting to a piggy bank.*- * @param PiggyBank $piggyBank- * @param PiggyBankRepetition $repetition- * @param TransactionJournal $journal+ * @param PiggyBank $piggyBank+ * @param PiggyBankRepetition $repetition+ * @param TransactionJournal $journal** @return string*/@@ -150,7 +150,7 @@ interface PiggyBankRepositoryInterface/*** Return note for piggy bank.*- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return string*/@@ -171,7 +171,7 @@ interface PiggyBankRepositoryInterfacepublic function getPiggyBanksWithAmount(): Collection;/**- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return PiggyBankRepetition|null*/@@ -180,7 +180,7 @@ interface PiggyBankRepositoryInterface/*** Returns the suggested amount the user should save per month, or "".*- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return string*/@@ -189,8 +189,8 @@ interface PiggyBankRepositoryInterface/*** Get for piggy account what is left to put in piggies.*- * @param PiggyBank $piggyBank- * @param Carbon $date+ * @param PiggyBank $piggyBank+ * @param Carbon $date** @return string*/@@ -205,7 +205,7 @@ interface PiggyBankRepositoryInterfacepublic function removeAmount(PiggyBank $piggyBank, string $amount, ?TransactionJournal $journal = null): bool;/**- * @param PiggyBank $piggyBank+ * @param PiggyBank $piggyBank** @return PiggyBank*/@@ -219,24 +219,24 @@ interface PiggyBankRepositoryInterface/*** Search for piggy banks.*- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/public function searchPiggyBank(string $query, int $limit): Collection;/**- * @param PiggyBank $piggyBank- * @param string $amount+ * @param PiggyBank $piggyBank+ * @param string $amount** @return PiggyBank*/public function setCurrentAmount(PiggyBank $piggyBank, string $amount): PiggyBank;/**- * @param PiggyBank $piggyBank- * @param string $objectGroupTitle+ * @param PiggyBank $piggyBank+ * @param string $objectGroupTitle** @return PiggyBank*/@@ -245,22 +245,22 @@ interface PiggyBankRepositoryInterface/*** Set specific piggy bank to specific order.*- * @param PiggyBank $piggyBank- * @param int $newOrder+ * @param PiggyBank $piggyBank+ * @param int $newOrder** @return bool*/public function setOrder(PiggyBank $piggyBank, int $newOrder): bool;/**- * @param User $user+ * @param User $user*/public function setUser(User $user);/*** Store new piggy bank.*- * @param array $data+ * @param array $data** @return PiggyBank* @throws FireflyException@@ -270,8 +270,8 @@ interface PiggyBankRepositoryInterface/*** Update existing piggy bank.*- * @param PiggyBank $piggyBank- * @param array $data+ * @param PiggyBank $piggyBank+ * @param array $data** @return PiggyBank*/diff --git a/app/Repositories/Recurring/RecurringRepository.php b/app/Repositories/Recurring/RecurringRepository.phpindex cdc1eafcc3..1097d9037c 100644--- a/app/Repositories/Recurring/RecurringRepository.php+++ b/app/Repositories/Recurring/RecurringRepository.php@@ -61,6 +61,36 @@ class RecurringRepository implements RecurringRepositoryInterfaceprivate User $user;+ /**+ * @inheritDoc+ */+ public function createdPreviously(Recurrence $recurrence, Carbon $date): bool+ {+ // if not, loop set and try to read the recurrence_date. If it matches start or end, return it as well.+ $set =+ TransactionJournalMeta::where(function (Builder $q1) use ($recurrence) {+ $q1->where('name', 'recurrence_id');+ $q1->where('data', json_encode((string)$recurrence->id));+ })->get(['journal_meta.transaction_journal_id']);++ // there are X journals made for this recurrence. Any of them meant for today?+ foreach ($set as $journalMeta) {+ $count = TransactionJournalMeta::where(function (Builder $q2) use ($date) {+ $string = (string)$date;+ Log::debug(sprintf('Search for date: %s', json_encode($string)));+ $q2->where('name', 'recurrence_date');+ $q2->where('data', json_encode($string));+ })+ ->where('transaction_journal_id', $journalMeta->transaction_journal_id)+ ->count();+ if ($count > 0) {+ Log::debug(sprintf('Looks like journal #%d was already created', $journalMeta->transaction_journal_id));+ return true;+ }+ }+ return false;+ }+/*** Destroy a recurring transaction.*@@ -81,6 +111,20 @@ class RecurringRepository implements RecurringRepositoryInterface$this->user->recurrences()->delete();}+ /**+ * Get ALL recurring transactions.+ *+ * @return Collection+ */+ public function getAll(): Collection+ {+ // grab ALL recurring transactions:+ return Recurrence::with(['TransactionCurrency', 'TransactionType', 'RecurrenceRepetitions', 'RecurrenceTransactions'])+ ->orderBy('active', 'DESC')+ ->orderBy('title', 'ASC')+ ->get();+ }+/*** Returns all of the user's recurring transactions.*@@ -96,20 +140,6 @@ class RecurringRepository implements RecurringRepositoryInterface->get();}- /**- * Get ALL recurring transactions.- *- * @return Collection- */- public function getAll(): Collection- {- // grab ALL recurring transactions:- return Recurrence::with(['TransactionCurrency', 'TransactionType', 'RecurrenceRepetitions', 'RecurrenceTransactions'])- ->orderBy('active', 'DESC')- ->orderBy('title', 'ASC')- ->get();- }-/*** @inheritDoc*/@@ -314,6 +344,16 @@ class RecurringRepository implements RecurringRepositoryInterfacereturn $collector->getPaginatedGroups();}+ /**+ * Set user for in repository.+ *+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }+/*** @param Recurrence $recurrence*@@ -521,16 +561,6 @@ class RecurringRepository implements RecurringRepositoryInterfacereturn $search->take($limit)->get(['id', 'title', 'description']);}- /**- * Set user for in repository.- *- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }-/*** @param array $data*@@ -629,34 +659,4 @@ class RecurringRepository implements RecurringRepositoryInterfacereturn $service->update($recurrence, $data);}-- /**- * @inheritDoc- */- public function createdPreviously(Recurrence $recurrence, Carbon $date): bool- {- // if not, loop set and try to read the recurrence_date. If it matches start or end, return it as well.- $set =- TransactionJournalMeta::where(function (Builder $q1) use ($recurrence) {- $q1->where('name', 'recurrence_id');- $q1->where('data', json_encode((string)$recurrence->id));- })->get(['journal_meta.transaction_journal_id']);-- // there are X journals made for this recurrence. Any of them meant for today?- foreach ($set as $journalMeta) {- $count = TransactionJournalMeta::where(function (Builder $q2) use ($date) {- $string = (string)$date;- Log::debug(sprintf('Search for date: %s', json_encode($string)));- $q2->where('name', 'recurrence_date');- $q2->where('data', json_encode($string));- })- ->where('transaction_journal_id', $journalMeta->transaction_journal_id)- ->count();- if ($count > 0) {- Log::debug(sprintf('Looks like journal #%d was already created', $journalMeta->transaction_journal_id));- return true;- }- }- return false;- }}diff --git a/app/Repositories/Recurring/RecurringRepositoryInterface.php b/app/Repositories/Recurring/RecurringRepositoryInterface.phpindex eddce93351..c4fca83361 100644--- a/app/Repositories/Recurring/RecurringRepositoryInterface.php+++ b/app/Repositories/Recurring/RecurringRepositoryInterface.php@@ -39,18 +39,18 @@ use Illuminate\Support\Collection;interface RecurringRepositoryInterface{/**- * Destroy a recurring transaction.- ** @param Recurrence $recurrence+ * @param Carbon $date+ * @return bool*/- public function destroy(Recurrence $recurrence): void;+ public function createdPreviously(Recurrence $recurrence, Carbon $date): bool;/**+ * Destroy a recurring transaction.+ ** @param Recurrence $recurrence- * @param Carbon $date- * @return bool*/- public function createdPreviously(Recurrence $recurrence, Carbon $date): bool;+ public function destroy(Recurrence $recurrence): void;/*** Destroy all recurring transactions.diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.phpindex 9cb52c36a7..32a1377b4b 100644--- a/app/Repositories/Rule/RuleRepository.php+++ b/app/Repositories/Rule/RuleRepository.php@@ -1,4 +1,5 @@<?php+/*** RuleRepository.php* Copyright (c) 2019 [email protected]@@ -44,15 +45,7 @@ class RuleRepository implements RuleRepositoryInterfaceprivate $user;/**- * @return int- */- public function count(): int- {- return $this->user->rules()->count();- }-- /**- * @param Rule $rule+ * @param Rule $rule** @return bool* @throws Exception@@ -76,7 +69,7 @@ class RuleRepository implements RuleRepositoryInterfacepublic function duplicate(Rule $rule): Rule{$newRule = $rule->replicate();- $newRule->title = (string) trans('firefly.rule_copy_of', ['title' => $rule->title]);+ $newRule->title = (string)trans('firefly.rule_copy_of', ['title' => $rule->title]);$newRule->save();// replicate all triggers@@ -98,16 +91,6 @@ class RuleRepository implements RuleRepositoryInterfacereturn $newRule;}- /**- * @param int $ruleId- *- * @return Rule|null- */- public function find(int $ruleId): ?Rule- {- return $this->user->rules()->find($ruleId);- }-/*** Get all the users rules.*@@ -129,17 +112,17 @@ class RuleRepository implements RuleRepositoryInterface}/**- * @param RuleGroup $ruleGroup+ * @param RuleGroup $ruleGroup** @return int*/public function getHighestOrderInRuleGroup(RuleGroup $ruleGroup): int{- return (int) $ruleGroup->rules()->max('order');+ return (int)$ruleGroup->rules()->max('order');}/**- * @param Rule $rule+ * @param Rule $rule** @return string*@@ -149,14 +132,22 @@ class RuleRepository implements RuleRepositoryInterface{$count = $rule->ruleTriggers()->count();if (0 === $count) {- throw new FireflyException('Rules should have more than zero triggers, rule #' . $rule->id . ' has none!');+ throw new FireflyException('Rules should have more than zero triggers, rule #'.$rule->id.' has none!');}return $rule->ruleTriggers()->where('trigger_type', 'user_action')->first()->trigger_value;}/**- * @param Rule $rule+ * @return int+ */+ public function count(): int+ {+ return $this->user->rules()->count();+ }++ /**+ * @param Rule $rule** @return Collection*/@@ -166,7 +157,7 @@ class RuleRepository implements RuleRepositoryInterface}/**- * @param Rule $rule+ * @param Rule $rule** @return Collection*/@@ -268,15 +259,7 @@ class RuleRepository implements RuleRepositoryInterface}/**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }-- /**- * @param array $data+ * @param array $data** @return Rule* @throws FireflyException@@ -330,8 +313,18 @@ class RuleRepository implements RuleRepositoryInterface}/**- * @param string $moment- * @param Rule $rule+ * @param int $ruleId+ *+ * @return Rule|null+ */+ public function find(int $ruleId): ?Rule+ {+ return $this->user->rules()->find($ruleId);+ }++ /**+ * @param string $moment+ * @param Rule $rule*/private function setRuleTrigger(string $moment, Rule $rule): void{@@ -354,7 +347,7 @@ class RuleRepository implements RuleRepositoryInterface}/**- * @param RuleGroup $ruleGroup+ * @param RuleGroup $ruleGroup** @return bool*/@@ -367,13 +360,21 @@ class RuleRepository implements RuleRepositoryInterfacereturn true;}+ /**+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }+/*** @inheritDoc*/public function setOrder(Rule $rule, int $newOrder): void{- $oldOrder = (int) $rule->order;- $groupId = (int) $rule->rule_group_id;+ $oldOrder = (int)$rule->order;+ $groupId = (int)$rule->rule_group_id;$maxOrder = $this->maxOrder($rule->ruleGroup);$newOrder = $newOrder > $maxOrder ? $maxOrder + 1 : $newOrder;Log::debug(sprintf('New order will be %d', $newOrder));@@ -408,12 +409,12 @@ class RuleRepository implements RuleRepositoryInterface*/public function maxOrder(RuleGroup $ruleGroup): int{- return (int) $ruleGroup->rules()->max('order');+ return (int)$ruleGroup->rules()->max('order');}/**- * @param Rule $rule- * @param array $data+ * @param Rule $rule+ * @param array $data** @return void*/@@ -442,8 +443,8 @@ class RuleRepository implements RuleRepositoryInterface}/**- * @param Rule $rule- * @param array $values+ * @param Rule $rule+ * @param array $values** @return RuleTrigger*/@@ -462,8 +463,8 @@ class RuleRepository implements RuleRepositoryInterface}/**- * @param Rule $rule- * @param array $data+ * @param Rule $rule+ * @param array $data** @return void*/@@ -487,8 +488,8 @@ class RuleRepository implements RuleRepositoryInterface}/**- * @param Rule $rule- * @param array $values+ * @param Rule $rule+ * @param array $values** @return RuleAction*/@@ -507,8 +508,8 @@ class RuleRepository implements RuleRepositoryInterface}/**- * @param Rule $rule- * @param array $data+ * @param Rule $rule+ * @param array $data** @return Rule*/@@ -534,7 +535,7 @@ class RuleRepository implements RuleRepositoryInterface// update the order:$this->resetRuleOrder($group);if (array_key_exists('order', $data)) {- $this->moveRule($rule, $group, (int) $data['order']);+ $this->moveRule($rule, $group, (int)$data['order']);}diff --git a/app/Repositories/Rule/RuleRepositoryInterface.php b/app/Repositories/Rule/RuleRepositoryInterface.phpindex 0fc7c4bf5e..5f2577737e 100644--- a/app/Repositories/Rule/RuleRepositoryInterface.php+++ b/app/Repositories/Rule/RuleRepositoryInterface.php@@ -1,4 +1,5 @@<?php+/*** RuleRepositoryInterface.php* Copyright (c) 2019 [email protected]@@ -40,21 +41,21 @@ interface RuleRepositoryInterfacepublic function count(): int;/**- * @param Rule $rule+ * @param Rule $rule** @return bool*/public function destroy(Rule $rule): bool;/**- * @param Rule $rule+ * @param Rule $rule** @return Rule*/public function duplicate(Rule $rule): Rule;/**- * @param int $ruleId+ * @param int $ruleId** @return Rule|null*/@@ -73,28 +74,28 @@ interface RuleRepositoryInterfacepublic function getFirstRuleGroup(): RuleGroup;/**- * @param RuleGroup $ruleGroup+ * @param RuleGroup $ruleGroup** @return int*/public function getHighestOrderInRuleGroup(RuleGroup $ruleGroup): int;/**- * @param Rule $rule+ * @param Rule $rule** @return string*/public function getPrimaryTrigger(Rule $rule): string;/**- * @param Rule $rule+ * @param Rule $rule** @return Collection*/public function getRuleActions(Rule $rule): Collection;/**- * @param Rule $rule+ * @param Rule $rule** @return Collection*/@@ -103,7 +104,7 @@ interface RuleRepositoryInterface/*** Return search query for rule.*- * @param Rule $rule+ * @param Rule $rule** @return string*/@@ -124,73 +125,73 @@ interface RuleRepositoryInterfacepublic function getUpdateRules(): Collection;/**- * @param RuleGroup $ruleGroup+ * @param RuleGroup $ruleGroup** @return int*/public function maxOrder(RuleGroup $ruleGroup): int;/**- * @param Rule $rule- * @param RuleGroup $ruleGroup- * @param int $order+ * @param Rule $rule+ * @param RuleGroup $ruleGroup+ * @param int $order** @return Rule*/public function moveRule(Rule $rule, RuleGroup $ruleGroup, int $order): Rule;/**- * @param RuleGroup $ruleGroup+ * @param RuleGroup $ruleGroup** @return bool*/public function resetRuleOrder(RuleGroup $ruleGroup): bool;/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/public function searchRule(string $query, int $limit): Collection;/**- * @param Rule $rule- * @param int $newOrder+ * @param Rule $rule+ * @param int $newOrder*/public function setOrder(Rule $rule, int $newOrder): void;/**- * @param User $user+ * @param User $user*/public function setUser(User $user);/**- * @param array $data+ * @param array $data** @return Rule*/public function store(array $data): Rule;/**- * @param Rule $rule- * @param array $values+ * @param Rule $rule+ * @param array $values** @return RuleAction*/public function storeAction(Rule $rule, array $values): RuleAction;/**- * @param Rule $rule- * @param array $values+ * @param Rule $rule+ * @param array $values** @return RuleTrigger*/public function storeTrigger(Rule $rule, array $values): RuleTrigger;/**- * @param Rule $rule- * @param array $data+ * @param Rule $rule+ * @param array $data** @return Rule*/diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.phpindex 2c0b109b13..e71c6f6f51 100644--- a/app/Repositories/RuleGroup/RuleGroupRepository.php+++ b/app/Repositories/RuleGroup/RuleGroupRepository.php@@ -1,4 +1,5 @@<?php+/*** RuleGroupRepository.php* Copyright (c) 2019 [email protected]@@ -61,6 +62,14 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface}}+ /**+ * @return Collection+ */+ public function get(): Collection+ {+ return $this->user->ruleGroups()->orderBy('order', 'ASC')->get();+ }+/*** @return int*/@@ -70,8 +79,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface}/**- * @param RuleGroup $ruleGroup- * @param RuleGroup|null $moveTo+ * @param RuleGroup $ruleGroup+ * @param RuleGroup|null $moveTo** @return bool* @throws Exception@@ -128,7 +137,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface}/**- * @param RuleGroup $ruleGroup+ * @param RuleGroup $ruleGroup** @return bool*/@@ -142,7 +151,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface$count = 1;/** @var Rule $entry */foreach ($set as $entry) {- if ((int) $entry->order !== $count) {+ if ((int)$entry->order !== $count) {Log::debug(sprintf('Rule #%d was on spot %d but must be on spot %d', $entry->id, $entry->order, $count));$entry->order = $count;$entry->save();@@ -157,7 +166,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface}/**- * @param Rule $rule+ * @param Rule $rule*/private function resetRuleActionOrder(Rule $rule): void{@@ -169,7 +178,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface$index = 1;/** @var RuleAction $action */foreach ($actions as $action) {- if ((int) $action->order !== $index) {+ if ((int)$action->order !== $index) {$action->order = $index;$action->save();Log::debug(sprintf('Rule action #%d was on spot %d but must be on spot %d', $action->id, $action->order, $index));@@ -179,7 +188,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface}/**- * @param Rule $rule+ * @param Rule $rule*/private function resetRuleTriggerOrder(Rule $rule): void{@@ -191,7 +200,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface$index = 1;/** @var RuleTrigger $trigger */foreach ($triggers as $trigger) {- $order = (int) $trigger->order;+ $order = (int)$trigger->order;if ($order !== $index) {$trigger->order = $index;$trigger->save();@@ -215,15 +224,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface}/**- * @return Collection- */- public function get(): Collection- {- return $this->user->ruleGroups()->orderBy('order', 'ASC')->get();- }-- /**- * @param int $ruleGroupId+ * @param int $ruleGroupId** @return RuleGroup|null*/@@ -233,7 +234,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface}/**- * @param string $title+ * @param string $title** @return RuleGroup|null*/@@ -251,7 +252,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface}/**- * @param RuleGroup $group+ * @param RuleGroup $group** @return Collection*/@@ -263,7 +264,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface}/**- * @param RuleGroup $group+ * @param RuleGroup $group** @return Collection*/@@ -278,7 +279,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface}/**- * @param RuleGroup $group+ * @param RuleGroup $group** @return Collection*/@@ -293,7 +294,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface}/**- * @param string|null $filter+ * @param string|null $filter** @return Collection*/@@ -351,11 +352,11 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface{$entry = $this->user->ruleGroups()->max('order');- return (int) $entry;+ return (int)$entry;}/**- * @param string|null $filter+ * @param string|null $filter** @return Collection*/@@ -408,7 +409,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface}/**- * @param RuleGroup $group+ * @param RuleGroup $group** @return Collection*/@@ -423,7 +424,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface*/public function maxOrder(): int{- return (int) $this->user->ruleGroups()->where('active', true)->max('order');+ return (int)$this->user->ruleGroups()->where('active', true)->max('order');}/**@@ -442,7 +443,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface}/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void{@@ -450,7 +451,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface}/**- * @param array $data+ * @param array $data** @return RuleGroup*/@@ -479,7 +480,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface*/public function setOrder(RuleGroup $ruleGroup, int $newOrder): void{- $oldOrder = (int) $ruleGroup->order;+ $oldOrder = (int)$ruleGroup->order;if ($newOrder > $oldOrder) {$this->user->ruleGroups()->where('rule_groups.order', '<=', $newOrder)->where('rule_groups.order', '>', $oldOrder)@@ -501,8 +502,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface}/**- * @param RuleGroup $ruleGroup- * @param array $data+ * @param RuleGroup $ruleGroup+ * @param array $data** @return RuleGroup*/@@ -521,7 +522,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface// orderif (array_key_exists('order', $data) && $ruleGroup->order !== $data['order']) {$this->resetOrder();- $this->setOrder($ruleGroup, (int) $data['order']);+ $this->setOrder($ruleGroup, (int)$data['order']);}$ruleGroup->save();diff --git a/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php b/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.phpindex aa1ef97406..f2fa871fde 100644--- a/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php+++ b/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php@@ -1,4 +1,5 @@<?php+/*** RuleGroupRepositoryInterface.php* Copyright (c) 2019 [email protected]@@ -42,8 +43,8 @@ interface RuleGroupRepositoryInterfacepublic function count(): int;/**- * @param RuleGroup $ruleGroup- * @param RuleGroup|null $moveTo+ * @param RuleGroup $ruleGroup+ * @param RuleGroup|null $moveTo** @return bool*/@@ -55,14 +56,14 @@ interface RuleGroupRepositoryInterfacepublic function destroyAll(): void;/**- * @param int $ruleGroupId+ * @param int $ruleGroupId** @return RuleGroup|null*/public function find(int $ruleGroupId): ?RuleGroup;/**- * @param string $title+ * @param string $title** @return RuleGroup|null*/@@ -81,21 +82,21 @@ interface RuleGroupRepositoryInterfacepublic function getActiveGroups(): Collection;/**- * @param RuleGroup $group+ * @param RuleGroup $group** @return Collection*/public function getActiveRules(RuleGroup $group): Collection;/**- * @param RuleGroup $group+ * @param RuleGroup $group** @return Collection*/public function getActiveStoreRules(RuleGroup $group): Collection;/**- * @param RuleGroup $group+ * @param RuleGroup $group** @return Collection*/@@ -104,7 +105,7 @@ interface RuleGroupRepositoryInterface/*** Also inactive groups.*- * @param string|null $filter+ * @param string|null $filter** @return Collection*/@@ -116,14 +117,14 @@ interface RuleGroupRepositoryInterfacepublic function getHighestOrderRuleGroup(): int;/**- * @param string|null $filter+ * @param string|null $filter** @return Collection*/public function getRuleGroupsWithRules(?string $filter): Collection;/**- * @param RuleGroup $group+ * @param RuleGroup $group** @return Collection*/@@ -142,41 +143,41 @@ interface RuleGroupRepositoryInterfacepublic function resetOrder(): bool;/**- * @param RuleGroup $ruleGroup+ * @param RuleGroup $ruleGroup** @return bool*/public function resetRuleOrder(RuleGroup $ruleGroup): bool;/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/public function searchRuleGroup(string $query, int $limit): Collection;/**- * @param RuleGroup $ruleGroup- * @param int $newOrder+ * @param RuleGroup $ruleGroup+ * @param int $newOrder*/public function setOrder(RuleGroup $ruleGroup, int $newOrder): void;/**- * @param User $user+ * @param User $user*/public function setUser(User $user);/**- * @param array $data+ * @param array $data** @return RuleGroup*/public function store(array $data): RuleGroup;/**- * @param RuleGroup $ruleGroup- * @param array $data+ * @param RuleGroup $ruleGroup+ * @param array $data** @return RuleGroup*/diff --git a/app/Repositories/Tag/OperationsRepository.php b/app/Repositories/Tag/OperationsRepository.phpindex 7b923bbc06..fc06b62718 100644--- a/app/Repositories/Tag/OperationsRepository.php+++ b/app/Repositories/Tag/OperationsRepository.php@@ -29,6 +29,8 @@ use FireflyIII\Helpers\Collector\GroupCollectorInterface;use FireflyIII\Models\TransactionType;use FireflyIII\User;use Illuminate\Support\Collection;+use Psr\Container\ContainerExceptionInterface;+use Psr\Container\NotFoundExceptionInterface;/***@@ -44,10 +46,10 @@ class OperationsRepository implements OperationsRepositoryInterface* which have the specified tag(s) set to them. It's grouped per currency, with as few details in the array* as possible. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $tags+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $tags** @return array*/@@ -70,31 +72,31 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];$listedJournals = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$array[$currencyId] = $array[$currencyId] ?? [- 'tags' => [],- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'tags' => [],+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];// may have multiple tags:foreach ($journal['tags'] as $tag) {- $tagId = (int) $tag['id'];- $tagName = (string) $tag['name'];- $journalId = (int) $journal['transaction_journal_id'];+ $tagId = (int)$tag['id'];+ $tagName = (string)$tag['name'];+ $journalId = (int)$journal['transaction_journal_id'];if (in_array($journalId, $listedJournals, true)) {continue;}$listedJournals[] = $journalId;$array[$currencyId]['tags'][$tagId] = $array[$currencyId]['tags'][$tagId] ?? [- 'id' => $tagId,- 'name' => $tagName,- 'transaction_journals' => [],- ];+ 'id' => $tagId,+ 'name' => $tagName,+ 'transaction_journals' => [],+ ];$array[$currencyId]['tags'][$tagId]['transaction_journals'][$journalId] = ['amount' => app('steam')->negative($journal['amount']),@@ -114,10 +116,18 @@ class OperationsRepository implements OperationsRepositoryInterfacereturn $array;}+ /**+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }+/*** @return Collection- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/private function getTags(): Collection{@@ -131,10 +141,10 @@ class OperationsRepository implements OperationsRepositoryInterface* which have the specified tag(s) set to them. It's grouped per currency, with as few details in the array* as possible. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $tags+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $tags** @return array*/@@ -158,21 +168,21 @@ class OperationsRepository implements OperationsRepositoryInterface$listedJournals = [];foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$array[$currencyId] = $array[$currencyId] ?? [- 'tags' => [],- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- ];+ 'tags' => [],+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_code' => $journal['currency_code'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ ];// may have multiple tags:foreach ($journal['tags'] as $tag) {- $tagId = (int) $tag['id'];- $tagName = (string) $tag['name'];- $journalId = (int) $journal['transaction_journal_id'];+ $tagId = (int)$tag['id'];+ $tagName = (string)$tag['name'];+ $journalId = (int)$journal['transaction_journal_id'];if (in_array($journalId, $listedJournals, true)) {continue;@@ -180,11 +190,11 @@ class OperationsRepository implements OperationsRepositoryInterface$listedJournals[] = $journalId;$array[$currencyId]['tags'][$tagId] = $array[$currencyId]['tags'][$tagId] ?? [- 'id' => $tagId,- 'name' => $tagName,- 'transaction_journals' => [],- ];- $journalId = (int) $journal['transaction_journal_id'];+ 'id' => $tagId,+ 'name' => $tagName,+ 'transaction_journals' => [],+ ];+ $journalId = (int)$journal['transaction_journal_id'];$array[$currencyId]['tags'][$tagId]['transaction_journals'][$journalId] = ['amount' => app('steam')->positive($journal['amount']),'date' => $journal['date'],@@ -202,21 +212,13 @@ class OperationsRepository implements OperationsRepositoryInterfacereturn $array;}- /**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }-/*** Sum of withdrawal journals in period for a set of tags, grouped per currency. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $tags+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $tags** @return array* @throws FireflyException@@ -229,10 +231,10 @@ class OperationsRepository implements OperationsRepositoryInterface/*** Sum of income journals in period for a set of tags, grouped per currency. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $tags+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $tags** @return array* @throws FireflyExceptiondiff --git a/app/Repositories/Tag/OperationsRepositoryInterface.php b/app/Repositories/Tag/OperationsRepositoryInterface.phpindex bb254c841b..f5f6dd09b1 100644--- a/app/Repositories/Tag/OperationsRepositoryInterface.php+++ b/app/Repositories/Tag/OperationsRepositoryInterface.php@@ -39,10 +39,10 @@ interface OperationsRepositoryInterface* which have the specified tag(s) set to them. It's grouped per currency, with as few details in the array* as possible. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $tags+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $tags** @return array*/@@ -53,27 +53,27 @@ interface OperationsRepositoryInterface* which have the specified tag(s) set to them. It's grouped per currency, with as few details in the array* as possible. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $tags+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $tags** @return array*/public function listIncome(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $tags = null): array;/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void;/*** Sum of withdrawal journals in period for a set of tags, grouped per currency. Amounts are always negative.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $tags+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $tags** @return array*/@@ -82,10 +82,10 @@ interface OperationsRepositoryInterface/*** Sum of income journals in period for a set of tags, grouped per currency. Amounts are always positive.*- * @param Carbon $start- * @param Carbon $end- * @param Collection|null $accounts- * @param Collection|null $tags+ * @param Carbon $start+ * @param Carbon $end+ * @param Collection|null $accounts+ * @param Collection|null $tags** @return array*/diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.phpindex 32cc326ab5..8e37750467 100644--- a/app/Repositories/Tag/TagRepository.php+++ b/app/Repositories/Tag/TagRepository.php@@ -1,4 +1,5 @@<?php+/*** TagRepository.php* Copyright (c) 2019 [email protected]@@ -54,7 +55,7 @@ class TagRepository implements TagRepositoryInterface}/**- * @param Tag $tag+ * @param Tag $tag** @return bool* @throws Exception@@ -90,9 +91,9 @@ class TagRepository implements TagRepositoryInterface}/**- * @param Tag $tag- * @param Carbon $start- * @param Carbon $end+ * @param Tag $tag+ * @param Carbon $start+ * @param Carbon $end** @return array*/@@ -108,7 +109,15 @@ class TagRepository implements TagRepositoryInterface}/**- * @param int $tagId+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }++ /**+ * @param int $tagId** @return Tag|null*/@@ -118,7 +127,7 @@ class TagRepository implements TagRepositoryInterface}/**- * @param string $tag+ * @param string $tag** @return Tag|null*/@@ -128,7 +137,7 @@ class TagRepository implements TagRepositoryInterface}/**- * @param Tag $tag+ * @param Tag $tag** @return Carbon|null*/@@ -163,7 +172,7 @@ class TagRepository implements TagRepositoryInterface}/**- * @param int|null $year+ * @param int|null $year** @return array*/@@ -180,7 +189,7 @@ class TagRepository implements TagRepositoryInterfaceif (null !== $year) {Log::debug(sprintf('Get tags with year %s.', $year));- $tagQuery->where('tags.date', '>=', $year . '-01-01 00:00:00')->where('tags.date', '<=', $year . '-12-31 23:59:59');+ $tagQuery->where('tags.date', '>=', $year.'-01-01 00:00:00')->where('tags.date', '<=', $year.'-12-31 23:59:59');}$collection = $tagQuery->get();$return = [];@@ -200,9 +209,9 @@ class TagRepository implements TagRepositoryInterface}/**- * @param Tag $tag- * @param Carbon $start- * @param Carbon $end+ * @param Tag $tag+ * @param Carbon $start+ * @param Carbon $end** @return array*/@@ -218,7 +227,7 @@ class TagRepository implements TagRepositoryInterface}/**- * @param Tag $tag+ * @param Tag $tag** @return Carbon|null*/@@ -253,7 +262,7 @@ class TagRepository implements TagRepositoryInterface/*** Find one or more tags based on the query.*- * @param string $query+ * @param string $query** @return Collection*/@@ -267,8 +276,8 @@ class TagRepository implements TagRepositoryInterface/*** Search the users tags.*- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/@@ -285,15 +294,7 @@ class TagRepository implements TagRepositoryInterface}/**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }-- /**- * @param array $data+ * @param array $data** @return Tag*/@@ -307,9 +308,9 @@ class TagRepository implements TagRepositoryInterface}/**- * @param Tag $tag- * @param Carbon|null $start- * @param Carbon|null $end+ * @param Tag $tag+ * @param Carbon|null $start+ * @param Carbon|null $end** @return array*@@ -330,21 +331,21 @@ class TagRepository implements TagRepositoryInterface/** @var array $journal */foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$sums[$currencyId] = $sums[$currencyId] ?? [- 'currency_id' => $currencyId,- 'currency_name' => $journal['currency_name'],- 'currency_symbol' => $journal['currency_symbol'],- 'currency_decimal_places' => $journal['currency_decimal_places'],- TransactionType::WITHDRAWAL => '0',- TransactionType::DEPOSIT => '0',- TransactionType::TRANSFER => '0',- TransactionType::RECONCILIATION => '0',- TransactionType::OPENING_BALANCE => '0',- ];+ 'currency_id' => $currencyId,+ 'currency_name' => $journal['currency_name'],+ 'currency_symbol' => $journal['currency_symbol'],+ 'currency_decimal_places' => $journal['currency_decimal_places'],+ TransactionType::WITHDRAWAL => '0',+ TransactionType::DEPOSIT => '0',+ TransactionType::TRANSFER => '0',+ TransactionType::RECONCILIATION => '0',+ TransactionType::OPENING_BALANCE => '0',+ ];// add amount to correct type:- $amount = app('steam')->positive((string) $journal['amount']);+ $amount = app('steam')->positive((string)$journal['amount']);$type = $journal['transaction_type_type'];if (TransactionType::WITHDRAWAL === $type) {$amount = bcmul($amount, '-1');@@ -354,18 +355,18 @@ class TagRepository implements TagRepositoryInterface$foreignCurrencyId = $journal['foreign_currency_id'];if (null !== $foreignCurrencyId && 0 !== $foreignCurrencyId) {$sums[$foreignCurrencyId] = $sums[$foreignCurrencyId] ?? [- 'currency_id' => $foreignCurrencyId,- 'currency_name' => $journal['foreign_currency_name'],- 'currency_symbol' => $journal['foreign_currency_symbol'],- 'currency_decimal_places' => $journal['foreign_currency_decimal_places'],- TransactionType::WITHDRAWAL => '0',- TransactionType::DEPOSIT => '0',- TransactionType::TRANSFER => '0',- TransactionType::RECONCILIATION => '0',- TransactionType::OPENING_BALANCE => '0',- ];+ 'currency_id' => $foreignCurrencyId,+ 'currency_name' => $journal['foreign_currency_name'],+ 'currency_symbol' => $journal['foreign_currency_symbol'],+ 'currency_decimal_places' => $journal['foreign_currency_decimal_places'],+ TransactionType::WITHDRAWAL => '0',+ TransactionType::DEPOSIT => '0',+ TransactionType::TRANSFER => '0',+ TransactionType::RECONCILIATION => '0',+ TransactionType::OPENING_BALANCE => '0',+ ];// add foreign amount to correct type:- $amount = app('steam')->positive((string) $journal['foreign_amount']);+ $amount = app('steam')->positive((string)$journal['foreign_amount']);$type = $journal['transaction_type_type'];if (TransactionType::WITHDRAWAL === $type) {$amount = bcmul($amount, '-1');@@ -378,9 +379,9 @@ class TagRepository implements TagRepositoryInterface}/**- * @param Tag $tag- * @param Carbon $start- * @param Carbon $end+ * @param Tag $tag+ * @param Carbon $start+ * @param Carbon $end** @return array*/@@ -395,8 +396,8 @@ class TagRepository implements TagRepositoryInterface}/**- * @param Tag $tag- * @param array $data+ * @param Tag $tag+ * @param array $data** @return Tag*/diff --git a/app/Repositories/Tag/TagRepositoryInterface.php b/app/Repositories/Tag/TagRepositoryInterface.phpindex afe80115ed..0a5bbd76cc 100644--- a/app/Repositories/Tag/TagRepositoryInterface.php+++ b/app/Repositories/Tag/TagRepositoryInterface.php@@ -1,4 +1,5 @@<?php+/*** TagRepositoryInterface.php* Copyright (c) 2019 [email protected]@@ -41,7 +42,7 @@ interface TagRepositoryInterface/*** This method destroys a tag.*- * @param Tag $tag+ * @param Tag $tag** @return bool*/@@ -53,30 +54,30 @@ interface TagRepositoryInterfacepublic function destroyAll(): void;/**- * @param Tag $tag- * @param Carbon $start- * @param Carbon $end+ * @param Tag $tag+ * @param Carbon $start+ * @param Carbon $end** @return array*/public function expenseInPeriod(Tag $tag, Carbon $start, Carbon $end): array;/**- * @param int $tagId+ * @param int $tagId** @return Tag|null*/public function find(int $tagId): ?Tag;/**- * @param string $tag+ * @param string $tag** @return Tag|null*/public function findByTag(string $tag): ?Tag;/**- * @param Tag $tag+ * @param Tag $tag** @return Carbon|null*/@@ -90,7 +91,7 @@ interface TagRepositoryInterfacepublic function get(): Collection;/**- * @param Tag $tag+ * @param Tag $tag** @return Collection*/@@ -99,30 +100,30 @@ interface TagRepositoryInterface/*** Return location, or NULL.*- * @param Tag $tag+ * @param Tag $tag** @return Location|null*/public function getLocation(Tag $tag): ?Location;/**- * @param int|null $year+ * @param int|null $year** @return array*/public function getTagsInYear(?int $year): array;/**- * @param Tag $tag- * @param Carbon $start- * @param Carbon $end+ * @param Tag $tag+ * @param Carbon $start+ * @param Carbon $end** @return array*/public function incomeInPeriod(Tag $tag, Carbon $start, Carbon $end): array;/**- * @param Tag $tag+ * @param Tag $tag** @return Carbon|null*/@@ -145,7 +146,7 @@ interface TagRepositoryInterface/*** Find one or more tags based on the query.*- * @param string $query+ * @param string $query** @return Collection*/@@ -154,22 +155,22 @@ interface TagRepositoryInterface/*** Search the users tags.*- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/public function searchTags(string $query, int $limit): Collection;/**- * @param User $user+ * @param User $user*/public function setUser(User $user);/*** This method stores a tag.*- * @param array $data+ * @param array $data** @return Tag*/@@ -178,18 +179,18 @@ interface TagRepositoryInterface/*** Calculates various amounts in tag.*- * @param Tag $tag- * @param Carbon|null $start- * @param Carbon|null $end+ * @param Tag $tag+ * @param Carbon|null $start+ * @param Carbon|null $end** @return array*/public function sumsOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): array;/**- * @param Tag $tag- * @param Carbon $start- * @param Carbon $end+ * @param Tag $tag+ * @param Carbon $start+ * @param Carbon $end** @return array*/@@ -198,8 +199,8 @@ interface TagRepositoryInterface/*** Update a tag.*- * @param Tag $tag- * @param array $data+ * @param Tag $tag+ * @param array $data** @return Tag*/diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.phpindex 8903c8935d..a6389f142b 100644--- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php+++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php@@ -47,6 +47,7 @@ use FireflyIII\Support\NullArrayObject;use FireflyIII\User;use Illuminate\Database\Eloquent\Builder;use Illuminate\Support\Collection;+use JsonException;use Log;/**@@ -68,7 +69,19 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface}/**- * @param TransactionGroup $group+ * Find a transaction group by its ID.+ *+ * @param int $groupId+ *+ * @return TransactionGroup|null+ */+ public function find(int $groupId): ?TransactionGroup+ {+ return $this->user->transactionGroups()->find($groupId);+ }++ /**+ * @param TransactionGroup $group*/public function destroy(TransactionGroup $group): void{@@ -92,7 +105,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface}/**- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return array*/@@ -119,7 +132,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface}/**- * @param Transaction $transaction+ * @param Transaction $transaction** @return array*/@@ -141,22 +154,10 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterfacereturn $array;}- /**- * Find a transaction group by its ID.- *- * @param int $groupId- *- * @return TransactionGroup|null- */- public function find(int $groupId): ?TransactionGroup- {- return $this->user->transactionGroups()->find($groupId);- }-/*** Return all attachments for all journals in the group.*- * @param TransactionGroup $group+ * @param TransactionGroup $group** @return array*/@@ -173,7 +174,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface$result = [];/** @var Attachment $attachment */foreach ($set as $attachment) {- $journalId = (int) $attachment->attachable_id;+ $journalId = (int)$attachment->attachable_id;$result[$journalId] = $result[$journalId] ?? [];$current = $attachment->toArray();$current['file_exists'] = true;@@ -185,10 +186,38 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterfacereturn $result;}+ /**+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }++ /**+ * Get the note text for a journal (by ID).+ *+ * @param int $journalId+ *+ * @return string|null+ */+ public function getNoteText(int $journalId): ?string+ {+ /** @var Note|null $note */+ $note = Note::where('noteable_id', $journalId)+ ->where('noteable_type', TransactionJournal::class)+ ->first();+ if (null === $note) {+ return null;+ }++ return $note->text;+ }+/*** Return all journal links for all journals in the group.*- * @param TransactionGroup $group+ * @param TransactionGroup $group** @return array*/@@ -202,9 +231,9 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface$q->orWhereIn('destination_id', $journals);})- ->with(['source', 'destination', 'source.transactions'])- ->leftJoin('link_types', 'link_types.id', '=', 'journal_links.link_type_id')- ->get(['journal_links.*', 'link_types.inward', 'link_types.outward', 'link_types.editable']);+ ->with(['source', 'destination', 'source.transactions'])+ ->leftJoin('link_types', 'link_types.id', '=', 'journal_links.link_type_id')+ ->get(['journal_links.*', 'link_types.inward', 'link_types.outward', 'link_types.editable']);/** @var TransactionJournalLink $entry */foreach ($set as $entry) {$journalId = in_array($entry->source_id, $journals, true) ? $entry->source_id : $entry->destination_id;@@ -242,7 +271,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface}/**- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return string*/@@ -265,7 +294,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface}/**- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return string*/@@ -307,8 +336,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface/*** Return object with all found meta field things as Carbon objects.*- * @param int $journalId- * @param array $fields+ * @param int $journalId+ * @param array $fields** @return NullArrayObject* @throws Exception@@ -316,10 +345,10 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterfacepublic function getMetaDateFields(int $journalId, array $fields): NullArrayObject{$query = DB::table('journal_meta')- ->where('transaction_journal_id', $journalId)- ->whereIn('name', $fields)- ->whereNull('deleted_at')- ->get(['name', 'data']);+ ->where('transaction_journal_id', $journalId)+ ->whereIn('name', $fields)+ ->whereNull('deleted_at')+ ->get(['name', 'data']);$return = [];foreach ($query as $row) {@@ -332,18 +361,18 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface/*** Return object with all found meta field things.*- * @param int $journalId- * @param array $fields+ * @param int $journalId+ * @param array $fields** @return NullArrayObject*/public function getMetaFields(int $journalId, array $fields): NullArrayObject{$query = DB::table('journal_meta')- ->where('transaction_journal_id', $journalId)- ->whereIn('name', $fields)- ->whereNull('deleted_at')- ->get(['name', 'data']);+ ->where('transaction_journal_id', $journalId)+ ->whereIn('name', $fields)+ ->whereNull('deleted_at')+ ->get(['name', 'data']);$return = [];foreach ($query as $row) {@@ -353,34 +382,14 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterfacereturn new NullArrayObject($return);}- /**- * Get the note text for a journal (by ID).- *- * @param int $journalId- *- * @return string|null- */- public function getNoteText(int $journalId): ?string- {- /** @var Note|null $note */- $note = Note::where('noteable_id', $journalId)- ->where('noteable_type', TransactionJournal::class)- ->first();- if (null === $note) {- return null;- }-- return $note->text;- }-/*** Return all piggy bank events for all journals in the group.*- * @param TransactionGroup $group+ * @param TransactionGroup $group** @return array* @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/public function getPiggyEvents(TransactionGroup $group): array{@@ -388,8 +397,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface$journals = $group->transactionJournals->pluck('id')->toArray();$currency = app('amount')->getDefaultCurrencyByUser($this->user);$data = PiggyBankEvent::whereIn('transaction_journal_id', $journals)- ->with('piggyBank', 'piggyBank.account')- ->get(['piggy_bank_events.*']);+ ->with('piggyBank', 'piggyBank.account')+ ->get(['piggy_bank_events.*']);/** @var PiggyBankEvent $row */foreach ($data as $row) {if (null === $row->piggyBank) {@@ -397,8 +406,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface}// get currency preference.$currencyPreference = AccountMeta::where('account_id', $row->piggyBank->account_id)- ->where('name', 'currency_id')- ->first();+ ->where('name', 'currency_id')+ ->first();if (null !== $currencyPreference) {$currency = TransactionCurrency::where('id', $currencyPreference->data)->first();}@@ -406,7 +415,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface$currencyCode = app('preferences')->getForUser($this->user, 'currencyPreference', 'EUR')->data;$currency = TransactionCurrency::where('code', $currencyCode)->first();}- $journalId = (int) $row->transaction_journal_id;+ $journalId = (int)$row->transaction_journal_id;$return[$journalId] = $return[$journalId] ?? [];$return[$journalId][] = [@@ -433,31 +442,23 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface/*** Get the tags for a journal (by ID).*- * @param int $journalId+ * @param int $journalId** @return array*/public function getTags(int $journalId): array{$result = DB::table('tag_transaction_journal')- ->leftJoin('tags', 'tag_transaction_journal.tag_id', '=', 'tags.id')- ->where('tag_transaction_journal.transaction_journal_id', $journalId)- ->orderBy('tags.tag', 'ASC')- ->get(['tags.tag']);+ ->leftJoin('tags', 'tag_transaction_journal.tag_id', '=', 'tags.id')+ ->where('tag_transaction_journal.transaction_journal_id', $journalId)+ ->orderBy('tags.tag', 'ASC')+ ->get(['tags.tag']);return $result->pluck('tag')->toArray();}/**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }-- /**- * @param array $data+ * @param array $data** @return TransactionGroup* @throws DuplicateTransactionException@@ -482,8 +483,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface}/**- * @param TransactionGroup $transactionGroup- * @param array $data+ * @param TransactionGroup $transactionGroup+ * @param array $data** @return TransactionGroup*diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepositoryInterface.php b/app/Repositories/TransactionGroup/TransactionGroupRepositoryInterface.phpindex 9d3900071f..36a1186d4c 100644--- a/app/Repositories/TransactionGroup/TransactionGroupRepositoryInterface.php+++ b/app/Repositories/TransactionGroup/TransactionGroupRepositoryInterface.php@@ -37,21 +37,21 @@ use Illuminate\Support\Collection;interface TransactionGroupRepositoryInterface{/**- * @param int $journalId+ * @param int $journalId** @return int*/public function countAttachments(int $journalId): int;/**- * @param TransactionGroup $group+ * @param TransactionGroup $group*/public function destroy(TransactionGroup $group): void;/*** Return a group and expand all meta data etc.*- * @param TransactionGroup $group+ * @param TransactionGroup $group** @return array*/@@ -60,7 +60,7 @@ interface TransactionGroupRepositoryInterface/*** Find a transaction group by its ID.*- * @param int $groupId+ * @param int $groupId** @return TransactionGroup|null*/@@ -69,7 +69,7 @@ interface TransactionGroupRepositoryInterface/*** Return all attachments for all journals in the group.*- * @param TransactionGroup $group+ * @param TransactionGroup $group** @return array*/@@ -78,7 +78,7 @@ interface TransactionGroupRepositoryInterface/*** Return all journal links for all journals in the group.*- * @param TransactionGroup $group+ * @param TransactionGroup $group** @return array*/@@ -87,7 +87,7 @@ interface TransactionGroupRepositoryInterface/*** Get the location of a journal or NULL.*- * @param int $journalId+ * @param int $journalId** @return Location|null*/@@ -96,8 +96,8 @@ interface TransactionGroupRepositoryInterface/*** Return object with all found meta field things as Carbon objects.*- * @param int $journalId- * @param array $fields+ * @param int $journalId+ * @param array $fields** @return NullArrayObject*/@@ -106,8 +106,8 @@ interface TransactionGroupRepositoryInterface/*** Return object with all found meta field things.*- * @param int $journalId- * @param array $fields+ * @param int $journalId+ * @param array $fields** @return NullArrayObject*/@@ -116,7 +116,7 @@ interface TransactionGroupRepositoryInterface/*** Get the note text for a journal (by ID).*- * @param int $journalId+ * @param int $journalId** @return string|null*/@@ -125,7 +125,7 @@ interface TransactionGroupRepositoryInterface/*** Return all piggy bank events for all journals in the group.*- * @param TransactionGroup $group+ * @param TransactionGroup $group** @return array*/@@ -134,7 +134,7 @@ interface TransactionGroupRepositoryInterface/*** Get the tags for a journal (by ID) as Tag objects.*- * @param int $journalId+ * @param int $journalId** @return Collection*/@@ -143,7 +143,7 @@ interface TransactionGroupRepositoryInterface/*** Get the tags for a journal (by ID).*- * @param int $journalId+ * @param int $journalId** @return array*/@@ -152,14 +152,14 @@ interface TransactionGroupRepositoryInterface/*** Set the user.*- * @param User $user+ * @param User $user*/public function setUser(User $user): void;/*** Create a new transaction group.*- * @param array $data+ * @param array $data** @return TransactionGroup* @throws DuplicateTransactionException@@ -170,8 +170,8 @@ interface TransactionGroupRepositoryInterface/*** Update an existing transaction group.*- * @param TransactionGroup $transactionGroup- * @param array $data+ * @param TransactionGroup $transactionGroup+ * @param array $data** @return TransactionGroup*/diff --git a/app/Repositories/TransactionType/TransactionTypeRepository.php b/app/Repositories/TransactionType/TransactionTypeRepository.phpindex 62e8071169..40f8edb19b 100644--- a/app/Repositories/TransactionType/TransactionTypeRepository.php+++ b/app/Repositories/TransactionType/TransactionTypeRepository.php@@ -33,8 +33,8 @@ use Log;class TransactionTypeRepository implements TransactionTypeRepositoryInterface{/**- * @param TransactionType|null $type- * @param string|null $typeString+ * @param TransactionType|null $type+ * @param string|null $typeString** @return TransactionType*/@@ -57,7 +57,7 @@ class TransactionTypeRepository implements TransactionTypeRepositoryInterface}/**- * @param string $type+ * @param string $type** @return TransactionType|null*/@@ -69,8 +69,8 @@ class TransactionTypeRepository implements TransactionTypeRepositoryInterface}/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/diff --git a/app/Repositories/TransactionType/TransactionTypeRepositoryInterface.php b/app/Repositories/TransactionType/TransactionTypeRepositoryInterface.phpindex ff4c4b296f..f0a1e4c19a 100644--- a/app/Repositories/TransactionType/TransactionTypeRepositoryInterface.php+++ b/app/Repositories/TransactionType/TransactionTypeRepositoryInterface.php@@ -32,23 +32,23 @@ use Illuminate\Support\Collection;interface TransactionTypeRepositoryInterface{/**- * @param string $type+ * @param string $type** @return TransactionType|null*/public function findByType(string $type): ?TransactionType;/**- * @param TransactionType|null $type- * @param string|null $typeString+ * @param TransactionType|null $type+ * @param string|null $typeString** @return TransactionType*/public function findTransactionType(?TransactionType $type, ?string $typeString): TransactionType;/**- * @param string $query- * @param int $limit+ * @param string $query+ * @param int $limit** @return Collection*/diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.phpindex baa06ead7e..3a49eb1893 100644--- a/app/Repositories/User/UserRepository.php+++ b/app/Repositories/User/UserRepository.php@@ -1,4 +1,5 @@<?php+/*** UserRepository.php* Copyright (c) 2019 [email protected]@@ -45,8 +46,8 @@ class UserRepository implements UserRepositoryInterface* This updates the users email address and records some things so it can be confirmed or undone later.* The user is blocked until the change is confirmed.*- * @param User $user- * @param string $newEmail+ * @param User $user+ * @param string $newEmail** @return bool* @throws Exception@@ -59,7 +60,7 @@ class UserRepository implements UserRepositoryInterface// save old email as prefapp('preferences')->setForUser($user, 'previous_email_latest', $oldEmail);- app('preferences')->setForUser($user, 'previous_email_' . date('Y-m-d-H-i-s'), $oldEmail);+ app('preferences')->setForUser($user, 'previous_email_'.date('Y-m-d-H-i-s'), $oldEmail);// set undo and confirm token:app('preferences')->setForUser($user, 'email_change_undo_token', bin2hex(random_bytes(16)));@@ -75,8 +76,8 @@ class UserRepository implements UserRepositoryInterface}/**- * @param User $user- * @param string $password+ * @param User $user+ * @param string $password** @return bool*/@@ -89,9 +90,9 @@ class UserRepository implements UserRepositoryInterface}/**- * @param User $user- * @param bool $isBlocked- * @param string $code+ * @param User $user+ * @param bool $isBlocked+ * @param string $code** @return bool*/@@ -106,9 +107,9 @@ class UserRepository implements UserRepositoryInterface}/**- * @param string $name- * @param string $displayName- * @param string $description+ * @param string $name+ * @param string $displayName+ * @param string $description** @return Role*/@@ -118,7 +119,7 @@ class UserRepository implements UserRepositoryInterface}/**- * @param User $user+ * @param User $user** @return bool* @throws Exception@@ -167,7 +168,7 @@ class UserRepository implements UserRepositoryInterface}/**- * @param int $userId+ * @param int $userId** @return User|null*/@@ -177,7 +178,7 @@ class UserRepository implements UserRepositoryInterface}/**- * @param string $email+ * @param string $email** @return User|null*/@@ -197,7 +198,15 @@ class UserRepository implements UserRepositoryInterface}/**- * @param User $user+ * @inheritDoc+ */+ public function getInvitedUsers(): Collection+ {+ return InvitedUser::with('user')->get();+ }++ /**+ * @param User $user** @return string|null*/@@ -215,7 +224,7 @@ class UserRepository implements UserRepositoryInterface/*** Return basic user information.*- * @param User $user+ * @param User $user** @return array*/@@ -226,7 +235,7 @@ class UserRepository implements UserRepositoryInterface// two factor:$return['has_2fa'] = $user->mfa_secret !== null;$return['is_admin'] = $this->hasRole($user, 'owner');- $return['blocked'] = 1 === (int) $user->blocked;+ $return['blocked'] = 1 === (int)$user->blocked;$return['blocked_code'] = $user->blocked_code;$return['accounts'] = $user->accounts()->count();$return['journals'] = $user->transactionJournals()->count();@@ -250,8 +259,8 @@ class UserRepository implements UserRepositoryInterface}/**- * @param User $user- * @param string $role+ * @param User $user+ * @param string $role** @return bool*/@@ -285,11 +294,23 @@ class UserRepository implements UserRepositoryInterfacereturn $invitee;}+ /**+ * @inheritDoc+ */+ public function redeemCode(string $code): void+ {+ $obj = InvitedUser::where('invite_code', $code)->where('redeemed', 0)->first();+ if ($obj) {+ $obj->redeemed = true;+ $obj->save();+ }+ }+/*** Set MFA code.*- * @param User $user- * @param string|null $code+ * @param User $user+ * @param string|null $code*/public function setMFACode(User $user, ?string $code): void{@@ -298,7 +319,7 @@ class UserRepository implements UserRepositoryInterface}/**- * @param array $data+ * @param array $data** @return User*/@@ -321,8 +342,8 @@ class UserRepository implements UserRepositoryInterface}/**- * @param User $user- * @param string $role+ * @param User $user+ * @param string $role** @return bool*/@@ -346,7 +367,7 @@ class UserRepository implements UserRepositoryInterface}/**- * @param User $user+ * @param User $user*/public function unblockUser(User $user): void{@@ -358,8 +379,8 @@ class UserRepository implements UserRepositoryInterface/*** Update user info.*- * @param User $user- * @param array $data+ * @param User $user+ * @param array $data** @return User* @throws FireflyException@@ -387,8 +408,8 @@ class UserRepository implements UserRepositoryInterface* This updates the users email address. Same as changeEmail just without most logging. This makes sure that the undo/confirm routine can't catch this one.* The user is NOT blocked.*- * @param User $user- * @param string $newEmail+ * @param User $user+ * @param string $newEmail** @return bool* @throws FireflyException@@ -403,7 +424,7 @@ class UserRepository implements UserRepositoryInterface// save old email as prefapp('preferences')->setForUser($user, 'admin_previous_email_latest', $oldEmail);- app('preferences')->setForUser($user, 'admin_previous_email_' . date('Y-m-d-H-i-s'), $oldEmail);+ app('preferences')->setForUser($user, 'admin_previous_email_'.date('Y-m-d-H-i-s'), $oldEmail);$user->email = $newEmail;$user->save();@@ -414,8 +435,8 @@ class UserRepository implements UserRepositoryInterface/*** Remove any role the user has.*- * @param User $user- * @param string $role+ * @param User $user+ * @param string $role*/public function removeRole(User $user, string $role): void{@@ -427,7 +448,7 @@ class UserRepository implements UserRepositoryInterface}/**- * @param string $role+ * @param string $role** @return Role|null*/@@ -436,14 +457,6 @@ class UserRepository implements UserRepositoryInterfacereturn Role::where('name', $role)->first();}- /**- * @inheritDoc- */- public function getInvitedUsers(): Collection- {- return InvitedUser::with('user')->get();- }-/*** @inheritDoc*/@@ -453,16 +466,4 @@ class UserRepository implements UserRepositoryInterface$invitee = InvitedUser::where('invite_code', $code)->where('expires', '>', $now->format('Y-m-d H:i:s'))->where('redeemed', 0)->first();return null !== $invitee;}-- /**- * @inheritDoc- */- public function redeemCode(string $code): void- {- $obj = InvitedUser::where('invite_code', $code)->where('redeemed', 0)->first();- if ($obj) {- $obj->redeemed = true;- $obj->save();- }- }}diff --git a/app/Repositories/User/UserRepositoryInterface.php b/app/Repositories/User/UserRepositoryInterface.phpindex 040ca46f7c..cd5aeb4f24 100644--- a/app/Repositories/User/UserRepositoryInterface.php+++ b/app/Repositories/User/UserRepositoryInterface.php@@ -1,4 +1,5 @@<?php+/*** UserRepositoryInterface.php* Copyright (c) 2019 [email protected]@@ -42,8 +43,8 @@ interface UserRepositoryInterface/*** Gives a user a role.*- * @param User $user- * @param string $role+ * @param User $user+ * @param string $role** @return bool*/@@ -53,8 +54,8 @@ interface UserRepositoryInterface* This updates the users email address and records some things so it can be confirmed or undone later.* The user is blocked until the change is confirmed.*- * @param User $user- * @param string $newEmail+ * @param User $user+ * @param string $newEmail** @return bool* @see updateEmail@@ -63,17 +64,17 @@ interface UserRepositoryInterfacepublic function changeEmail(User $user, string $newEmail): bool;/**- * @param User $user- * @param string $password+ * @param User $user+ * @param string $password** @return mixed*/public function changePassword(User $user, string $password);/**- * @param User $user- * @param bool $isBlocked- * @param string $code+ * @param User $user+ * @param bool $isBlocked+ * @param string $code** @return bool*/@@ -87,9 +88,9 @@ interface UserRepositoryInterfacepublic function count(): int;/**- * @param string $name- * @param string $displayName- * @param string $description+ * @param string $name+ * @param string $displayName+ * @param string $description** @return Role*/@@ -101,21 +102,21 @@ interface UserRepositoryInterfacepublic function deleteEmptyGroups(): void;/**- * @param User $user+ * @param User $user** @return bool*/public function destroy(User $user): bool;/**- * @param int $userId+ * @param int $userId** @return User|null*/public function find(int $userId): ?User;/**- * @param string $email+ * @param string $email** @return User|null*/@@ -129,14 +130,19 @@ interface UserRepositoryInterfacepublic function first(): ?User;/**- * @param string $role+ * @return Collection+ */+ public function getInvitedUsers(): Collection;++ /**+ * @param string $role** @return Role|null*/public function getRole(string $role): ?Role;/**- * @param User $user+ * @param User $user** @return string|null*/@@ -145,40 +151,29 @@ interface UserRepositoryInterface/*** Return basic user information.*- * @param User $user+ * @param User $user** @return array*/public function getUserData(User $user): array;/**- * @param User $user- * @param string $role+ * @param User $user+ * @param string $role** @return bool*/public function hasRole(User $user, string $role): bool;/**- * @param User $user- * @param string $email+ * @param User $user+ * @param string $email* @return InvitedUser*/public function inviteUser(User $user, string $email): InvitedUser;/**- * @return Collection- */- public function getInvitedUsers(): Collection;-- /**- * @param string $code- * @return bool- */- public function validateInviteCode(string $code): bool;-- /**- * @param string $code+ * @param string $code* @return void*/public function redeemCode(string $code): void;@@ -186,36 +181,36 @@ interface UserRepositoryInterface/*** Remove any role the user has.*- * @param User $user- * @param string $role+ * @param User $user+ * @param string $role*/public function removeRole(User $user, string $role): void;/*** Set MFA code.*- * @param User $user- * @param string|null $code+ * @param User $user+ * @param string|null $code*/public function setMFACode(User $user, ?string $code): void;/**- * @param array $data+ * @param array $data** @return User*/public function store(array $data): User;/**- * @param User $user+ * @param User $user*/public function unblockUser(User $user): void;/*** Update user info.*- * @param User $user- * @param array $data+ * @param User $user+ * @param array $data** @return User*/@@ -225,12 +220,18 @@ interface UserRepositoryInterface* This updates the users email address. Same as changeEmail just without most logging. This makes sure that the undo/confirm routine can't catch this one.* The user is NOT blocked.*- * @param User $user- * @param string $newEmail+ * @param User $user+ * @param string $newEmail** @return bool* @see changeEmail**/public function updateEmail(User $user, string $newEmail): bool;++ /**+ * @param string $code+ * @return bool+ */+ public function validateInviteCode(string $code): bool;}diff --git a/app/Repositories/Webhook/WebhookRepositoryInterface.php b/app/Repositories/Webhook/WebhookRepositoryInterface.phpindex 5ed9281c35..04201667b2 100644--- a/app/Repositories/Webhook/WebhookRepositoryInterface.php+++ b/app/Repositories/Webhook/WebhookRepositoryInterface.php@@ -42,36 +42,36 @@ interface WebhookRepositoryInterfacepublic function all(): Collection;/**- * @param Webhook $webhook+ * @param Webhook $webhook*/public function destroy(Webhook $webhook): void;/**- * @param WebhookAttempt $attempt+ * @param WebhookAttempt $attempt*/public function destroyAttempt(WebhookAttempt $attempt): void;/**- * @param WebhookMessage $message+ * @param WebhookMessage $message*/public function destroyMessage(WebhookMessage $message): void;/**- * @param WebhookMessage $webhookMessage+ * @param WebhookMessage $webhookMessage** @return Collection*/public function getAttempts(WebhookMessage $webhookMessage): Collection;/**- * @param Webhook $webhook+ * @param Webhook $webhook** @return Collection*/public function getMessages(Webhook $webhook): Collection;/**- * @param Webhook $webhook+ * @param Webhook $webhook** @return Collection*/@@ -80,20 +80,20 @@ interface WebhookRepositoryInterface/*** Set user.*- * @param User $user+ * @param User $user*/public function setUser(User $user): void;/**- * @param array $data+ * @param array $data** @return Webhook*/public function store(array $data): Webhook;/**- * @param Webhook $webhook- * @param array $data+ * @param Webhook $webhook+ * @param array $data** @return Webhook*/diff --git a/app/Rules/BelongsUser.php b/app/Rules/BelongsUser.phpindex bbf924795f..0c6ce5acb6 100644--- a/app/Rules/BelongsUser.php+++ b/app/Rules/BelongsUser.php@@ -58,14 +58,14 @@ class BelongsUser implements Rule*/public function message(): string{- return (string) trans('validation.belongs_user');+ return (string)trans('validation.belongs_user');}/*** Determine if the validation rule passes.*- * @param string $attribute- * @param mixed $value+ * @param string $attribute+ * @param mixed $value** @return bool* @throws FireflyException@@ -77,25 +77,25 @@ class BelongsUser implements Ruleif (!auth()->check()) {return true;}- $attribute = (string) $attribute;+ $attribute = (string)$attribute;Log::debug(sprintf('Going to validate %s', $attribute));return match ($attribute) {- 'piggy_bank_id' => $this->validatePiggyBankId((int) $value),+ 'piggy_bank_id' => $this->validatePiggyBankId((int)$value),'piggy_bank_name' => $this->validatePiggyBankName($value),- 'bill_id' => $this->validateBillId((int) $value),- 'transaction_journal_id' => $this->validateJournalId((int) $value),+ 'bill_id' => $this->validateBillId((int)$value),+ 'transaction_journal_id' => $this->validateJournalId((int)$value),'bill_name' => $this->validateBillName($value),- 'budget_id' => $this->validateBudgetId((int) $value),- 'category_id' => $this->validateCategoryId((int) $value),+ 'budget_id' => $this->validateBudgetId((int)$value),+ 'category_id' => $this->validateCategoryId((int)$value),'budget_name' => $this->validateBudgetName($value),- 'source_id', 'destination_id' => $this->validateAccountId((int) $value),+ 'source_id', 'destination_id' => $this->validateAccountId((int)$value),default => throw new FireflyException(sprintf('Rule BelongUser cannot handle "%s"', $attribute)),};}/**- * @param string $attribute+ * @param string $attribute** @return string*/@@ -113,7 +113,7 @@ class BelongsUser implements Rule}/**- * @param int $value+ * @param int $value** @return bool*/@@ -127,7 +127,7 @@ class BelongsUser implements Rule}/**- * @param string $value+ * @param string $value** @return bool*/@@ -139,9 +139,9 @@ class BelongsUser implements Rule}/**- * @param string $class- * @param string $field- * @param string $value+ * @param string $class+ * @param string $field+ * @param string $value** @return int*@@ -160,7 +160,7 @@ class BelongsUser implements Rule}$count = 0;foreach ($objects as $object) {- $objectValue = trim((string) $object->$field);+ $objectValue = trim((string)$object->$field);Log::debug(sprintf('Comparing object "%s" with value "%s"', $objectValue, $value));if ($objectValue === $value) {$count++;@@ -172,7 +172,7 @@ class BelongsUser implements Rule}/**- * @param int $value+ * @param int $value** @return bool*/@@ -187,7 +187,7 @@ class BelongsUser implements Rule}/**- * @param int $value+ * @param int $value** @return bool*/@@ -202,7 +202,7 @@ class BelongsUser implements Rule}/**- * @param string $value+ * @param string $value** @return bool*/@@ -215,7 +215,7 @@ class BelongsUser implements Rule}/**- * @param int $value+ * @param int $value** @return bool*/@@ -230,7 +230,7 @@ class BelongsUser implements Rule}/**- * @param int $value+ * @param int $value** @return bool*/@@ -242,7 +242,7 @@ class BelongsUser implements Rule}/**- * @param string $value+ * @param string $value** @return bool*/@@ -254,7 +254,7 @@ class BelongsUser implements Rule}/**- * @param int $value+ * @param int $value** @return bool*/diff --git a/app/Rules/IsAssetAccountId.php b/app/Rules/IsAssetAccountId.phpindex f30a327b58..7eb32b0d9d 100644--- a/app/Rules/IsAssetAccountId.php+++ b/app/Rules/IsAssetAccountId.php@@ -1,4 +1,5 @@<?php+/*** IsAssetAccountId.php* Copyright (c) 2019 [email protected]@@ -46,14 +47,14 @@ class IsAssetAccountId implements Rule/*** Determine if the validation rule passes.*- * @param string $attribute- * @param mixed $value+ * @param string $attribute+ * @param mixed $value** @return bool*/public function passes($attribute, $value): bool{- $accountId = (int) $value;+ $accountId = (int)$value;$account = Account::with('accountType')->find($accountId);if (null === $account) {return false;diff --git a/app/Rules/IsBoolean.php b/app/Rules/IsBoolean.phpindex f4e034829b..5ccea1498b 100644--- a/app/Rules/IsBoolean.php+++ b/app/Rules/IsBoolean.php@@ -39,14 +39,14 @@ class IsBoolean implements Rule*/public function message(): string{- return (string) trans('validation.boolean');+ return (string)trans('validation.boolean');}/*** Determine if the validation rule passes.*- * @param string $attribute- * @param mixed $value+ * @param string $attribute+ * @param mixed $value** @return bool*/diff --git a/app/Rules/IsDateOrTime.php b/app/Rules/IsDateOrTime.phpindex 63c5a63139..0fb9fff6b6 100644--- a/app/Rules/IsDateOrTime.php+++ b/app/Rules/IsDateOrTime.php@@ -43,20 +43,20 @@ class IsDateOrTime implements Rule*/public function message(){- return (string) trans('validation.date_or_time');+ return (string)trans('validation.date_or_time');}/*** Determine if the validation rule passes.*- * @param string $attribute- * @param mixed $value+ * @param string $attribute+ * @param mixed $value** @return bool*/public function passes($attribute, $value): bool{- $value = (string) $value;+ $value = (string)$value;if ('' === $value) {return false;}diff --git a/app/Rules/IsTransferAccount.php b/app/Rules/IsTransferAccount.phpindex 27103b1c8d..7cf7f00e0d 100644--- a/app/Rules/IsTransferAccount.php+++ b/app/Rules/IsTransferAccount.php@@ -41,14 +41,14 @@ class IsTransferAccount implements Rule*/public function message(): string{- return (string) trans('validation.not_transfer_account');+ return (string)trans('validation.not_transfer_account');}/*** Determine if the validation rule passes.*- * @param string $attribute- * @param mixed $value+ * @param string $attribute+ * @param mixed $value** @return bool*/@@ -60,15 +60,15 @@ class IsTransferAccount implements Rule$validator->setTransactionType(TransactionType::TRANSFER);$validator->setUser(auth()->user());- $validAccount = $validator->validateSource(['name' => (string) $value,]);+ $validAccount = $validator->validateSource(['name' => (string)$value,]);if (true === $validAccount) {Log::debug('Found account based on name. Return true.');// found by name, use repos to return.return true;}- $validAccount = $validator->validateSource(['id' => (int) $value,]);- Log::debug(sprintf('Search by id (%d), result is %s.', (int) $value, var_export($validAccount, true)));+ $validAccount = $validator->validateSource(['id' => (int)$value,]);+ Log::debug(sprintf('Search by id (%d), result is %s.', (int)$value, var_export($validAccount, true)));return false !== $validAccount;}diff --git a/app/Rules/IsValidAttachmentModel.php b/app/Rules/IsValidAttachmentModel.phpindex 1b6ec0dd56..8de8a7205f 100644--- a/app/Rules/IsValidAttachmentModel.php+++ b/app/Rules/IsValidAttachmentModel.php@@ -55,7 +55,7 @@ class IsValidAttachmentModel implements Rule** @codeCoverageIgnore*- * @param string $model+ * @param string $model*/public function __construct(string $model){@@ -64,7 +64,7 @@ class IsValidAttachmentModel implements Rule}/**- * @param string $model+ * @param string $model** @return string*/@@ -85,14 +85,14 @@ class IsValidAttachmentModel implements Rule*/public function message(): string{- return (string) trans('validation.model_id_invalid');+ return (string)trans('validation.model_id_invalid');}/*** Determine if the validation rule passes.*- * @param string $attribute- * @param mixed $value+ * @param string $attribute+ * @param mixed $value** @return bool*/@@ -118,11 +118,11 @@ class IsValidAttachmentModel implements Rule}$method = $methods[$this->model];- return $this->$method((int) $value);+ return $this->$method((int)$value);}/**- * @param int $value+ * @param int $value** @return bool*/@@ -136,7 +136,7 @@ class IsValidAttachmentModel implements Rule}/**- * @param int $value+ * @param int $value** @return bool*/@@ -150,7 +150,7 @@ class IsValidAttachmentModel implements Rule}/**- * @param int $value+ * @param int $value** @return bool*/@@ -164,7 +164,7 @@ class IsValidAttachmentModel implements Rule}/**- * @param int $value+ * @param int $value** @return bool*/@@ -178,7 +178,7 @@ class IsValidAttachmentModel implements Rule}/**- * @param int $value+ * @param int $value** @return bool*/@@ -191,7 +191,7 @@ class IsValidAttachmentModel implements Rule}/**- * @param int $value+ * @param int $value** @return bool*/@@ -205,7 +205,7 @@ class IsValidAttachmentModel implements Rule}/**- * @param int $value+ * @param int $value** @return bool*/@@ -219,7 +219,7 @@ class IsValidAttachmentModel implements Rule}/**- * @param int $value+ * @param int $value** @return bool*/@@ -229,6 +229,6 @@ class IsValidAttachmentModel implements Rule$repository = app(JournalAPIRepositoryInterface::class);$repository->setUser(auth()->user());- return null !== $repository->findTransaction((int) $value);+ return null !== $repository->findTransaction((int)$value);}}diff --git a/app/Rules/IsValidBulkClause.php b/app/Rules/IsValidBulkClause.phpindex 9b35893fb8..6211463fca 100644--- a/app/Rules/IsValidBulkClause.php+++ b/app/Rules/IsValidBulkClause.php@@ -37,12 +37,12 @@ class IsValidBulkClause implements Ruleprivate array $rules;/**- * @param string $type+ * @param string $type*/public function __construct(string $type){$this->rules = config(sprintf('bulk.%s', $type));- $this->error = (string) trans('firefly.belongs_user');+ $this->error = (string)trans('firefly.belongs_user');}/**@@ -54,14 +54,14 @@ class IsValidBulkClause implements Rule}/**- * @param string $attribute- * @param mixed $value+ * @param string $attribute+ * @param mixed $value** @return bool*/public function passes($attribute, $value): bool{- $result = $this->basicValidation((string) $value);+ $result = $this->basicValidation((string)$value);if (false === $result) {return false;}@@ -72,7 +72,7 @@ class IsValidBulkClause implements Rule/*** Does basic rule based validation.*- * @param string $value+ * @param string $value** @return bool*/@@ -81,24 +81,24 @@ class IsValidBulkClause implements Ruletry {$array = json_decode($value, true, 8, JSON_THROW_ON_ERROR);} catch (JsonException $e) {- $this->error = (string) trans('validation.json');+ $this->error = (string)trans('validation.json');return false;}$clauses = ['where', 'update'];foreach ($clauses as $clause) {if (!array_key_exists($clause, $array)) {- $this->error = (string) trans(sprintf('validation.missing_%s', $clause));+ $this->error = (string)trans(sprintf('validation.missing_%s', $clause));return false;}/*** @var string $arrayKey- * @var mixed $arrayValue+ * @var mixed $arrayValue*/foreach ($array[$clause] as $arrayKey => $arrayValue) {if (!array_key_exists($arrayKey, $this->rules[$clause])) {- $this->error = (string) trans(sprintf('validation.invalid_%s_key', $clause));+ $this->error = (string)trans(sprintf('validation.invalid_%s_key', $clause));return false;}diff --git a/app/Rules/LessThanPiggyTarget.php b/app/Rules/LessThanPiggyTarget.phpindex 9e4567ec55..8ac44f63f5 100644--- a/app/Rules/LessThanPiggyTarget.php+++ b/app/Rules/LessThanPiggyTarget.php@@ -38,14 +38,14 @@ class LessThanPiggyTarget implements Rule*/public function message(): string{- return (string) trans('validation.current_target_amount');+ return (string)trans('validation.current_target_amount');}/*** Determine if the validation rule passes.*- * @param string $attribute- * @param mixed $value+ * @param string $attribute+ * @param mixed $value** @return bool*/diff --git a/app/Rules/UniqueAccountNumber.php b/app/Rules/UniqueAccountNumber.phpindex 32b5e80474..4bc92a4c44 100644--- a/app/Rules/UniqueAccountNumber.php+++ b/app/Rules/UniqueAccountNumber.php@@ -42,8 +42,8 @@ class UniqueAccountNumber implements Rule** @codeCoverageIgnore*- * @param Account|null $account- * @param string|null $expectedType+ * @param Account|null $account+ * @param string|null $expectedType*/public function __construct(?Account $account, ?string $expectedType){@@ -72,14 +72,14 @@ class UniqueAccountNumber implements Rule*/public function message(): string{- return (string) trans('validation.unique_account_number_for_user');+ return (string)trans('validation.unique_account_number_for_user');}/*** Determine if the validation rule passes.*- * @param string $attribute- * @param mixed $value+ * @param string $attribute+ * @param mixed $value** @return bool*@@ -143,19 +143,19 @@ class UniqueAccountNumber implements Rule}/**- * @param string $type- * @param string $accountNumber+ * @param string $type+ * @param string $accountNumber** @return int*/private function countHits(string $type, string $accountNumber): int{$query = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')- ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')- ->where('accounts.user_id', auth()->user()->id)- ->where('account_types.type', $type)- ->where('account_meta.name', '=', 'account_number')- ->where('account_meta.data', json_encode($accountNumber));+ ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')+ ->where('accounts.user_id', auth()->user()->id)+ ->where('account_types.type', $type)+ ->where('account_meta.name', '=', 'account_number')+ ->where('account_meta.data', json_encode($accountNumber));if (null !== $this->account) {$query->where('accounts.id', '!=', $this->account->id);diff --git a/app/Rules/UniqueIban.php b/app/Rules/UniqueIban.phpindex 6b807e04b9..5edebb1199 100644--- a/app/Rules/UniqueIban.php+++ b/app/Rules/UniqueIban.php@@ -41,8 +41,8 @@ class UniqueIban implements Rule** @codeCoverageIgnore*- * @param Account|null $account- * @param string|null $expectedType+ * @param Account|null $account+ * @param string|null $expectedType*/public function __construct(?Account $account, ?string $expectedType){@@ -69,14 +69,14 @@ class UniqueIban implements Rule*/public function message(): string{- return (string) trans('validation.unique_iban_for_user');+ return (string)trans('validation.unique_iban_for_user');}/*** Determine if the validation rule passes.*- * @param string $attribute- * @param mixed $value+ * @param string $attribute+ * @param mixed $value** @return bool*@@ -139,8 +139,8 @@ class UniqueIban implements Rule}/**- * @param string $type- * @param string $iban+ * @param string $type+ * @param string $iban** @return int*/diff --git a/app/Rules/ValidJournals.php b/app/Rules/ValidJournals.phpindex e9575a4bc8..5618fbfe98 100644--- a/app/Rules/ValidJournals.php+++ b/app/Rules/ValidJournals.php@@ -42,14 +42,14 @@ class ValidJournals implements Rule*/public function message(): string{- return (string) trans('validation.invalid_selection');+ return (string)trans('validation.invalid_selection');}/*** Determine if the validation rule passes.*- * @param string $attribute- * @param mixed $value+ * @param string $attribute+ * @param mixed $value** @return bool*diff --git a/app/Rules/ValidRecurrenceRepetitionType.php b/app/Rules/ValidRecurrenceRepetitionType.phpindex f8c1d0188f..74af36d979 100644--- a/app/Rules/ValidRecurrenceRepetitionType.php+++ b/app/Rules/ValidRecurrenceRepetitionType.php@@ -39,21 +39,21 @@ class ValidRecurrenceRepetitionType implements Rule*/public function message(): string{- return (string) trans('validation.valid_recurrence_rep_type');+ return (string)trans('validation.valid_recurrence_rep_type');}/*** Determine if the validation rule passes.*- * @param string $attribute- * @param mixed $value+ * @param string $attribute+ * @param mixed $value** @return bool**/public function passes($attribute, $value): bool{- $value = (string) $value;+ $value = (string)$value;if ('daily' === $value) {return true;}diff --git a/app/Rules/ValidRecurrenceRepetitionValue.php b/app/Rules/ValidRecurrenceRepetitionValue.phpindex f9fd59b45f..8860d5a6d8 100644--- a/app/Rules/ValidRecurrenceRepetitionValue.php+++ b/app/Rules/ValidRecurrenceRepetitionValue.php@@ -42,21 +42,21 @@ class ValidRecurrenceRepetitionValue implements Rule*/public function message(): string{- return (string) trans('validation.valid_recurrence_rep_type');+ return (string)trans('validation.valid_recurrence_rep_type');}/*** Determine if the validation rule passes.*- * @param string $attribute- * @param mixed $value+ * @param string $attribute+ * @param mixed $value** @return bool**/public function passes($attribute, $value): bool{- $value = (string) $value;+ $value = (string)$value;if ('daily' === $value) {return true;@@ -86,19 +86,19 @@ class ValidRecurrenceRepetitionValue implements Rule}/**- * @param string $value+ * @param string $value** @return bool*/private function validateMonthly(string $value): bool{- $dayOfMonth = (int) substr($value, 8);+ $dayOfMonth = (int)substr($value, 8);return $dayOfMonth > 0 && $dayOfMonth < 32;}/**- * @param string $value+ * @param string $value** @return bool*@@ -109,8 +109,8 @@ class ValidRecurrenceRepetitionValue implements Ruleif (2 !== count($parameters)) {return false;}- $nthDay = (int) ($parameters[0] ?? 0.0);- $dayOfWeek = (int) ($parameters[1] ?? 0.0);+ $nthDay = (int)($parameters[0] ?? 0.0);+ $dayOfWeek = (int)($parameters[1] ?? 0.0);if ($nthDay < 1 || $nthDay > 5) {return false;}@@ -119,19 +119,19 @@ class ValidRecurrenceRepetitionValue implements Rule}/**- * @param string $value+ * @param string $value** @return bool*/private function validateWeekly(string $value): bool{- $dayOfWeek = (int) substr($value, 7);+ $dayOfWeek = (int)substr($value, 7);return $dayOfWeek > 0 && $dayOfWeek < 8;}/**- * @param string $value+ * @param string $value** @return bool*/diff --git a/app/Services/FireflyIIIOrg/Update/UpdateRequest.php b/app/Services/FireflyIIIOrg/Update/UpdateRequest.phpindex 9dd876f513..d8d5b24ebe 100644--- a/app/Services/FireflyIIIOrg/Update/UpdateRequest.php+++ b/app/Services/FireflyIIIOrg/Update/UpdateRequest.php@@ -37,7 +37,7 @@ use Log;class UpdateRequest implements UpdateRequestInterface{/**- * @param string $channel+ * @param string $channel** @return array*/@@ -46,7 +46,7 @@ class UpdateRequest implements UpdateRequestInterfaceLog::debug(sprintf('Now in getUpdateInformation(%s)', $channel));$information = ['level' => 'error',- 'message' => (string) trans('firefly.unknown_error'),+ 'message' => (string)trans('firefly.unknown_error'),];// try get array from update server:@@ -64,7 +64,7 @@ class UpdateRequest implements UpdateRequestInterface}/**- * @param string $channel+ * @param string $channel** @return array*/@@ -76,7 +76,7 @@ class UpdateRequest implements UpdateRequestInterface'version' => config('firefly.version'),'date' => Carbon::today()->startOfDay(),'level' => 'error',- 'message' => (string) trans('firefly.unknown_error'),+ 'message' => (string)trans('firefly.unknown_error'),];$url = config('firefly.update_endpoint');@@ -101,12 +101,12 @@ class UpdateRequest implements UpdateRequestInterfaceif (200 !== $res->getStatusCode()) {Log::error(sprintf('Response status from server is %d.', $res->getStatusCode()));- Log::error((string) $res->getBody());+ Log::error((string)$res->getBody());$return['message'] = sprintf('Error: %d', $res->getStatusCode());return $return;}- $body = (string) $res->getBody();+ $body = (string)$res->getBody();try {$json = json_decode($body, true, 512, JSON_THROW_ON_ERROR);} catch (JsonException $e) {@@ -134,7 +134,7 @@ class UpdateRequest implements UpdateRequestInterface}/**- * @param array $information+ * @param array $information** @return array*/@@ -143,7 +143,7 @@ class UpdateRequest implements UpdateRequestInterfaceLog::debug('Now in parseResult()', $information);$return = ['level' => 'error',- 'message' => (string) trans('firefly.unknown_error'),+ 'message' => (string)trans('firefly.unknown_error'),];$current = config('firefly.version');$latest = $information['version'];@@ -154,7 +154,7 @@ class UpdateRequest implements UpdateRequestInterface// -1: you're running a newer version:if (-1 === $compare) {$return['level'] = 'info';- $return['message'] = (string) trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $latest]);+ $return['message'] = (string)trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $latest]);Log::debug('User is running a newer version', $return);return $return;@@ -162,7 +162,7 @@ class UpdateRequest implements UpdateRequestInterface// running the current version:if (0 === $compare) {$return['level'] = 'info';- $return['message'] = (string) trans('firefly.update_current_version_alert', ['version' => $current]);+ $return['message'] = (string)trans('firefly.update_current_version_alert', ['version' => $current]);Log::debug('User is the current version.', $return);return $return;@@ -177,11 +177,12 @@ class UpdateRequest implements UpdateRequestInterface// it's still very fresh, and user wants a stable release:if ($diff <= $expectedDiff) {$return['level'] = 'info';- $return['message'] = (string) trans(+ $return['message'] = (string)trans('firefly.just_new_release',- ['version' => $latest,- 'date' => $released->isoFormat((string) trans('config.month_and_day_js')),- 'days' => $expectedDiff,+ [+ 'version' => $latest,+ 'date' => $released->isoFormat((string)trans('config.month_and_day_js')),+ 'days' => $expectedDiff,]);Log::debug('Release is very fresh.', $return);@@ -191,12 +192,13 @@ class UpdateRequest implements UpdateRequestInterface// it's been around for a while:$return['level'] = 'success';- $return['message'] = (string) trans(+ $return['message'] = (string)trans('firefly.update_new_version_alert',['your_version' => $current,'new_version' => $latest,- 'date' => $released->isoFormat((string) trans('config.month_and_day_js'))]+ 'date' => $released->isoFormat((string)trans('config.month_and_day_js')),+ ]);Log::debug('New release is old enough.');diff --git a/app/Services/FireflyIIIOrg/Update/UpdateRequestInterface.php b/app/Services/FireflyIIIOrg/Update/UpdateRequestInterface.phpindex de0e8f294b..e616837222 100644--- a/app/Services/FireflyIIIOrg/Update/UpdateRequestInterface.php+++ b/app/Services/FireflyIIIOrg/Update/UpdateRequestInterface.php@@ -30,7 +30,7 @@ namespace FireflyIII\Services\FireflyIIIOrg\Update;interface UpdateRequestInterface{/**- * @param string $channel+ * @param string $channel** @return array*/diff --git a/app/Services/Internal/Destroy/AccountDestroyService.php b/app/Services/Internal/Destroy/AccountDestroyService.phpindex 4a7b30f40b..52bf6d61eb 100644--- a/app/Services/Internal/Destroy/AccountDestroyService.php+++ b/app/Services/Internal/Destroy/AccountDestroyService.php@@ -41,8 +41,8 @@ use stdClass;class AccountDestroyService{/**- * @param Account $account- * @param Account|null $moveTo+ * @param Account $account+ * @param Account|null $moveTo** @return void*/@@ -76,7 +76,7 @@ class AccountDestroyService}/**- * @param Account $account+ * @param Account $account*/private function destroyOpeningBalance(Account $account): void{@@ -87,13 +87,13 @@ class AccountDestroyService->where('transaction_types.type', TransactionType::OPENING_BALANCE)->get(['transactions.transaction_journal_id']);if ($set->count() > 0) {- $journalId = (int) $set->first()->transaction_journal_id;+ $journalId = (int)$set->first()->transaction_journal_id;Log::debug(sprintf('Found opening balance journal with ID #%d', $journalId));// get transactions with this journal (should be just one):$transactions = Transaction::where('transaction_journal_id', $journalId)- ->where('account_id', '!=', $account->id)- ->get();+ ->where('account_id', '!=', $account->id)+ ->get();/** @var Transaction $transaction */foreach ($transactions as $transaction) {Log::debug(sprintf('Found transaction with ID #%d', $transaction->id));@@ -112,8 +112,8 @@ class AccountDestroyService}/**- * @param Account $account- * @param Account $moveTo+ * @param Account $account+ * @param Account $moveTo*/public function moveTransactions(Account $account, Account $moveTo): void{@@ -132,8 +132,8 @@ class AccountDestroyService$user = $account->user;/** @var stdClass $row */foreach ($collection as $row) {- if ((int) $row->the_count > 1) {- $journalId = (int) $row->transaction_journal_id;+ if ((int)$row->the_count > 1) {+ $journalId = (int)$row->transaction_journal_id;$journal = $user->transactionJournals()->find($journalId);if (null !== $journal) {Log::debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id));@@ -144,8 +144,8 @@ class AccountDestroyService}/**- * @param Account $account- * @param Account $moveTo+ * @param Account $account+ * @param Account $moveTo*/private function updateRecurrences(Account $account, Account $moveTo): void{@@ -154,28 +154,28 @@ class AccountDestroyService}/**- * @param Account $account+ * @param Account $account*/private function destroyJournals(Account $account): void{/** @var JournalDestroyService $service */$service = app(JournalDestroyService::class);- Log::debug('Now trigger account delete response #' . $account->id);+ Log::debug('Now trigger account delete response #'.$account->id);/** @var Transaction $transaction */foreach ($account->transactions()->get() as $transaction) {- Log::debug('Now at transaction #' . $transaction->id);+ Log::debug('Now at transaction #'.$transaction->id);/** @var TransactionJournal $journal */$journal = $transaction->transactionJournal()->first();if (null !== $journal) {- Log::debug('Call for deletion of journal #' . $journal->id);+ Log::debug('Call for deletion of journal #'.$journal->id);$service->destroy($journal);}}}/**- * @param Account $account+ * @param Account $account*/private function destroyRecurrences(Account $account): void{@@ -189,7 +189,7 @@ class AccountDestroyService/** @var RecurrenceDestroyService $destroyService */$destroyService = app(RecurrenceDestroyService::class);foreach ($recurrences as $recurrenceId) {- $destroyService->destroyById((int) $recurrenceId);+ $destroyService->destroyById((int)$recurrenceId);}}}diff --git a/app/Services/Internal/Destroy/BillDestroyService.php b/app/Services/Internal/Destroy/BillDestroyService.phpindex cd6f4d5d62..48e53f0b8b 100644--- a/app/Services/Internal/Destroy/BillDestroyService.php+++ b/app/Services/Internal/Destroy/BillDestroyService.php@@ -33,7 +33,7 @@ use FireflyIII\Models\Bill;class BillDestroyService{/**- * @param Bill $bill+ * @param Bill $bill*/public function destroy(Bill $bill): void{diff --git a/app/Services/Internal/Destroy/BudgetDestroyService.php b/app/Services/Internal/Destroy/BudgetDestroyService.phpindex 19595df179..df0b279b99 100644--- a/app/Services/Internal/Destroy/BudgetDestroyService.php+++ b/app/Services/Internal/Destroy/BudgetDestroyService.php@@ -35,7 +35,7 @@ use FireflyIII\Models\Budget;class BudgetDestroyService{/**- * @param Budget $budget+ * @param Budget $budget*/public function destroy(Budget $budget): void{@@ -51,10 +51,10 @@ class BudgetDestroyService}// also delete all relations between categories and transaction journals:- DB::table('budget_transaction_journal')->where('budget_id', (int) $budget->id)->delete();+ DB::table('budget_transaction_journal')->where('budget_id', (int)$budget->id)->delete();// also delete all relations between categories and transactions:- DB::table('budget_transaction')->where('budget_id', (int) $budget->id)->delete();+ DB::table('budget_transaction')->where('budget_id', (int)$budget->id)->delete();// also delete all budget limits$budget->budgetlimits()->delete();diff --git a/app/Services/Internal/Destroy/CategoryDestroyService.php b/app/Services/Internal/Destroy/CategoryDestroyService.phpindex 45facd1535..f79ec91050 100644--- a/app/Services/Internal/Destroy/CategoryDestroyService.php+++ b/app/Services/Internal/Destroy/CategoryDestroyService.php@@ -35,7 +35,7 @@ use FireflyIII\Models\Category;class CategoryDestroyService{/**- * @param Category $category+ * @param Category $category*/public function destroy(Category $category): void{@@ -46,9 +46,9 @@ class CategoryDestroyService}// also delete all relations between categories and transaction journals:- DB::table('category_transaction_journal')->where('category_id', (int) $category->id)->delete();+ DB::table('category_transaction_journal')->where('category_id', (int)$category->id)->delete();// also delete all relations between categories and transactions:- DB::table('category_transaction')->where('category_id', (int) $category->id)->delete();+ DB::table('category_transaction')->where('category_id', (int)$category->id)->delete();}}diff --git a/app/Services/Internal/Destroy/CurrencyDestroyService.php b/app/Services/Internal/Destroy/CurrencyDestroyService.phpindex 92cb738ba9..bbaab9d043 100644--- a/app/Services/Internal/Destroy/CurrencyDestroyService.php+++ b/app/Services/Internal/Destroy/CurrencyDestroyService.php@@ -34,7 +34,7 @@ use FireflyIII\Models\TransactionCurrency;class CurrencyDestroyService{/**- * @param TransactionCurrency $currency+ * @param TransactionCurrency $currency*/public function destroy(TransactionCurrency $currency): void{diff --git a/app/Services/Internal/Destroy/JournalDestroyService.php b/app/Services/Internal/Destroy/JournalDestroyService.phpindex 65a4954d8c..3d52a1c108 100644--- a/app/Services/Internal/Destroy/JournalDestroyService.php+++ b/app/Services/Internal/Destroy/JournalDestroyService.php@@ -39,7 +39,7 @@ use Log;class JournalDestroyService{/**- * @param TransactionJournal $journal+ * @param TransactionJournal $journal*/public function destroy(TransactionJournal $journal): void{diff --git a/app/Services/Internal/Destroy/RecurrenceDestroyService.php b/app/Services/Internal/Destroy/RecurrenceDestroyService.phpindex 8542cf64f2..d010737f1a 100644--- a/app/Services/Internal/Destroy/RecurrenceDestroyService.php+++ b/app/Services/Internal/Destroy/RecurrenceDestroyService.php@@ -36,7 +36,7 @@ class RecurrenceDestroyService/*** Delete recurrence by ID*- * @param int $recurrenceId+ * @param int $recurrenceId*/public function destroyById(int $recurrenceId): void{@@ -50,7 +50,7 @@ class RecurrenceDestroyService/*** Delete recurrence.*- * @param Recurrence $recurrence+ * @param Recurrence $recurrence**/public function destroy(Recurrence $recurrence): voiddiff --git a/app/Services/Internal/Destroy/TransactionGroupDestroyService.php b/app/Services/Internal/Destroy/TransactionGroupDestroyService.phpindex 886118eeaf..cbd4bfcfa9 100644--- a/app/Services/Internal/Destroy/TransactionGroupDestroyService.php+++ b/app/Services/Internal/Destroy/TransactionGroupDestroyService.php@@ -35,7 +35,7 @@ use FireflyIII\Models\TransactionGroup;class TransactionGroupDestroyService{/**- * @param TransactionGroup $transactionGroup+ * @param TransactionGroup $transactionGroup*/public function destroy(TransactionGroup $transactionGroup): void{diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.phpindex ebc524b083..16a77f63e3 100644--- a/app/Services/Internal/Support/AccountServiceTrait.php+++ b/app/Services/Internal/Support/AccountServiceTrait.php@@ -39,6 +39,7 @@ use FireflyIII\Models\TransactionGroup;use FireflyIII\Models\TransactionJournal;use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Services\Internal\Destroy\TransactionGroupDestroyService;+use JsonException;use Log;use Validator;@@ -377,7 +378,7 @@ trait AccountServiceTrait** @return TransactionCurrency* @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/protected function getCurrency(int $currencyId, string $currencyCode): TransactionCurrency{diff --git a/app/Services/Internal/Support/BillServiceTrait.php b/app/Services/Internal/Support/BillServiceTrait.phpindex 12c71baf00..98e17fe510 100644--- a/app/Services/Internal/Support/BillServiceTrait.php+++ b/app/Services/Internal/Support/BillServiceTrait.php@@ -37,9 +37,9 @@ use Log;trait BillServiceTrait{/**- * @param Bill $bill- * @param string $oldName- * @param string $newName+ * @param Bill $bill+ * @param string $oldName+ * @param string $newName*/public function updateBillActions(Bill $bill, string $oldName, string $newName): void{@@ -60,8 +60,8 @@ trait BillServiceTrait}/**- * @param Bill $bill- * @param string $note+ * @param Bill $bill+ * @param string $note** @return bool*/diff --git a/app/Services/Internal/Support/CreditRecalculateService.php b/app/Services/Internal/Support/CreditRecalculateService.phpindex 1936ef51b6..c37dbf181d 100644--- a/app/Services/Internal/Support/CreditRecalculateService.php+++ b/app/Services/Internal/Support/CreditRecalculateService.php@@ -262,7 +262,9 @@ class CreditRecalculateService&& 'credit' === $direction) {$amount = bcadd($amount, app('steam')->positive($usedAmount));- Log::debug(sprintf('Is withdrawal (%s) into credit liability #%d, will increase amount due to %s.', $transaction->account_id, $usedAmount, $amount));+ Log::debug(+ sprintf('Is withdrawal (%s) into credit liability #%d, will increase amount due to %s.', $transaction->account_id, $usedAmount, $amount)+ );return $amount;}diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.phpindex 9c93770831..dfddffd7ac 100644--- a/app/Services/Internal/Support/JournalServiceTrait.php+++ b/app/Services/Internal/Support/JournalServiceTrait.php@@ -50,9 +50,9 @@ trait JournalServiceTraitprivate TagFactory $tagFactory;/**- * @param string $transactionType- * @param string $direction- * @param array $data+ * @param string $transactionType+ * @param string $direction+ * @param array $data** @return Account|null* @codeCoverageIgnore@@ -88,8 +88,8 @@ trait JournalServiceTrait}/**- * @param array $data- * @param array $types+ * @param array $data+ * @param array $types** @return Account|null*/@@ -98,7 +98,7 @@ trait JournalServiceTrait$search = null;// first attempt, find by ID.if (null !== $data['id']) {- $search = $this->accountRepository->find((int) $data['id']);+ $search = $this->accountRepository->find((int)$data['id']);if (null !== $search && in_array($search->accountType->type, $types, true)) {Log::debug(sprintf('Found "account_id" object: #%d, "%s" of type %s', $search->id, $search->name, $search->accountType->type)@@ -110,9 +110,9 @@ trait JournalServiceTrait}/**- * @param Account|null $account- * @param array $data- * @param array $types+ * @param Account|null $account+ * @param array $data+ * @param array $types** @return Account|null*/@@ -137,22 +137,22 @@ trait JournalServiceTrait}/**- * @param Account|null $account- * @param array $data- * @param array $types+ * @param Account|null $account+ * @param array $data+ * @param array $types** @return Account|null*/private function findAccountByNumber(?Account $account, array $data, array $types): ?Account{// third attempt, find by account number- if (null === $account && null !== $data['number'] && '' !== (string) $data['number']) {+ if (null === $account && null !== $data['number'] && '' !== (string)$data['number']) {Log::debug(sprintf('Searching for account number "%s".', $data['number']));// find by preferred type.- $source = $this->accountRepository->findByAccountNumber((string) $data['number'], [$types[0]]);+ $source = $this->accountRepository->findByAccountNumber((string)$data['number'], [$types[0]]);// or any expected type.- $source = $source ?? $this->accountRepository->findByAccountNumber((string) $data['number'], $types);+ $source = $source ?? $this->accountRepository->findByAccountNumber((string)$data['number'], $types);if (null !== $source) {Log::debug(sprintf('Found account: #%d, %s', $source->id, $source->name));@@ -165,9 +165,9 @@ trait JournalServiceTrait}/**- * @param Account|null $account- * @param array $data- * @param array $types+ * @param Account|null $account+ * @param array $data+ * @param array $types** @return Account|null*/@@ -191,9 +191,9 @@ trait JournalServiceTrait}/**- * @param Account|null $account- * @param array $data- * @param string $preferredType+ * @param Account|null $account+ * @param array $data+ * @param string $preferredType** @return Account|null* @throws FireflyException@@ -218,12 +218,12 @@ trait JournalServiceTraitthrow new FireflyException(sprintf('TransactionFactory: Cannot create asset account with these values: %s', json_encode($data)));}// fix name of account if only IBAN is given:- if ('' === (string) $data['name'] && '' !== (string) $data['iban']) {+ if ('' === (string)$data['name'] && '' !== (string)$data['iban']) {Log::debug(sprintf('Account name is now IBAN ("%s")', $data['iban']));$data['name'] = $data['iban'];}// fix name of account if only number is given:- if ('' === (string) $data['name'] && '' !== (string) $data['number']) {+ if ('' === (string)$data['name'] && '' !== (string)$data['number']) {Log::debug(sprintf('Account name is now account number ("%s")', $data['number']));$data['name'] = $data['number'];}@@ -264,16 +264,16 @@ trait JournalServiceTrait}/**- * @param Account|null $account- * @param array $data- * @param array $types+ * @param Account|null $account+ * @param array $data+ * @param array $types** @return Account|null*/private function getCashAccount(?Account $account, array $data, array $types): ?Account{// return cash account.- if (null === $account && '' === (string) $data['name']+ if (null === $account && '' === (string)$data['name']&& in_array(AccountType::CASH, $types, true)) {$account = $this->accountRepository->getCashAccount();}@@ -282,7 +282,7 @@ trait JournalServiceTrait}/**- * @param string $amount+ * @param string $amount** @return string* @throws FireflyException@@ -302,7 +302,7 @@ trait JournalServiceTrait}/**- * @param string|null $amount+ * @param string|null $amount** @return string|null* @codeCoverageIgnore@@ -330,8 +330,8 @@ trait JournalServiceTrait}/**- * @param TransactionJournal $journal- * @param NullArrayObject $data+ * @param TransactionJournal $journal+ * @param NullArrayObject $data** @codeCoverageIgnore*/@@ -354,8 +354,8 @@ trait JournalServiceTrait}/**- * @param TransactionJournal $journal- * @param NullArrayObject $data+ * @param TransactionJournal $journal+ * @param NullArrayObject $data** @codeCoverageIgnore*/@@ -373,14 +373,14 @@ trait JournalServiceTrait}/**- * @param TransactionJournal $journal- * @param string|null $notes+ * @param TransactionJournal $journal+ * @param string|null $notes** @codeCoverageIgnore*/protected function storeNotes(TransactionJournal $journal, ?string $notes): void{- $notes = (string) $notes;+ $notes = (string)$notes;$note = $journal->notes()->first();if ('' !== $notes) {if (null === $note) {@@ -406,8 +406,8 @@ trait JournalServiceTrait/*** Link tags to journal.*- * @param TransactionJournal $journal- * @param array|null $tags+ * @param TransactionJournal $journal+ * @param array|null $tags** @codeCoverageIgnore*/@@ -423,7 +423,7 @@ trait JournalServiceTrait}Log::debug('Start of loop.');foreach ($tags as $string) {- $string = (string) $string;+ $string = (string)$string;Log::debug(sprintf('Now at tag "%s"', $string));if ('' !== $string) {$tag = $this->tagFactory->findOrCreate($string);diff --git a/app/Services/Internal/Support/LocationServiceTrait.php b/app/Services/Internal/Support/LocationServiceTrait.phpindex c2e1766e68..4652928a2b 100644--- a/app/Services/Internal/Support/LocationServiceTrait.php+++ b/app/Services/Internal/Support/LocationServiceTrait.php@@ -33,8 +33,8 @@ use Illuminate\Database\Eloquent\Model;trait LocationServiceTrait{/**- * @param Model $model- * @param array $data+ * @param Model $model+ * @param array $data** @return Location|null*/diff --git a/app/Services/Internal/Support/RecurringTransactionTrait.php b/app/Services/Internal/Support/RecurringTransactionTrait.phpindex 93eedd04bc..c3b0665c23 100644--- a/app/Services/Internal/Support/RecurringTransactionTrait.php+++ b/app/Services/Internal/Support/RecurringTransactionTrait.php@@ -41,6 +41,7 @@ use FireflyIII\Models\RecurrenceTransaction;use FireflyIII\Models\RecurrenceTransactionMeta;use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Validation\AccountValidator;+use JsonException;use Log;/**@@ -50,8 +51,8 @@ use Log;trait RecurringTransactionTrait{/**- * @param Recurrence $recurrence- * @param string $note+ * @param Recurrence $recurrence+ * @param string $note** @return bool*/@@ -81,8 +82,8 @@ trait RecurringTransactionTrait}/**- * @param Recurrence $recurrence- * @param array $repetitions+ * @param Recurrence $recurrence+ * @param array $repetitions*/protected function createRepetitions(Recurrence $recurrence, array $repetitions): void{@@ -103,11 +104,11 @@ trait RecurringTransactionTrait/*** Store transactions of a recurring transactions. It's complex but readable.*- * @param Recurrence $recurrence- * @param array $transactions+ * @param Recurrence $recurrence+ * @param array $transactions** @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/protected function createTransactions(Recurrence $recurrence, array $transactions): void{@@ -144,7 +145,7 @@ trait RecurringTransactionTraitif (!$validator->validateDestination(['id' => $destination->id])) {throw new FireflyException(sprintf('Destination invalid: %s', $validator->destError));}- if (array_key_exists('foreign_amount', $array) && '' === (string) $array['foreign_amount']) {+ if (array_key_exists('foreign_amount', $array) && '' === (string)$array['foreign_amount']) {unset($array['foreign_amount']);}// TODO typeOverrule. The account validator may have a different opinion on the type of the transaction.@@ -156,25 +157,25 @@ trait RecurringTransactionTrait'source_id' => $source->id,'destination_id' => $destination->id,'amount' => $array['amount'],- 'foreign_amount' => array_key_exists('foreign_amount', $array) ? (string) $array['foreign_amount'] : null,+ 'foreign_amount' => array_key_exists('foreign_amount', $array) ? (string)$array['foreign_amount'] : null,'description' => $array['description'],]);$transaction->save();if (array_key_exists('budget_id', $array)) {- $this->setBudget($transaction, (int) $array['budget_id']);+ $this->setBudget($transaction, (int)$array['budget_id']);}if (array_key_exists('bill_id', $array)) {- $this->setBill($transaction, (int) $array['bill_id']);+ $this->setBill($transaction, (int)$array['bill_id']);}if (array_key_exists('category_id', $array)) {- $this->setCategory($transaction, (int) $array['category_id']);+ $this->setCategory($transaction, (int)$array['category_id']);}// same for piggy bankif (array_key_exists('piggy_bank_id', $array)) {- $this->updatePiggyBank($transaction, (int) $array['piggy_bank_id']);+ $this->updatePiggyBank($transaction, (int)$array['piggy_bank_id']);}if (array_key_exists('tags', $array) && is_array($array['tags'])) {@@ -184,23 +185,23 @@ trait RecurringTransactionTrait}/**- * @param array $expectedTypes- * @param int|null $accountId- * @param string|null $accountName+ * @param array $expectedTypes+ * @param int|null $accountId+ * @param string|null $accountName** @return Account*/protected function findAccount(array $expectedTypes, ?int $accountId, ?string $accountName): Account{$result = null;- $accountId = (int) $accountId;- $accountName = (string) $accountName;+ $accountId = (int)$accountId;+ $accountName = (string)$accountName;/** @var AccountRepositoryInterface $repository */$repository = app(AccountRepositoryInterface::class);$repository->setUser($this->user);// if user has submitted an account ID, search for it.- $result = $repository->find((int) $accountId);+ $result = $repository->find((int)$accountId);if (null !== $result) {return $result;}@@ -234,8 +235,8 @@ trait RecurringTransactionTrait}/**- * @param RecurrenceTransaction $transaction- * @param int $budgetId+ * @param RecurrenceTransaction $transaction+ * @param int $budgetId*/private function setBudget(RecurrenceTransaction $transaction, int $budgetId): void{@@ -257,8 +258,8 @@ trait RecurringTransactionTrait}/**- * @param RecurrenceTransaction $transaction- * @param int $billId+ * @param RecurrenceTransaction $transaction+ * @param int $billId*/private function setBill(RecurrenceTransaction $transaction, int $billId): void{@@ -280,8 +281,8 @@ trait RecurringTransactionTrait}/**- * @param RecurrenceTransaction $transaction- * @param int $categoryId+ * @param RecurrenceTransaction $transaction+ * @param int $categoryId** @throws FireflyException*/@@ -309,8 +310,8 @@ trait RecurringTransactionTrait}/**- * @param RecurrenceTransaction $transaction- * @param int $piggyId+ * @param RecurrenceTransaction $transaction+ * @param int $piggyId*/protected function updatePiggyBank(RecurrenceTransaction $transaction, int $piggyId): void{@@ -334,8 +335,8 @@ trait RecurringTransactionTrait}/**- * @param RecurrenceTransaction $transaction- * @param array $tags+ * @param RecurrenceTransaction $transaction+ * @param array $tags*/protected function updateTags(RecurrenceTransaction $transaction, array $tags): void{@@ -355,7 +356,7 @@ trait RecurringTransactionTrait}/**- * @param Recurrence $recurrence+ * @param Recurrence $recurrence** @codeCoverageIgnore*/@@ -365,7 +366,7 @@ trait RecurringTransactionTrait}/**- * @param Recurrence $recurrence+ * @param Recurrence $recurrence** @codeCoverageIgnore*/diff --git a/app/Services/Internal/Support/TransactionTypeTrait.php b/app/Services/Internal/Support/TransactionTypeTrait.phpindex b21f9f03dc..518f06a327 100644--- a/app/Services/Internal/Support/TransactionTypeTrait.php+++ b/app/Services/Internal/Support/TransactionTypeTrait.php@@ -38,7 +38,7 @@ trait TransactionTypeTrait* Get the transaction type. Since this is mandatory, will throw an exception when nothing comes up. Will always* use TransactionType repository.*- * @param string $type+ * @param string $type** @return TransactionType* @throws FireflyExceptiondiff --git a/app/Services/Internal/Update/AccountUpdateService.php b/app/Services/Internal/Update/AccountUpdateService.phpindex 57029d206e..8c177f7732 100644--- a/app/Services/Internal/Update/AccountUpdateService.php+++ b/app/Services/Internal/Update/AccountUpdateService.php@@ -62,19 +62,11 @@ class AccountUpdateService$this->accountRepository = app(AccountRepositoryInterface::class);}- /**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }-/*** Update account data.*- * @param Account $account- * @param array $data+ * @param Account $account+ * @param array $data** @return Account* @throws FireflyException@@ -89,7 +81,7 @@ class AccountUpdateService// find currency, or use default currency instead.if (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {- $currency = $this->getCurrency((int) ($data['currency_id'] ?? null), (string) ($data['currency_code'] ?? null));+ $currency = $this->getCurrency((int)($data['currency_id'] ?? null), (string)($data['currency_code'] ?? null));unset($data['currency_code'], $data['currency_id']);$data['currency_id'] = $currency->id;}@@ -108,7 +100,7 @@ class AccountUpdateService// update note:if (array_key_exists('notes', $data) && null !== $data['notes']) {- $this->updateNote($account, (string) $data['notes']);+ $this->updateNote($account, (string)$data['notes']);}// update preferences if inactive:@@ -120,8 +112,16 @@ class AccountUpdateService}/**- * @param Account $account- * @param array $data+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }++ /**+ * @param Account $account+ * @param array $data** @return Account*/@@ -135,19 +135,19 @@ class AccountUpdateService$account->active = $data['active'];}if (array_key_exists('iban', $data)) {- $account->iban = app('steam')->filterSpaces((string) $data['iban']);+ $account->iban = app('steam')->filterSpaces((string)$data['iban']);}// set liability, but account must already be a liability.//$liabilityType = $data['liability_type'] ?? '';if ($this->isLiability($account) && array_key_exists('liability_type', $data)) {- $type = $this->getAccountType($data['liability_type']);+ $type = $this->getAccountType($data['liability_type']);$account->account_type_id = $type->id;}// set liability, alternative method used in v1 layout:if ($this->isLiability($account) && array_key_exists('account_type_id', $data)) {- $type = AccountType::find((int) $data['account_type_id']);+ $type = AccountType::find((int)$data['account_type_id']);if (null !== $type && in_array($type->type, config('firefly.valid_liabilities'), true)) {$account->account_type_id = $type->id;@@ -165,7 +165,7 @@ class AccountUpdateService}/**- * @param Account $account+ * @param Account $account** @return bool*/@@ -177,7 +177,7 @@ class AccountUpdateService}/**- * @param string $type+ * @param string $type** @return AccountType*/@@ -187,8 +187,8 @@ class AccountUpdateService}/**- * @param Account $account- * @param array $data+ * @param Account $account+ * @param array $data** @return Account*/@@ -208,7 +208,7 @@ class AccountUpdateServicereturn $account;}// get account type ID's because a join and an update is hard:- $oldOrder = (int) $account->order;+ $oldOrder = (int)$account->order;$newOrder = $data['order'];Log::debug(sprintf('Order is set to be updated from %s to %s', $oldOrder, $newOrder));$list = $this->getTypeIds([AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT]);@@ -246,15 +246,15 @@ class AccountUpdateServiceforeach ($array as $type) {/** @var AccountType $type */$type = AccountType::whereType($type)->first();- $return[] = (int) $type->id;+ $return[] = (int)$type->id;}return $return;}/**- * @param Account $account- * @param array $data+ * @param Account $account+ * @param array $data*/private function updateLocation(Account $account, array $data): void{@@ -283,8 +283,8 @@ class AccountUpdateService}/**- * @param Account $account- * @param array $data+ * @param Account $account+ * @param array $data** @throws FireflyException*/@@ -308,8 +308,8 @@ class AccountUpdateService}/**- * @param Account $account- * @param array $data+ * @param Account $account+ * @param array $data** @throws FireflyException*/@@ -338,7 +338,7 @@ class AccountUpdateService}/**- * @param Account $account+ * @param Account $account** @throws FireflyException*/@@ -355,12 +355,12 @@ class AccountUpdateService$array = $preference->data;Log::debug('Old array is: ', $array);Log::debug(sprintf('Must remove : %d', $account->id));- $removeAccountId = (int) $account->id;+ $removeAccountId = (int)$account->id;$new = [];foreach ($array as $value) {- if ((int) $value !== $removeAccountId) {+ if ((int)$value !== $removeAccountId) {Log::debug(sprintf('Will include: %d', $value));- $new[] = (int) $value;+ $new[] = (int)$value;}}Log::debug('Final new array is', $new);diff --git a/app/Services/Internal/Update/BillUpdateService.php b/app/Services/Internal/Update/BillUpdateService.phpindex eae4a4ad13..af0b98644c 100644--- a/app/Services/Internal/Update/BillUpdateService.php+++ b/app/Services/Internal/Update/BillUpdateService.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Services\Internal\Update;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Factory\TransactionCurrencyFactory;use FireflyIII\Models\Bill;use FireflyIII\Models\Rule;@@ -32,6 +33,7 @@ use FireflyIII\Repositories\ObjectGroup\CreatesObjectGroups;use FireflyIII\Services\Internal\Support\BillServiceTrait;use FireflyIII\User;use Illuminate\Support\Collection;+use JsonException;use Log;/**@@ -46,12 +48,12 @@ class BillUpdateServiceprotected User $user;/**- * @param Bill $bill- * @param array $data+ * @param Bill $bill+ * @param array $data** @return Bill- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/public function update(Bill $bill, array $data): Bill{@@ -59,7 +61,7 @@ class BillUpdateServiceif (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {$factory = app(TransactionCurrencyFactory::class);- $currency = $factory->find((int) ($data['currency_id'] ?? null), $data['currency_code'] ?? null) ??+ $currency = $factory->find((int)($data['currency_id'] ?? null), $data['currency_code'] ?? null) ??app('amount')->getDefaultCurrencyByUser($bill->user);// enable the currency if it isn't.@@ -81,14 +83,14 @@ class BillUpdateService];// update note:if (array_key_exists('notes', $data)) {- $this->updateNote($bill, (string) $data['notes']);+ $this->updateNote($bill, (string)$data['notes']);}// update order.if (array_key_exists('order', $data)) {// update the order of the piggy bank:- $oldOrder = (int) $bill->order;- $newOrder = (int) ($data['order'] ?? $oldOrder);+ $oldOrder = (int)$bill->order;+ $newOrder = (int)($data['order'] ?? $oldOrder);if ($oldOrder !== $newOrder) {$this->updateOrder($bill, $oldOrder, $newOrder);}@@ -120,7 +122,7 @@ class BillUpdateService}if (array_key_exists('object_group_id', $data)) {// try also with ID:- $objectGroupId = (int) ($data['object_group_id'] ?? 0);+ $objectGroupId = (int)($data['object_group_id'] ?? 0);if (0 !== $objectGroupId) {$objectGroup = $this->findObjectGroupById($objectGroupId);if (null !== $objectGroup) {@@ -140,27 +142,27 @@ class BillUpdateService}/**- * @param Bill $bill- * @param array $data+ * @param Bill $bill+ * @param array $data** @return Bill*/private function updateBillProperties(Bill $bill, array $data): Bill{- if (array_key_exists('name', $data) && '' !== (string) $data['name']) {+ if (array_key_exists('name', $data) && '' !== (string)$data['name']) {$bill->name = $data['name'];}- if (array_key_exists('amount_min', $data) && '' !== (string) $data['amount_min']) {+ if (array_key_exists('amount_min', $data) && '' !== (string)$data['amount_min']) {$bill->amount_min = $data['amount_min'];}- if (array_key_exists('amount_max', $data) && '' !== (string) $data['amount_max']) {+ if (array_key_exists('amount_max', $data) && '' !== (string)$data['amount_max']) {$bill->amount_max = $data['amount_max'];}- if (array_key_exists('date', $data) && '' !== (string) $data['date']) {+ if (array_key_exists('date', $data) && '' !== (string)$data['date']) {$bill->date = $data['date'];}- if (array_key_exists('repeat_freq', $data) && '' !== (string) $data['repeat_freq']) {+ if (array_key_exists('repeat_freq', $data) && '' !== (string)$data['repeat_freq']) {$bill->repeat_freq = $data['repeat_freq'];}if (array_key_exists('skip', $data)) {@@ -184,9 +186,9 @@ class BillUpdateService}/**- * @param Bill $bill- * @param int $oldOrder- * @param int $newOrder+ * @param Bill $bill+ * @param int $oldOrder+ * @param int $newOrder*/private function updateOrder(Bill $bill, int $oldOrder, int $newOrder): void{@@ -207,9 +209,9 @@ class BillUpdateService}/**- * @param Bill $bill- * @param array $oldData- * @param array $newData+ * @param Bill $bill+ * @param array $oldData+ * @param array $newData*/private function updateBillTriggers(Bill $bill, array $oldData, array $newData): void{@@ -228,7 +230,8 @@ class BillUpdateService'name' => 'description_contains','amount_min' => 'amount_more','amount_max' => 'amount_less',- 'transaction_currency_name' => 'currency_is'];+ 'transaction_currency_name' => 'currency_is',+ ];foreach ($fields as $field => $ruleTriggerKey) {if (!array_key_exists($field, $newData)) {continue;@@ -242,10 +245,10 @@ class BillUpdateService}/**- * @param Collection $rules- * @param string $key- * @param string $oldValue- * @param string $newValue+ * @param Collection $rules+ * @param string $key+ * @param string $oldValue+ * @param string $newValue*/private function updateRules(Collection $rules, string $key, string $oldValue, string $newValue): void{@@ -268,8 +271,8 @@ class BillUpdateService}/**- * @param Rule $rule- * @param string $key+ * @param Rule $rule+ * @param string $key** @return RuleTrigger|null*/diff --git a/app/Services/Internal/Update/CategoryUpdateService.php b/app/Services/Internal/Update/CategoryUpdateService.phpindex 369e4fd7cf..e50e2c24be 100644--- a/app/Services/Internal/Update/CategoryUpdateService.php+++ b/app/Services/Internal/Update/CategoryUpdateService.php@@ -51,7 +51,7 @@ class CategoryUpdateService}/**- * @param mixed $user+ * @param mixed $user*/public function setUser($user): void{@@ -59,8 +59,8 @@ class CategoryUpdateService}/**- * @param Category $category- * @param array $data+ * @param Category $category+ * @param array $data** @return Category* @throws Exception@@ -83,8 +83,8 @@ class CategoryUpdateService}/**- * @param string $oldName- * @param string $newName+ * @param string $oldName+ * @param string $newName*/private function updateRuleTriggers(string $oldName, string $newName): void{@@ -104,8 +104,8 @@ class CategoryUpdateService}/**- * @param string $oldName- * @param string $newName+ * @param string $oldName+ * @param string $newName*/private function updateRuleActions(string $oldName, string $newName): void{@@ -125,22 +125,22 @@ class CategoryUpdateService}/**- * @param string $oldName- * @param string $newName+ * @param string $oldName+ * @param string $newName*/private function updateRecurrences(string $oldName, string $newName): void{RecurrenceTransactionMeta::leftJoin('recurrences_transactions', 'rt_meta.rt_id', '=', 'recurrences_transactions.id')- ->leftJoin('recurrences', 'recurrences.id', '=', 'recurrences_transactions.recurrence_id')- ->where('recurrences.user_id', $this->user->id)- ->where('rt_meta.name', 'category_name')- ->where('rt_meta.value', $oldName)- ->update(['rt_meta.value' => $newName]);+ ->leftJoin('recurrences', 'recurrences.id', '=', 'recurrences_transactions.recurrence_id')+ ->where('recurrences.user_id', $this->user->id)+ ->where('rt_meta.name', 'category_name')+ ->where('rt_meta.value', $oldName)+ ->update(['rt_meta.value' => $newName]);}/**- * @param Category $category- * @param array $data+ * @param Category $category+ * @param array $data** @throws Exception*/diff --git a/app/Services/Internal/Update/CurrencyUpdateService.php b/app/Services/Internal/Update/CurrencyUpdateService.phpindex 07e678d810..bc8372a744 100644--- a/app/Services/Internal/Update/CurrencyUpdateService.php+++ b/app/Services/Internal/Update/CurrencyUpdateService.php@@ -33,22 +33,22 @@ use FireflyIII\Models\TransactionCurrency;class CurrencyUpdateService{/**- * @param TransactionCurrency $currency- * @param array $data+ * @param TransactionCurrency $currency+ * @param array $data** @return TransactionCurrency*/public function update(TransactionCurrency $currency, array $data): TransactionCurrency{- if (array_key_exists('code', $data) && '' !== (string) $data['code']) {+ if (array_key_exists('code', $data) && '' !== (string)$data['code']) {$currency->code = $data['code'];}- if (array_key_exists('symbol', $data) && '' !== (string) $data['symbol']) {+ if (array_key_exists('symbol', $data) && '' !== (string)$data['symbol']) {$currency->symbol = $data['symbol'];}- if (array_key_exists('name', $data) && '' !== (string) $data['name']) {+ if (array_key_exists('name', $data) && '' !== (string)$data['name']) {$currency->name = $data['name'];}diff --git a/app/Services/Internal/Update/GroupCloneService.php b/app/Services/Internal/Update/GroupCloneService.phpindex bb2fcab22d..3957164e92 100644--- a/app/Services/Internal/Update/GroupCloneService.php+++ b/app/Services/Internal/Update/GroupCloneService.php@@ -41,7 +41,7 @@ use FireflyIII\Models\TransactionJournalMeta;class GroupCloneService{/**- * @param TransactionGroup $group+ * @param TransactionGroup $group** @return TransactionGroup*/@@ -50,16 +50,16 @@ class GroupCloneService$newGroup = $group->replicate();$newGroup->save();foreach ($group->transactionJournals as $journal) {- $this->cloneJournal($journal, $newGroup, (int) $group->id);+ $this->cloneJournal($journal, $newGroup, (int)$group->id);}return $newGroup;}/**- * @param TransactionJournal $journal- * @param TransactionGroup $newGroup- * @param int $originalGroup+ * @param TransactionJournal $journal+ * @param TransactionGroup $newGroup+ * @param int $originalGroup*/private function cloneJournal(TransactionJournal $journal, TransactionGroup $newGroup, int $originalGroup): void{@@ -107,17 +107,17 @@ class GroupCloneService// add relation.// TODO clone ALL linked piggy banks/** @var PiggyBankEvent $event */- $event = $journal->piggyBankEvents()->first();+ $event = $journal->piggyBankEvents()->first();if (null !== $event) {$piggyBank = $event->piggyBank;- $factory = app(PiggyBankEventFactory::class);+ $factory = app(PiggyBankEventFactory::class);$factory->create($newJournal, $piggyBank);}}/**- * @param Transaction $transaction- * @param TransactionJournal $newJournal+ * @param Transaction $transaction+ * @param TransactionJournal $newJournal*/private function cloneTransaction(Transaction $transaction, TransactionJournal $newJournal): void{@@ -128,9 +128,9 @@ class GroupCloneService}/**- * @param Note $note- * @param TransactionJournal $newJournal- * @param int $oldGroupId+ * @param Note $note+ * @param TransactionJournal $newJournal+ * @param int $oldGroupId*/private function cloneNote(Note $note, TransactionJournal $newJournal, int $oldGroupId): void{@@ -144,8 +144,8 @@ class GroupCloneService}/**- * @param TransactionJournalMeta $meta- * @param TransactionJournal $newJournal+ * @param TransactionJournalMeta $meta+ * @param TransactionJournal $newJournal*/private function cloneMeta(TransactionJournalMeta $meta, TransactionJournal $newJournal): void{diff --git a/app/Services/Internal/Update/GroupUpdateService.php b/app/Services/Internal/Update/GroupUpdateService.phpindex 2817cf8ab4..7eeb574321 100644--- a/app/Services/Internal/Update/GroupUpdateService.php+++ b/app/Services/Internal/Update/GroupUpdateService.php@@ -29,6 +29,7 @@ use FireflyIII\Factory\TransactionJournalFactory;use FireflyIII\Models\TransactionGroup;use FireflyIII\Models\TransactionJournal;use FireflyIII\Services\Internal\Destroy\JournalDestroyService;+use JsonException;use Log;/**@@ -39,8 +40,8 @@ class GroupUpdateService/*** Update a transaction group.*- * @param TransactionGroup $transactionGroup- * @param array $data+ * @param TransactionGroup $transactionGroup+ * @param array $data** @return TransactionGroup* @throws DuplicateTransactionException@@ -96,7 +97,7 @@ class GroupUpdateService/** @var string $deletedId */foreach ($result as $deletedId) {/** @var TransactionJournal $journal */- $journal = $transactionGroup->transactionJournals()->find((int) $deletedId);+ $journal = $transactionGroup->transactionJournals()->find((int)$deletedId);/** @var JournalDestroyService $service */$service = app(JournalDestroyService::class);$service->destroy($journal);@@ -112,9 +113,9 @@ class GroupUpdateService/*** Update single journal.*- * @param TransactionGroup $transactionGroup- * @param TransactionJournal $journal- * @param array $data+ * @param TransactionGroup $transactionGroup+ * @param TransactionJournal $journal+ * @param array $data*/private function updateTransactionJournal(TransactionGroup $transactionGroup, TransactionJournal $journal, array $data): void{@@ -134,8 +135,8 @@ class GroupUpdateService}/**- * @param TransactionGroup $transactionGroup- * @param array $transactions+ * @param TransactionGroup $transactionGroup+ * @param array $transactions** @return array* @throws DuplicateTransactionException@@ -147,12 +148,12 @@ class GroupUpdateService// updated or created transaction journals:$updated = [];/**- * @var int $index+ * @var int $index* @var array $transaction*/foreach ($transactions as $index => $transaction) {Log::debug(sprintf('Now at #%d of %d', ($index + 1), count($transactions)), $transaction);- $journalId = (int) ($transaction['transaction_journal_id'] ?? 0);+ $journalId = (int)($transaction['transaction_journal_id'] ?? 0);/** @var TransactionJournal|null $journal */$journal = $transactionGroup->transactionJournals()->find($journalId);if (null === $journal) {@@ -190,14 +191,14 @@ class GroupUpdateService}/**- * @param TransactionGroup $transactionGroup- * @param array $data+ * @param TransactionGroup $transactionGroup+ * @param array $data** @return TransactionJournal|null** @throws DuplicateTransactionException* @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/private function createTransactionJournal(TransactionGroup $transactionGroup, array $data): ?TransactionJournal{diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.phpindex 27c09eb44c..b670ebdbdd 100644--- a/app/Services/Internal/Update/JournalUpdateService.php+++ b/app/Services/Internal/Update/JournalUpdateService.php@@ -82,14 +82,26 @@ class JournalUpdateService$this->tagFactory = app(TagFactory::class);$this->accountRepository = app(AccountRepositoryInterface::class);$this->currencyRepository = app(CurrencyRepositoryInterface::class);- $this->metaString = ['sepa_cc', 'sepa_ct_op', 'sepa_ct_id', 'sepa_db', 'sepa_country', 'sepa_ep', 'sepa_ci', 'sepa_batch_id',- 'recurrence_id',- 'internal_reference', 'bunq_payment_id', 'external_id', 'external_url'];+ $this->metaString = [+ 'sepa_cc',+ 'sepa_ct_op',+ 'sepa_ct_id',+ 'sepa_db',+ 'sepa_country',+ 'sepa_ep',+ 'sepa_ci',+ 'sepa_batch_id',+ 'recurrence_id',+ 'internal_reference',+ 'bunq_payment_id',+ 'external_id',+ 'external_url',+ ];$this->metaDate = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date',];}/**- * @param array $data+ * @param array $data*/public function setData(array $data): void{@@ -97,7 +109,7 @@ class JournalUpdateService}/**- * @param TransactionGroup $transactionGroup+ * @param TransactionGroup $transactionGroup*/public function setTransactionGroup(TransactionGroup $transactionGroup): void{@@ -114,7 +126,7 @@ class JournalUpdateService}/**- * @param TransactionJournal $transactionJournal+ * @param TransactionJournal $transactionJournal*/public function setTransactionJournal(TransactionJournal $transactionJournal): void{@@ -226,7 +238,7 @@ class JournalUpdateService}/**- * @param array $fields+ * @param array $fields** @return bool*/@@ -360,7 +372,7 @@ class JournalUpdateService}$sourceInfo = [- 'id' => (int) ($this->data['source_id'] ?? null),+ 'id' => (int)($this->data['source_id'] ?? null),'name' => $this->data['source_name'] ?? null,'iban' => $this->data['source_iban'] ?? null,'number' => $this->data['source_number'] ?? null,@@ -425,7 +437,7 @@ class JournalUpdateService}$destInfo = [- 'id' => (int) ($this->data['destination_id'] ?? null),+ 'id' => (int)($this->data['destination_id'] ?? null),'name' => $this->data['destination_name'] ?? null,'iban' => $this->data['destination_iban'] ?? null,'number' => $this->data['destination_number'] ?? null,@@ -490,8 +502,8 @@ class JournalUpdateService)&& TransactionType::WITHDRAWAL === $type) {- $billId = (int) ($this->data['bill_id'] ?? 0);- $billName = (string) ($this->data['bill_name'] ?? '');+ $billId = (int)($this->data['bill_id'] ?? 0);+ $billName = (string)($this->data['bill_name'] ?? '');$bill = $this->billRepository->findBill($billId, $billName);$this->transactionJournal->bill_id = $bill?->id;Log::debug('Updated bill ID');@@ -501,11 +513,11 @@ class JournalUpdateService/*** Update journal generic field. Cannot be set to NULL.*- * @param string $fieldName+ * @param string $fieldName*/private function updateField(string $fieldName): void{- if (array_key_exists($fieldName, $this->data) && '' !== (string) $this->data[$fieldName]) {+ if (array_key_exists($fieldName, $this->data) && '' !== (string)$this->data[$fieldName]) {$value = $this->data[$fieldName];if ('date' === $fieldName) {@@ -582,7 +594,7 @@ class JournalUpdateService{// update notes.if ($this->hasFields(['notes'])) {- $notes = '' === (string) $this->data['notes'] ? null : $this->data['notes'];+ $notes = '' === (string)$this->data['notes'] ? null : $this->data['notes'];$this->storeNotes($this->transactionJournal, $notes);}}@@ -639,7 +651,7 @@ class JournalUpdateServiceforeach ($this->metaDate as $field) {if ($this->hasFields([$field])) {try {- $value = '' === (string) $this->data[$field] ? null : new Carbon($this->data[$field]);+ $value = '' === (string)$this->data[$field] ? null : new Carbon($this->data[$field]);} catch (Exception $e) {Log::debug(sprintf('%s is not a valid date value: %s', $this->data[$field], $e->getMessage()));diff --git a/app/Services/Internal/Update/RecurrenceUpdateService.php b/app/Services/Internal/Update/RecurrenceUpdateService.phpindex 60327bc94f..329eff9886 100644--- a/app/Services/Internal/Update/RecurrenceUpdateService.php+++ b/app/Services/Internal/Update/RecurrenceUpdateService.php@@ -52,8 +52,8 @@ class RecurrenceUpdateService** TODO if the user updates the type, the accounts must be validated again.*- * @param Recurrence $recurrence- * @param array $data+ * @param Recurrence $recurrence+ * @param array $data** @return Recurrence* @throws FireflyException@@ -79,7 +79,7 @@ class RecurrenceUpdateService$recurrence->repetitions = 0;}if (array_key_exists('nr_of_repetitions', $info)) {- if (0 !== (int) $info['nr_of_repetitions']) {+ if (0 !== (int)$info['nr_of_repetitions']) {$recurrence->repeat_until = null;}$recurrence->repetitions = $info['nr_of_repetitions'];@@ -115,8 +115,8 @@ class RecurrenceUpdateService}/**- * @param Recurrence $recurrence- * @param string $text+ * @param Recurrence $recurrence+ * @param string $text*/private function setNoteText(Recurrence $recurrence, string $text): void{@@ -142,8 +142,8 @@ class RecurrenceUpdateService/***- * @param Recurrence $recurrence- * @param array $repetitions+ * @param Recurrence $recurrence+ * @param array $repetitions** @throws FireflyException*/@@ -187,8 +187,8 @@ class RecurrenceUpdateService}/**- * @param Recurrence $recurrence- * @param array $data+ * @param Recurrence $recurrence+ * @param array $data** @return RecurrenceRepetition|null*/@@ -201,11 +201,12 @@ class RecurrenceUpdateServicereturn $recurrence->recurrenceRepetitions()->first();}// find it:- $fields = ['id' => 'id',- 'type' => 'repetition_type',- 'moment' => 'repetition_moment',- 'skip' => 'repetition_skip',- 'weekend' => 'weekend',+ $fields = [+ 'id' => 'id',+ 'type' => 'repetition_type',+ 'moment' => 'repetition_moment',+ 'skip' => 'repetition_skip',+ 'weekend' => 'weekend',];$query = $recurrence->recurrenceRepetitions();foreach ($fields as $field => $column) {@@ -220,8 +221,8 @@ class RecurrenceUpdateService/*** TODO this method is very complex.*- * @param Recurrence $recurrence- * @param array $transactions+ * @param Recurrence $recurrence+ * @param array $transactions** @throws FireflyException*/@@ -258,7 +259,7 @@ class RecurrenceUpdateServiceunset($current['currency_id'], $current['currency_code']);}if (null !== $currency) {- $current['currency_id'] = (int) $currency->id;+ $current['currency_id'] = (int)$currency->id;}if (array_key_exists('foreign_currency_id', $current) || array_key_exists('foreign_currency_code', $current)) {$foreignCurrency = $currencyFactory->find($current['foreign_currency_id'] ?? null, $currency['foreign_currency_code'] ?? null);@@ -267,7 +268,7 @@ class RecurrenceUpdateServiceunset($current['foreign_currency_id'], $currency['foreign_currency_code']);}if (null !== $foreignCurrency) {- $current['foreign_currency_id'] = (int) $foreignCurrency->id;+ $current['foreign_currency_id'] = (int)$foreignCurrency->id;}// update fields@@ -288,35 +289,35 @@ class RecurrenceUpdateService}// update meta dataif (array_key_exists('budget_id', $current)) {- $this->setBudget($match, (int) $current['budget_id']);+ $this->setBudget($match, (int)$current['budget_id']);}if (array_key_exists('bill_id', $current)) {- $this->setBill($match, (int) $current['bill_id']);+ $this->setBill($match, (int)$current['bill_id']);}// reset category if name is set but empty:// can be removed when v1 is retired.- if (array_key_exists('category_name', $current) && '' === (string) $current['category_name']) {+ if (array_key_exists('category_name', $current) && '' === (string)$current['category_name']) {$current['category_name'] = null;$current['category_id'] = 0;}if (array_key_exists('category_id', $current)) {- $this->setCategory($match, (int) $current['category_id']);+ $this->setCategory($match, (int)$current['category_id']);}if (array_key_exists('tags', $current) && is_array($current['tags'])) {$this->updateTags($match, $current['tags']);}if (array_key_exists('piggy_bank_id', $current)) {- $this->updatePiggyBank($match, (int) $current['piggy_bank_id']);+ $this->updatePiggyBank($match, (int)$current['piggy_bank_id']);}}}}/**- * @param Recurrence $recurrence- * @param array $data+ * @param Recurrence $recurrence+ * @param array $data** @return RecurrenceTransaction|null*/diff --git a/app/Services/Password/PwndVerifierV2.php b/app/Services/Password/PwndVerifierV2.phpindex 7e40580e07..39bee2ca32 100644--- a/app/Services/Password/PwndVerifierV2.php+++ b/app/Services/Password/PwndVerifierV2.php@@ -1,4 +1,5 @@<?php+/*** PwndVerifierV2.php* Copyright (c) 2019 [email protected]@@ -38,7 +39,7 @@ class PwndVerifierV2 implements Verifier/*** Verify the given password against (some) service.*- * @param string $password+ * @param string $password** @return bool*/@@ -54,7 +55,8 @@ class PwndVerifierV2 implements Verifier'User-Agent' => sprintf('Firefly III v%s', config('firefly.version')),'Add-Padding' => 'true',],- 'timeout' => 3.1415];+ 'timeout' => 3.1415,+ ];Log::debug(sprintf('hash prefix is %s', $prefix));Log::debug(sprintf('rest is %s', $rest));diff --git a/app/Services/Password/Verifier.php b/app/Services/Password/Verifier.phpindex 0883aeaf64..ac688d7d6d 100644--- a/app/Services/Password/Verifier.php+++ b/app/Services/Password/Verifier.php@@ -1,4 +1,5 @@<?php+/*** Verifier.php* Copyright (c) 2019 [email protected]@@ -30,7 +31,7 @@ interface Verifier/*** Verify the given password against (some) service.*- * @param string $password+ * @param string $password** @return bool*/diff --git a/app/Services/Webhook/WebhookSenderInterface.php b/app/Services/Webhook/WebhookSenderInterface.phpindex 6b827fa9d0..e60aaf1fca 100644--- a/app/Services/Webhook/WebhookSenderInterface.php+++ b/app/Services/Webhook/WebhookSenderInterface.php@@ -41,7 +41,7 @@ interface WebhookSenderInterfacepublic function send(): void;/**- * @param WebhookMessage $message+ * @param WebhookMessage $message*/public function setMessage(WebhookMessage $message): void;}diff --git a/app/Support/Amount.php b/app/Support/Amount.phpindex 485a9fa94d..22afd97785 100644--- a/app/Support/Amount.php+++ b/app/Support/Amount.php@@ -29,8 +29,9 @@ use FireflyIII\Models\TransactionCurrency;use FireflyIII\User;use Illuminate\Contracts\Encryption\DecryptException;use Illuminate\Support\Collection;-use JsonException;use NumberFormatter;+use Psr\Container\ContainerExceptionInterface;+use Psr\Container\NotFoundExceptionInterface;/*** Class Amount.@@ -113,8 +114,8 @@ class Amount/*** @return string* @throws FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/public function getCurrencyCode(): string{diff --git a/app/Support/Authentication/RemoteUserGuard.php b/app/Support/Authentication/RemoteUserGuard.phpindex 24c415f7ed..8c9e5e5a40 100644--- a/app/Support/Authentication/RemoteUserGuard.php+++ b/app/Support/Authentication/RemoteUserGuard.php@@ -44,8 +44,8 @@ class RemoteUserGuard implements Guard/*** Create a new authentication guard.*- * @param UserProvider $provider- * @param Application $app+ * @param UserProvider $provider+ * @param Application $app*/public function __construct(UserProvider $provider, Application $app){@@ -81,7 +81,7 @@ class RemoteUserGuard implements Guard$header = config('auth.guard_email');if (null !== $header) {- $emailAddress = (string) (request()->server($header) ?? apache_request_headers()[$header] ?? null);+ $emailAddress = (string)(request()->server($header) ?? apache_request_headers()[$header] ?? null);$preference = app('preferences')->getForUser($retrievedUser, 'remote_guard_alt_email');if ('' !== $emailAddress && null === $preference && $emailAddress !== $userID) {diff --git a/app/Support/Binder/AccountList.php b/app/Support/Binder/AccountList.phpindex 2034ba5f2d..4d2c2b9e43 100644--- a/app/Support/Binder/AccountList.php+++ b/app/Support/Binder/AccountList.php@@ -1,4 +1,5 @@<?php+/*** AccountList.php* Copyright (c) 2019 [email protected]@@ -34,8 +35,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;class AccountList implements BinderInterface{/**- * @param string $value- * @param Route $route+ * @param string $value+ * @param Route $route** @return Collection* @throws NotFoundHttpExceptiondiff --git a/app/Support/Binder/BinderInterface.php b/app/Support/Binder/BinderInterface.phpindex 1aaefe4c30..e0b42449d1 100644--- a/app/Support/Binder/BinderInterface.php+++ b/app/Support/Binder/BinderInterface.php@@ -1,4 +1,5 @@<?php+/*** BinderInterface.php* Copyright (c) 2019 [email protected]@@ -30,8 +31,8 @@ use Illuminate\Routing\Route;interface BinderInterface{/**- * @param string $value- * @param Route $route+ * @param string $value+ * @param Route $route** @return mixed*/diff --git a/app/Support/Binder/BudgetList.php b/app/Support/Binder/BudgetList.phpindex a38842b2f8..5b17ac7ddf 100644--- a/app/Support/Binder/BudgetList.php+++ b/app/Support/Binder/BudgetList.php@@ -1,4 +1,5 @@<?php+/*** BudgetList.php* Copyright (c) 2019 [email protected]@@ -25,7 +26,6 @@ namespace FireflyIII\Support\Binder;use FireflyIII\Models\Budget;use Illuminate\Routing\Route;use Illuminate\Support\Collection;-use Log;use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/**@@ -34,8 +34,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;class BudgetList implements BinderInterface{/**- * @param string $value- * @param Route $route+ * @param string $value+ * @param Route $route** @return Collection* @throws NotFoundHttpExceptiondiff --git a/app/Support/Binder/CLIToken.php b/app/Support/Binder/CLIToken.phpindex 7825e0cd5a..e26a775aae 100644--- a/app/Support/Binder/CLIToken.php+++ b/app/Support/Binder/CLIToken.php@@ -35,8 +35,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;class CLIToken implements BinderInterface{/**- * @param string $value- * @param Route $route+ * @param string $value+ * @param Route $route** @return mixed* @throws FireflyException@@ -48,7 +48,7 @@ class CLIToken implements BinderInterface$users = $repository->all();// check for static token- if ($value === config('firefly.static_cron_token') && 32 === strlen((string) config('firefly.static_cron_token'))) {+ if ($value === config('firefly.static_cron_token') && 32 === strlen((string)config('firefly.static_cron_token'))) {return $value;}diff --git a/app/Support/Binder/CategoryList.php b/app/Support/Binder/CategoryList.phpindex f01677ada5..e37c23b8a0 100644--- a/app/Support/Binder/CategoryList.php+++ b/app/Support/Binder/CategoryList.php@@ -1,4 +1,5 @@<?php+/*** CategoryList.php* Copyright (c) 2019 [email protected]@@ -33,8 +34,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;class CategoryList implements BinderInterface{/**- * @param string $value- * @param Route $route+ * @param string $value+ * @param Route $route** @return Collection* @throws NotFoundHttpExceptiondiff --git a/app/Support/Binder/CurrencyCode.php b/app/Support/Binder/CurrencyCode.phpindex a790308322..7afbfc238b 100644--- a/app/Support/Binder/CurrencyCode.php+++ b/app/Support/Binder/CurrencyCode.php@@ -1,4 +1,5 @@<?php+/*** CurrencyCode.php* Copyright (c) 2019 [email protected]@@ -32,8 +33,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;class CurrencyCode implements BinderInterface{/**- * @param string $value- * @param Route $route+ * @param string $value+ * @param Route $route** @return TransactionCurrency* @throws NotFoundHttpExceptiondiff --git a/app/Support/Binder/Date.php b/app/Support/Binder/Date.phpindex 1cb1e18719..538746df47 100644--- a/app/Support/Binder/Date.php+++ b/app/Support/Binder/Date.php@@ -1,4 +1,5 @@<?php+/*** Date.php* Copyright (c) 2019 [email protected]@@ -35,8 +36,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;class Date implements BinderInterface{/**- * @param string $value- * @param Route $route+ * @param string $value+ * @param Route $route** @return Carbon* @throws NotFoundHttpExceptiondiff --git a/app/Support/Binder/DynamicConfigKey.php b/app/Support/Binder/DynamicConfigKey.phpindex e3fb1c608d..03d5c58133 100644--- a/app/Support/Binder/DynamicConfigKey.php+++ b/app/Support/Binder/DynamicConfigKey.php@@ -40,8 +40,8 @@ class DynamicConfigKey];/**- * @param string $value- * @param Route $route+ * @param string $value+ * @param Route $route** @return string* @throws NotFoundHttpExceptiondiff --git a/app/Support/Binder/EitherConfigKey.php b/app/Support/Binder/EitherConfigKey.phpindex f41db15cbf..a1638f7dfe 100644--- a/app/Support/Binder/EitherConfigKey.php+++ b/app/Support/Binder/EitherConfigKey.php@@ -57,8 +57,8 @@ class EitherConfigKey];/**- * @param string $value- * @param Route $route+ * @param string $value+ * @param Route $route** @return string* @throws NotFoundHttpExceptiondiff --git a/app/Support/Binder/JournalList.php b/app/Support/Binder/JournalList.phpindex 909920e183..4efbbf2c09 100644--- a/app/Support/Binder/JournalList.php+++ b/app/Support/Binder/JournalList.php@@ -1,4 +1,5 @@<?php+/*** JournalList.php* Copyright (c) 2019 [email protected]@@ -33,8 +34,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;class JournalList implements BinderInterface{/**- * @param string $value- * @param Route $route+ * @param string $value+ * @param Route $route** @return array*@@ -62,7 +63,7 @@ class JournalList implements BinderInterface}/**- * @param string $value+ * @param string $value** @return array*/diff --git a/app/Support/Binder/TagList.php b/app/Support/Binder/TagList.phpindex 6f78d35f53..8b432a07d0 100644--- a/app/Support/Binder/TagList.php+++ b/app/Support/Binder/TagList.php@@ -1,4 +1,5 @@<?php+/*** TagList.php* Copyright (c) 2019 [email protected]@@ -35,8 +36,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;class TagList implements BinderInterface{/**- * @param string $value- * @param Route $route+ * @param string $value+ * @param Route $route** @return Collection* @throws NotFoundHttpException@@ -68,7 +69,7 @@ class TagList implements BinderInterfaceif (in_array(strtolower($tag->tag), $list, true)) {return true;}- if (in_array((string) $tag->id, $list, true)) {+ if (in_array((string)$tag->id, $list, true)) {return true;}diff --git a/app/Support/Binder/TagOrId.php b/app/Support/Binder/TagOrId.phpindex 72ab7fb31a..12ecd26c0f 100644--- a/app/Support/Binder/TagOrId.php+++ b/app/Support/Binder/TagOrId.php@@ -1,4 +1,5 @@<?php+/*** TagOrId.php* Copyright (c) 2019 [email protected]@@ -34,8 +35,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;class TagOrId implements BinderInterface{/**- * @param string $value- * @param Route $route+ * @param string $value+ * @param Route $route** @return Tag*/@@ -48,7 +49,7 @@ class TagOrId implements BinderInterface$result = $repository->findByTag($value);if (null === $result) {- $result = $repository->find((int) $value);+ $result = $repository->find((int)$value);}if (null !== $result) {return $result;diff --git a/app/Support/CacheProperties.php b/app/Support/CacheProperties.phpindex 865a786bb2..df7adf5809 100644--- a/app/Support/CacheProperties.php+++ b/app/Support/CacheProperties.php@@ -1,4 +1,5 @@<?php+/*** CacheProperties.php* Copyright (c) 2019 [email protected]@@ -49,7 +50,7 @@ class CacheProperties}/**- * @param mixed $property+ * @param mixed $property*/public function addProperty($property): void{@@ -95,14 +96,14 @@ class CacheProperties$content .= json_encode($property, JSON_THROW_ON_ERROR);} catch (JsonException $e) {// @ignoreException- $content .= hash('sha256', (string) time());+ $content .= hash('sha256', (string)time());}}$this->hash = substr(hash('sha256', $content), 0, 16);}/**- * @param mixed $data+ * @param mixed $data*/public function store($data): void{diff --git a/app/Support/Chart/Budget/FrontpageChartGenerator.php b/app/Support/Chart/Budget/FrontpageChartGenerator.phpindex 0163a4b30d..633b339ddf 100644--- a/app/Support/Chart/Budget/FrontpageChartGenerator.php+++ b/app/Support/Chart/Budget/FrontpageChartGenerator.php@@ -1,4 +1,5 @@<?php+/*** FrontpageChartGenerator.php* Copyright (c) 2020 [email protected]@@ -23,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Support\Chart\Budget;use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Budget;use FireflyIII\Models\BudgetLimit;use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;@@ -64,9 +66,9 @@ class FrontpageChartGenerator{$budgets = $this->budgetRepository->getActiveBudgets();$data = [- ['label' => (string) trans('firefly.spent_in_budget'), 'entries' => [], 'type' => 'bar'],- ['label' => (string) trans('firefly.left_to_spend'), 'entries' => [], 'type' => 'bar'],- ['label' => (string) trans('firefly.overspent'), 'entries' => [], 'type' => 'bar'],+ ['label' => (string)trans('firefly.spent_in_budget'), 'entries' => [], 'type' => 'bar'],+ ['label' => (string)trans('firefly.left_to_spend'), 'entries' => [], 'type' => 'bar'],+ ['label' => (string)trans('firefly.overspent'), 'entries' => [], 'type' => 'bar'],];// loop al budgets:@@ -83,8 +85,8 @@ class FrontpageChartGenerator* When no limits are present, the time range is used to collect information on money spent.* If limits are present, each limit is processed individually.*- * @param array $data- * @param Budget $budget+ * @param array $data+ * @param Budget $budget** @return array*/@@ -105,8 +107,8 @@ class FrontpageChartGenerator* When no limits are present, the expenses of the whole period are collected and grouped.* This is grouped per currency. Because there is no limit set, "left to spend" and "overspent" are empty.*- * @param array $data- * @param Budget $budget+ * @param array $data+ * @param Budget $budget** @return array*/@@ -127,9 +129,9 @@ class FrontpageChartGenerator/*** If a budget has budget limit, each limit is processed individually.*- * @param array $data- * @param Budget $budget- * @param Collection $limits+ * @param array $data+ * @param Budget $budget+ * @param Collection $limits** @return array*/@@ -146,9 +148,9 @@ class FrontpageChartGenerator/*** For each limit, the expenses from the time range of the limit are collected. Each row from the result is processed individually.*- * @param array $data- * @param Budget $budget- * @param BudgetLimit $limit+ * @param array $data+ * @param Budget $budget+ * @param BudgetLimit $limit** @return array*/@@ -158,7 +160,7 @@ class FrontpageChartGenerator/** @var array $entry */foreach ($spent as $entry) {// only spent the entry where the entry's currency matches the budget limit's currency- if ($entry['currency_id'] === (int) $limit->transaction_currency_id) {+ if ($entry['currency_id'] === (int)$limit->transaction_currency_id) {$data = $this->processRow($data, $budget, $limit, $entry);}}@@ -172,10 +174,10 @@ class FrontpageChartGenerator* Each one is added to the $data array. If the limit's date range is different from the global $start and $end dates,* for example when a limit only partially falls into this month, the title is expanded to clarify.*- * @param array $data- * @param Budget $budget- * @param BudgetLimit $limit- * @param array $entry+ * @param array $data+ * @param Budget $budget+ * @param BudgetLimit $limit+ * @param array $entry** @return array*/@@ -201,7 +203,7 @@ class FrontpageChartGenerator}/**- * @param Carbon $end+ * @param Carbon $end*/public function setEnd(Carbon $end): void{@@ -209,7 +211,7 @@ class FrontpageChartGenerator}/**- * @param Carbon $start+ * @param Carbon $start*/public function setStart(Carbon $start): void{@@ -219,8 +221,8 @@ class FrontpageChartGenerator/*** A basic setter for the user. Also updates the repositories with the right user.*- * @param User $user- * @throws \FireflyIII\Exceptions\FireflyException+ * @param User $user+ * @throws FireflyException*/public function setUser(User $user): void{@@ -230,6 +232,6 @@ class FrontpageChartGenerator$this->opsRepository->setUser($user);$locale = app('steam')->getLocale();- $this->monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);+ $this->monthAndDayFormat = (string)trans('config.month_and_day_js', [], $locale);}}diff --git a/app/Support/Chart/Category/FrontpageChartGenerator.php b/app/Support/Chart/Category/FrontpageChartGenerator.phpindex b251399455..ab1a9985f9 100644--- a/app/Support/Chart/Category/FrontpageChartGenerator.php+++ b/app/Support/Chart/Category/FrontpageChartGenerator.php@@ -52,8 +52,8 @@ class FrontpageChartGenerator/*** FrontpageChartGenerator constructor.*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end*/public function __construct(Carbon $start, Carbon $end){@@ -99,8 +99,8 @@ class FrontpageChartGenerator}/**- * @param Category $category- * @param Collection $accounts+ * @param Category $category+ * @param Collection $accounts** @return array*/@@ -113,8 +113,8 @@ class FrontpageChartGenerator$tempData[] = ['name' => $category->name,'sum' => $currency['sum'],- 'sum_float' => round((float) $currency['sum'], $currency['currency_decimal_places']),- 'currency_id' => (int) $currency['currency_id'],+ 'sum_float' => round((float)$currency['sum'], $currency['currency_decimal_places']),+ 'currency_id' => (int)$currency['currency_id'],];}@@ -122,23 +122,23 @@ class FrontpageChartGenerator}/**- * @param array $currency+ * @param array $currency*/private function addCurrency(array $currency): void{- $currencyId = (int) $currency['currency_id'];+ $currencyId = (int)$currency['currency_id'];$this->currencies[$currencyId] = $this->currencies[$currencyId] ?? [- 'currency_id' => $currencyId,- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_code' => $currency['currency_code'],- 'currency_decimal_places' => $currency['currency_decimal_places'],- ];+ 'currency_id' => $currencyId,+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_code' => $currency['currency_code'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];}/**- * @param Collection $accounts+ * @param Collection $accounts** @return array*/@@ -151,8 +151,8 @@ class FrontpageChartGenerator$tempData[] = ['name' => trans('firefly.no_category'),'sum' => $currency['sum'],- 'sum_float' => round((float) $currency['sum'], $currency['currency_decimal_places'] ?? 2), // intentional float- 'currency_id' => (int) $currency['currency_id'],+ 'sum_float' => round((float)$currency['sum'], $currency['currency_decimal_places'] ?? 2), // intentional float+ 'currency_id' => (int)$currency['currency_id'],];}@@ -160,7 +160,7 @@ class FrontpageChartGenerator}/**- * @param array $data+ * @param array $data** @return array*/@@ -174,7 +174,7 @@ class FrontpageChartGeneratorforeach ($this->currencies as $currencyId => $currency) {$key = sprintf('spent-%d', $currencyId);$return[$key] = [- 'label' => sprintf('%s (%s)', (string) trans('firefly.spent'), $currency['currency_name']),+ 'label' => sprintf('%s (%s)', (string)trans('firefly.spent'), $currency['currency_name']),'type' => 'bar','currency_symbol' => $currency['currency_symbol'],'entries' => $names,@@ -185,8 +185,8 @@ class FrontpageChartGenerator}/**- * @param array $currencyData- * @param array $monetaryData+ * @param array $currencyData+ * @param array $monetaryData** @return array*/diff --git a/app/Support/Chart/Category/WholePeriodChartGenerator.php b/app/Support/Chart/Category/WholePeriodChartGenerator.phpindex b4bac1df0a..4b4e500b52 100644--- a/app/Support/Chart/Category/WholePeriodChartGenerator.php+++ b/app/Support/Chart/Category/WholePeriodChartGenerator.php@@ -36,9 +36,9 @@ use Illuminate\Support\Collection;class WholePeriodChartGenerator{/**- * @param Category $category- * @param Carbon $start- * @param Carbon $end+ * @param Category $category+ * @param Carbon $start+ * @param Carbon $end** @return array*/@@ -77,14 +77,14 @@ class WholePeriodChartGenerator$code = $currency['currency_code'];$name = $currency['currency_name'];$chartData[sprintf('spent-in-%s', $code)] = [- 'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $name]),+ 'label' => (string)trans('firefly.box_spent_in_currency', ['currency' => $name]),'entries' => [],'type' => 'bar','backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red];$chartData[sprintf('earned-in-%s', $code)] = [- 'label' => (string) trans('firefly.box_earned_in_currency', ['currency' => $name]),+ 'label' => (string)trans('firefly.box_earned_in_currency', ['currency' => $name]),'entries' => [],'type' => 'bar','backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green@@ -117,8 +117,8 @@ class WholePeriodChartGenerator/*** TODO this method is duplicated*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -143,7 +143,7 @@ class WholePeriodChartGenerator* Loop array of spent/earned info, and extract which currencies are present.* Key is the currency ID.*- * @param array $array+ * @param array $array** @return array*/@@ -153,12 +153,12 @@ class WholePeriodChartGeneratorforeach ($array as $block) {foreach ($block as $currencyId => $currencyRow) {$return[$currencyId] = $return[$currencyId] ?? [- 'currency_id' => $currencyId,- 'currency_name' => $currencyRow['currency_name'],- 'currency_symbol' => $currencyRow['currency_symbol'],- 'currency_code' => $currencyRow['currency_code'],- 'currency_decimal_places' => $currencyRow['currency_decimal_places'],- ];+ 'currency_id' => $currencyId,+ 'currency_name' => $currencyRow['currency_name'],+ 'currency_symbol' => $currencyRow['currency_symbol'],+ 'currency_code' => $currencyRow['currency_code'],+ 'currency_decimal_places' => $currencyRow['currency_decimal_places'],+ ];}}diff --git a/app/Support/ChartColour.php b/app/Support/ChartColour.phpindex 2969a496d3..82dbb2d238 100644--- a/app/Support/ChartColour.php+++ b/app/Support/ChartColour.php@@ -1,4 +1,5 @@<?php+/*** ChartColour.php* Copyright (c) 2019 [email protected]@@ -54,7 +55,7 @@ class ChartColour];/**- * @param int $index+ * @param int $index** @return string*/diff --git a/app/Support/Cronjobs/AbstractCronjob.php b/app/Support/Cronjobs/AbstractCronjob.phpindex c13183a527..0fd2974ac1 100644--- a/app/Support/Cronjobs/AbstractCronjob.php+++ b/app/Support/Cronjobs/AbstractCronjob.php@@ -59,7 +59,7 @@ abstract class AbstractCronjobabstract public function fire(): void;/**- * @param Carbon $date+ * @param Carbon $date*/final public function setDate(Carbon $date): void{@@ -68,7 +68,7 @@ abstract class AbstractCronjob}/**- * @param bool $force+ * @param bool $force*/final public function setForce(bool $force): void{diff --git a/app/Support/Cronjobs/AutoBudgetCronjob.php b/app/Support/Cronjobs/AutoBudgetCronjob.phpindex 9a55188916..bff4d6d96e 100644--- a/app/Support/Cronjobs/AutoBudgetCronjob.php+++ b/app/Support/Cronjobs/AutoBudgetCronjob.php@@ -41,7 +41,7 @@ class AutoBudgetCronjob extends AbstractCronjob{/** @var Configuration $config */$config = app('fireflyconfig')->get('last_ab_job', 0);- $lastTime = (int) $config->data;+ $lastTime = (int)$config->data;$diff = time() - $lastTime;$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);if (0 === $lastTime) {@@ -88,7 +88,7 @@ class AutoBudgetCronjob extends AbstractCronjob$this->jobSucceeded = true;$this->message = 'Auto-budget cron job fired successfully.';- app('fireflyconfig')->set('last_ab_job', (int) $this->date->format('U'));+ app('fireflyconfig')->set('last_ab_job', (int)$this->date->format('U'));Log::info('Done with auto budget cron job task.');}}diff --git a/app/Support/Cronjobs/BillWarningCronjob.php b/app/Support/Cronjobs/BillWarningCronjob.phpindex 79ce30f5af..70c84c0bcf 100644--- a/app/Support/Cronjobs/BillWarningCronjob.php+++ b/app/Support/Cronjobs/BillWarningCronjob.php@@ -28,6 +28,8 @@ use FireflyIII\Exceptions\FireflyException;use FireflyIII\Jobs\WarnAboutBills;use FireflyIII\Models\Configuration;use Log;+use Psr\Container\ContainerExceptionInterface;+use Psr\Container\NotFoundExceptionInterface;/*** Class BillWarningCronjob@@ -36,15 +38,15 @@ class BillWarningCronjob extends AbstractCronjob{/*** @throws FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/public function fire(): void{Log::debug(sprintf('Now in %s', __METHOD__));/** @var Configuration $config */$config = app('fireflyconfig')->get('last_bw_job', 0);- $lastTime = (int) $config->data;+ $lastTime = (int)$config->data;$diff = time() - $lastTime;$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);@@ -97,8 +99,8 @@ class BillWarningCronjob extends AbstractCronjob$this->jobSucceeded = true;$this->message = 'Bill warning cron job fired successfully.';- app('fireflyconfig')->set('last_bw_job', (int) $this->date->format('U'));- Log::info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int) $this->date->format('U')));+ app('fireflyconfig')->set('last_bw_job', (int)$this->date->format('U'));+ Log::info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int)$this->date->format('U')));Log::info('Done with bill warning cron job task.');}}diff --git a/app/Support/Cronjobs/ExchangeRatesCronjob.php b/app/Support/Cronjobs/ExchangeRatesCronjob.phpindex 379d2483de..91a946b806 100644--- a/app/Support/Cronjobs/ExchangeRatesCronjob.php+++ b/app/Support/Cronjobs/ExchangeRatesCronjob.php@@ -41,7 +41,7 @@ class ExchangeRatesCronjob extends AbstractCronjob{/** @var Configuration $config */$config = app('fireflyconfig')->get('last_cer_job', 0);- $lastTime = (int) $config->data;+ $lastTime = (int)$config->data;$diff = time() - $lastTime;$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);if (0 === $lastTime) {@@ -88,7 +88,7 @@ class ExchangeRatesCronjob extends AbstractCronjob$this->jobSucceeded = true;$this->message = 'Exchange rates cron job fired successfully.';- app('fireflyconfig')->set('last_cer_job', (int) $this->date->format('U'));+ app('fireflyconfig')->set('last_cer_job', (int)$this->date->format('U'));Log::info('Done with exchange rates job task.');}}diff --git a/app/Support/Cronjobs/RecurringCronjob.php b/app/Support/Cronjobs/RecurringCronjob.phpindex b71bdf4f3d..cba3e594cb 100644--- a/app/Support/Cronjobs/RecurringCronjob.php+++ b/app/Support/Cronjobs/RecurringCronjob.php@@ -28,6 +28,8 @@ use FireflyIII\Exceptions\FireflyException;use FireflyIII\Jobs\CreateRecurringTransactions;use FireflyIII\Models\Configuration;use Log;+use Psr\Container\ContainerExceptionInterface;+use Psr\Container\NotFoundExceptionInterface;/*** Class RecurringCronjob@@ -36,15 +38,15 @@ class RecurringCronjob extends AbstractCronjob{/*** @throws FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/public function fire(): void{Log::debug(sprintf('Now in %s', __METHOD__));/** @var Configuration $config */$config = app('fireflyconfig')->get('last_rt_job', 0);- $lastTime = (int) $config->data;+ $lastTime = (int)$config->data;$diff = time() - $lastTime;$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);@@ -97,8 +99,8 @@ class RecurringCronjob extends AbstractCronjob$this->jobSucceeded = true;$this->message = 'Recurring transactions cron job fired successfully.';- app('fireflyconfig')->set('last_rt_job', (int) $this->date->format('U'));- Log::info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int) $this->date->format('U')));+ app('fireflyconfig')->set('last_rt_job', (int)$this->date->format('U'));+ Log::info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int)$this->date->format('U')));Log::info('Done with recurring cron job task.');}}diff --git a/app/Support/Domain.php b/app/Support/Domain.phpindex ced5cd7ae7..6422919533 100644--- a/app/Support/Domain.php+++ b/app/Support/Domain.php@@ -1,4 +1,5 @@<?php+/*** Domain.php* Copyright (c) 2019 [email protected]diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.phpindex 29dba255e6..7f4a1b0ab9 100644--- a/app/Support/ExpandedForm.php+++ b/app/Support/ExpandedForm.php@@ -1,4 +1,5 @@<?php+/*** ExpandedForm.php* Copyright (c) 2019 [email protected]@@ -42,9 +43,9 @@ class ExpandedFormuse FormSupport;/**- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -74,10 +75,10 @@ class ExpandedForm}/**- * @param string $name- * @param int|null $value- * @param mixed $checked- * @param array|null $options+ * @param string $name+ * @param int|null $value+ * @param mixed $checked+ * @param array|null $options** @return string*/@@ -110,9 +111,9 @@ class ExpandedForm}/**- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -135,8 +136,8 @@ class ExpandedForm}/**- * @param string $name- * @param array|null $options+ * @param string $name+ * @param array|null $options** @return string*/@@ -158,9 +159,9 @@ class ExpandedForm}/**- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -184,9 +185,9 @@ class ExpandedForm}/**- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -209,7 +210,7 @@ class ExpandedForm}/**- * @param Collection $set+ * @param Collection $set** @return array*@@ -221,7 +222,7 @@ class ExpandedForm$fields = ['title', 'name', 'description'];/** @var Eloquent $entry */foreach ($set as $entry) {- $entryId = (int) $entry->id;+ $entryId = (int)$entry->id;$current = $entry->toArray();$title = null;foreach ($fields as $field) {@@ -236,9 +237,9 @@ class ExpandedForm}/**- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -268,9 +269,9 @@ class ExpandedForm}/**- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -294,8 +295,8 @@ class ExpandedForm}/**- * @param null $value- * @param array|null $options+ * @param null $value+ * @param array|null $options** @return string*/@@ -324,8 +325,8 @@ class ExpandedForm}/**- * @param string $type- * @param string $name+ * @param string $type+ * @param string $name** @return string*@@ -344,8 +345,8 @@ class ExpandedForm}/**- * @param string $name- * @param array|null $options+ * @param string $name+ * @param array|null $options** @return string*/@@ -368,9 +369,9 @@ class ExpandedForm/*** Function to render a percentage.*- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -394,9 +395,9 @@ class ExpandedForm}/**- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -417,9 +418,9 @@ class ExpandedForm}/**- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -441,9 +442,9 @@ class ExpandedForm}/**- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/diff --git a/app/Support/Export/ExportDataGenerator.php b/app/Support/Export/ExportDataGenerator.phpindex 669ba0e016..23ca937c53 100644--- a/app/Support/Export/ExportDataGenerator.php+++ b/app/Support/Export/ExportDataGenerator.php@@ -56,6 +56,8 @@ use Illuminate\Support\Collection;use League\Csv\CannotInsertRecord;use League\Csv\Exception;use League\Csv\Writer;+use Psr\Container\ContainerExceptionInterface;+use Psr\Container\NotFoundExceptionInterface;/*** Class ExportDataGenerator@@ -141,8 +143,25 @@ class ExportDataGenerator*/private function exportAccounts(): string{- $header = ['user_id', 'account_id', 'created_at', 'updated_at', 'type', 'name', 'virtual_balance', 'iban', 'number', 'active', 'currency_code', 'role',- 'cc_type', 'cc_payment_date', 'in_net_worth', 'interest', 'interest_period',];+ $header = [+ 'user_id',+ 'account_id',+ 'created_at',+ 'updated_at',+ 'type',+ 'name',+ 'virtual_balance',+ 'iban',+ 'number',+ 'active',+ 'currency_code',+ 'role',+ 'cc_type',+ 'cc_payment_date',+ 'in_net_worth',+ 'interest',+ 'interest_period',+ ];/** @var AccountRepositoryInterface $repository */$repository = app(AccountRepositoryInterface::class);$repository->setUser($this->user);@@ -194,6 +213,14 @@ class ExportDataGeneratorreturn $string;}+ /**+ * @param User $user+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ }+/*** @return string* @throws FireflyException@@ -204,8 +231,20 @@ class ExportDataGenerator$repository = app(BillRepositoryInterface::class);$repository->setUser($this->user);$bills = $repository->getBills();- $header = ['user_id', 'bill_id', 'created_at', 'updated_at', 'currency_code', 'name', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip',- 'active',];+ $header = [+ 'user_id',+ 'bill_id',+ 'created_at',+ 'updated_at',+ 'currency_code',+ 'name',+ 'amount_min',+ 'amount_max',+ 'date',+ 'repeat_freq',+ 'skip',+ 'active',+ ];$records = [];/** @var Bill $bill */@@ -374,9 +413,22 @@ class ExportDataGenerator$accountRepos = app(AccountRepositoryInterface::class);$accountRepos->setUser($this->user);- $header = ['user_id', 'piggy_bank_id', 'created_at', 'updated_at', 'account_name', 'account_type', 'name',- 'currency_code', 'target_amount', 'current_amount', 'start_date', 'target_date', 'order',- 'active'];+ $header = [+ 'user_id',+ 'piggy_bank_id',+ 'created_at',+ 'updated_at',+ 'account_name',+ 'account_type',+ 'name',+ 'currency_code',+ 'target_amount',+ 'current_amount',+ 'start_date',+ 'target_date',+ 'order',+ 'active',+ ];$records = [];$piggies = $piggyRepos->getPiggyBanks();@@ -435,14 +487,39 @@ class ExportDataGenerator$recurringRepos->setUser($this->user);$header = [// recurrence:- 'user_id', 'recurrence_id', 'row_contains', 'created_at', 'updated_at', 'type', 'title', 'description', 'first_date', 'repeat_until',- 'latest_date', 'repetitions', 'apply_rules', 'active',+ 'user_id',+ 'recurrence_id',+ 'row_contains',+ 'created_at',+ 'updated_at',+ 'type',+ 'title',+ 'description',+ 'first_date',+ 'repeat_until',+ 'latest_date',+ 'repetitions',+ 'apply_rules',+ 'active',// repetition info:- 'type', 'moment', 'skip', 'weekend',+ 'type',+ 'moment',+ 'skip',+ 'weekend',// transactions + meta:- 'currency_code', 'foreign_currency_code', 'source_name', 'source_type', 'destination_name', 'destination_type', 'amount', 'foreign_amount',- 'category', 'budget', 'piggy_bank', 'tags',+ 'currency_code',+ 'foreign_currency_code',+ 'source_name',+ 'source_type',+ 'destination_name',+ 'destination_type',+ 'amount',+ 'foreign_amount',+ 'category',+ 'budget',+ 'piggy_bank',+ 'tags',];$records = [];$recurrences = $recurringRepos->getAll();@@ -471,10 +548,25 @@ class ExportDataGenerator$records[] = [// recurrence$this->user->id,- $recurrence->id, 'repetition', null, null, null, null, null, null, null, null, null, null, null,+ $recurrence->id,+ 'repetition',+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,// repetition:- $repetition->repetition_type, $repetition->repetition_moment, $repetition->repetition_skip, $repetition->weekend,+ $repetition->repetition_type,+ $repetition->repetition_moment,+ $repetition->repetition_skip,+ $repetition->weekend,];}/** @var RecurrenceTransaction $transaction */@@ -487,16 +579,39 @@ class ExportDataGenerator$records[] = [// recurrence$this->user->id,- $recurrence->id, 'transaction', null, null, null, null, null, null, null, null, null, null, null,+ $recurrence->id,+ 'transaction',+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,// repetition:- null, null, null, null,+ null,+ null,+ null,+ null,// transaction:- $transaction->transactionCurrency->code, $transaction->foreignCurrency?->code,- $transaction->sourceAccount->name, $transaction->sourceAccount->accountType->type, $transaction->destinationAccount->name,- $transaction->destinationAccount->accountType->type, $transaction->amount, $transaction->foreign_amount,- $categoryName, $budgetId, $piggyBankId, implode(',', $tags),+ $transaction->transactionCurrency->code,+ $transaction->foreignCurrency?->code,+ $transaction->sourceAccount->name,+ $transaction->sourceAccount->accountType->type,+ $transaction->destinationAccount->name,+ $transaction->destinationAccount->accountType->type,+ $transaction->amount,+ $transaction->foreign_amount,+ $categoryName,+ $budgetId,+ $piggyBankId,+ implode(',', $tags),];}}@@ -528,9 +643,31 @@ class ExportDataGenerator*/private function exportRules(): string{- $header = ['user_id', 'rule_id', 'row_contains', 'created_at', 'updated_at', 'group_id', 'group_name', 'title', 'description', 'order', 'active',- 'stop_processing', 'strict', 'trigger_type', 'trigger_value', 'trigger_order', 'trigger_active', 'trigger_stop_processing', 'action_type',- 'action_value', 'action_order', 'action_active', 'action_stop_processing',];+ $header = [+ 'user_id',+ 'rule_id',+ 'row_contains',+ 'created_at',+ 'updated_at',+ 'group_id',+ 'group_name',+ 'title',+ 'description',+ 'order',+ 'active',+ 'stop_processing',+ 'strict',+ 'trigger_type',+ 'trigger_value',+ 'trigger_order',+ 'trigger_active',+ 'trigger_stop_processing',+ 'action_type',+ 'action_value',+ 'action_order',+ 'action_active',+ 'action_stop_processing',+ ];$ruleRepos = app(RuleRepositoryInterface::class);$ruleRepos->setUser($this->user);$rules = $ruleRepos->getAll();@@ -538,31 +675,70 @@ class ExportDataGenerator/** @var Rule $rule */foreach ($rules as $rule) {$records[] = [- $this->user->id, $rule->id, 'rule',- $rule->created_at->toAtomString(), $rule->updated_at->toAtomString(),- $rule->ruleGroup->id, $rule->ruleGroup->title,- $rule->title, $rule->description, $rule->order, $rule->active, $rule->stop_processing, $rule->strict,+ $this->user->id,+ $rule->id,+ 'rule',+ $rule->created_at->toAtomString(),+ $rule->updated_at->toAtomString(),+ $rule->ruleGroup->id,+ $rule->ruleGroup->title,+ $rule->title,+ $rule->description,+ $rule->order,+ $rule->active,+ $rule->stop_processing,+ $rule->strict,];/** @var RuleTrigger $trigger */foreach ($rule->ruleTriggers as $trigger) {$records[] = [- $this->user->id, $rule->id, 'trigger',- null, null,- null, null,- null, null, null, null, null, null,- $trigger->trigger_type, $trigger->trigger_value, $trigger->order, $trigger->active, $trigger->stop_processing,+ $this->user->id,+ $rule->id,+ 'trigger',+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ $trigger->trigger_type,+ $trigger->trigger_value,+ $trigger->order,+ $trigger->active,+ $trigger->stop_processing,];}/** @var RuleAction $action */foreach ($rule->ruleActions as $action) {$records[] = [- $this->user->id, $rule->id, 'action',- null, null,- null, null,- null, null, null, null, null, null,- null, null, null, null, null,- $action->action_type, $action->action_value, $action->order, $action->active, $action->stop_processing,+ $this->user->id,+ $rule->id,+ 'action',+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ $action->action_type,+ $action->action_value,+ $action->order,+ $action->active,+ $action->stop_processing,];}}@@ -592,8 +768,8 @@ class ExportDataGenerator/*** @return string* @throws FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/private function exportTags(): string{@@ -648,10 +824,33 @@ class ExportDataGeneratorprivate function exportTransactions(): string{// TODO better place for keys?- $header = ['user_id', 'group_id', 'journal_id', 'created_at', 'updated_at', 'group_title', 'type', 'amount', 'foreign_amount', 'currency_code',- 'foreign_currency_code', 'description', 'date', 'source_name', 'source_iban', 'source_type', 'destination_name', 'destination_iban',- 'destination_type', 'reconciled', 'category', 'budget', 'bill', 'tags', 'notes',- // all optional meta fields:+ $header = [+ 'user_id',+ 'group_id',+ 'journal_id',+ 'created_at',+ 'updated_at',+ 'group_title',+ 'type',+ 'amount',+ 'foreign_amount',+ 'currency_code',+ 'foreign_currency_code',+ 'description',+ 'date',+ 'source_name',+ 'source_iban',+ 'source_type',+ 'destination_name',+ 'destination_iban',+ 'destination_type',+ 'reconciled',+ 'category',+ 'budget',+ 'bill',+ 'tags',+ 'notes',+ // all optional meta fields:];$metaFields = config('firefly.journal_meta_fields');@@ -761,7 +960,15 @@ class ExportDataGenerator}/**- * @param array $tags+ * @param Collection $accounts+ */+ public function setAccounts(Collection $accounts): void+ {+ $this->accounts = $accounts;+ }++ /**+ * @param array $tags** @return string*/@@ -779,15 +986,7 @@ class ExportDataGenerator}/**- * @param Collection $accounts- */- public function setAccounts(Collection $accounts): void- {- $this->accounts = $accounts;- }-- /**- * @param Carbon $end+ * @param Carbon $end*/public function setEnd(Carbon $end): void{@@ -795,7 +994,7 @@ class ExportDataGenerator}/**- * @param bool $exportAccounts+ * @param bool $exportAccounts*/public function setExportAccounts(bool $exportAccounts): void{@@ -803,7 +1002,7 @@ class ExportDataGenerator}/**- * @param bool $exportBills+ * @param bool $exportBills*/public function setExportBills(bool $exportBills): void{@@ -811,7 +1010,7 @@ class ExportDataGenerator}/**- * @param bool $exportBudgets+ * @param bool $exportBudgets*/public function setExportBudgets(bool $exportBudgets): void{@@ -819,7 +1018,7 @@ class ExportDataGenerator}/**- * @param bool $exportCategories+ * @param bool $exportCategories*/public function setExportCategories(bool $exportCategories): void{@@ -827,7 +1026,7 @@ class ExportDataGenerator}/**- * @param bool $exportPiggies+ * @param bool $exportPiggies*/public function setExportPiggies(bool $exportPiggies): void{@@ -835,7 +1034,7 @@ class ExportDataGenerator}/**- * @param bool $exportRecurring+ * @param bool $exportRecurring*/public function setExportRecurring(bool $exportRecurring): void{@@ -843,7 +1042,7 @@ class ExportDataGenerator}/**- * @param bool $exportRules+ * @param bool $exportRules*/public function setExportRules(bool $exportRules): void{@@ -851,7 +1050,7 @@ class ExportDataGenerator}/**- * @param bool $exportTags+ * @param bool $exportTags*/public function setExportTags(bool $exportTags): void{@@ -859,7 +1058,7 @@ class ExportDataGenerator}/**- * @param bool $exportTransactions+ * @param bool $exportTransactions*/public function setExportTransactions(bool $exportTransactions): void{@@ -867,18 +1066,10 @@ class ExportDataGenerator}/**- * @param Carbon $start+ * @param Carbon $start*/public function setStart(Carbon $start): void{$this->start = $start;}-- /**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- }}diff --git a/app/Support/Facades/AccountForm.php b/app/Support/Facades/AccountForm.phpindex 06d4f2da11..86c7046c07 100644--- a/app/Support/Facades/AccountForm.php+++ b/app/Support/Facades/AccountForm.php@@ -1,4 +1,5 @@<?php+/*** AccountForm.php* Copyright (c) 2019 [email protected]diff --git a/app/Support/Facades/Amount.php b/app/Support/Facades/Amount.phpindex a72db8bb45..0c1bb53dd2 100644--- a/app/Support/Facades/Amount.php+++ b/app/Support/Facades/Amount.php@@ -1,4 +1,5 @@<?php+/*** Amount.php* Copyright (c) 2019 [email protected]diff --git a/app/Support/Facades/CurrencyForm.php b/app/Support/Facades/CurrencyForm.phpindex f544726ec0..92f5bedfdf 100644--- a/app/Support/Facades/CurrencyForm.php+++ b/app/Support/Facades/CurrencyForm.php@@ -1,4 +1,5 @@<?php+/*** CurrencyForm.php* Copyright (c) 2019 [email protected]diff --git a/app/Support/Facades/ExpandedForm.php b/app/Support/Facades/ExpandedForm.phpindex 0eb5b58540..d55363e739 100644--- a/app/Support/Facades/ExpandedForm.php+++ b/app/Support/Facades/ExpandedForm.php@@ -1,4 +1,5 @@<?php+/*** ExpandedForm.php* Copyright (c) 2019 [email protected]diff --git a/app/Support/Facades/FireflyConfig.php b/app/Support/Facades/FireflyConfig.phpindex 84e05e0988..09f13e512c 100644--- a/app/Support/Facades/FireflyConfig.php+++ b/app/Support/Facades/FireflyConfig.php@@ -1,4 +1,5 @@<?php+/*** FireflyConfig.php* Copyright (c) 2019 [email protected]diff --git a/app/Support/Facades/Navigation.php b/app/Support/Facades/Navigation.phpindex 1e1946a5d5..45d8007f02 100644--- a/app/Support/Facades/Navigation.php+++ b/app/Support/Facades/Navigation.php@@ -1,4 +1,5 @@<?php+/*** Navigation.php* Copyright (c) 2019 [email protected]diff --git a/app/Support/Facades/PiggyBankForm.php b/app/Support/Facades/PiggyBankForm.phpindex e559629b94..ebf07351bb 100644--- a/app/Support/Facades/PiggyBankForm.php+++ b/app/Support/Facades/PiggyBankForm.php@@ -1,4 +1,5 @@<?php+/*** PiggyBankForm.php* Copyright (c) 2019 [email protected]diff --git a/app/Support/Facades/Preferences.php b/app/Support/Facades/Preferences.phpindex 56d212193b..d18a46a10d 100644--- a/app/Support/Facades/Preferences.php+++ b/app/Support/Facades/Preferences.php@@ -1,4 +1,5 @@<?php+/*** Preferences.php* Copyright (c) 2019 [email protected]@@ -26,7 +27,6 @@ use FireflyIII\Models\Preference;use FireflyIII\User;use Illuminate\Support\Collection;use Illuminate\Support\Facades\Facade;-use Log;/*** @codeCoverageIgnorediff --git a/app/Support/Facades/RuleForm.php b/app/Support/Facades/RuleForm.phpindex 9a9caaf29a..fe103723ed 100644--- a/app/Support/Facades/RuleForm.php+++ b/app/Support/Facades/RuleForm.php@@ -1,4 +1,5 @@<?php+/*** RuleForm.php* Copyright (c) 2019 [email protected]diff --git a/app/Support/Facades/Steam.php b/app/Support/Facades/Steam.phpindex d3e37e0ee8..e9c5a4890e 100644--- a/app/Support/Facades/Steam.php+++ b/app/Support/Facades/Steam.php@@ -1,4 +1,5 @@<?php+/*** Steam.php* Copyright (c) 2019 [email protected]diff --git a/app/Support/FireflyConfig.php b/app/Support/FireflyConfig.phpindex fe65bc0ef5..2421bb6065 100644--- a/app/Support/FireflyConfig.php+++ b/app/Support/FireflyConfig.php@@ -1,4 +1,5 @@<?php+/*** FireflyConfig.php* Copyright (c) 2019 [email protected]@@ -36,11 +37,11 @@ use Illuminate\Database\QueryException;class FireflyConfig{/**- * @param string $name+ * @param string $name*/public function delete(string $name): void{- $fullName = 'ff-config-' . $name;+ $fullName = 'ff-config-'.$name;if (Cache::has($fullName)) {Cache::forget($fullName);}@@ -52,15 +53,25 @@ class FireflyConfig}/**- * @param string $name- * @param bool|string|int|null $default+ * @param string $name+ *+ * @return bool+ */+ public function has(string $name): bool+ {+ return Configuration::where('name', $name)->count() === 1;+ }++ /**+ * @param string $name+ * @param bool|string|int|null $default** @return Configuration|null* @throws FireflyException*/public function get(string $name, $default = null): ?Configuration{- $fullName = 'ff-config-' . $name;+ $fullName = 'ff-config-'.$name;if (Cache::has($fullName)) {return Cache::get($fullName);}@@ -86,8 +97,8 @@ class FireflyConfig}/**- * @param string $name- * @param mixed $value+ * @param string $name+ * @param mixed $value** @return Configuration*/@@ -108,20 +119,20 @@ class FireflyConfig$item->name = $name;$item->data = $value;$item->save();- Cache::forget('ff-config-' . $name);+ Cache::forget('ff-config-'.$name);return $item;}$config->data = $value;$config->save();- Cache::forget('ff-config-' . $name);+ Cache::forget('ff-config-'.$name);return $config;}/**- * @param string $name- * @param mixed $default+ * @param string $name+ * @param mixed $default** @return Configuration|null*/@@ -140,18 +151,8 @@ class FireflyConfig}/**- * @param string $name- *- * @return bool- */- public function has(string $name): bool- {- return Configuration::where('name', $name)->count() === 1;- }-- /**- * @param string $name- * @param mixed $value+ * @param string $name+ * @param mixed $value** @return Configuration*/diff --git a/app/Support/Form/AccountForm.php b/app/Support/Form/AccountForm.phpindex e1253809e7..31b02dcb93 100644--- a/app/Support/Form/AccountForm.php+++ b/app/Support/Form/AccountForm.php@@ -45,9 +45,9 @@ class AccountForm/*** Grouped dropdown list of all accounts that are valid as the destination of a withdrawal.*- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -57,8 +57,8 @@ class AccountForm$repository = $this->getAccountRepository();$grouped = $this->getAccountsGrouped($types, $repository);$cash = $repository->getCashAccount();- $key = (string) trans('firefly.cash_account_type');- $grouped[$key][$cash->id] = sprintf('(%s)', (string) trans('firefly.cash'));+ $key = (string)trans('firefly.cash_account_type');+ $grouped[$key][$cash->id] = sprintf('(%s)', (string)trans('firefly.cash'));return $this->select($name, $grouped, $value, $options);}@@ -74,7 +74,7 @@ class AccountForm/** @var Account $account */foreach ($accountList as $account) {- $role = (string) $repository->getMetaValue($account, 'account_role');+ $role = (string)$repository->getMetaValue($account, 'account_role');if (in_array($account->accountType->type, $liabilityTypes, true)) {$role = sprintf('l_%s', $account->accountType->type);} elseif ('' === $role) {@@ -86,7 +86,7 @@ class AccountForm$role = 'no_account_type';}}- $key = (string) trans(sprintf('firefly.opt_group_%s', $role));+ $key = (string)trans(sprintf('firefly.opt_group_%s', $role));$grouped[$key][$account->id] = $account->name;}@@ -96,9 +96,9 @@ class AccountForm/*** Grouped dropdown list of all accounts that are valid as the destination of a withdrawal.*- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -109,8 +109,8 @@ class AccountForm$grouped = $this->getAccountsGrouped($types, $repository);$cash = $repository->getCashAccount();- $key = (string) trans('firefly.cash_account_type');- $grouped[$key][$cash->id] = sprintf('(%s)', (string) trans('firefly.cash'));+ $key = (string)trans('firefly.cash_account_type');+ $grouped[$key][$cash->id] = sprintf('(%s)', (string)trans('firefly.cash'));return $this->select($name, $grouped, $value, $options);}@@ -118,8 +118,8 @@ class AccountForm/*** Check list of asset accounts.*- * @param string $name- * @param array|null $options+ * @param string $name+ * @param array|null $options** @return string*/@@ -150,9 +150,9 @@ class AccountForm/*** Basic list of asset accounts.*- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -167,9 +167,9 @@ class AccountForm/*** Same list but all liabilities as well.*- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/diff --git a/app/Support/Form/CurrencyForm.php b/app/Support/Form/CurrencyForm.phpindex 1294e140d4..6f07c77fd5 100644--- a/app/Support/Form/CurrencyForm.php+++ b/app/Support/Form/CurrencyForm.php@@ -41,9 +41,9 @@ class CurrencyFormuse FormSupport;/**- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -53,10 +53,10 @@ class CurrencyForm}/**- * @param string $name- * @param string $view- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param string $view+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -77,8 +77,8 @@ class CurrencyFormif (!is_array($preFilled)) {$preFilled = [];}- $key = 'amount_currency_id_' . $name;- $sentCurrencyId = array_key_exists($key, $preFilled) ? (int) $preFilled[$key] : $defaultCurrency->id;+ $key = 'amount_currency_id_'.$name;+ $sentCurrencyId = array_key_exists($key, $preFilled) ? (int)$preFilled[$key] : $defaultCurrency->id;Log::debug(sprintf('Sent currency ID is %d', $sentCurrencyId));@@ -96,7 +96,7 @@ class CurrencyForm$value = app('steam')->bcround($value, $defaultCurrency->decimal_places);}try {- $html = view('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();+ $html = view('form.'.$view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();} catch (Throwable $e) {Log::debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));$html = 'Could not render currencyField.';@@ -109,9 +109,9 @@ class CurrencyForm/*** TODO describe and cleanup.*- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -123,10 +123,10 @@ class CurrencyForm/*** TODO describe and cleanup*- * @param string $name- * @param string $view- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param string $view+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -147,8 +147,8 @@ class CurrencyFormif (!is_array($preFilled)) {$preFilled = [];}- $key = 'amount_currency_id_' . $name;- $sentCurrencyId = array_key_exists($key, $preFilled) ? (int) $preFilled[$key] : $defaultCurrency->id;+ $key = 'amount_currency_id_'.$name;+ $sentCurrencyId = array_key_exists($key, $preFilled) ? (int)$preFilled[$key] : $defaultCurrency->id;Log::debug(sprintf('Sent currency ID is %d', $sentCurrencyId));@@ -166,7 +166,7 @@ class CurrencyForm$value = app('steam')->bcround($value, $defaultCurrency->decimal_places);}try {- $html = view('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();+ $html = view('form.'.$view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();} catch (Throwable $e) {Log::debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));$html = 'Could not render currencyField.';@@ -179,9 +179,9 @@ class CurrencyForm/*** TODO cleanup and describe*- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -195,7 +195,7 @@ class CurrencyForm$array = [];/** @var TransactionCurrency $currency */foreach ($list as $currency) {- $array[$currency->id] = $currency->name . ' (' . $currency->symbol . ')';+ $array[$currency->id] = $currency->name.' ('.$currency->symbol.')';}return $this->select($name, $array, $value, $options);@@ -204,9 +204,9 @@ class CurrencyForm/*** TODO cleanup and describe*- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -218,11 +218,11 @@ class CurrencyForm// get all currencies:$list = $currencyRepos->get();$array = [- 0 => (string) trans('firefly.no_currency'),+ 0 => (string)trans('firefly.no_currency'),];/** @var TransactionCurrency $currency */foreach ($list as $currency) {- $array[$currency->id] = $currency->name . ' (' . $currency->symbol . ')';+ $array[$currency->id] = $currency->name.' ('.$currency->symbol.')';}return $this->select($name, $array, $value, $options);diff --git a/app/Support/Form/FormSupport.php b/app/Support/Form/FormSupport.phpindex 509a3d4dd9..80b9390d1c 100644--- a/app/Support/Form/FormSupport.php+++ b/app/Support/Form/FormSupport.php@@ -37,10 +37,10 @@ use Throwable;trait FormSupport{/**- * @param string $name- * @param array|null $list- * @param mixed $selected- * @param array|null $options+ * @param string $name+ * @param array|null $list+ * @param mixed $selected+ * @param array|null $options** @return string*/@@ -63,8 +63,8 @@ trait FormSupport}/**- * @param string $name- * @param array|null $options+ * @param string $name+ * @param array|null $options** @return string*/@@ -76,13 +76,13 @@ trait FormSupport}$name = str_replace('[]', '', $name);- return (string) trans('form.' . $name);+ return (string)trans('form.'.$name);}/**- * @param string $name- * @param mixed $label- * @param array|null $options+ * @param string $name+ * @param mixed $label+ * @param array|null $options** @return array*/@@ -91,7 +91,7 @@ trait FormSupport$options = $options ?? [];$name = str_replace('[]', '', $name);$options['class'] = 'form-control';- $options['id'] = 'ffInput_' . $name;+ $options['id'] = 'ffInput_'.$name;$options['autocomplete'] = 'off';$options['placeholder'] = ucfirst($label);@@ -99,7 +99,7 @@ trait FormSupport}/**- * @param string $name+ * @param string $name** @return string*/@@ -118,8 +118,8 @@ trait FormSupport}/**- * @param string $name- * @param mixed|null $value+ * @param string $name+ * @param mixed|null $value** @return mixed*/diff --git a/app/Support/Form/PiggyBankForm.php b/app/Support/Form/PiggyBankForm.phpindex 493505924c..c9391d375a 100644--- a/app/Support/Form/PiggyBankForm.php+++ b/app/Support/Form/PiggyBankForm.php@@ -38,9 +38,9 @@ class PiggyBankForm/*** TODO cleanup and describe*- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -50,7 +50,7 @@ class PiggyBankForm/** @var PiggyBankRepositoryInterface $repository */$repository = app(PiggyBankRepositoryInterface::class);$piggyBanks = $repository->getPiggyBanksWithAmount();- $title = (string) trans('firefly.default_group_title_name');+ $title = (string)trans('firefly.default_group_title_name');$array = [];$subList = [0 => [@@ -58,7 +58,7 @@ class PiggyBankForm'title' => $title,],'piggies' => [- (string) trans('firefly.none_in_select_list'),+ (string)trans('firefly.none_in_select_list'),],],];@@ -72,11 +72,11 @@ class PiggyBankForm$groupOrder = $group->order;}$subList[$groupOrder] = $subList[$groupOrder] ?? [- 'group' => [- 'title' => $groupTitle,- ],- 'piggies' => [],- ];+ 'group' => [+ 'title' => $groupTitle,+ ],+ 'piggies' => [],+ ];$subList[$groupOrder]['piggies'][$piggy->id] = $piggy->name;}ksort($subList);diff --git a/app/Support/Form/RuleForm.php b/app/Support/Form/RuleForm.phpindex 6b30dd269a..c20d8e49ce 100644--- a/app/Support/Form/RuleForm.php+++ b/app/Support/Form/RuleForm.php@@ -37,9 +37,9 @@ class RuleFormuse FormSupport;/**- * @param string $name- * @param mixed $value- * @param array|null $options+ * @param string $name+ * @param mixed $value+ * @param array|null $options** @return string*/@@ -60,9 +60,9 @@ class RuleForm}/**- * @param string $name- * @param null $value- * @param array|null $options+ * @param string $name+ * @param null $value+ * @param array|null $options** @return HtmlString*/@@ -76,11 +76,11 @@ class RuleForm// get all currencies:$list = $groupRepos->get();$array = [- 0 => (string) trans('firefly.none_in_select_list'),+ 0 => (string)trans('firefly.none_in_select_list'),];/** @var RuleGroup $group */foreach ($list as $group) {- if (array_key_exists('hidden', $options) && (int) $options['hidden'] !== $group->id) {+ if (array_key_exists('hidden', $options) && (int)$options['hidden'] !== $group->id) {$array[$group->id] = $group->title;}}diff --git a/app/Support/Http/Api/AccountFilter.php b/app/Support/Http/Api/AccountFilter.phpindex 8624181e5d..1204164501 100644--- a/app/Support/Http/Api/AccountFilter.php+++ b/app/Support/Http/Api/AccountFilter.php@@ -35,17 +35,27 @@ trait AccountFilter/*** All the available types.*- * @param string $type+ * @param string $type** @return array*/protected function mapAccountTypes(string $type): array{$types = [- 'all' => [AccountType::DEFAULT, AccountType::CASH,- AccountType::ASSET, AccountType::EXPENSE, AccountType::REVENUE,- AccountType::INITIAL_BALANCE, AccountType::BENEFICIARY, AccountType::IMPORT, AccountType::RECONCILIATION,- AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],+ 'all' => [+ AccountType::DEFAULT,+ AccountType::CASH,+ AccountType::ASSET,+ AccountType::EXPENSE,+ AccountType::REVENUE,+ AccountType::INITIAL_BALANCE,+ AccountType::BENEFICIARY,+ AccountType::IMPORT,+ AccountType::RECONCILIATION,+ AccountType::LOAN,+ AccountType::DEBT,+ AccountType::MORTGAGE,+ ],'asset' => [AccountType::DEFAULT, AccountType::ASSET,],'cash' => [AccountType::CASH,],'expense' => [AccountType::EXPENSE, AccountType::BENEFICIARY,],diff --git a/app/Support/Http/Api/ApiSupport.php b/app/Support/Http/Api/ApiSupport.phpindex afe8de3b9e..342c8eb51d 100644--- a/app/Support/Http/Api/ApiSupport.php+++ b/app/Support/Http/Api/ApiSupport.php@@ -36,7 +36,7 @@ trait ApiSupport/*** Small helper function for the revenue and expense account charts.*- * @param array $names+ * @param array $names** @return array*/@@ -53,7 +53,7 @@ trait ApiSupport/*** Small helper function for the revenue and expense account charts.*- * @param Collection $accounts+ * @param Collection $accounts** @return array*/diff --git a/app/Support/Http/Api/ConvertsExchangeRates.php b/app/Support/Http/Api/ConvertsExchangeRates.phpindex ac022c6908..e3e567fcba 100644--- a/app/Support/Http/Api/ConvertsExchangeRates.php+++ b/app/Support/Http/Api/ConvertsExchangeRates.php@@ -37,10 +37,47 @@ trait ConvertsExchangeRates{private ?bool $enabled = null;+ /**+ * @param array $set+ * @return array+ */+ public function cerChartSet(array $set): array+ {+ if (null === $this->enabled) {+ $this->getPreference();+ }++ // if not enabled, return the same array but without conversion:+ if (false === $this->enabled) {+ $set['converted'] = false;+ return $set;+ }++ $set['converted'] = true;+ /** @var TransactionCurrency $native */+ $native = app('amount')->getDefaultCurrency();+ $currency = $this->getCurrency((int)$set['currency_id']);+ if ($native->id === $currency->id) {+ $set['native_id'] = (string)$currency->id;+ $set['native_code'] = $currency->code;+ $set['native_symbol'] = $currency->symbol;+ $set['native_decimal_places'] = $currency->decimal_places;+ return $set;+ }+ foreach ($set['entries'] as $date => $entry) {+ $carbon = Carbon::createFromFormat(DateTimeInterface::ATOM, $date);+ $rate = $this->getRate($currency, $native, $carbon);+ $rate = '0' === $rate ? '1' : $rate;+ Log::debug(sprintf('bcmul("%s", "%s")', (string)$entry, $rate));+ $set['entries'][$date] = (float)bcmul((string)$entry, $rate);+ }+ return $set;+ }+/*** For a sum of entries, get the exchange rate to the native currency of* the user.- * @param array $entries+ * @param array $entries* @return array*/public function cerSum(array $entries): array@@ -66,12 +103,12 @@ trait ConvertsExchangeRates$return = [];/** @var array $entry */foreach ($entries as $entry) {- $currency = $this->getCurrency((int) $entry['id']);+ $currency = $this->getCurrency((int)$entry['id']);if ($currency->id !== $native->id) {$amount = $this->convertAmount($entry['sum'], $currency, $native);$entry['converted'] = true;$entry['native_sum'] = $amount;- $entry['native_id'] = (string) $native->id;+ $entry['native_id'] = (string)$native->id;$entry['native_name'] = $native->name;$entry['native_symbol'] = $native->symbol;$entry['native_code'] = $native->code;@@ -80,7 +117,7 @@ trait ConvertsExchangeRatesif ($currency->id === $native->id) {$entry['converted'] = false;$entry['native_sum'] = $entry['sum'];- $entry['native_id'] = (string) $native->id;+ $entry['native_id'] = (string)$native->id;$entry['native_name'] = $native->name;$entry['native_symbol'] = $native->symbol;$entry['native_code'] = $native->code;@@ -92,44 +129,15 @@ trait ConvertsExchangeRates}/**- * @param array $set- * @return array+ * @return void*/- public function cerChartSet(array $set): array+ private function getPreference(): void{- if (null === $this->enabled) {- $this->getPreference();- }-- // if not enabled, return the same array but without conversion:- if (false === $this->enabled) {- $set['converted'] = false;- return $set;- }-- $set['converted'] = true;- /** @var TransactionCurrency $native */- $native = app('amount')->getDefaultCurrency();- $currency = $this->getCurrency((int) $set['currency_id']);- if ($native->id === $currency->id) {- $set['native_id'] = (string) $currency->id;- $set['native_code'] = $currency->code;- $set['native_symbol'] = $currency->symbol;- $set['native_decimal_places'] = $currency->decimal_places;- return $set;- }- foreach ($set['entries'] as $date => $entry) {- $carbon = Carbon::createFromFormat(DateTimeInterface::ATOM, $date);- $rate = $this->getRate($currency, $native, $carbon);- $rate = '0' === $rate ? '1' : $rate;- Log::debug(sprintf('bcmul("%s", "%s")', (string) $entry, $rate));- $set['entries'][$date] = (float) bcmul((string) $entry, $rate);- }- return $set;+ $this->enabled = true;}/**- * @param int $currencyId+ * @param int $currencyId* @return TransactionCurrency*/private function getCurrency(int $currencyId): TransactionCurrency@@ -142,9 +150,9 @@ trait ConvertsExchangeRates}/**- * @param string $amount- * @param TransactionCurrency $from- * @param TransactionCurrency $to+ * @param string $amount+ * @param TransactionCurrency $from+ * @param TransactionCurrency $to* @return string*/private function convertAmount(string $amount, TransactionCurrency $from, TransactionCurrency $to, ?Carbon $date = null): string@@ -157,9 +165,9 @@ trait ConvertsExchangeRates}/**- * @param TransactionCurrency $from- * @param TransactionCurrency $to- * @param Carbon $date+ * @param TransactionCurrency $from+ * @param TransactionCurrency $to+ * @param Carbon $date* @return string*/private function getRate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): string@@ -174,7 +182,7 @@ trait ConvertsExchangeRates->orderBy('date', 'DESC')->first();if (null !== $result) {- $rate = (string) $result->rate;+ $rate = (string)$result->rate;Log::debug(sprintf('Rate is %s', $rate));return $rate;}@@ -188,7 +196,7 @@ trait ConvertsExchangeRates->orderBy('date', 'DESC')->first();if (null !== $result) {- $rate = bcdiv('1', (string) $result->rate);+ $rate = bcdiv('1', (string)$result->rate);Log::debug(sprintf('Reversed rate is %s', $rate));return $rate;}@@ -213,8 +221,8 @@ trait ConvertsExchangeRates}/**- * @param TransactionCurrency $currency- * @param Carbon $date+ * @param TransactionCurrency $currency+ * @param Carbon $date* @return string*/private function getEuroRate(TransactionCurrency $currency, Carbon $date): string@@ -236,7 +244,7 @@ trait ConvertsExchangeRates->orderBy('date', 'DESC')->first();if (null !== $result) {- $rate = (string) $result->rate;+ $rate = (string)$result->rate;Log::debug(sprintf('Rate for %s to EUR is %s.', $currency->code, $rate));return $rate;}@@ -250,7 +258,7 @@ trait ConvertsExchangeRates->orderBy('date', 'DESC')->first();if (null !== $result) {- $rate = bcdiv('1', (string) $result->rate);+ $rate = bcdiv('1', (string)$result->rate);Log::debug(sprintf('Inverted rate for %s to EUR is %s.', $currency->code, $rate));return $rate;}@@ -258,12 +266,4 @@ trait ConvertsExchangeRatesLog::debug(sprintf('No rate for %s to EUR.', $currency->code));return '0';}-- /**- * @return void- */- private function getPreference(): void- {- $this->enabled = true;- }}diff --git a/app/Support/Http/Api/TransactionFilter.php b/app/Support/Http/Api/TransactionFilter.phpindex f0e703860d..b5b4376df0 100644--- a/app/Support/Http/Api/TransactionFilter.php+++ b/app/Support/Http/Api/TransactionFilter.php@@ -35,15 +35,20 @@ trait TransactionFilter/*** All the types you can request.*- * @param string $type+ * @param string $type** @return array*/protected function mapTransactionTypes(string $type): array{$types = [- 'all' => [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER, TransactionType::OPENING_BALANCE,- TransactionType::RECONCILIATION,],+ 'all' => [+ TransactionType::WITHDRAWAL,+ TransactionType::DEPOSIT,+ TransactionType::TRANSFER,+ TransactionType::OPENING_BALANCE,+ TransactionType::RECONCILIATION,+ ],'withdrawal' => [TransactionType::WITHDRAWAL,],'withdrawals' => [TransactionType::WITHDRAWAL,],'expense' => [TransactionType::WITHDRAWAL,],diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.phpindex 954cc77a65..1db9fb5f8f 100644--- a/app/Support/Http/Controllers/AugumentData.php+++ b/app/Support/Http/Controllers/AugumentData.php@@ -37,7 +37,6 @@ use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;use FireflyIII\Repositories\Category\CategoryRepositoryInterface;use FireflyIII\Support\CacheProperties;use Illuminate\Support\Collection;-use JsonException;/*** Trait AugumentData@@ -48,7 +47,7 @@ trait AugumentData/*** Searches for the opposing account.*- * @param Collection $accounts+ * @param Collection $accounts** @return array*/@@ -75,7 +74,7 @@ trait AugumentData/*** Small helper function for the revenue and expense account charts.*- * @param array $names+ * @param array $names** @return array*/@@ -92,7 +91,7 @@ trait AugumentData/*** Small helper function for the revenue and expense account charts.*- * @param Collection $accounts+ * @param Collection $accounts** @return array*/@@ -110,7 +109,7 @@ trait AugumentData/*** Get the account names belonging to a bunch of account ID's.*- * @param array $accountIds+ * @param array $accountIds** @return array*/@@ -123,7 +122,7 @@ trait AugumentData$return = [];foreach ($accountIds as $combinedId) {$parts = explode('-', $combinedId);- $accountId = (int) $parts[0];+ $accountId = (int)$parts[0];if (array_key_exists($accountId, $grouped)) {$return[$accountId] = $grouped[$accountId][0]['name'];}@@ -136,7 +135,7 @@ trait AugumentData/*** Get the budget names from a set of budget ID's.*- * @param array $budgetIds+ * @param array $budgetIds** @return array*/@@ -152,7 +151,7 @@ trait AugumentData$return[$budgetId] = $grouped[$budgetId][0]['name'];}}- $return[0] = (string) trans('firefly.no_budget');+ $return[0] = (string)trans('firefly.no_budget');return $return;}@@ -160,7 +159,7 @@ trait AugumentData/*** Get the category names from a set of category ID's. Small helper function for some of the charts.*- * @param array $categoryIds+ * @param array $categoryIds** @return array*/@@ -173,12 +172,12 @@ trait AugumentData$return = [];foreach ($categoryIds as $combinedId) {$parts = explode('-', $combinedId);- $categoryId = (int) $parts[0];+ $categoryId = (int)$parts[0];if (array_key_exists($categoryId, $grouped)) {$return[$categoryId] = $grouped[$categoryId][0]['name'];}}- $return[0] = (string) trans('firefly.no_category');+ $return[0] = (string)trans('firefly.no_category');return $return;}@@ -186,9 +185,9 @@ trait AugumentData/*** Gets all budget limits for a budget.*- * @param Budget $budget- * @param Carbon $start- * @param Carbon $end+ * @param Budget $budget+ * @param Carbon $start+ * @param Carbon $end** @return Collection*/@@ -221,7 +220,7 @@ trait AugumentData$currentStart = clone $entry->start_date;$currentEnd = clone $entry->end_date;$expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $currency);- $spent = $expenses[(int) $currency->id]['sum'] ?? '0';+ $spent = $expenses[(int)$currency->id]['sum'] ?? '0';$entry->spent = $spent;$limits->push($entry);@@ -234,7 +233,7 @@ trait AugumentData/*** Group set of transactions by name of opposing account.*- * @param array $array+ * @param array $array** @return array*/@@ -262,10 +261,10 @@ trait AugumentData/*** Spent in a period.*- * @param Collection $assets- * @param Collection $opposing- * @param Carbon $start- * @param Carbon $end+ * @param Collection $assets+ * @param Collection $opposing+ * @param Carbon $start+ * @param Carbon $end** @return array*/@@ -283,7 +282,7 @@ trait AugumentData];// loop to support multi currencyforeach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];// if not set, set to zero:if (!array_key_exists($currencyId, $sum['per_currency'])) {diff --git a/app/Support/Http/Controllers/BasicDataSupport.php b/app/Support/Http/Controllers/BasicDataSupport.phpindex 360634330b..d0bc600038 100644--- a/app/Support/Http/Controllers/BasicDataSupport.php+++ b/app/Support/Http/Controllers/BasicDataSupport.php@@ -34,8 +34,8 @@ trait BasicDataSupport/*** Find the ID in a given array. Return '0' if not there (amount).*- * @param array $array- * @param int $entryId+ * @param array $array+ * @param int $entryId** @return null|mixed*/@@ -47,8 +47,8 @@ trait BasicDataSupport/*** Find the ID in a given array. Return null if not there (amount).*- * @param array $array- * @param int $entryId+ * @param array $array+ * @param int $entryId** @return null|Carbon*/diff --git a/app/Support/Http/Controllers/ChartGeneration.php b/app/Support/Http/Controllers/ChartGeneration.phpindex 7ccdbe8a73..ce5518e8d3 100644--- a/app/Support/Http/Controllers/ChartGeneration.php+++ b/app/Support/Http/Controllers/ChartGeneration.php@@ -42,9 +42,9 @@ trait ChartGeneration/*** Shows an overview of the account balances for a set of accounts.*- * @param Collection $accounts- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end** @return array* @throws FireflyException@@ -76,7 +76,7 @@ trait ChartGeneration/** @var Account $account */foreach ($accounts as $account) {// TODO we can use getAccountCurrency instead.- $currency = $repository->find((int) $accountRepos->getMetaValue($account, 'currency_id'));+ $currency = $repository->find((int)$accountRepos->getMetaValue($account, 'currency_id'));if (null === $currency) {$currency = $default;}@@ -91,7 +91,7 @@ trait ChartGeneration$previous = array_values($range)[0];while ($currentStart <= $end) {$format = $currentStart->format('Y-m-d');- $label = trim($currentStart->isoFormat((string) trans('config.month_and_day_js', [], $locale)));+ $label = trim($currentStart->isoFormat((string)trans('config.month_and_day_js', [], $locale)));$balance = $range[$format] ?? $previous;$previous = $balance;$currentStart->addDay();diff --git a/app/Support/Http/Controllers/CreateStuff.php b/app/Support/Http/Controllers/CreateStuff.phpindex 690d652915..368b57ea1e 100644--- a/app/Support/Http/Controllers/CreateStuff.php+++ b/app/Support/Http/Controllers/CreateStuff.php@@ -42,8 +42,8 @@ trait CreateStuff/*** Creates an asset account.*- * @param NewUserFormRequest $request- * @param TransactionCurrency $currency+ * @param NewUserFormRequest $request+ * @param TransactionCurrency $currency** @return bool*/@@ -72,8 +72,8 @@ trait CreateStuff/*** Creates a cash wallet.*- * @param TransactionCurrency $currency- * @param string $language+ * @param TransactionCurrency $currency+ * @param string $language** @return bool*/@@ -82,7 +82,7 @@ trait CreateStuff/** @var AccountRepositoryInterface $repository */$repository = app(AccountRepositoryInterface::class);$assetAccount = [- 'name' => (string) trans('firefly.cash_wallet', [], $language),+ 'name' => (string)trans('firefly.cash_wallet', [], $language),'iban' => null,'account_type_name' => 'asset','virtual_balance' => 0,@@ -138,9 +138,9 @@ trait CreateStuff/*** Create a savings account.*- * @param NewUserFormRequest $request- * @param TransactionCurrency $currency- * @param string $language+ * @param NewUserFormRequest $request+ * @param TransactionCurrency $currency+ * @param string $language** @return bool*/@@ -149,7 +149,7 @@ trait CreateStuff/** @var AccountRepositoryInterface $repository */$repository = app(AccountRepositoryInterface::class);$savingsAccount = [- 'name' => (string) trans('firefly.new_savings_account', ['bank_name' => $request->get('bank_name')], $language),+ 'name' => (string)trans('firefly.new_savings_account', ['bank_name' => $request->get('bank_name')], $language),'iban' => null,'account_type_name' => 'asset','account_type_id' => null,@@ -168,7 +168,7 @@ trait CreateStuff/*** Create a new user instance after a valid registration.*- * @param array $data+ * @param array $data** @return User*/diff --git a/app/Support/Http/Controllers/CronRunner.php b/app/Support/Http/Controllers/CronRunner.phpindex 58ca2826d9..db119cab87 100644--- a/app/Support/Http/Controllers/CronRunner.php+++ b/app/Support/Http/Controllers/CronRunner.php@@ -34,8 +34,8 @@ use FireflyIII\Support\Cronjobs\RecurringCronjob;trait CronRunner{/**- * @param bool $force- * @param Carbon $date+ * @param bool $force+ * @param Carbon $date** @return array*/@@ -65,8 +65,8 @@ trait CronRunner}/**- * @param bool $force- * @param Carbon $date+ * @param bool $force+ * @param Carbon $date** @return array*/diff --git a/app/Support/Http/Controllers/DateCalculation.php b/app/Support/Http/Controllers/DateCalculation.phpindex 9c92f971ac..563146f321 100644--- a/app/Support/Http/Controllers/DateCalculation.php+++ b/app/Support/Http/Controllers/DateCalculation.php@@ -37,8 +37,8 @@ trait DateCalculation** If both are in the past OR both are in the future, simply return the number of days in the period with a minimum of 1*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return int*/@@ -59,8 +59,8 @@ trait DateCalculation** If both are in the past OR both are in the future, simply return the period between them with a minimum of 1*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return int*/@@ -77,8 +77,8 @@ trait DateCalculation}/**- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -103,8 +103,8 @@ trait DateCalculation* Get a list of the periods that will occur after this date. For example,* March 2018, April 2018, etc.*- * @param Carbon $date- * @param string $range+ * @param Carbon $date+ * @param string $range** @return array*/@@ -139,8 +139,8 @@ trait DateCalculation* Get a list of the periods that occurred before the start date. For example,* March 2018, February 2018, etc.*- * @param Carbon $date- * @param string $range+ * @param Carbon $date+ * @param string $range** @return array*/diff --git a/app/Support/Http/Controllers/GetConfigurationData.php b/app/Support/Http/Controllers/GetConfigurationData.phpindex b465743356..7b5561d3a2 100644--- a/app/Support/Http/Controllers/GetConfigurationData.php+++ b/app/Support/Http/Controllers/GetConfigurationData.php@@ -26,6 +26,8 @@ namespace FireflyIII\Support\Http\Controllers;use Carbon\Carbon;use FireflyIII\Exceptions\FireflyException;use Log;+use Psr\Container\ContainerExceptionInterface;+use Psr\Container\NotFoundExceptionInterface;/*** Trait GetConfigurationData@@ -36,7 +38,7 @@ trait GetConfigurationData/*** Some common combinations.*- * @param int $value+ * @param int $value** @return string*/@@ -52,13 +54,13 @@ trait GetConfigurationDataE_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERROR => 'E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR',];- return $array[$value] ?? (string) $value;+ return $array[$value] ?? (string)$value;}/*** Get the basic steps from config.*- * @param string $route+ * @param string $route** @return array*/@@ -72,7 +74,7 @@ trait GetConfigurationData$currentStep = $options;// get the text:- $currentStep['intro'] = (string) trans('intro.' . $route . '_' . $key);+ $currentStep['intro'] = (string)trans('intro.'.$route.'_'.$key);// save in array:$steps[] = $currentStep;@@ -88,12 +90,12 @@ trait GetConfigurationData** @return array* @throws FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/protected function getDateRangeConfig(): array // get configuration + get preferences.{- $viewRange = (string) app('preferences')->get('viewRange', '1M')->data;+ $viewRange = (string)app('preferences')->get('viewRange', '1M')->data;/** @var Carbon $start */$start = session('start');/** @var Carbon $end */@@ -134,41 +136,41 @@ trait GetConfigurationData/** @var Carbon $todayEnd */$todayEnd = app('navigation')->endOfPeriod($todayStart, $viewRange);if ($todayStart->ne($start) || $todayEnd->ne($end)) {- $ranges[ucfirst((string) trans('firefly.today'))] = [$todayStart, $todayEnd];+ $ranges[ucfirst((string)trans('firefly.today'))] = [$todayStart, $todayEnd];}// last seven days:$seven = Carbon::now()->subDays(7);- $index = (string) trans('firefly.last_seven_days');+ $index = (string)trans('firefly.last_seven_days');$ranges[$index] = [$seven, new Carbon()];// last 30 days:$thirty = Carbon::now()->subDays(30);- $index = (string) trans('firefly.last_thirty_days');+ $index = (string)trans('firefly.last_thirty_days');$ranges[$index] = [$thirty, new Carbon()];// month to date:$monthBegin = Carbon::now()->startOfMonth();- $index = (string) trans('firefly.month_to_date');+ $index = (string)trans('firefly.month_to_date');$ranges[$index] = [$monthBegin, new Carbon()];// year to date:$yearBegin = Carbon::now()->startOfYear();- $index = (string) trans('firefly.year_to_date');+ $index = (string)trans('firefly.year_to_date');$ranges[$index] = [$yearBegin, new Carbon()];// everything- $index = (string) trans('firefly.everything');+ $index = (string)trans('firefly.everything');$ranges[$index] = [$first, new Carbon()];return ['title' => $title,'configuration' => [- 'apply' => (string) trans('firefly.apply'),- 'cancel' => (string) trans('firefly.cancel'),- 'from' => (string) trans('firefly.from'),- 'to' => (string) trans('firefly.to'),- 'customRange' => (string) trans('firefly.customRange'),+ 'apply' => (string)trans('firefly.apply'),+ 'cancel' => (string)trans('firefly.cancel'),+ 'from' => (string)trans('firefly.from'),+ 'to' => (string)trans('firefly.to'),+ 'customRange' => (string)trans('firefly.customRange'),'start' => $start->format('Y-m-d'),'end' => $end->format('Y-m-d'),'ranges' => $ranges,@@ -179,8 +181,8 @@ trait GetConfigurationData/*** Get specific info for special routes.*- * @param string $route- * @param string $specificPage+ * @param string $route+ * @param string $specificPage** @return array*@@ -193,13 +195,13 @@ trait GetConfigurationData// user is on page with specific instructions:if ('' !== $specificPage) {$routeKey = str_replace('.', '_', $route);- $elements = config(sprintf('intro.%s', $routeKey . '_' . $specificPage));+ $elements = config(sprintf('intro.%s', $routeKey.'_'.$specificPage));if (is_array($elements) && count($elements) > 0) {foreach ($elements as $key => $options) {$currentStep = $options;// get the text:- $currentStep['intro'] = (string) trans('intro.' . $route . '_' . $specificPage . '_' . $key);+ $currentStep['intro'] = (string)trans('intro.'.$route.'_'.$specificPage.'_'.$key);// save in array:$steps[] = $currentStep;@@ -217,7 +219,7 @@ trait GetConfigurationDataprotected function verifyRecurringCronJob(): void{$config = app('fireflyconfig')->get('last_rt_job', 0);- $lastTime = (int) $config->data;+ $lastTime = (int)$config->data;$now = time();Log::debug(sprintf('verifyRecurringCronJob: last time is %d ("%s"), now is %d', $lastTime, $config->data, $now));if (0 === $lastTime) {diff --git a/app/Support/Http/Controllers/ModelInformation.php b/app/Support/Http/Controllers/ModelInformation.phpindex 7581e2b871..957549e1cd 100644--- a/app/Support/Http/Controllers/ModelInformation.php+++ b/app/Support/Http/Controllers/ModelInformation.php@@ -42,7 +42,7 @@ trait ModelInformation/*** Get actions based on a bill.*- * @param Bill $bill+ * @param Bill $bill** @return array*/@@ -80,13 +80,13 @@ trait ModelInformation/** @var AccountRepositoryInterface $repository */$repository = app(AccountRepositoryInterface::class);// types of liability:- $debt = $repository->getAccountTypeByType(AccountType::DEBT);- $loan = $repository->getAccountTypeByType(AccountType::LOAN);- $mortgage = $repository->getAccountTypeByType(AccountType::MORTGAGE);+ $debt = $repository->getAccountTypeByType(AccountType::DEBT);+ $loan = $repository->getAccountTypeByType(AccountType::LOAN);+ $mortgage = $repository->getAccountTypeByType(AccountType::MORTGAGE);$liabilityTypes = [- $debt->id => (string) trans(sprintf('firefly.account_type_%s', AccountType::DEBT)),- $loan->id => (string) trans(sprintf('firefly.account_type_%s', AccountType::LOAN)),- $mortgage->id => (string) trans(sprintf('firefly.account_type_%s', AccountType::MORTGAGE)),+ $debt->id => (string)trans(sprintf('firefly.account_type_%s', AccountType::DEBT)),+ $loan->id => (string)trans(sprintf('firefly.account_type_%s', AccountType::LOAN)),+ $mortgage->id => (string)trans(sprintf('firefly.account_type_%s', AccountType::MORTGAGE)),];asort($liabilityTypes);@@ -101,7 +101,7 @@ trait ModelInformation{$roles = [];foreach (config('firefly.accountRoles') as $role) {- $roles[$role] = (string) trans(sprintf('firefly.account_role_%s', $role));+ $roles[$role] = (string)trans(sprintf('firefly.account_role_%s', $role));}return $roles;@@ -110,7 +110,7 @@ trait ModelInformation/*** Create fake triggers to match the bill's properties*- * @param Bill $bill+ * @param Bill $bill** @return array*/@@ -121,7 +121,7 @@ trait ModelInformation$triggers = [];foreach ($operators as $key => $operator) {if ('user_action' !== $key && false === $operator['alias']) {- $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));+ $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));}}asort($triggers);@@ -161,7 +161,7 @@ trait ModelInformation}/**- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return array*/@@ -172,7 +172,7 @@ trait ModelInformation$triggers = [];foreach ($operators as $key => $operator) {if ('user_action' !== $key && false === $operator['alias']) {- $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));+ $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));}}asort($triggers);diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.phpindex f851d0b59c..99e98c590b 100644--- a/app/Support/Http/Controllers/PeriodOverview.php+++ b/app/Support/Http/Controllers/PeriodOverview.php@@ -33,8 +33,9 @@ use FireflyIII\Models\TransactionType;use FireflyIII\Repositories\Journal\JournalRepositoryInterface;use FireflyIII\Support\CacheProperties;use Illuminate\Support\Collection;-use JsonException;use Log;+use Psr\Container\ContainerExceptionInterface;+use Psr\Container\NotFoundExceptionInterface;/*** Trait PeriodOverview.@@ -73,14 +74,14 @@ trait PeriodOverview* and for each period, the amount of money spent and earned. This is a complex operation which is cached for* performance reasons.*- * @param Account $account- * @param Carbon $start- * @param Carbon $end+ * @param Account $account+ * @param Carbon $start+ * @param Carbon $end** @return array* @throws FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/protected function getAccountPeriodOverview(Account $account, Carbon $start, Carbon $end): array{@@ -152,9 +153,9 @@ trait PeriodOverview/*** Filter a list of journals by a set of dates, and then group them by currency.*- * @param array $array- * @param Carbon $start- * @param Carbon $end+ * @param array $array+ * @param Carbon $start+ * @param Carbon $end** @return array*/@@ -174,8 +175,8 @@ trait PeriodOverview/*** Return only transactions where $account is the source.*- * @param Account $account- * @param array $journals+ * @param Account $account+ * @param array $journals** @return array*/@@ -184,7 +185,7 @@ trait PeriodOverview$return = [];/** @var array $journal */foreach ($journals as $journal) {- if ($account->id === (int) $journal['source_account_id']) {+ if ($account->id === (int)$journal['source_account_id']) {$return[] = $journal;}}@@ -195,8 +196,8 @@ trait PeriodOverview/*** Return only transactions where $account is the source.*- * @param Account $account- * @param array $journals+ * @param Account $account+ * @param array $journals** @return array* @codeCoverageIgnore@@ -206,7 +207,7 @@ trait PeriodOverview$return = [];/** @var array $journal */foreach ($journals as $journal) {- if ($account->id === (int) $journal['destination_account_id']) {+ if ($account->id === (int)$journal['destination_account_id']) {$return[] = $journal;}}@@ -215,7 +216,7 @@ trait PeriodOverview}/**- * @param array $journals+ * @param array $journals** @return array* @codeCoverageIgnore@@ -225,7 +226,7 @@ trait PeriodOverview$return = [];/** @var array $journal */foreach ($journals as $journal) {- $currencyId = (int) $journal['currency_id'];+ $currencyId = (int)$journal['currency_id'];$foreignCurrencyId = $journal['foreign_currency_id'];if (!array_key_exists($currencyId, $return)) {$return[$currencyId] = [@@ -246,7 +247,7 @@ trait PeriodOverview$return[$foreignCurrencyId] = ['amount' => '0','count' => 0,- 'currency_id' => (int) $foreignCurrencyId,+ 'currency_id' => (int)$foreignCurrencyId,'currency_name' => $journal['foreign_currency_name'],'currency_code' => $journal['foreign_currency_code'],'currency_symbol' => $journal['foreign_currency_symbol'],@@ -264,14 +265,14 @@ trait PeriodOverview/*** Overview for single category. Has been refactored recently.*- * @param Category $category- * @param Carbon $start- * @param Carbon $end+ * @param Category $category+ * @param Carbon $start+ * @param Carbon $end** @return array* @throws FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/protected function getCategoryPeriodOverview(Category $category, Carbon $start, Carbon $end): array{@@ -345,13 +346,13 @@ trait PeriodOverview** This method has been refactored recently.*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return array* @throws FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/protected function getNoBudgetPeriodOverview(Carbon $start, Carbon $end): array{@@ -401,12 +402,12 @@ trait PeriodOverview** Show period overview for no category view.*- * @param Carbon $theDate+ * @param Carbon $theDate** @return array* @throws FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/protected function getNoCategoryPeriodOverview(Carbon $theDate): array{@@ -471,14 +472,14 @@ trait PeriodOverview/*** This shows a period overview for a tag. It goes back in time and lists all relevant transactions and sums.*- * @param Tag $tag- * @param Carbon $start- * @param Carbon $end+ * @param Tag $tag+ * @param Carbon $start+ * @param Carbon $end** @return array* @throws FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/protected function getTagPeriodOverview(Tag $tag, Carbon $start, Carbon $end): array // period overview for tags.{@@ -546,14 +547,14 @@ trait PeriodOverview}/**- * @param string $transactionType- * @param Carbon $start- * @param Carbon $end+ * @param string $transactionType+ * @param Carbon $start+ * @param Carbon $end** @return array* @throws FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/protected function getTransactionPeriodOverview(string $transactionType, Carbon $start, Carbon $end): array{diff --git a/app/Support/Http/Controllers/RenderPartialViews.php b/app/Support/Http/Controllers/RenderPartialViews.phpindex 19817ba2f7..026bffd204 100644--- a/app/Support/Http/Controllers/RenderPartialViews.php+++ b/app/Support/Http/Controllers/RenderPartialViews.php@@ -48,7 +48,7 @@ trait RenderPartialViews/*** View for transactions in a budget for an account.*- * @param array $attributes+ * @param array $attributes** @return string*/@@ -59,10 +59,10 @@ trait RenderPartialViews/** @var BudgetRepositoryInterface $budgetRepository */$budgetRepository = app(BudgetRepositoryInterface::class);- $budget = $budgetRepository->find((int) $attributes['budgetId']);+ $budget = $budgetRepository->find((int)$attributes['budgetId']);$accountRepos = app(AccountRepositoryInterface::class);- $account = $accountRepos->find((int) $attributes['accountId']);+ $account = $accountRepos->find((int)$attributes['accountId']);$journals = $popupHelper->balanceForBudget($budget, $account, $attributes);@@ -102,7 +102,7 @@ trait RenderPartialViews/*** View for spent in a single budget.*- * @param array $attributes+ * @param array $attributes** @return string*/@@ -114,7 +114,7 @@ trait RenderPartialViews/** @var PopupReportInterface $popupHelper */$popupHelper = app(PopupReportInterface::class);- $budget = $budgetRepository->find((int) $attributes['budgetId']);+ $budget = $budgetRepository->find((int)$attributes['budgetId']);if (null === $budget) {$budget = new Budget();}@@ -134,7 +134,7 @@ trait RenderPartialViews/*** View for transactions in a category.*- * @param array $attributes+ * @param array $attributes** @return string*/@@ -145,7 +145,7 @@ trait RenderPartialViews/** @var CategoryRepositoryInterface $categoryRepository */$categoryRepository = app(CategoryRepositoryInterface::class);- $category = $categoryRepository->find((int) $attributes['categoryId']);+ $category = $categoryRepository->find((int)$attributes['categoryId']);$journals = $popupHelper->byCategory($category, $attributes);try {@@ -226,7 +226,7 @@ trait RenderPartialViews/*** Returns all the expenses that went to the given expense account.*- * @param array $attributes+ * @param array $attributes** @return string*/@@ -238,7 +238,7 @@ trait RenderPartialViews/** @var PopupReportInterface $popupHelper */$popupHelper = app(PopupReportInterface::class);- $account = $accountRepository->find((int) $attributes['accountId']);+ $account = $accountRepository->find((int)$attributes['accountId']);if (null === $account) {return 'This is an unknown account. Apologies.';@@ -260,7 +260,7 @@ trait RenderPartialViews/*** Get current (from system) rule actions.*- * @param Rule $rule+ * @param Rule $rule** @return array*/@@ -298,7 +298,7 @@ trait RenderPartialViews/*** Get current (from DB) rule triggers.*- * @param Rule $rule+ * @param Rule $rule** @return array*@@ -310,7 +310,7 @@ trait RenderPartialViews$triggers = [];foreach ($operators as $key => $operator) {if ('user_action' !== $key && false === $operator['alias']) {- $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));+ $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));}}asort($triggers);@@ -354,7 +354,7 @@ trait RenderPartialViews/*** Returns all the incomes that went to the given asset account.*- * @param array $attributes+ * @param array $attributes** @return string*/@@ -365,7 +365,7 @@ trait RenderPartialViews/** @var PopupReportInterface $popupHelper */$popupHelper = app(PopupReportInterface::class);- $account = $accountRepository->find((int) $attributes['accountId']);+ $account = $accountRepository->find((int)$attributes['accountId']);if (null === $account) {return 'This is an unknown category. Apologies.';diff --git a/app/Support/Http/Controllers/RequestInformation.php b/app/Support/Http/Controllers/RequestInformation.phpindex f0d9ca2d73..e85afb2e81 100644--- a/app/Support/Http/Controllers/RequestInformation.php+++ b/app/Support/Http/Controllers/RequestInformation.php@@ -37,6 +37,8 @@ use Illuminate\Routing\Route;use Illuminate\Support\Facades\Validator;use InvalidArgumentException;use Log;+use Psr\Container\ContainerExceptionInterface;+use Psr\Container\NotFoundExceptionInterface;use Route as RouteFacade;/**@@ -88,8 +90,8 @@ trait RequestInformation** @return bool* @throws FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/final protected function hasSeenDemo(): bool // get request info + get preference{diff --git a/app/Support/Http/Controllers/RuleManagement.php b/app/Support/Http/Controllers/RuleManagement.phpindex 7803c2edb8..a839b01018 100644--- a/app/Support/Http/Controllers/RuleManagement.php+++ b/app/Support/Http/Controllers/RuleManagement.php@@ -37,7 +37,7 @@ use Throwable;trait RuleManagement{/**- * @param Request $request+ * @param Request $request** @return array* @codeCoverageIgnore@@ -55,7 +55,7 @@ trait RuleManagement['oldAction' => $oldAction['type'],'oldValue' => $oldAction['value'],- 'oldChecked' => 1 === (int) ($oldAction['stop_processing'] ?? '0'),+ 'oldChecked' => 1 === (int)($oldAction['stop_processing'] ?? '0'),'count' => $index + 1,])->render();@@ -72,7 +72,7 @@ trait RuleManagement}/**- * @param Request $request+ * @param Request $request** @return array* @codeCoverageIgnore@@ -84,7 +84,7 @@ trait RuleManagement$triggers = [];foreach ($operators as $key => $operator) {if ('user_action' !== $key && false === $operator['alias']) {- $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));+ $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));}}asort($triggers);@@ -100,8 +100,8 @@ trait RuleManagement['oldTrigger' => OperatorQuerySearch::getRootOperator($oldTrigger['type']),'oldValue' => $oldTrigger['value'],- 'oldChecked' => 1 === (int) ($oldTrigger['stop_processing'] ?? '0'),- 'oldProhibited' => 1 === (int) ($oldTrigger['prohibited'] ?? '0'),+ 'oldChecked' => 1 === (int)($oldTrigger['stop_processing'] ?? '0'),+ 'oldProhibited' => 1 === (int)($oldTrigger['prohibited'] ?? '0'),'count' => $index + 1,'triggers' => $triggers,]@@ -119,7 +119,7 @@ trait RuleManagement}/**- * @param array $submittedOperators+ * @param array $submittedOperators** @return array*/@@ -131,7 +131,7 @@ trait RuleManagement$triggers = [];foreach ($operators as $key => $operator) {if ('user_action' !== $key && false === $operator['alias']) {- $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));+ $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));}}asort($triggers);@@ -169,8 +169,8 @@ trait RuleManagement$repository = app(RuleGroupRepositoryInterface::class);if (0 === $repository->count()) {$data = [- 'title' => (string) trans('firefly.default_rule_group_name'),- 'description' => (string) trans('firefly.default_rule_group_description'),+ 'title' => (string)trans('firefly.default_rule_group_name'),+ 'description' => (string)trans('firefly.default_rule_group_description'),'active' => true,];diff --git a/app/Support/Http/Controllers/TransactionCalculation.php b/app/Support/Http/Controllers/TransactionCalculation.phpindex c17c26a7a5..5d8ac77d9d 100644--- a/app/Support/Http/Controllers/TransactionCalculation.php+++ b/app/Support/Http/Controllers/TransactionCalculation.php@@ -37,10 +37,10 @@ trait TransactionCalculation/*** Get all expenses for a set of accounts.*- * @param Collection $accounts- * @param Collection $opposing- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $opposing+ * @param Carbon $start+ * @param Carbon $end** @return array*/@@ -61,10 +61,10 @@ trait TransactionCalculation/*** Get all expenses by tags.*- * @param Collection $accounts- * @param Collection $tags- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $tags+ * @param Carbon $start+ * @param Carbon $end** @return array*@@ -83,10 +83,10 @@ trait TransactionCalculation/*** Helper function that collects expenses for the given budgets.*- * @param Collection $accounts- * @param Collection $budgets- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $budgets+ * @param Carbon $start+ * @param Carbon $end** @return array*/@@ -103,10 +103,10 @@ trait TransactionCalculation/*** Get all expenses in a period for categories.*- * @param Collection $accounts- * @param Collection $categories- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end** @return array*/@@ -127,10 +127,10 @@ trait TransactionCalculation/*** Get all income for a period and a bunch of categories.*- * @param Collection $accounts- * @param Collection $categories- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end** @return array*/@@ -147,10 +147,10 @@ trait TransactionCalculation/*** Get the income for a set of accounts.*- * @param Collection $accounts- * @param Collection $opposing- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $opposing+ * @param Carbon $start+ * @param Carbon $end** @return array*/@@ -167,10 +167,10 @@ trait TransactionCalculation/*** Get all income by tag.*- * @param Collection $accounts- * @param Collection $tags- * @param Carbon $start- * @param Carbon $end+ * @param Collection $accounts+ * @param Collection $tags+ * @param Carbon $start+ * @param Carbon $end** @return array*/diff --git a/app/Support/Http/Controllers/UserNavigation.php b/app/Support/Http/Controllers/UserNavigation.phpindex 328501a1e1..84cf46b458 100644--- a/app/Support/Http/Controllers/UserNavigation.php+++ b/app/Support/Http/Controllers/UserNavigation.php@@ -46,14 +46,14 @@ trait UserNavigation* will be returned.* - If the remembered url contains "jscript/" the remembered url will not be returned but instead the index (/) will be returned.*- * @param string $identifier+ * @param string $identifier** @return string*/final protected function getPreviousUrl(string $identifier): string{Log::debug(sprintf('Trying to retrieve URL stored under "%s"', $identifier));- $url = (string) session($identifier);+ $url = (string)session($identifier);Log::debug(sprintf('The URL is %s', $url));return app('steam')->getSafeUrl($url, route('index'));@@ -62,7 +62,7 @@ trait UserNavigation/*** Will return false if you cant edit this account type.*- * @param Account $account+ * @param Account $account** @return bool*/@@ -75,7 +75,7 @@ trait UserNavigation}/**- * @param TransactionGroup $group+ * @param TransactionGroup $group** @return bool*/@@ -93,7 +93,7 @@ trait UserNavigation}/**- * @param Account $account+ * @param Account $account** @return RedirectResponse|Redirector*/@@ -128,7 +128,7 @@ trait UserNavigation}/**- * @param TransactionGroup $group+ * @param TransactionGroup $group** @return RedirectResponse|Redirector*/@@ -156,7 +156,7 @@ trait UserNavigation}/**- * @param string $identifier+ * @param string $identifier** @return string|null*/diff --git a/app/Support/Logging/AuditLogger.php b/app/Support/Logging/AuditLogger.phpindex 73a805ace2..d08542122d 100644--- a/app/Support/Logging/AuditLogger.php+++ b/app/Support/Logging/AuditLogger.php@@ -38,7 +38,7 @@ class AuditLogger/*** Customize the given logger instance.*- * @param Logger $logger+ * @param Logger $logger** @return void*/diff --git a/app/Support/Logging/AuditProcessor.php b/app/Support/Logging/AuditProcessor.phpindex a233be4118..acc4cc1e33 100644--- a/app/Support/Logging/AuditProcessor.php+++ b/app/Support/Logging/AuditProcessor.php@@ -32,7 +32,7 @@ namespace FireflyIII\Support\Logging;class AuditProcessor{/**- * @param array $record+ * @param array $record** @return array*/diff --git a/app/Support/Navigation.php b/app/Support/Navigation.phpindex 900c9c9767..26ac764273 100644--- a/app/Support/Navigation.php+++ b/app/Support/Navigation.php@@ -1,4 +1,5 @@<?php+/*** Navigation.php* Copyright (c) 2019 [email protected]@@ -33,9 +34,9 @@ use Log;class Navigation{/**- * @param Carbon $theDate- * @param string $repeatFreq- * @param int $skip+ * @param Carbon $theDate+ * @param string $repeatFreq+ * @param int $skip** @return Carbon*/@@ -99,9 +100,9 @@ class Navigation}/**- * @param Carbon $start- * @param Carbon $end- * @param string $range+ * @param Carbon $start+ * @param Carbon $end+ * @param string $range** @return array*@@ -160,8 +161,8 @@ class Navigation}/**- * @param Carbon $theDate- * @param string $repeatFreq+ * @param Carbon $theDate+ * @param string $repeatFreq** @return Carbon*/@@ -210,8 +211,8 @@ class Navigation}/**- * @param Carbon $end- * @param string $repeatFreq+ * @param Carbon $end+ * @param string $repeatFreq** @return Carbon*/@@ -288,9 +289,9 @@ class Navigation}/**- * @param Carbon $theCurrentEnd- * @param string $repeatFreq- * @param Carbon|null $maxDate+ * @param Carbon $theCurrentEnd+ * @param string $repeatFreq+ * @param Carbon|null $maxDate** @return Carbon*/@@ -328,8 +329,8 @@ class Navigation}/**- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return array* @throws FireflyException@@ -340,17 +341,17 @@ class Navigation// define period to increment$increment = 'addDay';$format = $this->preferredCarbonFormat($start, $end);- $displayFormat = (string) trans('config.month_and_day_js', [], $locale);+ $displayFormat = (string)trans('config.month_and_day_js', [], $locale);// increment by month (for year)if ($start->diffInMonths($end) > 1) {$increment = 'addMonth';- $displayFormat = (string) trans('config.month_js');+ $displayFormat = (string)trans('config.month_js');}// increment by year (for multi year)if ($start->diffInMonths($end) > 12) {$increment = 'addYear';- $displayFormat = (string) trans('config.year_js');+ $displayFormat = (string)trans('config.year_js');}$begin = clone $start;$entries = [];@@ -368,8 +369,8 @@ class Navigation* If the date difference between start and end is less than a month, method returns "Y-m-d". If the difference is less than a year,* method returns "Y-m". If the date difference is larger, method returns "Y".*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -388,8 +389,8 @@ class Navigation}/**- * @param Carbon $theDate- * @param string $repeatFrequency+ * @param Carbon $theDate+ * @param string $repeatFrequency** @return string*/@@ -397,23 +398,23 @@ class Navigation{$date = clone $theDate;$formatMap = [- '1D' => (string) trans('config.specific_day_js'),- 'daily' => (string) trans('config.specific_day_js'),- 'custom' => (string) trans('config.specific_day_js'),- '1W' => (string) trans('config.week_in_year_js'),- 'week' => (string) trans('config.week_in_year_js'),- 'weekly' => (string) trans('config.week_in_year_js'),- '1M' => (string) trans('config.month_js'),- 'month' => (string) trans('config.month_js'),- 'monthly' => (string) trans('config.month_js'),- '1Y' => (string) trans('config.year_js'),- 'year' => (string) trans('config.year_js'),- 'yearly' => (string) trans('config.year_js'),- '6M' => (string) trans('config.half_year_js'),+ '1D' => (string)trans('config.specific_day_js'),+ 'daily' => (string)trans('config.specific_day_js'),+ 'custom' => (string)trans('config.specific_day_js'),+ '1W' => (string)trans('config.week_in_year_js'),+ 'week' => (string)trans('config.week_in_year_js'),+ 'weekly' => (string)trans('config.week_in_year_js'),+ '1M' => (string)trans('config.month_js'),+ 'month' => (string)trans('config.month_js'),+ 'monthly' => (string)trans('config.month_js'),+ '1Y' => (string)trans('config.year_js'),+ 'year' => (string)trans('config.year_js'),+ 'yearly' => (string)trans('config.year_js'),+ '6M' => (string)trans('config.half_year_js'),];if (array_key_exists($repeatFrequency, $formatMap)) {- return $date->isoFormat((string) $formatMap[$repeatFrequency]);+ return $date->isoFormat((string)$formatMap[$repeatFrequency]);}if ('3M' === $repeatFrequency || 'quarter' === $repeatFrequency) {$quarter = ceil($theDate->month / 3);@@ -431,8 +432,8 @@ class Navigation* If the date difference between start and end is less than a month, method returns trans(config.month_and_day). If the difference is less than a year,* method returns "config.month". If the date difference is larger, method returns "config.year".*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return string* @throws FireflyException@@ -440,13 +441,13 @@ class Navigationpublic function preferredCarbonLocalizedFormat(Carbon $start, Carbon $end): string{$locale = app('steam')->getLocale();- $format = (string) trans('config.month_and_day_js', [], $locale);+ $format = (string)trans('config.month_and_day_js', [], $locale);if ($start->diffInMonths($end) > 1) {- $format = (string) trans('config.month_js', [], $locale);+ $format = (string)trans('config.month_js', [], $locale);}if ($start->diffInMonths($end) > 12) {- $format = (string) trans('config.year_js', [], $locale);+ $format = (string)trans('config.year_js', [], $locale);}return $format;@@ -456,8 +457,8 @@ class Navigation* If the date difference between start and end is less than a month, method returns "endOfDay". If the difference is less than a year,* method returns "endOfMonth". If the date difference is larger, method returns "endOfYear".*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -479,8 +480,8 @@ class Navigation* If the date difference between start and end is less than a month, method returns "1D". If the difference is less than a year,* method returns "1M". If the date difference is larger, method returns "1Y".*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -502,8 +503,8 @@ class Navigation* If the date difference between start and end is less than a month, method returns "%Y-%m-%d". If the difference is less than a year,* method returns "%Y-%m". If the date difference is larger, method returns "%Y".*- * @param Carbon $start- * @param Carbon $end+ * @param Carbon $start+ * @param Carbon $end** @return string*/@@ -522,9 +523,9 @@ class Navigation}/**- * @param Carbon $theDate- * @param string $repeatFreq- * @param int|null $subtract+ * @param Carbon $theDate+ * @param string $repeatFreq+ * @param int|null $subtract** @return Carbon*@@ -611,8 +612,8 @@ class Navigation}/**- * @param string $range- * @param Carbon $start+ * @param string $range+ * @param Carbon $start** @return Carbon*@@ -670,8 +671,8 @@ class Navigation}/**- * @param string $range- * @param Carbon $start+ * @param string $range+ * @param Carbon $start** @return Carbon*diff --git a/app/Support/NullArrayObject.php b/app/Support/NullArrayObject.phpindex 60d20319db..061bceba6b 100644--- a/app/Support/NullArrayObject.php+++ b/app/Support/NullArrayObject.php@@ -37,8 +37,8 @@ class NullArrayObject extends ArrayObject/*** NullArrayObject constructor.*- * @param array $array- * @param null $default+ * @param array $array+ * @param null $default*/public function __construct(array $array, $default = null){@@ -47,7 +47,7 @@ class NullArrayObject extends ArrayObject}/**- * @param mixed $key+ * @param mixed $key** @return mixed|null*/diff --git a/app/Support/ParseDateString.php b/app/Support/ParseDateString.phpindex fe2ef36bcb..2b6255c7fc 100644--- a/app/Support/ParseDateString.php+++ b/app/Support/ParseDateString.php@@ -49,7 +49,7 @@ class ParseDateString];/**- * @param string $date+ * @param string $date** @return bool*/@@ -73,7 +73,7 @@ class ParseDateString}/**- * @param string $date+ * @param string $date** @return Carbon* @throws FireflyException@@ -114,7 +114,7 @@ class ParseDateStringreturn new Carbon('1984-09-17');}// maybe a year, nothing else?- if (4 === strlen($date) && is_numeric($date) && (int) $date > 1000 && (int) $date <= 3000) {+ if (4 === strlen($date) && is_numeric($date) && (int)$date > 1000 && (int)$date <= 3000) {return new Carbon(sprintf('%d-01-01', $date));}@@ -122,7 +122,7 @@ class ParseDateString}/**- * @param string $keyword+ * @param string $keyword** @return Carbon*/@@ -146,7 +146,7 @@ class ParseDateString}/**- * @param string $date+ * @param string $date** @return Carbon*/@@ -156,7 +156,7 @@ class ParseDateString}/**- * @param string $date+ * @param string $date** @return Carbon*/@@ -172,7 +172,8 @@ class ParseDateString'm' => 'subMonths','q' => 'subQuarters','y' => 'subYears',- ], [+ ],+ ['d' => 'addDays','w' => 'addWeeks','m' => 'addMonths',@@ -194,7 +195,7 @@ class ParseDateString}$direction = str_starts_with($part, '+') ? 1 : 0;$period = $part[strlen($part) - 1];- $number = (int) substr($part, 1, -1);+ $number = (int)substr($part, 1, -1);if (!array_key_exists($period, $functions[$direction])) {Log::error(sprintf('No method for direction %d and period "%s".', $direction, $period));continue;@@ -209,7 +210,7 @@ class ParseDateString}/**- * @param string $date+ * @param string $date** @return array*/@@ -246,7 +247,7 @@ class ParseDateString}/**- * @param string $date+ * @param string $date** @return bool*/@@ -267,7 +268,7 @@ class ParseDateString/*** format of string is xxxx-xx-DD*- * @param string $date+ * @param string $date** @return array*/@@ -281,7 +282,7 @@ class ParseDateString}/**- * @param string $date+ * @param string $date** @return bool*/@@ -302,7 +303,7 @@ class ParseDateString/*** format of string is xxxx-MM-xx*- * @param string $date+ * @param string $date** @return array*/@@ -317,7 +318,7 @@ class ParseDateString}/**- * @param string $date+ * @param string $date** @return bool*/@@ -338,7 +339,7 @@ class ParseDateString/*** format of string is YYYY-xx-xx*- * @param string $date+ * @param string $date** @return array*/@@ -353,7 +354,7 @@ class ParseDateString}/**- * @param string $date+ * @param string $date** @return bool*/@@ -374,7 +375,7 @@ class ParseDateString/*** format of string is xxxx-MM-DD*- * @param string $date+ * @param string $date** @return array*/@@ -390,7 +391,7 @@ class ParseDateString}/**- * @param string $date+ * @param string $date** @return bool*/@@ -411,7 +412,7 @@ class ParseDateString/*** format of string is YYYY-xx-DD*- * @param string $date+ * @param string $date** @return array*/@@ -427,7 +428,7 @@ class ParseDateString}/**- * @param string $date+ * @param string $date** @return bool*/@@ -448,7 +449,7 @@ class ParseDateString/*** format of string is YYYY-MM-xx*- * @param string $date+ * @param string $date** @return array*/diff --git a/app/Support/Preferences.php b/app/Support/Preferences.phpindex 336a547791..78c7dfedfd 100644--- a/app/Support/Preferences.php+++ b/app/Support/Preferences.php@@ -1,4 +1,5 @@<?php+/*** Preferences.php* Copyright (c) 2019 [email protected]@@ -52,89 +53,13 @@ class Preferences}/**- * @param User $user- * @param string $search- *- * @return Collection- */- public function beginsWith(User $user, string $search): Collection- {- return Preference::where('user_id', $user->id)->where('name', 'LIKE', $search . '%')->get();- }-- /**- * @param string $name- *- * @return bool- * @throws FireflyException- */- public function delete(string $name): bool- {- $fullName = sprintf('preference%s%s', auth()->user()->id, $name);- if (Cache::has($fullName)) {- Cache::forget($fullName);- }- try {- Preference::where('user_id', auth()->user()->id)->where('name', $name)->delete();- } catch (Exception $e) {- throw new FireflyException(sprintf('Could not delete preference: %s', $e->getMessage()), 0, $e);- }-- return true;- }-- /**- * @param string $name- *- * @return Collection- */- public function findByName(string $name): Collection- {- return Preference::where('name', $name)->get();- }-- /**- * @param User $user- * @param string $name- */- public function forget(User $user, string $name): void- {- $key = sprintf('preference%s%s', $user->id, $name);- Cache::forget($key);- Cache::put($key, '', 5);- }-- /**- * @param User $user- * @param array $list- *- * @return array- */- public function getArrayForUser(User $user, array $list): array- {- $result = [];- $preferences = Preference::where('user_id', $user->id)->whereIn('name', $list)->get(['id', 'name', 'data']);- /** @var Preference $preference */- foreach ($preferences as $preference) {- $result[$preference->name] = $preference->data;- }- foreach ($list as $name) {- if (!array_key_exists($name, $result)) {- $result[$name] = null;- }- }-- return $result;- }-- /**- * @param string $name- * @param mixed $default+ * @param string $name+ * @param mixed $default** @return Preference|null* @throws FireflyException*/- public function getFresh(string $name, $default = null): ?Preference+ public function get(string $name, $default = null): ?Preference{/** @var User|null $user */$user = auth()->user();@@ -145,27 +70,13 @@ class Preferencesreturn $preference;}- return $this->getFreshForUser($user, $name, $default);- }-- /**- * @param User $user- * @param string $name- * @param null $default- *- * @return Preference|null- * TODO remove me.- * @throws FireflyException- */- public function getFreshForUser(User $user, string $name, $default = null): ?Preference- {return $this->getForUser($user, $name, $default);}/**- * @param User $user- * @param string $name- * @param null|string|int $default+ * @param User $user+ * @param string $name+ * @param null|string|int $default** @return Preference|null* @throws FireflyException@@ -195,9 +106,41 @@ class Preferences}/**- * @param User $user- * @param string $name- * @param mixed $value+ * @param string $name+ *+ * @return bool+ * @throws FireflyException+ */+ public function delete(string $name): bool+ {+ $fullName = sprintf('preference%s%s', auth()->user()->id, $name);+ if (Cache::has($fullName)) {+ Cache::forget($fullName);+ }+ try {+ Preference::where('user_id', auth()->user()->id)->where('name', $name)->delete();+ } catch (Exception $e) {+ throw new FireflyException(sprintf('Could not delete preference: %s', $e->getMessage()), 0, $e);+ }++ return true;+ }++ /**+ * @param User $user+ * @param string $name+ */+ public function forget(User $user, string $name): void+ {+ $key = sprintf('preference%s%s', $user->id, $name);+ Cache::forget($key);+ Cache::put($key, '', 5);+ }++ /**+ * @param User $user+ * @param string $name+ * @param mixed $value** @return Preference* @throws FireflyException@@ -238,32 +181,57 @@ class Preferences}/**- * @return string- * @throws FireflyException+ * @param User $user+ * @param string $search+ *+ * @return Collection*/- public function lastActivity(): string+ public function beginsWith(User $user, string $search): Collection{- $lastActivity = microtime();- $preference = $this->get('lastActivity', microtime());+ return Preference::where('user_id', $user->id)->where('name', 'LIKE', $search.'%')->get();+ }- if (null !== $preference && null !== $preference->data) {- $lastActivity = $preference->data;+ /**+ * @param string $name+ *+ * @return Collection+ */+ public function findByName(string $name): Collection+ {+ return Preference::where('name', $name)->get();+ }++ /**+ * @param User $user+ * @param array $list+ *+ * @return array+ */+ public function getArrayForUser(User $user, array $list): array+ {+ $result = [];+ $preferences = Preference::where('user_id', $user->id)->whereIn('name', $list)->get(['id', 'name', 'data']);+ /** @var Preference $preference */+ foreach ($preferences as $preference) {+ $result[$preference->name] = $preference->data;}- if (is_array($lastActivity)) {- $lastActivity = implode(',', $lastActivity);+ foreach ($list as $name) {+ if (!array_key_exists($name, $result)) {+ $result[$name] = null;+ }}- return hash('sha256', $lastActivity);+ return $result;}/**- * @param string $name- * @param mixed $default+ * @param string $name+ * @param mixed $default** @return Preference|null* @throws FireflyException*/- public function get(string $name, $default = null): ?Preference+ public function getFresh(string $name, $default = null): ?Preference{/** @var User|null $user */$user = auth()->user();@@ -274,9 +242,42 @@ class Preferencesreturn $preference;}+ return $this->getFreshForUser($user, $name, $default);+ }++ /**+ * @param User $user+ * @param string $name+ * @param null $default+ *+ * @return Preference|null+ * TODO remove me.+ * @throws FireflyException+ */+ public function getFreshForUser(User $user, string $name, $default = null): ?Preference+ {return $this->getForUser($user, $name, $default);}+ /**+ * @return string+ * @throws FireflyException+ */+ public function lastActivity(): string+ {+ $lastActivity = microtime();+ $preference = $this->get('lastActivity', microtime());++ if (null !== $preference && null !== $preference->data) {+ $lastActivity = $preference->data;+ }+ if (is_array($lastActivity)) {+ $lastActivity = implode(',', $lastActivity);+ }++ return hash('sha256', $lastActivity);+ }+/****/@@ -287,8 +288,8 @@ class Preferences}/**- * @param string $name- * @param mixed $value+ * @param string $name+ * @param mixed $value** @return Preference* @throws FireflyExceptiondiff --git a/app/Support/Report/Budget/BudgetReportGenerator.php b/app/Support/Report/Budget/BudgetReportGenerator.phpindex bc40dab0d4..8c79b5faa8 100644--- a/app/Support/Report/Budget/BudgetReportGenerator.php+++ b/app/Support/Report/Budget/BudgetReportGenerator.php@@ -1,4 +1,5 @@<?php+/** BudgetReportGenerator.php* Copyright (c) 2020 [email protected]@@ -23,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Support\Report\Budget;use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\Budget;use FireflyIII\Models\BudgetLimit;@@ -33,6 +35,7 @@ use FireflyIII\Repositories\Budget\NoBudgetRepositoryInterface;use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;use FireflyIII\User;use Illuminate\Support\Collection;+use JsonException;/*** Class BudgetReportGenerator@@ -75,11 +78,11 @@ class BudgetReportGeneratorforeach ($this->accounts as $account) {$accountId = $account->id;$this->report[$accountId] = $this->report[$accountId] ?? [- 'name' => $account->name,- 'id' => $account->id,- 'iban' => $account->iban,- 'currencies' => [],- ];+ 'name' => $account->name,+ 'id' => $account->id,+ 'iban' => $account->iban,+ 'currencies' => [],+ ];}// loop expenses.@@ -91,7 +94,7 @@ class BudgetReportGenerator/*** Process each row of expenses collected for the "Account per budget" partial*- * @param array $expenses+ * @param array $expenses*/private function processExpenses(array $expenses): void{@@ -103,24 +106,24 @@ class BudgetReportGenerator/*** Process each set of transactions for each row of expenses.*- * @param array $expenses- * @param array $budget+ * @param array $expenses+ * @param array $budget*/private function processBudgetExpenses(array $expenses, array $budget): void{- $budgetId = (int) $budget['id'];- $currencyId = (int) $expenses['currency_id'];+ $budgetId = (int)$budget['id'];+ $currencyId = (int)$expenses['currency_id'];foreach ($budget['transaction_journals'] as $journal) {$sourceAccountId = $journal['source_account_id'];$this->report[$sourceAccountId]['currencies'][$currencyId]= $this->report[$sourceAccountId]['currencies'][$currencyId] ?? [- 'currency_id' => $expenses['currency_id'],- 'currency_symbol' => $expenses['currency_symbol'],- 'currency_name' => $expenses['currency_name'],- 'currency_decimal_places' => $expenses['currency_decimal_places'],- 'budgets' => [],- ];+ 'currency_id' => $expenses['currency_id'],+ 'currency_symbol' => $expenses['currency_symbol'],+ 'currency_name' => $expenses['currency_name'],+ 'currency_decimal_places' => $expenses['currency_decimal_places'],+ 'budgets' => [],+ ];$this->report[$sourceAccountId]['currencies'][$currencyId]['budgets'][$budgetId]= $this->report[$sourceAccountId]['currencies'][$currencyId]['budgets'][$budgetId] ?? '0';@@ -161,17 +164,17 @@ class BudgetReportGenerator/*** Process expenses etc. for a single budget for the budgets block on the default report.*- * @param Budget $budget+ * @param Budget $budget*/private function processBudget(Budget $budget): void{- $budgetId = (int) $budget->id;+ $budgetId = (int)$budget->id;$this->report['budgets'][$budgetId] = $this->report['budgets'][$budgetId] ?? [- 'budget_id' => $budgetId,- 'budget_name' => $budget->name,- 'no_budget' => false,- 'budget_limits' => [],- ];+ 'budget_id' => $budgetId,+ 'budget_name' => $budget->name,+ 'no_budget' => false,+ 'budget_limits' => [],+ ];// get all budget limits for budget in period:$limits = $this->blRepository->getBudgetLimits($budget, $this->start, $this->end);@@ -184,50 +187,50 @@ class BudgetReportGenerator/*** Process a single budget limit for the budgets block on the default report.*- * @param Budget $budget- * @param BudgetLimit $limit+ * @param Budget $budget+ * @param BudgetLimit $limit*/private function processLimit(Budget $budget, BudgetLimit $limit): void{- $budgetId = (int) $budget->id;- $limitId = (int) $limit->id;+ $budgetId = (int)$budget->id;+ $limitId = (int)$limit->id;$limitCurrency = $limit->transactionCurrency ?? $this->currency;- $currencyId = (int) $limitCurrency->id;+ $currencyId = (int)$limitCurrency->id;$expenses = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, $this->accounts, new Collection([$budget]));$spent = $expenses[$currencyId]['sum'] ?? '0';$left = -1 === bccomp(bcadd($limit->amount, $spent), '0') ? '0' : bcadd($limit->amount, $spent);$overspent = 1 === bccomp(bcmul($spent, '-1'), $limit->amount) ? bcadd($spent, $limit->amount) : '0';$this->report['budgets'][$budgetId]['budget_limits'][$limitId] = $this->report['budgets'][$budgetId]['budget_limits'][$limitId] ?? [- 'budget_limit_id' => $limitId,- 'start_date' => $limit->start_date,- 'end_date' => $limit->end_date,- 'budgeted' => $limit->amount,- 'budgeted_pct' => '0',- 'spent' => $spent,- 'spent_pct' => '0',- 'left' => $left,- 'overspent' => $overspent,- 'currency_id' => $currencyId,- 'currency_code' => $limitCurrency->code,- 'currency_name' => $limitCurrency->name,- 'currency_symbol' => $limitCurrency->symbol,- 'currency_decimal_places' => $limitCurrency->decimal_places,- ];+ 'budget_limit_id' => $limitId,+ 'start_date' => $limit->start_date,+ 'end_date' => $limit->end_date,+ 'budgeted' => $limit->amount,+ 'budgeted_pct' => '0',+ 'spent' => $spent,+ 'spent_pct' => '0',+ 'left' => $left,+ 'overspent' => $overspent,+ 'currency_id' => $currencyId,+ 'currency_code' => $limitCurrency->code,+ 'currency_name' => $limitCurrency->name,+ 'currency_symbol' => $limitCurrency->symbol,+ 'currency_decimal_places' => $limitCurrency->decimal_places,+ ];// make sum information:$this->report['sums'][$currencyId]= $this->report['sums'][$currencyId] ?? [- 'budgeted' => '0',- 'spent' => '0',- 'left' => '0',- 'overspent' => '0',- 'currency_id' => $currencyId,- 'currency_code' => $limitCurrency->code,- 'currency_name' => $limitCurrency->name,- 'currency_symbol' => $limitCurrency->symbol,- 'currency_decimal_places' => $limitCurrency->decimal_places,- ];+ 'budgeted' => '0',+ 'spent' => '0',+ 'left' => '0',+ 'overspent' => '0',+ 'currency_id' => $currencyId,+ 'currency_code' => $limitCurrency->code,+ 'currency_name' => $limitCurrency->name,+ 'currency_symbol' => $limitCurrency->symbol,+ 'currency_decimal_places' => $limitCurrency->decimal_places,+ ];$this->report['sums'][$currencyId]['budgeted'] = bcadd($this->report['sums'][$currencyId]['budgeted'], $limit->amount);$this->report['sums'][$currencyId]['spent'] = bcadd($this->report['sums'][$currencyId]['spent'], $spent);$this->report['sums'][$currencyId]['left'] = bcadd($this->report['sums'][$currencyId]['left'], bcadd($limit->amount, $spent));@@ -250,7 +253,7 @@ class BudgetReportGenerator$noBudget = $this->nbRepository->sumExpenses($this->start, $this->end, $this->accounts);foreach ($noBudget as $noBudgetEntry) {// currency information:- $nbCurrencyId = (int) ($noBudgetEntry['currency_id'] ?? $this->currency->id);+ $nbCurrencyId = (int)($noBudgetEntry['currency_id'] ?? $this->currency->id);$nbCurrencyCode = $noBudgetEntry['currency_code'] ?? $this->currency->code;$nbCurrencyName = $noBudgetEntry['currency_name'] ?? $this->currency->name;$nbCurrencySymbol = $noBudgetEntry['currency_symbol'] ?? $this->currency->symbol;@@ -295,9 +298,9 @@ class BudgetReportGenerator// make percentages based on total amount.foreach ($this->report['budgets'] as $budgetId => $data) {foreach ($data['budget_limits'] as $limitId => $entry) {- $budgetId = (int) $budgetId;- $limitId = (int) $limitId;- $currencyId = (int) $entry['currency_id'];+ $budgetId = (int)$budgetId;+ $limitId = (int)$limitId;+ $currencyId = (int)$entry['currency_id'];$spent = $entry['spent'];$totalSpent = $this->report['sums'][$currencyId]['spent'] ?? '0';$spentPct = '0';@@ -306,10 +309,10 @@ class BudgetReportGenerator$budgetedPct = '0';if (0 !== bccomp($spent, '0') && 0 !== bccomp($totalSpent, '0')) {- $spentPct = round((float) bcmul(bcdiv($spent, $totalSpent), '100'));+ $spentPct = round((float)bcmul(bcdiv($spent, $totalSpent), '100'));}if (0 !== bccomp($budgeted, '0') && 0 !== bccomp($totalBudgeted, '0')) {- $budgetedPct = round((float) bcmul(bcdiv($budgeted, $totalBudgeted), '100'));+ $budgetedPct = round((float)bcmul(bcdiv($budgeted, $totalBudgeted), '100'));}$this->report['sums'][$currencyId]['budgeted'] = $this->report['sums'][$currencyId]['budgeted'] ?? '0';$this->report['budgets'][$budgetId]['budget_limits'][$limitId]['spent_pct'] = $spentPct;@@ -327,7 +330,7 @@ class BudgetReportGenerator}/**- * @param Collection $accounts+ * @param Collection $accounts*/public function setAccounts(Collection $accounts): void{@@ -335,7 +338,7 @@ class BudgetReportGenerator}/**- * @param Collection $budgets+ * @param Collection $budgets*/public function setBudgets(Collection $budgets): void{@@ -343,7 +346,7 @@ class BudgetReportGenerator}/**- * @param Carbon $end+ * @param Carbon $end*/public function setEnd(Carbon $end): void{@@ -351,7 +354,7 @@ class BudgetReportGenerator}/**- * @param Carbon $start+ * @param Carbon $start*/public function setStart(Carbon $start): void{@@ -359,9 +362,9 @@ class BudgetReportGenerator}/**- * @param User $user- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @param User $user+ * @throws FireflyException+ * @throws JsonException*/public function setUser(User $user): void{diff --git a/app/Support/Report/Category/CategoryReportGenerator.php b/app/Support/Report/Category/CategoryReportGenerator.phpindex 564a160935..93097dd029 100644--- a/app/Support/Report/Category/CategoryReportGenerator.php+++ b/app/Support/Report/Category/CategoryReportGenerator.php@@ -88,12 +88,12 @@ class CategoryReportGenerator/*** Process one of the spent arrays from the operations method.*- * @param array $data+ * @param array $data*/private function processOpsArray(array $data): void{/**- * @var int $currencyId+ * @var int $currencyId* @var array $currencyRow*/foreach ($data as $currencyId => $currencyRow) {@@ -102,24 +102,24 @@ class CategoryReportGenerator}/**- * @param int $currencyId- * @param array $currencyRow+ * @param int $currencyId+ * @param array $currencyRow*/private function processCurrencyArray(int $currencyId, array $currencyRow): void{$this->report['sums'][$currencyId] = $this->report['sums'][$currencyId] ?? [- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- 'currency_id' => $currencyRow['currency_id'],- 'currency_symbol' => $currencyRow['currency_symbol'],- 'currency_name' => $currencyRow['currency_name'],- 'currency_code' => $currencyRow['currency_code'],- 'currency_decimal_places' => $currencyRow['currency_decimal_places'],- ];+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ 'currency_id' => $currencyRow['currency_id'],+ 'currency_symbol' => $currencyRow['currency_symbol'],+ 'currency_name' => $currencyRow['currency_name'],+ 'currency_code' => $currencyRow['currency_code'],+ 'currency_decimal_places' => $currencyRow['currency_decimal_places'],+ ];/**- * @var int $categoryId+ * @var int $categoryId* @var array $categoryRow*/foreach ($currencyRow['categories'] as $categoryId => $categoryRow) {@@ -128,26 +128,26 @@ class CategoryReportGenerator}/**- * @param int $currencyId- * @param array $currencyRow- * @param int $categoryId- * @param array $categoryRow+ * @param int $currencyId+ * @param array $currencyRow+ * @param int $categoryId+ * @param array $categoryRow*/private function processCategoryRow(int $currencyId, array $currencyRow, int $categoryId, array $categoryRow): void{$key = sprintf('%s-%s', $currencyId, $categoryId);$this->report['categories'][$key] = $this->report['categories'][$key] ?? [- 'id' => $categoryId,- 'title' => $categoryRow['name'],- 'currency_id' => $currencyRow['currency_id'],- 'currency_symbol' => $currencyRow['currency_symbol'],- 'currency_name' => $currencyRow['currency_name'],- 'currency_code' => $currencyRow['currency_code'],- 'currency_decimal_places' => $currencyRow['currency_decimal_places'],- 'spent' => '0',- 'earned' => '0',- 'sum' => '0',- ];+ 'id' => $categoryId,+ 'title' => $categoryRow['name'],+ 'currency_id' => $currencyRow['currency_id'],+ 'currency_symbol' => $currencyRow['currency_symbol'],+ 'currency_name' => $currencyRow['currency_name'],+ 'currency_code' => $currencyRow['currency_code'],+ 'currency_decimal_places' => $currencyRow['currency_decimal_places'],+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ ];// loop journals:foreach ($categoryRow['transaction_journals'] as $journal) {// sum of sums@@ -179,7 +179,7 @@ class CategoryReportGenerator}/**- * @param Collection $accounts+ * @param Collection $accounts*/public function setAccounts(Collection $accounts): void{@@ -187,7 +187,7 @@ class CategoryReportGenerator}/**- * @param Carbon $end+ * @param Carbon $end*/public function setEnd(Carbon $end): void{@@ -195,7 +195,7 @@ class CategoryReportGenerator}/**- * @param Carbon $start+ * @param Carbon $start*/public function setStart(Carbon $start): void{@@ -203,7 +203,7 @@ class CategoryReportGenerator}/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void{diff --git a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.phpindex 680f1af0d3..cccdb12026 100644--- a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php+++ b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php@@ -35,9 +35,9 @@ trait CalculateRangeOccurrences/*** Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.*- * @param Carbon $start- * @param Carbon $end- * @param int $skipMod+ * @param Carbon $start+ * @param Carbon $end+ * @param int $skipMod** @return array*/@@ -59,10 +59,10 @@ trait CalculateRangeOccurrences/*** Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.*- * @param Carbon $start- * @param Carbon $end- * @param int $skipMod- * @param string $moment+ * @param Carbon $start+ * @param Carbon $end+ * @param int $skipMod+ * @param string $moment** @return array*@@ -71,7 +71,7 @@ trait CalculateRangeOccurrences{$return = [];$attempts = 0;- $dayOfMonth = (int) $moment;+ $dayOfMonth = (int)$moment;if ($start->day > $dayOfMonth) {// day has passed already, add a month.$start->addMonth();@@ -92,10 +92,10 @@ trait CalculateRangeOccurrences/*** Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.*- * @param Carbon $start- * @param Carbon $end- * @param int $skipMod- * @param string $moment+ * @param Carbon $start+ * @param Carbon $end+ * @param int $skipMod+ * @param string $moment** @return array*/@@ -124,10 +124,10 @@ trait CalculateRangeOccurrences/*** Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.*- * @param Carbon $start- * @param Carbon $end- * @param int $skipMod- * @param string $moment+ * @param Carbon $start+ * @param Carbon $end+ * @param int $skipMod+ * @param string $moment** @return array*@@ -139,7 +139,7 @@ trait CalculateRangeOccurrencesLog::debug('Rep is weekly.');// monday = 1// sunday = 7- $dayOfWeek = (int) $moment;+ $dayOfWeek = (int)$moment;Log::debug(sprintf('DoW in repetition is %d, in mutator is %d', $dayOfWeek, $start->dayOfWeekIso));if ($start->dayOfWeekIso > $dayOfWeek) {// day has already passed this week, add one week:@@ -168,10 +168,10 @@ trait CalculateRangeOccurrences/*** Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.*- * @param Carbon $start- * @param Carbon $end- * @param int $skipMod- * @param string $moment+ * @param Carbon $start+ * @param Carbon $end+ * @param int $skipMod+ * @param string $moment** @return array*diff --git a/app/Support/Repositories/Recurring/CalculateXOccurrences.php b/app/Support/Repositories/Recurring/CalculateXOccurrences.phpindex 4cd955fbd3..59e7ea2861 100644--- a/app/Support/Repositories/Recurring/CalculateXOccurrences.php+++ b/app/Support/Repositories/Recurring/CalculateXOccurrences.php@@ -35,9 +35,9 @@ trait CalculateXOccurrences* Calculates the number of daily occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.*- * @param Carbon $date- * @param int $count- * @param int $skipMod+ * @param Carbon $date+ * @param int $count+ * @param int $skipMod** @return array*/@@ -63,10 +63,10 @@ trait CalculateXOccurrences* Calculates the number of monthly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.*- * @param Carbon $date- * @param int $count- * @param int $skipMod- * @param string $moment+ * @param Carbon $date+ * @param int $count+ * @param int $skipMod+ * @param string $moment** @return array*/@@ -76,7 +76,7 @@ trait CalculateXOccurrences$mutator = clone $date;$total = 0;$attempts = 0;- $dayOfMonth = (int) $moment;+ $dayOfMonth = (int)$moment;if ($mutator->day > $dayOfMonth) {// day has passed already, add a month.$mutator->addMonth();@@ -100,10 +100,10 @@ trait CalculateXOccurrences* Calculates the number of NDOM occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.*- * @param Carbon $date- * @param int $count- * @param int $skipMod- * @param string $moment+ * @param Carbon $date+ * @param int $count+ * @param int $skipMod+ * @param string $moment** @return array*/@@ -138,10 +138,10 @@ trait CalculateXOccurrences* Calculates the number of weekly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.*- * @param Carbon $date- * @param int $count- * @param int $skipMod- * @param string $moment+ * @param Carbon $date+ * @param int $count+ * @param int $skipMod+ * @param string $moment** @return array*/@@ -154,7 +154,7 @@ trait CalculateXOccurrences// monday = 1// sunday = 7$mutator->addDay(); // always assume today has passed.- $dayOfWeek = (int) $moment;+ $dayOfWeek = (int)$moment;if ($mutator->dayOfWeekIso > $dayOfWeek) {// day has already passed this week, add one week:$mutator->addWeek();@@ -180,10 +180,10 @@ trait CalculateXOccurrences* Calculates the number of yearly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.*- * @param Carbon $date- * @param int $count- * @param int $skipMod- * @param string $moment+ * @param Carbon $date+ * @param int $count+ * @param int $skipMod+ * @param string $moment** @return array*/diff --git a/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php b/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.phpindex 5a12ce7a0f..c9b505c25a 100644--- a/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php+++ b/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php@@ -36,10 +36,10 @@ trait CalculateXOccurrencesSince* Calculates the number of daily occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.*- * @param Carbon $date- * @param Carbon $afterDate- * @param int $count- * @param int $skipMod+ * @param Carbon $date+ * @param Carbon $afterDate+ * @param int $count+ * @param int $skipMod** @return array*/@@ -66,11 +66,11 @@ trait CalculateXOccurrencesSince* Calculates the number of monthly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.*- * @param Carbon $date- * @param Carbon $afterDate- * @param int $count- * @param int $skipMod- * @param string $moment+ * @param Carbon $date+ * @param Carbon $afterDate+ * @param int $count+ * @param int $skipMod+ * @param string $moment** @return array*/@@ -81,7 +81,7 @@ trait CalculateXOccurrencesSince$mutator = clone $date;$total = 0;$attempts = 0;- $dayOfMonth = (int) $moment;+ $dayOfMonth = (int)$moment;$dayOfMonth = 0 === $dayOfMonth ? 1 : $dayOfMonth;if ($mutator->day > $dayOfMonth) {Log::debug(sprintf('%d is after %d, add a month. Mutator is now', $mutator->day, $dayOfMonth));@@ -109,11 +109,11 @@ trait CalculateXOccurrencesSince* Calculates the number of NDOM occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.*- * @param Carbon $date- * @param Carbon $afterDate- * @param int $count- * @param int $skipMod- * @param string $moment+ * @param Carbon $date+ * @param Carbon $afterDate+ * @param int $count+ * @param int $skipMod+ * @param string $moment** @return array*/@@ -149,11 +149,11 @@ trait CalculateXOccurrencesSince* Calculates the number of weekly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.*- * @param Carbon $date- * @param Carbon $afterDate- * @param int $count- * @param int $skipMod- * @param string $moment+ * @param Carbon $date+ * @param Carbon $afterDate+ * @param int $count+ * @param int $skipMod+ * @param string $moment** @return array*/@@ -168,7 +168,7 @@ trait CalculateXOccurrencesSince// sunday = 7// Removed assumption today has passed, see issue https://github.com/firefly-iii/firefly-iii/issues/4798//$mutator->addDay(); // always assume today has passed.- $dayOfWeek = (int) $moment;+ $dayOfWeek = (int)$moment;if ($mutator->dayOfWeekIso > $dayOfWeek) {// day has already passed this week, add one week:$mutator->addWeek();@@ -194,11 +194,11 @@ trait CalculateXOccurrencesSince* Calculates the number of yearly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.*- * @param Carbon $date- * @param Carbon $afterDate- * @param int $count- * @param int $skipMod- * @param string $moment+ * @param Carbon $date+ * @param Carbon $afterDate+ * @param int $count+ * @param int $skipMod+ * @param string $moment** @return array*/diff --git a/app/Support/Repositories/Recurring/FiltersWeekends.php b/app/Support/Repositories/Recurring/FiltersWeekends.phpindex 8d2f04fa78..a86be7a4fc 100644--- a/app/Support/Repositories/Recurring/FiltersWeekends.php+++ b/app/Support/Repositories/Recurring/FiltersWeekends.php@@ -37,8 +37,8 @@ trait FiltersWeekends/*** Filters out all weekend entries, if necessary.*- * @param RecurrenceRepetition $repetition- * @param array $dates+ * @param RecurrenceRepetition $repetition+ * @param array $dates** @return array*@@ -46,7 +46,7 @@ trait FiltersWeekendsprotected function filterWeekends(RecurrenceRepetition $repetition, array $dates): array{Log::debug(sprintf('Now in %s', __METHOD__));- if ((int) $repetition->weekend === RecurrenceRepetition::WEEKEND_DO_NOTHING) {+ if ((int)$repetition->weekend === RecurrenceRepetition::WEEKEND_DO_NOTHING) {Log::debug('Repetition will not be filtered on weekend days.');return $dates;diff --git a/app/Support/Request/AppendsLocationData.php b/app/Support/Request/AppendsLocationData.phpindex 77a3e8e081..0bd76b8143 100644--- a/app/Support/Request/AppendsLocationData.php+++ b/app/Support/Request/AppendsLocationData.php@@ -42,9 +42,9 @@ trait AppendsLocationData/*** Read the submitted Request data and add new or updated Location data to the array.*- * @param array $data+ * @param array $data*- * @param string|null $prefix+ * @param string|null $prefix** @return array*/@@ -100,8 +100,8 @@ trait AppendsLocationData}/**- * @param string|null $prefix- * @param string $key+ * @param string|null $prefix+ * @param string $key** @return string*/@@ -115,7 +115,7 @@ trait AppendsLocationData}/**- * @param string|null $prefix+ * @param string|null $prefix** @return bool*/@@ -167,7 +167,7 @@ trait AppendsLocationData/*** Abstract method.*- * @param mixed ...$patterns+ * @param mixed ...$patterns** @return mixed*/@@ -176,15 +176,15 @@ trait AppendsLocationData/*** Abstract method stolen from "InteractsWithInput".*- * @param null $key- * @param bool $default+ * @param null $key+ * @param bool $default** @return mixed*/abstract public function boolean($key = null, $default = false);/**- * @param string|null $prefix+ * @param string|null $prefix** @return bool*/@@ -229,7 +229,7 @@ trait AppendsLocationData}/**- * @param string|null $prefix+ * @param string|null $prefix** @return bool*/@@ -245,7 +245,7 @@ trait AppendsLocationData&& null === $this->get($zoomLevelKey))&& ('PUT' === $this->method()- || ('POST' === $this->method() && $this->routeIs('*.update'))+ || ('POST' === $this->method() && $this->routeIs('*.update')));}}diff --git a/app/Support/Request/ConvertsDataTypes.php b/app/Support/Request/ConvertsDataTypes.phpindex f98d172c10..e91c4bbc4d 100644--- a/app/Support/Request/ConvertsDataTypes.php+++ b/app/Support/Request/ConvertsDataTypes.php@@ -35,30 +35,30 @@ trait ConvertsDataTypes/*** Return integer value.*- * @param string $field+ * @param string $field** @return int*/public function convertInteger(string $field): int{- return (int) $this->get($field);+ return (int)$this->get($field);}/*** Return string value.*- * @param string $field+ * @param string $field** @return string*/public function convertString(string $field): string{- return $this->clearString((string) ($this->get($field) ?? ''), false);+ return $this->clearString((string)($this->get($field) ?? ''), false);}/**- * @param string|null $string- * @param bool $keepNewlines+ * @param string|null $string+ * @param bool $keepNewlines** @return string|null*/@@ -131,17 +131,17 @@ trait ConvertsDataTypes/*** Return string value with newlines.*- * @param string $field+ * @param string $field** @return string*/public function stringWithNewlines(string $field): string{- return $this->clearString((string) ($this->get($field) ?? ''));+ return $this->clearString((string)($this->get($field) ?? ''));}/**- * @param mixed $array+ * @param mixed $array** @return array|null*/@@ -161,7 +161,7 @@ trait ConvertsDataTypes}/**- * @param string|null $value+ * @param string|null $value** @return bool*/@@ -187,7 +187,24 @@ trait ConvertsDataTypes}/**- * @param string|null $string+ * Return floating value.+ *+ * @param string $field+ *+ * @return float|null+ */+ protected function convertFloat(string $field): ?float+ {+ $res = $this->get($field);+ if (null === $res) {+ return null;+ }++ return (float)$res;+ }++ /**+ * @param string|null $string** @return Carbon|null*/@@ -215,28 +232,11 @@ trait ConvertsDataTypesreturn $carbon;}- /**- * Return floating value.- *- * @param string $field- *- * @return float|null- */- protected function convertFloat(string $field): ?float- {- $res = $this->get($field);- if (null === $res) {- return null;- }-- return (float) $res;- }-/*** Returns all data in the request, or omits the field if not set,* according to the config from the request. This is the way.*- * @param array $fields+ * @param array $fields** @return array*/@@ -256,7 +256,7 @@ trait ConvertsDataTypes/*** Return date or NULL.*- * @param string $field+ * @param string $field** @return Carbon|null*/@@ -278,7 +278,7 @@ trait ConvertsDataTypes/*** Parse to integer*- * @param string|null $string+ * @param string|null $string** @return int|null*/@@ -291,13 +291,13 @@ trait ConvertsDataTypesreturn null;}- return (int) $string;+ return (int)$string;}/*** Return integer value, or NULL when it's not set.*- * @param string $field+ * @param string $field** @return int|null*/@@ -307,11 +307,11 @@ trait ConvertsDataTypesreturn null;}- $value = (string) $this->get($field);+ $value = (string)$this->get($field);if ('' === $value) {return null;}- return (int) $value;+ return (int)$value;}}diff --git a/app/Support/Request/GetRecurrenceData.php b/app/Support/Request/GetRecurrenceData.phpindex 3fa48d8aaa..661823ac60 100644--- a/app/Support/Request/GetRecurrenceData.php+++ b/app/Support/Request/GetRecurrenceData.php@@ -29,7 +29,7 @@ namespace FireflyIII\Support\Request;trait GetRecurrenceData{/**- * @param array $transaction+ * @param array $transaction** @return array*/@@ -42,7 +42,7 @@ trait GetRecurrenceData$return['amount'] = $transaction['amount'];}if (array_key_exists('currency_id', $transaction)) {- $return['currency_id'] = (int) $transaction['currency_id'];+ $return['currency_id'] = (int)$transaction['currency_id'];}if (array_key_exists('currency_code', $transaction)) {$return['currency_code'] = $transaction['currency_code'];@@ -53,17 +53,17 @@ trait GetRecurrenceData$return['foreign_amount'] = $transaction['foreign_amount'];}if (array_key_exists('foreign_currency_id', $transaction)) {- $return['foreign_currency_id'] = (int) $transaction['foreign_currency_id'];+ $return['foreign_currency_id'] = (int)$transaction['foreign_currency_id'];}if (array_key_exists('foreign_currency_code', $transaction)) {$return['foreign_currency_code'] = $transaction['foreign_currency_code'];}// source + destif (array_key_exists('source_id', $transaction)) {- $return['source_id'] = (int) $transaction['source_id'];+ $return['source_id'] = (int)$transaction['source_id'];}if (array_key_exists('destination_id', $transaction)) {- $return['destination_id'] = (int) $transaction['destination_id'];+ $return['destination_id'] = (int)$transaction['destination_id'];}// descriptionif (array_key_exists('description', $transaction)) {@@ -71,17 +71,17 @@ trait GetRecurrenceData}if (array_key_exists('piggy_bank_id', $transaction)) {- $return['piggy_bank_id'] = (int) $transaction['piggy_bank_id'];+ $return['piggy_bank_id'] = (int)$transaction['piggy_bank_id'];}if (array_key_exists('tags', $transaction)) {$return['tags'] = $transaction['tags'];}if (array_key_exists('budget_id', $transaction)) {- $return['budget_id'] = (int) $transaction['budget_id'];+ $return['budget_id'] = (int)$transaction['budget_id'];}if (array_key_exists('category_id', $transaction)) {- $return['category_id'] = (int) $transaction['category_id'];+ $return['category_id'] = (int)$transaction['category_id'];}return $return;diff --git a/app/Support/Search/AccountSearch.php b/app/Support/Search/AccountSearch.phpindex a6decf6392..1a8cd8e002 100644--- a/app/Support/Search/AccountSearch.php+++ b/app/Support/Search/AccountSearch.php@@ -27,7 +27,6 @@ namespace FireflyIII\Support\Search;use FireflyIII\User;use Illuminate\Database\Eloquent\Builder;use Illuminate\Support\Collection;-use JsonException;/*** Class AccountSearch@@ -85,7 +84,7 @@ class AccountSearch implements GenericSearchInterface);break;case self::SEARCH_ID:- $searchQuery->where('accounts.id', '=', (int) $originalQuery);+ $searchQuery->where('accounts.id', '=', (int)$originalQuery);break;case self::SEARCH_NAME:$searchQuery->where('accounts.name', 'LIKE', $like);@@ -109,7 +108,7 @@ class AccountSearch implements GenericSearchInterface}/**- * @param string $field+ * @param string $field*/public function setField(string $field): void{@@ -117,7 +116,7 @@ class AccountSearch implements GenericSearchInterface}/**- * @param string $query+ * @param string $query*/public function setQuery(string $query): void{@@ -125,7 +124,7 @@ class AccountSearch implements GenericSearchInterface}/**- * @param array $types+ * @param array $types*/public function setTypes(array $types): void{@@ -133,7 +132,7 @@ class AccountSearch implements GenericSearchInterface}/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void{diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.phpindex d512848bd2..77ae90d4f8 100644--- a/app/Support/Search/OperatorQuerySearch.php+++ b/app/Support/Search/OperatorQuerySearch.php@@ -74,11 +74,11 @@ class OperatorQuerySearch implements SearchInterfaceprivate int $limit;private Collection $operators;private int $page;+ private array $prohibitedWords;private float $startTime;private TagRepositoryInterface $tagRepository;private array $validOperators;private array $words;- private array $prohibitedWords;/*** OperatorQuerySearch constructor.@@ -175,7 +175,7 @@ class OperatorQuerySearch implements SearchInterface}/**- * @param Node $searchNode+ * @param Node $searchNode** @throws FireflyException*/@@ -202,7 +202,7 @@ class OperatorQuerySearch implements SearchInterfacecase Emoticon::class:case Emoji::class:case Mention::class:- $allWords = (string) $searchNode->getValue();+ $allWords = (string)$searchNode->getValue();Log::debug(sprintf('Add words "%s" to search string, because Node class is "%s"', $allWords, $class));$this->words[] = $allWords;break;@@ -223,11 +223,11 @@ class OperatorQuerySearch implements SearchInterface// must be valid operator:if (in_array($operator, $this->validOperators, true) &&- $this->updateCollector($operator, (string) $value, $prohibited)) {+ $this->updateCollector($operator, (string)$value, $prohibited)) {$this->operators->push(['type' => self::getRootOperator($operator),- 'value' => (string) $value,+ 'value' => (string)$value,'prohibited' => $prohibited,]);@@ -237,15 +237,15 @@ class OperatorQuerySearch implements SearchInterfaceLog::debug(sprintf('Added INVALID operator type "%s"', $operator));$this->invalidOperators[] = ['type' => $operator,- 'value' => (string) $value,+ 'value' => (string)$value,];}}}/**- * @param string $operator- * @param string $value+ * @param string $operator+ * @param string $value** @return bool* @throws FireflyException@@ -371,7 +371,7 @@ class OperatorQuerySearch implements SearchInterface$this->searchAccount($value, 1, 3, true);break;case 'source_account_id':- $account = $this->accountRepository->find((int) $value);+ $account = $this->accountRepository->find((int)$value);if (null !== $account) {$this->collector->setSourceAccounts(new Collection([$account]));}@@ -381,7 +381,7 @@ class OperatorQuerySearch implements SearchInterface}break;case '-source_account_id':- $account = $this->accountRepository->find((int) $value);+ $account = $this->accountRepository->find((int)$value);if (null !== $account) {$this->collector->excludeSourceAccounts(new Collection([$account]));}@@ -455,7 +455,7 @@ class OperatorQuerySearch implements SearchInterface$this->searchAccount($value, 2, 3, true);break;case 'destination_account_id':- $account = $this->accountRepository->find((int) $value);+ $account = $this->accountRepository->find((int)$value);if (null !== $account) {$this->collector->setDestinationAccounts(new Collection([$account]));}@@ -464,7 +464,7 @@ class OperatorQuerySearch implements SearchInterface}break;case '-destination_account_id':- $account = $this->accountRepository->find((int) $value);+ $account = $this->accountRepository->find((int)$value);if (null !== $account) {$this->collector->excludeDestinationAccounts(new Collection([$account]));}@@ -476,7 +476,7 @@ class OperatorQuerySearch implements SearchInterface$parts = explode(',', $value);$collection = new Collection();foreach ($parts as $accountId) {- $account = $this->accountRepository->find((int) $accountId);+ $account = $this->accountRepository->find((int)$accountId);if (null !== $account) {$collection->push($account);}@@ -492,7 +492,7 @@ class OperatorQuerySearch implements SearchInterface$parts = explode(',', $value);$collection = new Collection();foreach ($parts as $accountId) {- $account = $this->accountRepository->find((int) $accountId);+ $account = $this->accountRepository->find((int)$accountId);if (null !== $account) {$collection->push($account);}@@ -928,7 +928,7 @@ class OperatorQuerySearch implements SearchInterfacecase 'amount_is':// strip comma's, make dots.Log::debug(sprintf('Original value "%s"', $value));- $value = str_replace(',', '.', (string) $value);+ $value = str_replace(',', '.', (string)$value);$amount = app('steam')->positive($value);Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));$this->collector->amountIs($amount);@@ -936,7 +936,7 @@ class OperatorQuerySearch implements SearchInterfacecase '-amount_is':// strip comma's, make dots.Log::debug(sprintf('Original value "%s"', $value));- $value = str_replace(',', '.', (string) $value);+ $value = str_replace(',', '.', (string)$value);$amount = app('steam')->positive($value);Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));$this->collector->amountIsNot($amount);@@ -944,7 +944,7 @@ class OperatorQuerySearch implements SearchInterfacecase 'foreign_amount_is':// strip comma's, make dots.- $value = str_replace(',', '.', (string) $value);+ $value = str_replace(',', '.', (string)$value);$amount = app('steam')->positive($value);Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));@@ -953,7 +953,7 @@ class OperatorQuerySearch implements SearchInterfacecase '-foreign_amount_is':// strip comma's, make dots.- $value = str_replace(',', '.', (string) $value);+ $value = str_replace(',', '.', (string)$value);$amount = app('steam')->positive($value);Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));@@ -962,7 +962,7 @@ class OperatorQuerySearch implements SearchInterfacecase '-amount_more':case 'amount_less':// strip comma's, make dots.- $value = str_replace(',', '.', (string) $value);+ $value = str_replace(',', '.', (string)$value);$amount = app('steam')->positive($value);Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));@@ -971,7 +971,7 @@ class OperatorQuerySearch implements SearchInterfacecase '-foreign_amount_more':case 'foreign_amount_less':// strip comma's, make dots.- $value = str_replace(',', '.', (string) $value);+ $value = str_replace(',', '.', (string)$value);$amount = app('steam')->positive($value);Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));@@ -981,7 +981,7 @@ class OperatorQuerySearch implements SearchInterfacecase 'amount_more':Log::debug(sprintf('Now handling operator "%s"', $operator));// strip comma's, make dots.- $value = str_replace(',', '.', (string) $value);+ $value = str_replace(',', '.', (string)$value);$amount = app('steam')->positive($value);Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));$this->collector->amountMore($amount);@@ -990,7 +990,7 @@ class OperatorQuerySearch implements SearchInterfacecase 'foreign_amount_more':Log::debug(sprintf('Now handling operator "%s"', $operator));// strip comma's, make dots.- $value = str_replace(',', '.', (string) $value);+ $value = str_replace(',', '.', (string)$value);$amount = app('steam')->positive($value);Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));$this->collector->foreignAmountMore($amount);@@ -1325,7 +1325,7 @@ class OperatorQuerySearch implements SearchInterface}/**- * @param string $operator+ * @param string $operator** @return string* @throws FireflyException@@ -1361,10 +1361,10 @@ class OperatorQuerySearch implements SearchInterface* searchDirection: 1 = source (default), 2 = destination, 3 = both* stringPosition: 1 = start (default), 2 = end, 3 = contains, 4 = is*- * @param string $value- * @param int $searchDirection- * @param int $stringPosition- * @param bool $prohibited+ * @param string $value+ * @param int $searchDirection+ * @param int $stringPosition+ * @param bool $prohibited*/private function searchAccount(string $value, int $searchDirection, int $stringPosition, bool $prohibited = false): void{@@ -1437,10 +1437,10 @@ class OperatorQuerySearch implements SearchInterface* searchDirection: 1 = source (default), 2 = destination, 3 = both* stringPosition: 1 = start (default), 2 = end, 3 = contains, 4 = is*- * @param string $value- * @param int $searchDirection- * @param int $stringPosition- * @param bool $prohibited+ * @param string $value+ * @param int $searchDirection+ * @param int $stringPosition+ * @param bool $prohibited*/private function searchAccountNr(string $value, int $searchDirection, int $stringPosition, bool $prohibited = false): void{@@ -1500,7 +1500,7 @@ class OperatorQuerySearch implements SearchInterface$filtered = $accounts->filter(function (Account $account) use ($value, $stringMethod) {// either IBAN or account number- $ibanMatch = $stringMethod(strtolower((string) $account->iban), strtolower((string) $value));+ $ibanMatch = $stringMethod(strtolower((string)$account->iban), strtolower((string)$value));$accountNrMatch = false;/** @var AccountMeta $meta */foreach ($account->accountMeta as $meta) {@@ -1532,7 +1532,7 @@ class OperatorQuerySearch implements SearchInterface}/**- * @param string $value+ * @param string $value** @return TransactionCurrency|null*/@@ -1552,7 +1552,7 @@ class OperatorQuerySearch implements SearchInterface}/**- * @param string $value+ * @param string $value** @return array* @throws FireflyException@@ -1571,14 +1571,14 @@ class OperatorQuerySearch implements SearchInterface}/**- * @param array $range+ * @param array $range** @throws FireflyException*/private function setExactDateParams(array $range, bool $prohibited = false): void{/**- * @var string $key+ * @var string $key* @var Carbon|string $value*/foreach ($range as $key => $value) {@@ -1630,14 +1630,14 @@ class OperatorQuerySearch implements SearchInterface}/**- * @param array $range+ * @param array $range** @throws FireflyException*/private function setDateBeforeParams(array $range, bool $prohibited = false): void{/**- * @var string $key+ * @var string $key* @var Carbon|string $value*/foreach ($range as $key => $value) {@@ -1669,14 +1669,14 @@ class OperatorQuerySearch implements SearchInterface}/**- * @param array $range+ * @param array $range** @throws FireflyException*/private function setDateAfterParams(array $range, bool $prohibited = false){/**- * @var string $key+ * @var string $key* @var Carbon|string $value*/foreach ($range as $key => $value) {@@ -1708,8 +1708,8 @@ class OperatorQuerySearch implements SearchInterface}/**- * @param string $field- * @param array $range+ * @param string $field+ * @param array $range* @return void* @throws FireflyException*/@@ -1717,7 +1717,7 @@ class OperatorQuerySearch implements SearchInterface{Log::debug('Now in setExactMetaDateParams()');/**- * @var string $key+ * @var string $key* @var Carbon|string $value*/foreach ($range as $key => $value) {@@ -1770,15 +1770,15 @@ class OperatorQuerySearch implements SearchInterface}/**- * @param string $field- * @param array $range+ * @param string $field+ * @param array $range* @return void* @throws FireflyException*/private function setMetaDateBeforeParams(string $field, array $range, bool $prohibited = false): void{/**- * @var string $key+ * @var string $key* @var Carbon|string $value*/foreach ($range as $key => $value) {@@ -1810,15 +1810,15 @@ class OperatorQuerySearch implements SearchInterface}/**- * @param string $field- * @param array $range+ * @param string $field+ * @param array $range* @return void* @throws FireflyException*/private function setMetaDateAfterParams(string $field, array $range, bool $prohibited = false): void{/**- * @var string $key+ * @var string $key* @var Carbon|string $value*/foreach ($range as $key => $value) {@@ -1850,15 +1850,15 @@ class OperatorQuerySearch implements SearchInterface}/**- * @param string $field- * @param array $range+ * @param string $field+ * @param array $range* @return void* @throws FireflyException*/private function setExactObjectDateParams(string $field, array $range, bool $prohibited = false): void{/**- * @var string $key+ * @var string $key* @var Carbon|string $value*/foreach ($range as $key => $value) {@@ -1911,15 +1911,15 @@ class OperatorQuerySearch implements SearchInterface}/**- * @param string $field- * @param array $range+ * @param string $field+ * @param array $range** @throws FireflyException*/private function setObjectDateBeforeParams(string $field, array $range, bool $prohibited = false): void{/**- * @var string $key+ * @var string $key* @var Carbon|string $value*/foreach ($range as $key => $value) {@@ -1951,15 +1951,15 @@ class OperatorQuerySearch implements SearchInterface}/**- * @param string $field- * @param array $range+ * @param string $field+ * @param array $range** @throws FireflyException*/private function setObjectDateAfterParams(string $field, array $range, bool $prohibited = false): void{/**- * @var string $key+ * @var string $key* @var Carbon|string $value*/foreach ($range as $key => $value) {@@ -2020,7 +2020,7 @@ class OperatorQuerySearch implements SearchInterface}/**- * @param Carbon $date+ * @param Carbon $date*/public function setDate(Carbon $date): void{@@ -2052,11 +2052,11 @@ class OperatorQuerySearch implements SearchInterface$this->collector->setUser($user);$this->collector->withAccountInformation()->withCategoryInformation()->withBudgetInformation();- $this->setLimit((int) app('preferences')->getForUser($user, 'listPageSize', 50)->data);+ $this->setLimit((int)app('preferences')->getForUser($user, 'listPageSize', 50)->data);}/**- * @param int $limit+ * @param int $limit*/public function setLimit(int $limit): void{diff --git a/app/Support/Search/SearchInterface.php b/app/Support/Search/SearchInterface.phpindex a50f35c833..97bca2720b 100644--- a/app/Support/Search/SearchInterface.php+++ b/app/Support/Search/SearchInterface.php@@ -1,4 +1,5 @@<?php+/*** SearchInterface.php* Copyright (c) 2019 [email protected]@@ -58,7 +59,7 @@ interface SearchInterfacepublic function hasModifiers(): bool;/**- * @param string $query+ * @param string $query*/public function parseQuery(string $query);@@ -73,22 +74,22 @@ interface SearchInterfacepublic function searchTransactions(): LengthAwarePaginator;/**- * @param Carbon $date+ * @param Carbon $date*/public function setDate(Carbon $date): void;/**- * @param int $limit+ * @param int $limit*/public function setLimit(int $limit): void;/**- * @param int $page+ * @param int $page*/public function setPage(int $page): void;/**- * @param User $user+ * @param User $user*/public function setUser(User $user);}diff --git a/app/Support/Steam.php b/app/Support/Steam.phpindex 6adaf58006..402d375ef0 100644--- a/app/Support/Steam.php+++ b/app/Support/Steam.php@@ -33,6 +33,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;use Illuminate\Support\Collection;use JsonException;use Log;+use Psr\Container\ContainerExceptionInterface;+use Psr\Container\NotFoundExceptionInterface;use stdClass;use Str;use ValueError;@@ -95,38 +97,6 @@ class Steamreturn $sum;}- /**- * https://stackoverflow.com/questions/1642614/how-to-ceil-floor-and-round-bcmath-numbers- *- * @param null|string $number- * @param int $precision- * @return string- */- public function bcround(?string $number, int $precision = 0): string- {- if (null === $number) {- return '0';- }- if ('' === trim($number)) {- return '0';- }- // if the number contains "E", it's in scientific notation, so we need to convert it to a normal number first.- if (false !== stripos($number, 'e')) {- $number = sprintf('%.24f', $number);- }-- Log::debug(sprintf('Trying bcround("%s",%d)', $number, $precision));- if (str_contains($number, '.')) {- if ($number[0] !== '-') {- return bcadd($number, '0.'.str_repeat('0', $precision).'5', $precision);- }-- return bcsub($number, '0.'.str_repeat('0', $precision).'5', $precision);- }-- return $number;- }-/*** Gets the balance for the given account during the whole range, using this format:.*@@ -182,11 +152,11 @@ class Steam->whereNull('transaction_journals.deleted_at')->get([- 'transaction_journals.date',- 'transactions.transaction_currency_id',- DB::raw('SUM(transactions.amount) AS modified'),- 'transactions.foreign_currency_id',- DB::raw('SUM(transactions.foreign_amount) AS modified_foreign'),+ 'transaction_journals.date',+ 'transactions.transaction_currency_id',+ DB::raw('SUM(transactions.amount) AS modified'),+ 'transactions.foreign_currency_id',+ DB::raw('SUM(transactions.foreign_amount) AS modified_foreign'),]);@@ -363,6 +333,38 @@ class Steamreturn $return;}+ /**+ * https://stackoverflow.com/questions/1642614/how-to-ceil-floor-and-round-bcmath-numbers+ *+ * @param null|string $number+ * @param int $precision+ * @return string+ */+ public function bcround(?string $number, int $precision = 0): string+ {+ if (null === $number) {+ return '0';+ }+ if ('' === trim($number)) {+ return '0';+ }+ // if the number contains "E", it's in scientific notation, so we need to convert it to a normal number first.+ if (false !== stripos($number, 'e')) {+ $number = sprintf('%.24f', $number);+ }++ Log::debug(sprintf('Trying bcround("%s",%d)', $number, $precision));+ if (str_contains($number, '.')) {+ if ($number[0] !== '-') {+ return bcadd($number, '0.'.str_repeat('0', $precision).'5', $precision);+ }++ return bcsub($number, '0.'.str_repeat('0', $precision).'5', $precision);+ }++ return $number;+ }+/*** @param string $string*@@ -453,8 +455,8 @@ class Steam** @return string* @throws FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/public function getLocale(): string // get preference{@@ -476,8 +478,8 @@ class Steam** @return string* @throws FireflyException- * @throws \Psr\Container\ContainerExceptionInterface- * @throws \Psr\Container\NotFoundExceptionInterface+ * @throws ContainerExceptionInterface+ * @throws NotFoundExceptionInterface*/public function getLanguage(): string // get preference{diff --git a/app/Support/System/GeneratesInstallationId.php b/app/Support/System/GeneratesInstallationId.phpindex c40eb89c65..8ac9d8dd3e 100644--- a/app/Support/System/GeneratesInstallationId.php+++ b/app/Support/System/GeneratesInstallationId.php@@ -53,7 +53,7 @@ trait GeneratesInstallationIdif (null === $config) {$uuid4 = Uuid::uuid4();- $uniqueId = (string) $uuid4;+ $uniqueId = (string)$uuid4;Log::info(sprintf('Created Firefly III installation ID %s', $uniqueId));app('fireflyconfig')->set('installation_id', $uniqueId);}diff --git a/app/Support/System/OAuthKeys.php b/app/Support/System/OAuthKeys.phpindex 59ad7d15dc..0266cb5feb 100644--- a/app/Support/System/OAuthKeys.php+++ b/app/Support/System/OAuthKeys.php@@ -72,8 +72,8 @@ class OAuthKeys// better check if keys are in the database:if (app('fireflyconfig')->has(self::PRIVATE_KEY) && app('fireflyconfig')->has(self::PUBLIC_KEY)) {try {- $privateKey = (string) app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;- $publicKey = (string) app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;+ $privateKey = (string)app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;+ $publicKey = (string)app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;} catch (ContainerExceptionInterface|NotFoundExceptionInterface|FireflyException $e) {Log::error(sprintf('Could not validate keysInDatabase(): %s', $e->getMessage()));Log::error($e->getTraceAsString());@@ -125,8 +125,8 @@ class OAuthKeys*/public static function restoreKeysFromDB(): bool{- $privateKey = (string) app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;- $publicKey = (string) app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;+ $privateKey = (string)app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;+ $publicKey = (string)app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;try {$privateContent = Crypt::decrypt($privateKey);$publicContent = Crypt::decrypt($publicKey);diff --git a/app/Support/Twig/AmountFormat.php b/app/Support/Twig/AmountFormat.phpindex b099496113..5ae6db2121 100644--- a/app/Support/Twig/AmountFormat.php+++ b/app/Support/Twig/AmountFormat.php@@ -1,4 +1,5 @@<?php+/*** AmountFormat.php* Copyright (c) 2019 [email protected]diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.phpindex 74e0794a07..670ed6b005 100644--- a/app/Support/Twig/General.php+++ b/app/Support/Twig/General.php@@ -1,4 +1,5 @@<?php+/*** General.php* Copyright (c) 2019 [email protected]@@ -85,15 +86,15 @@ class General extends AbstractExtensionstatic function (int $size): string {// less than one GB, more than one MBif ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) {- return round($size / (1024 * 1024), 2) . ' MB';+ return round($size / (1024 * 1024), 2).' MB';}// less than one MBif ($size < (1024 * 1024)) {- return round($size / 1024, 2) . ' KB';+ return round($size / 1024, 2).' KB';}- return $size . ' bytes';+ return $size.' bytes';});}@@ -192,7 +193,7 @@ class General extends AbstractExtension]);- return (string) $converter->convert($text);+ return (string)$converter->convert($text);},['is_safe' => ['html']]);@@ -208,8 +209,8 @@ class General extends AbstractExtensionreturn new TwigFilter('phphost',static function (string $string): string {- $proto = (string) parse_url($string, PHP_URL_SCHEME);- $host = (string) parse_url($string, PHP_URL_HOST);+ $proto = (string)parse_url($string, PHP_URL_SCHEME);+ $host = (string)parse_url($string, PHP_URL_HOST);return e(sprintf('%s://%s', $proto, $host));}@@ -406,7 +407,7 @@ class General extends AbstractExtensionreturn new TwigFunction('getRootSearchOperator',static function (string $operator): string {- $result = OperatorQuerySearch::getRootOperator($operator);+ $result = OperatorQuerySearch::getRootOperator($operator);return str_replace('-', 'not_', $result);});diff --git a/app/Support/Twig/Rule.php b/app/Support/Twig/Rule.phpindex 564547b325..924cd5157d 100644--- a/app/Support/Twig/Rule.php+++ b/app/Support/Twig/Rule.php@@ -1,4 +1,5 @@<?php+/*** Rule.php* Copyright (c) 2019 [email protected]@@ -52,8 +53,8 @@ class Rule extends AbstractExtension'allJournalTriggers',static function () {return [- 'store-journal' => (string) trans('firefly.rule_trigger_store_journal'),- 'update-journal' => (string) trans('firefly.rule_trigger_update_journal'),+ 'store-journal' => (string)trans('firefly.rule_trigger_store_journal'),+ 'update-journal' => (string)trans('firefly.rule_trigger_update_journal'),];});@@ -71,7 +72,7 @@ class Rule extends AbstractExtension$possibleTriggers = [];foreach ($ruleTriggers as $key) {if ('user_action' !== $key) {- $possibleTriggers[$key] = (string) trans('firefly.rule_trigger_' . $key . '_choice');+ $possibleTriggers[$key] = (string)trans('firefly.rule_trigger_'.$key.'_choice');}}unset($ruleTriggers);@@ -94,7 +95,7 @@ class Rule extends AbstractExtension$ruleActions = array_keys(Config::get('firefly.rule-actions'));$possibleActions = [];foreach ($ruleActions as $key) {- $possibleActions[$key] = (string) trans('firefly.rule_action_' . $key . '_choice');+ $possibleActions[$key] = (string)trans('firefly.rule_action_'.$key.'_choice');}unset($ruleActions);asort($possibleActions);diff --git a/app/Support/Twig/TransactionGroupTwig.php b/app/Support/Twig/TransactionGroupTwig.phpindex b2d64f3b7a..409f3b21d9 100644--- a/app/Support/Twig/TransactionGroupTwig.php+++ b/app/Support/Twig/TransactionGroupTwig.php@@ -79,7 +79,7 @@ class TransactionGroupTwig extends AbstractExtension/*** Generate normal amount for transaction from a transaction group.*- * @param array $array+ * @param array $array** @return string*/@@ -95,7 +95,7 @@ class TransactionGroupTwig extends AbstractExtension$colored = false;}- $result = app('amount')->formatFlat($array['currency_symbol'], (int) $array['currency_decimal_places'], $amount, $colored);+ $result = app('amount')->formatFlat($array['currency_symbol'], (int)$array['currency_decimal_places'], $amount, $colored);if ($type === TransactionType::TRANSFER) {$result = sprintf('<span class="text-info">%s</span>', $result);}@@ -104,9 +104,9 @@ class TransactionGroupTwig extends AbstractExtension}/**- * @param string $amount- * @param string $transactionType- * @param string $sourceType+ * @param string $amount+ * @param string $transactionType+ * @param string $sourceType** @return string*/@@ -133,7 +133,7 @@ class TransactionGroupTwig extends AbstractExtension/*** Generate foreign amount for transaction from a transaction group.*- * @param array $array+ * @param array $array** @return string*/@@ -149,7 +149,7 @@ class TransactionGroupTwig extends AbstractExtensionif ($type === TransactionType::TRANSFER) {$colored = false;}- $result = app('amount')->formatFlat($array['foreign_currency_symbol'], (int) $array['foreign_currency_decimal_places'], $amount, $colored);+ $result = app('amount')->formatFlat($array['foreign_currency_symbol'], (int)$array['foreign_currency_decimal_places'], $amount, $colored);if ($type === TransactionType::TRANSFER) {$result = sprintf('<span class="text-info">%s</span>', $result);}@@ -183,7 +183,7 @@ class TransactionGroupTwig extends AbstractExtension/*** Generate normal amount for transaction from a transaction group.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return string*/@@ -201,7 +201,7 @@ class TransactionGroupTwig extends AbstractExtensionif ($type === TransactionType::TRANSFER) {$colored = false;}- $result = app('amount')->formatFlat($currency->symbol, (int) $currency->decimal_places, $amount, $colored);+ $result = app('amount')->formatFlat($currency->symbol, (int)$currency->decimal_places, $amount, $colored);if ($type === TransactionType::TRANSFER) {$result = sprintf('<span class="text-info">%s</span>', $result);}@@ -210,7 +210,7 @@ class TransactionGroupTwig extends AbstractExtension}/**- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return bool*/@@ -225,7 +225,7 @@ class TransactionGroupTwig extends AbstractExtension/*** Generate foreign amount for journal from a transaction group.*- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return string*/@@ -244,7 +244,7 @@ class TransactionGroupTwig extends AbstractExtensionif ($type === TransactionType::TRANSFER) {$colored = false;}- $result = app('amount')->formatFlat($currency->symbol, (int) $currency->decimal_places, $amount, $colored);+ $result = app('amount')->formatFlat($currency->symbol, (int)$currency->decimal_places, $amount, $colored);if ($type === TransactionType::TRANSFER) {$result = sprintf('<span class="text-info">%s</span>', $result);}diff --git a/app/Support/Twig/Translation.php b/app/Support/Twig/Translation.phpindex 752fd27c79..11b420f0be 100644--- a/app/Support/Twig/Translation.php+++ b/app/Support/Twig/Translation.php@@ -1,4 +1,5 @@<?php+/*** Translation.php* Copyright (c) 2019 [email protected]@@ -40,7 +41,7 @@ class Translation extends AbstractExtensionnew TwigFilter('_',static function ($name) {- return (string) trans(sprintf('firefly.%s', $name));+ return (string)trans(sprintf('firefly.%s', $name));},['is_safe' => ['html']]),diff --git a/app/TransactionRules/Actions/ActionInterface.php b/app/TransactionRules/Actions/ActionInterface.phpindex 0686714f3e..4dd7e1161f 100644--- a/app/TransactionRules/Actions/ActionInterface.php+++ b/app/TransactionRules/Actions/ActionInterface.php@@ -1,4 +1,5 @@<?php+/*** ActionInterface.php* Copyright (c) 2019 [email protected]@@ -31,7 +32,7 @@ interface ActionInterface* Execute the action on an array. Returns "true" if the action was a success and the action* was applied. Returns false if otherwise.*- * @param array $journal+ * @param array $journal** @return bool*/diff --git a/app/TransactionRules/Actions/AddTag.php b/app/TransactionRules/Actions/AddTag.phpindex afdb267073..ff80c70a02 100644--- a/app/TransactionRules/Actions/AddTag.php+++ b/app/TransactionRules/Actions/AddTag.php@@ -1,4 +1,5 @@<?php+/*** AddTag.php* Copyright (c) 2019 [email protected]@@ -40,7 +41,7 @@ class AddTag implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){diff --git a/app/TransactionRules/Actions/AppendDescription.php b/app/TransactionRules/Actions/AppendDescription.phpindex 214baa761a..0b24f8e4af 100644--- a/app/TransactionRules/Actions/AppendDescription.php+++ b/app/TransactionRules/Actions/AppendDescription.php@@ -1,4 +1,5 @@<?php+/*** AppendDescription.php* Copyright (c) 2019 [email protected]@@ -37,7 +38,7 @@ class AppendDescription implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){diff --git a/app/TransactionRules/Actions/AppendDescriptionToNotes.php b/app/TransactionRules/Actions/AppendDescriptionToNotes.phpindex c69e5e0cb4..7c887557f5 100644--- a/app/TransactionRules/Actions/AppendDescriptionToNotes.php+++ b/app/TransactionRules/Actions/AppendDescriptionToNotes.php@@ -37,7 +37,7 @@ class AppendDescriptionToNotes implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -66,7 +66,7 @@ class AppendDescriptionToNotes implements ActionInterface$note->text = trim(sprintf("%s \n%s", $note->text, $object->description));}if ('' === $note->text) {- $note->text = (string) $object->description;+ $note->text = (string)$object->description;}$after = $note->text;diff --git a/app/TransactionRules/Actions/AppendNotes.php b/app/TransactionRules/Actions/AppendNotes.phpindex a521334d1a..f55d6dc358 100644--- a/app/TransactionRules/Actions/AppendNotes.php+++ b/app/TransactionRules/Actions/AppendNotes.php@@ -1,4 +1,5 @@<?php+/*** AppendNotes.php* Copyright (c) 2019 [email protected]@@ -38,7 +39,7 @@ class AppendNotes implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -50,12 +51,12 @@ class AppendNotes implements ActionInterface*/public function actOnArray(array $journal): bool{- $dbNote = Note::where('noteable_id', (int) $journal['transaction_journal_id'])- ->where('noteable_type', TransactionJournal::class)- ->first(['notes.*']);+ $dbNote = Note::where('noteable_id', (int)$journal['transaction_journal_id'])+ ->where('noteable_type', TransactionJournal::class)+ ->first(['notes.*']);if (null === $dbNote) {$dbNote = new Note();- $dbNote->noteable_id = (int) $journal['transaction_journal_id'];+ $dbNote->noteable_id = (int)$journal['transaction_journal_id'];$dbNote->noteable_type = TransactionJournal::class;$dbNote->text = '';}diff --git a/app/TransactionRules/Actions/AppendNotesToDescription.php b/app/TransactionRules/Actions/AppendNotesToDescription.phpindex f26e8677bc..9ca6fdaa7a 100644--- a/app/TransactionRules/Actions/AppendNotesToDescription.php+++ b/app/TransactionRules/Actions/AppendNotesToDescription.php@@ -43,7 +43,7 @@ class AppendNotesToDescription implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -71,8 +71,8 @@ class AppendNotesToDescription implements ActionInterface}// only append if there is something to appendif ('' !== $note->text) {- $before = $object->description;- $object->description = trim(sprintf("%s %s", $object->description, (string) $this->clearString($note->text, false)));+ $before = $object->description;+ $object->description = trim(sprintf("%s %s", $object->description, (string)$this->clearString($note->text, false)));$object->save();Log::debug(sprintf('Journal description is updated to "%s".', $object->description));diff --git a/app/TransactionRules/Actions/ClearBudget.php b/app/TransactionRules/Actions/ClearBudget.phpindex c58eb59dd5..2bef3a4fe4 100644--- a/app/TransactionRules/Actions/ClearBudget.php+++ b/app/TransactionRules/Actions/ClearBudget.php@@ -1,4 +1,5 @@<?php+/*** ClearBudget.php* Copyright (c) 2019 [email protected]@@ -38,7 +39,7 @@ class ClearBudget implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -52,7 +53,7 @@ class ClearBudget implements ActionInterface{/** @var TransactionJournal $object */$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);- $budget = $object->budgets()->first();+ $budget = $object->budgets()->first();if (null === $budget) {Log::debug(sprintf('RuleAction ClearBudget, no budget in journal #%d.', $journal['transaction_journal_id']));return false;diff --git a/app/TransactionRules/Actions/ClearCategory.php b/app/TransactionRules/Actions/ClearCategory.phpindex 3e8719ee57..43874d063c 100644--- a/app/TransactionRules/Actions/ClearCategory.php+++ b/app/TransactionRules/Actions/ClearCategory.php@@ -1,4 +1,5 @@<?php+/*** ClearCategory.php* Copyright (c) 2019 [email protected]@@ -38,7 +39,7 @@ class ClearCategory implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -51,7 +52,7 @@ class ClearCategory implements ActionInterfacepublic function actOnArray(array $journal): bool{/** @var TransactionJournal $object */- $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);$category = $object->categories()->first();if (null === $category) {Log::debug(sprintf('RuleAction ClearCategory, no category in journal #%d.', $journal['transaction_journal_id']));diff --git a/app/TransactionRules/Actions/ClearNotes.php b/app/TransactionRules/Actions/ClearNotes.phpindex 52ca3e24ca..e14fe32b95 100644--- a/app/TransactionRules/Actions/ClearNotes.php+++ b/app/TransactionRules/Actions/ClearNotes.php@@ -1,4 +1,5 @@<?php+/*** ClearNotes.php* Copyright (c) 2019 [email protected]@@ -38,7 +39,7 @@ class ClearNotes implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -51,7 +52,7 @@ class ClearNotes implements ActionInterfacepublic function actOnArray(array $journal): bool{$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);- $notes = $object->notes()->first();+ $notes = $object->notes()->first();if (null === $notes) {Log::debug(sprintf('RuleAction ClearNotes, journal #%d has no notes.', $journal['transaction_journal_id']));return false;diff --git a/app/TransactionRules/Actions/ConvertToDeposit.php b/app/TransactionRules/Actions/ConvertToDeposit.phpindex 1b05ea053e..ce9a74a7f8 100644--- a/app/TransactionRules/Actions/ConvertToDeposit.php+++ b/app/TransactionRules/Actions/ConvertToDeposit.php@@ -45,7 +45,7 @@ class ConvertToDeposit implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -94,7 +94,7 @@ class ConvertToDeposit implements ActionInterface* Input is a withdrawal from A to B* Is converted to a deposit from C to A.*- * @param array $journal+ * @param array $journal** @return bool* @throws FireflyException@@ -142,7 +142,7 @@ class ConvertToDeposit implements ActionInterface* Input is a transfer from A to B.* Output is a deposit from C to B.*- * @param array $journal+ * @param array $journal** @return bool* @throws FireflyExceptiondiff --git a/app/TransactionRules/Actions/ConvertToTransfer.php b/app/TransactionRules/Actions/ConvertToTransfer.phpindex 9d3035db24..067a622735 100644--- a/app/TransactionRules/Actions/ConvertToTransfer.php+++ b/app/TransactionRules/Actions/ConvertToTransfer.php@@ -45,7 +45,7 @@ class ConvertToTransfer implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -114,8 +114,8 @@ class ConvertToTransfer implements ActionInterface* A withdrawal is from Asset to Expense.* We replace the Expense with another asset.*- * @param array $journal- * @param Account $asset+ * @param array $journal+ * @param Account $asset** @return bool*/@@ -154,8 +154,8 @@ class ConvertToTransfer implements ActionInterface* A deposit is from Revenue to Asset.* We replace the Revenue with another asset.*- * @param array $journal- * @param Account $asset+ * @param array $journal+ * @param Account $asset** @return bool*/diff --git a/app/TransactionRules/Actions/ConvertToWithdrawal.php b/app/TransactionRules/Actions/ConvertToWithdrawal.phpindex f7844045a4..447682cfbe 100644--- a/app/TransactionRules/Actions/ConvertToWithdrawal.php+++ b/app/TransactionRules/Actions/ConvertToWithdrawal.php@@ -45,7 +45,7 @@ class ConvertToWithdrawal implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -127,7 +127,7 @@ class ConvertToWithdrawal implements ActionInterface* Input is a transfer from A to B.* Output is a withdrawal from A to C.*- * @param array $journal+ * @param array $journal** @return bool* @throws FireflyExceptiondiff --git a/app/TransactionRules/Actions/DeleteTransaction.php b/app/TransactionRules/Actions/DeleteTransaction.phpindex 2912082630..35be86196a 100644--- a/app/TransactionRules/Actions/DeleteTransaction.php+++ b/app/TransactionRules/Actions/DeleteTransaction.php@@ -1,4 +1,5 @@<?php+/*** DeleteTransaction.php* Copyright (c) 2019 [email protected]@@ -40,7 +41,7 @@ class DeleteTransaction implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){diff --git a/app/TransactionRules/Actions/LinkToBill.php b/app/TransactionRules/Actions/LinkToBill.phpindex c9a3802aba..d4c7ed522c 100644--- a/app/TransactionRules/Actions/LinkToBill.php+++ b/app/TransactionRules/Actions/LinkToBill.php@@ -1,4 +1,5 @@<?php+/*** LinkToBill.php* Copyright (c) 2019 [email protected]@@ -43,7 +44,7 @@ class LinkToBill implements ActionInterface** @codeCoverageIgnore*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -59,14 +60,20 @@ class LinkToBill implements ActionInterface/** @var BillRepositoryInterface $repository */$repository = app(BillRepositoryInterface::class);$repository->setUser($user);- $billName = (string) $this->action->action_value;+ $billName = (string)$this->action->action_value;$bill = $repository->findByName($billName);if (null !== $bill && $journal['transaction_type_type'] === TransactionType::WITHDRAWAL) {$count = DB::table('transaction_journals')->where('id', '=', $journal['transaction_journal_id'])->where('bill_id', $bill->id)->count();if (0 !== $count) {- Log::error(sprintf('RuleAction LinkToBill could not set the bill of journal #%d to bill "%s": already set.', $journal['transaction_journal_id'], $billName));+ Log::error(+ sprintf(+ 'RuleAction LinkToBill could not set the bill of journal #%d to bill "%s": already set.',+ $journal['transaction_journal_id'],+ $billName+ )+ );return false;}diff --git a/app/TransactionRules/Actions/MoveDescriptionToNotes.php b/app/TransactionRules/Actions/MoveDescriptionToNotes.phpindex 45faf1aef6..fcab74d39b 100644--- a/app/TransactionRules/Actions/MoveDescriptionToNotes.php+++ b/app/TransactionRules/Actions/MoveDescriptionToNotes.php@@ -42,7 +42,7 @@ class MoveDescriptionToNotes implements ActionInterface** @codeCoverageIgnore*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -69,11 +69,11 @@ class MoveDescriptionToNotes implements ActionInterface$before = $note->text;$beforeDescription = $object->description;if ('' !== $note->text) {- $note->text = trim(sprintf("%s \n%s", $note->text, $object->description));+ $note->text = trim(sprintf("%s \n%s", $note->text, $object->description));$object->description = '(no description)';}if ('' === $note->text) {- $note->text = (string) $object->description;+ $note->text = (string)$object->description;$object->description = '(no description)';}$after = $note->text;diff --git a/app/TransactionRules/Actions/MoveNotesToDescription.php b/app/TransactionRules/Actions/MoveNotesToDescription.phpindex bd697e8205..0825d17885 100644--- a/app/TransactionRules/Actions/MoveNotesToDescription.php+++ b/app/TransactionRules/Actions/MoveNotesToDescription.php@@ -41,7 +41,7 @@ class MoveNotesToDescription implements ActionInterface** @codeCoverageIgnore*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -69,9 +69,9 @@ class MoveNotesToDescription implements ActionInterface$note->delete();return false;}- $before = $object->description;- $beforeNote = $note->text;- $object->description = (string) $this->clearString($note->text, false);+ $before = $object->description;+ $beforeNote = $note->text;+ $object->description = (string)$this->clearString($note->text, false);$object->save();$note->delete();diff --git a/app/TransactionRules/Actions/PrependDescription.php b/app/TransactionRules/Actions/PrependDescription.phpindex 824a015768..f2a12ef24b 100644--- a/app/TransactionRules/Actions/PrependDescription.php+++ b/app/TransactionRules/Actions/PrependDescription.php@@ -1,4 +1,5 @@<?php+/*** PrependDescription.php* Copyright (c) 2019 [email protected]@@ -37,7 +38,7 @@ class PrependDescription implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){diff --git a/app/TransactionRules/Actions/PrependNotes.php b/app/TransactionRules/Actions/PrependNotes.phpindex 9ff40f9ee6..cff973022c 100644--- a/app/TransactionRules/Actions/PrependNotes.php+++ b/app/TransactionRules/Actions/PrependNotes.php@@ -1,4 +1,5 @@<?php+/*** PrependNotes.php* Copyright (c) 2019 [email protected]@@ -38,7 +39,7 @@ class PrependNotes implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -50,12 +51,12 @@ class PrependNotes implements ActionInterface*/public function actOnArray(array $journal): bool{- $dbNote = Note::where('noteable_id', (int) $journal['transaction_journal_id'])- ->where('noteable_type', TransactionJournal::class)- ->first(['notes.*']);+ $dbNote = Note::where('noteable_id', (int)$journal['transaction_journal_id'])+ ->where('noteable_type', TransactionJournal::class)+ ->first(['notes.*']);if (null === $dbNote) {$dbNote = new Note();- $dbNote->noteable_id = (int) $journal['transaction_journal_id'];+ $dbNote->noteable_id = (int)$journal['transaction_journal_id'];$dbNote->noteable_type = TransactionJournal::class;$dbNote->text = '';}diff --git a/app/TransactionRules/Actions/RemoveAllTags.php b/app/TransactionRules/Actions/RemoveAllTags.phpindex 486ec340f9..54c9d06e2f 100644--- a/app/TransactionRules/Actions/RemoveAllTags.php+++ b/app/TransactionRules/Actions/RemoveAllTags.php@@ -1,4 +1,5 @@<?php+/*** RemoveAllTags.php* Copyright (c) 2019 [email protected]@@ -38,7 +39,7 @@ class RemoveAllTags implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){diff --git a/app/TransactionRules/Actions/RemoveTag.php b/app/TransactionRules/Actions/RemoveTag.phpindex e19875655a..f2b14aa109 100644--- a/app/TransactionRules/Actions/RemoveTag.php+++ b/app/TransactionRules/Actions/RemoveTag.php@@ -1,4 +1,5 @@<?php+/*** RemoveTag.php* Copyright (c) 2019 [email protected]@@ -39,7 +40,7 @@ class RemoveTag implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -64,7 +65,9 @@ class RemoveTag implements ActionInterface}$count = DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal['transaction_journal_id'])->where('tag_id', $tag->id)->count();if (0 === $count) {- Log::debug(sprintf('RuleAction RemoveTag tried to remove tag "%s" from journal #%d but no such tag is linked.', $name, $journal['transaction_journal_id']));+ Log::debug(+ sprintf('RuleAction RemoveTag tried to remove tag "%s" from journal #%d but no such tag is linked.', $name, $journal['transaction_journal_id'])+ );return false;}diff --git a/app/TransactionRules/Actions/SetBudget.php b/app/TransactionRules/Actions/SetBudget.phpindex 4bd2b078d0..35714bd276 100644--- a/app/TransactionRules/Actions/SetBudget.php+++ b/app/TransactionRules/Actions/SetBudget.php@@ -1,4 +1,5 @@<?php+/*** SetBudget.php* Copyright (c) 2019 [email protected]@@ -40,7 +41,7 @@ class SetBudget implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){diff --git a/app/TransactionRules/Actions/SetCategory.php b/app/TransactionRules/Actions/SetCategory.phpindex 6dec531851..ed4cdc34c6 100644--- a/app/TransactionRules/Actions/SetCategory.php+++ b/app/TransactionRules/Actions/SetCategory.php@@ -1,4 +1,5 @@<?php+/*** SetCategory.php* Copyright (c) 2019 [email protected]@@ -40,7 +41,7 @@ class SetCategory implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){diff --git a/app/TransactionRules/Actions/SetDescription.php b/app/TransactionRules/Actions/SetDescription.phpindex d588e5db81..17eaedce95 100644--- a/app/TransactionRules/Actions/SetDescription.php+++ b/app/TransactionRules/Actions/SetDescription.php@@ -1,4 +1,5 @@<?php+/*** SetDescription.php* Copyright (c) 2019 [email protected]@@ -38,7 +39,7 @@ class SetDescription implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -52,7 +53,7 @@ class SetDescription implements ActionInterface{/** @var TransactionJournal $object */$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);- $before = $object->description;+ $before = $object->description;DB::table('transaction_journals')->where('id', '=', $journal['transaction_journal_id'])diff --git a/app/TransactionRules/Actions/SetDestinationAccount.php b/app/TransactionRules/Actions/SetDestinationAccount.phpindex a283fea95a..0bf9b4f187 100644--- a/app/TransactionRules/Actions/SetDestinationAccount.php+++ b/app/TransactionRules/Actions/SetDestinationAccount.php@@ -1,4 +1,5 @@<?php+/*** SetDestinationAccount.php* Copyright (c) 2019 [email protected]@@ -44,7 +45,7 @@ class SetDestinationAccount implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -59,7 +60,7 @@ class SetDestinationAccount implements ActionInterface$user = User::find($journal['user_id']);$type = $journal['transaction_type_type'];/** @var TransactionJournal|null $object */- $object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']);+ $object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);$this->repository = app(AccountRepositoryInterface::class);if (null === $object) {@@ -98,7 +99,7 @@ class SetDestinationAccount implements ActionInterfacereturn false;}- if (null !== $newAccount && (int) $newAccount->id === (int) $source->account_id) {+ if (null !== $newAccount && (int)$newAccount->id === (int)$source->account_id) {Log::error(sprintf('New destination account ID #%d and current source account ID #%d are the same. Do nothing.',@@ -132,7 +133,7 @@ class SetDestinationAccount implements ActionInterface}/**- * @param string $type+ * @param string $type** @return Account|null*/diff --git a/app/TransactionRules/Actions/SetNotes.php b/app/TransactionRules/Actions/SetNotes.phpindex 76457cb887..0979fd8e48 100644--- a/app/TransactionRules/Actions/SetNotes.php+++ b/app/TransactionRules/Actions/SetNotes.php@@ -1,4 +1,5 @@<?php+/*** SetNotes.php* Copyright (c) 2019 [email protected]@@ -38,7 +39,7 @@ class SetNotes implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){diff --git a/app/TransactionRules/Actions/SetSourceAccount.php b/app/TransactionRules/Actions/SetSourceAccount.phpindex a264fdd176..f79650e8ea 100644--- a/app/TransactionRules/Actions/SetSourceAccount.php+++ b/app/TransactionRules/Actions/SetSourceAccount.php@@ -1,4 +1,5 @@<?php+/*** SetSourceAccount.php* Copyright (c) 2019 [email protected]@@ -44,7 +45,7 @@ class SetSourceAccount implements ActionInterface/*** TriggerInterface constructor.*- * @param RuleAction $action+ * @param RuleAction $action*/public function __construct(RuleAction $action){@@ -59,7 +60,7 @@ class SetSourceAccount implements ActionInterface$user = User::find($journal['user_id']);$type = $journal['transaction_type_type'];/** @var TransactionJournal|null $object */- $object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']);+ $object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);$this->repository = app(AccountRepositoryInterface::class);if (null === $object) {Log::error('Could not find journal.');@@ -93,7 +94,7 @@ class SetSourceAccount implements ActionInterfacereturn false;}- if (null !== $newAccount && (int) $newAccount->id === (int) $destination->account_id) {+ if (null !== $newAccount && (int)$newAccount->id === (int)$destination->account_id) {Log::error(sprintf('New source account ID #%d and current destination account ID #%d are the same. Do nothing.',@@ -127,7 +128,7 @@ class SetSourceAccount implements ActionInterface}/**- * @param string $type+ * @param string $type** @return Account|null*/diff --git a/app/TransactionRules/Actions/UpdatePiggybank.php b/app/TransactionRules/Actions/UpdatePiggybank.phpindex 2f55051b10..10ad6a967c 100644--- a/app/TransactionRules/Actions/UpdatePiggybank.php+++ b/app/TransactionRules/Actions/UpdatePiggybank.php@@ -91,7 +91,20 @@ class UpdatePiggybank implements ActionInterfaceLog::debug('Piggy bank account is linked to source, so remove amount from piggy bank.');$this->removeAmount($piggyBank, $journalObj, $destination->amount);- event(new TriggeredAuditLog($this->action->rule, $journalObj, 'remove_from_piggy', null, ['currency_symbol' => $journalObj->transactionCurrency->symbol, 'decimal_places' => $journalObj->transactionCurrency->decimal_places, 'amount' => $destination->amount, 'piggy' => $piggyBank->name]));+ event(+ new TriggeredAuditLog(+ $this->action->rule,+ $journalObj,+ 'remove_from_piggy',+ null,+ [+ 'currency_symbol' => $journalObj->transactionCurrency->symbol,+ 'decimal_places' => $journalObj->transactionCurrency->decimal_places,+ 'amount' => $destination->amount,+ 'piggy' => $piggyBank->name,+ ]+ )+ );return true;}@@ -99,7 +112,20 @@ class UpdatePiggybank implements ActionInterfaceLog::debug('Piggy bank account is linked to source, so add amount to piggy bank.');$this->addAmount($piggyBank, $journalObj, $destination->amount);- event(new TriggeredAuditLog($this->action->rule, $journalObj, 'add_to_piggy', null, ['currency_symbol' => $journalObj->transactionCurrency->symbol, 'decimal_places' => $journalObj->transactionCurrency->decimal_places, 'amount' => $destination->amount, 'piggy' => $piggyBank->name]));+ event(+ new TriggeredAuditLog(+ $this->action->rule,+ $journalObj,+ 'add_to_piggy',+ null,+ [+ 'currency_symbol' => $journalObj->transactionCurrency->symbol,+ 'decimal_places' => $journalObj->transactionCurrency->decimal_places,+ 'amount' => $destination->amount,+ 'piggy' => $piggyBank->name,+ ]+ )+ );return true;}diff --git a/app/TransactionRules/Engine/RuleEngineInterface.php b/app/TransactionRules/Engine/RuleEngineInterface.phpindex d6e54d0002..111fdb6231 100644--- a/app/TransactionRules/Engine/RuleEngineInterface.php+++ b/app/TransactionRules/Engine/RuleEngineInterface.php@@ -34,7 +34,7 @@ interface RuleEngineInterface/*** Add operators added to each search by the rule engine.*- * @param array $operator+ * @param array $operator*/public function addOperator(array $operator): void;@@ -58,19 +58,19 @@ interface RuleEngineInterface/*** Add entire rule groups for the engine to execute.*- * @param Collection $ruleGroups+ * @param Collection $ruleGroups*/public function setRuleGroups(Collection $ruleGroups): void;/*** Add rules for the engine to execute.*- * @param Collection $rules+ * @param Collection $rules*/public function setRules(Collection $rules): void;/**- * @param User $user+ * @param User $user*/public function setUser(User $user): void;}diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.phpindex 19c45599d0..756716ce82 100644--- a/app/TransactionRules/Engine/SearchRuleEngine.php+++ b/app/TransactionRules/Engine/SearchRuleEngine.php@@ -89,7 +89,7 @@ class SearchRuleEngine implements RuleEngineInterface/*** Finds the transactions a strict rule will execute on.*- * @param Rule $rule+ * @param Rule $rule** @return Collection*/@@ -152,7 +152,7 @@ class SearchRuleEngine implements RuleEngineInterface* one search operator for "journal_id" it means the date ranges* in the search may need to be updated.*- * @param array $array+ * @param array $array** @return bool*/@@ -178,7 +178,7 @@ class SearchRuleEngine implements RuleEngineInterface}/**- * @param array $array+ * @param array $array** @return Carbon*/@@ -188,7 +188,7 @@ class SearchRuleEngine implements RuleEngineInterface$journalId = 0;foreach ($array as $triggerName => $values) {if ('journal_id' === $triggerName && is_array($values) && 1 === count($values)) {- $journalId = (int) trim(($values[0] ?? '"0"'), '"'); // follows format "123".+ $journalId = (int)trim(($values[0] ?? '"0"'), '"'); // follows format "123".Log::debug(sprintf('Found journal ID #%d', $journalId));}}@@ -209,7 +209,16 @@ class SearchRuleEngine implements RuleEngineInterface}/**- * @param Rule $rule+ * @inheritDoc+ */+ public function setUser(User $user): void+ {+ $this->user = $user;+ $this->operators = [];+ }++ /**+ * @param Rule $rule** @return Collection*/@@ -320,7 +329,7 @@ class SearchRuleEngine implements RuleEngineInterface/*** Returns true if the rule has been triggered.*- * @param Rule $rule+ * @param Rule $rule** @return bool* @throws FireflyException@@ -346,7 +355,7 @@ class SearchRuleEngine implements RuleEngineInterface/*** Return true if the rule is fired (the collection is larger than zero).*- * @param Rule $rule+ * @param Rule $rule** @return bool* @throws FireflyException@@ -371,8 +380,8 @@ class SearchRuleEngine implements RuleEngineInterface}/**- * @param Rule $rule- * @param Collection $collection+ * @param Rule $rule+ * @param Collection $collection** @throws FireflyException*/@@ -386,8 +395,8 @@ class SearchRuleEngine implements RuleEngineInterface}/**- * @param Rule $rule- * @param array $group+ * @param Rule $rule+ * @param array $group** @throws FireflyException*/@@ -401,8 +410,8 @@ class SearchRuleEngine implements RuleEngineInterface}/**- * @param Rule $rule- * @param array $transaction+ * @param Rule $rule+ * @param array $transaction** @throws FireflyException*/@@ -423,8 +432,8 @@ class SearchRuleEngine implements RuleEngineInterface}/**- * @param RuleAction $ruleAction- * @param array $transaction+ * @param RuleAction $ruleAction+ * @param array $transaction** @return bool* @throws FireflyException@@ -463,7 +472,7 @@ class SearchRuleEngine implements RuleEngineInterface/*** Return true if the rule is fired (the collection is larger than zero).*- * @param Rule $rule+ * @param Rule $rule** @return bool* @throws FireflyException@@ -480,7 +489,7 @@ class SearchRuleEngine implements RuleEngineInterface}/**- * @param RuleGroup $group+ * @param RuleGroup $group** @return void* @throws FireflyException@@ -541,13 +550,4 @@ class SearchRuleEngine implements RuleEngineInterface}}}-- /**- * @inheritDoc- */- public function setUser(User $user): void- {- $this->user = $user;- $this->operators = [];- }}diff --git a/app/TransactionRules/Factory/ActionFactory.php b/app/TransactionRules/Factory/ActionFactory.phpindex 37a8acae7b..5627727ea6 100644--- a/app/TransactionRules/Factory/ActionFactory.php+++ b/app/TransactionRules/Factory/ActionFactory.php@@ -1,4 +1,5 @@<?php+/*** ActionFactory.php* Copyright (c) 2019 Robert Horlings@@ -44,7 +45,7 @@ class ActionFactory* with value "Groceries" this method will return a corresponding SetCategory object preset* to "Groceries". Any transaction journal then fed to this object will have its category changed.*- * @param RuleAction $action+ * @param RuleAction $action** @return ActionInterface*@@ -63,7 +64,7 @@ class ActionFactory* that will match the given action type (ie. "change_category") to the matching class name* (SetCategory) using the configuration (firefly.php).*- * @param string $actionType+ * @param string $actionType** @return string*@@ -74,12 +75,12 @@ class ActionFactory$actionTypes = self::getActionTypes();if (!array_key_exists($actionType, $actionTypes)) {- throw new FireflyException('No such action exists ("' . e($actionType) . '").');+ throw new FireflyException('No such action exists ("'.e($actionType).'").');}$class = $actionTypes[$actionType];if (!class_exists($class)) {- throw new FireflyException('Could not instantiate class for rule action type "' . e($actionType) . '" (' . e($class) . ').');+ throw new FireflyException('Could not instantiate class for rule action type "'.e($actionType).'" ('.e($class).').');}return $class;diff --git a/app/Transformers/AbstractTransformer.php b/app/Transformers/AbstractTransformer.phpindex 1e76cf7ac1..19780f730b 100644--- a/app/Transformers/AbstractTransformer.php+++ b/app/Transformers/AbstractTransformer.php@@ -43,7 +43,7 @@ abstract class AbstractTransformer extends TransformerAbstract}/**- * @param ParameterBag $parameters+ * @param ParameterBag $parameters*/final public function setParameters(ParameterBag $parameters): void{diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.phpindex cc56a4b3f8..d3e42102bd 100644--- a/app/Transformers/AccountTransformer.php+++ b/app/Transformers/AccountTransformer.php@@ -52,7 +52,7 @@ class AccountTransformer extends AbstractTransformer/*** Transform the account.*- * @param Account $account+ * @param Account $account** @return array* @throws JsonException@@ -63,8 +63,8 @@ class AccountTransformer extends AbstractTransformer// get account type:$fullType = $account->accountType->type;- $accountType = (string) config(sprintf('firefly.shortNamesByFullName.%s', $fullType));- $liabilityType = (string) config(sprintf('firefly.shortLiabilityNameByFullName.%s', $fullType));+ $accountType = (string)config(sprintf('firefly.shortNamesByFullName.%s', $fullType));+ $liabilityType = (string)config(sprintf('firefly.shortLiabilityNameByFullName.%s', $fullType));$liabilityType = '' === $liabilityType ? null : strtolower($liabilityType);$liabilityDirection = $this->repository->getMetaValue($account, 'liability_direction');@@ -87,17 +87,17 @@ class AccountTransformer extends AbstractTransformerif (null !== $location) {$longitude = $location->longitude;$latitude = $location->latitude;- $zoomLevel = (int) $location->zoom_level;+ $zoomLevel = (int)$location->zoom_level;}// no order for some accounts:- $order = (int) $account->order;+ $order = (int)$account->order;if (!in_array(strtolower($accountType), ['liability', 'liabilities', 'asset'], true)) {$order = null;}return [- 'id' => (string) $account->id,+ 'id' => (string)$account->id,'created_at' => $account->created_at->toAtomString(),'updated_at' => $account->updated_at->toAtomString(),'active' => $account->active,@@ -132,23 +132,23 @@ class AccountTransformer extends AbstractTransformer'links' => [['rel' => 'self',- 'uri' => '/accounts/' . $account->id,+ 'uri' => '/accounts/'.$account->id,],],];}/**- * @param Account $account+ * @param Account $account*- * @param string $accountType+ * @param string $accountType** @return string|null*/private function getAccountRole(Account $account, string $accountType): ?string{$accountRole = $this->repository->getMetaValue($account, 'account_role');- if ('asset' !== $accountType || '' === (string) $accountRole) {+ if ('asset' !== $accountType || '' === (string)$accountRole) {$accountRole = null;}@@ -170,7 +170,7 @@ class AccountTransformer extends AbstractTransformer}/**- * @param Account $account+ * @param Account $account** @return array* @throws FireflyException@@ -184,7 +184,7 @@ class AccountTransformer extends AbstractTransformerif (null === $currency) {$currency = app('amount')->getDefaultCurrencyByUser($account->user);}- $currencyId = (string) $currency->id;+ $currencyId = (string)$currency->id;$currencyCode = $currency->code;$decimalPlaces = $currency->decimal_places;$currencySymbol = $currency->symbol;@@ -193,9 +193,9 @@ class AccountTransformer extends AbstractTransformer}/**- * @param Account $account- * @param string|null $accountRole- * @param string $accountType+ * @param Account $account+ * @param string|null $accountRole+ * @param string $accountType** @return array*/@@ -215,8 +215,8 @@ class AccountTransformer extends AbstractTransformer}/**- * @param Account $account- * @param string $accountType+ * @param Account $account+ * @param string $accountType** @return array*@@ -239,8 +239,8 @@ class AccountTransformer extends AbstractTransformer}/**- * @param Account $account- * @param string $accountType+ * @param Account $account+ * @param string $accountType** @return array*/diff --git a/app/Transformers/AttachmentTransformer.php b/app/Transformers/AttachmentTransformer.phpindex 3d03a79c4d..e816a8ba3f 100644--- a/app/Transformers/AttachmentTransformer.php+++ b/app/Transformers/AttachmentTransformer.php@@ -46,7 +46,7 @@ class AttachmentTransformer extends AbstractTransformer/*** Transform attachment.*- * @param Attachment $attachment+ * @param Attachment $attachment** @return array*/@@ -55,10 +55,10 @@ class AttachmentTransformer extends AbstractTransformer$this->repository->setUser($attachment->user);return [- 'id' => (string) $attachment->id,+ 'id' => (string)$attachment->id,'created_at' => $attachment->created_at->toAtomString(),'updated_at' => $attachment->updated_at->toAtomString(),- 'attachable_id' => (string) $attachment->attachable_id,+ 'attachable_id' => (string)$attachment->attachable_id,'attachable_type' => str_replace('FireflyIII\\Models\\', '', $attachment->attachable_type),'md5' => $attachment->md5,'filename' => $attachment->filename,@@ -67,11 +67,11 @@ class AttachmentTransformer extends AbstractTransformer'title' => $attachment->title,'notes' => $this->repository->getNoteText($attachment),'mime' => $attachment->mime,- 'size' => (int) $attachment->size,+ 'size' => (int)$attachment->size,'links' => [['rel' => 'self',- 'uri' => '/attachment/' . $attachment->id,+ 'uri' => '/attachment/'.$attachment->id,],],];diff --git a/app/Transformers/AvailableBudgetTransformer.php b/app/Transformers/AvailableBudgetTransformer.phpindex 62944bab86..ec7cdd1b23 100644--- a/app/Transformers/AvailableBudgetTransformer.php+++ b/app/Transformers/AvailableBudgetTransformer.php@@ -52,7 +52,7 @@ class AvailableBudgetTransformer extends AbstractTransformer/*** Transform the note.*- * @param AvailableBudget $availableBudget+ * @param AvailableBudget $availableBudget** @return array*/@@ -62,13 +62,13 @@ class AvailableBudgetTransformer extends AbstractTransformer$currency = $availableBudget->transactionCurrency;$data = [- 'id' => (string) $availableBudget->id,+ 'id' => (string)$availableBudget->id,'created_at' => $availableBudget->created_at->toAtomString(),'updated_at' => $availableBudget->updated_at->toAtomString(),- 'currency_id' => (string) $currency->id,+ 'currency_id' => (string)$currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,- 'currency_decimal_places' => (int) $currency->decimal_places,+ 'currency_decimal_places' => (int)$currency->decimal_places,'amount' => app('steam')->bcround($availableBudget->amount, $currency->decimal_places),'start' => $availableBudget->start_date->toAtomString(),'end' => $availableBudget->end_date->endOfDay()->toAtomString(),@@ -77,7 +77,7 @@ class AvailableBudgetTransformer extends AbstractTransformer'links' => [['rel' => 'self',- 'uri' => '/available_budgets/' . $availableBudget->id,+ 'uri' => '/available_budgets/'.$availableBudget->id,],],];diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.phpindex 54b1d11348..e88ddc7786 100644--- a/app/Transformers/BillTransformer.php+++ b/app/Transformers/BillTransformer.php@@ -52,7 +52,7 @@ class BillTransformer extends AbstractTransformer/*** Transform the bill.*- * @param Bill $bill+ * @param Bill $bill** @return array*/@@ -72,8 +72,8 @@ class BillTransformer extends AbstractTransformer/** @var ObjectGroup $objectGroup */$objectGroup = $bill->objectGroups->first();if (null !== $objectGroup) {- $objectGroupId = (int) $objectGroup->id;- $objectGroupOrder = (int) $objectGroup->order;+ $objectGroupId = (int)$objectGroup->id;+ $objectGroupOrder = (int)$objectGroup->order;$objectGroupTitle = $objectGroup->title;}@@ -107,13 +107,13 @@ class BillTransformer extends AbstractTransformerunset($temp, $temp2);return [- 'id' => (int) $bill->id,+ 'id' => (int)$bill->id,'created_at' => $bill->created_at->toAtomString(),'updated_at' => $bill->updated_at->toAtomString(),- 'currency_id' => (string) $bill->transaction_currency_id,+ 'currency_id' => (string)$bill->transaction_currency_id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,- 'currency_decimal_places' => (int) $currency->decimal_places,+ 'currency_decimal_places' => (int)$currency->decimal_places,'name' => $bill->name,'amount_min' => app('steam')->bcround($bill->amount_min, $currency->decimal_places),'amount_max' => app('steam')->bcround($bill->amount_max, $currency->decimal_places),@@ -121,11 +121,11 @@ class BillTransformer extends AbstractTransformer'end_date' => $bill->end_date?->toAtomString(),'extension_date' => $bill->extension_date?->toAtomString(),'repeat_freq' => $bill->repeat_freq,- 'skip' => (int) $bill->skip,+ 'skip' => (int)$bill->skip,'active' => $bill->active,- 'order' => (int) $bill->order,+ 'order' => (int)$bill->order,'notes' => $notes,- 'object_group_id' => $objectGroupId ? (string) $objectGroupId : null,+ 'object_group_id' => $objectGroupId ? (string)$objectGroupId : null,'object_group_order' => $objectGroupOrder,'object_group_title' => $objectGroupTitle,@@ -137,7 +137,7 @@ class BillTransformer extends AbstractTransformer'links' => [['rel' => 'self',- 'uri' => '/bills/' . $bill->id,+ 'uri' => '/bills/'.$bill->id,],],];@@ -146,7 +146,7 @@ class BillTransformer extends AbstractTransformer/*** Get the data the bill was paid and predict the next expected match.*- * @param Bill $bill+ * @param Bill $bill** @return array*/@@ -203,8 +203,8 @@ class BillTransformer extends AbstractTransformer$result = [];foreach ($set as $entry) {$result[] = [- 'transaction_group_id' => (int) $entry->transaction_group_id,- 'transaction_journal_id' => (int) $entry->id,+ 'transaction_group_id' => (int)$entry->transaction_group_id,+ 'transaction_journal_id' => (int)$entry->id,'date' => $entry->date->format('Y-m-d'),];}@@ -220,8 +220,8 @@ class BillTransformer extends AbstractTransformer/*** Returns the latest date in the set, or start when set is empty.*- * @param Collection $dates- * @param Carbon $default+ * @param Collection $dates+ * @param Carbon $default** @return Carbon*/@@ -242,7 +242,7 @@ class BillTransformer extends AbstractTransformer}/**- * @param Bill $bill+ * @param Bill $bill** @return array*/@@ -285,8 +285,8 @@ class BillTransformer extends AbstractTransformer* Given a bill and a date, this method will tell you at which moment this bill expects its next* transaction. Whether or not it is there already, is not relevant.*- * @param Bill $bill- * @param Carbon $date+ * @param Bill $bill+ * @param Carbon $date** @return Carbon*/