diff --git a/app/Http/Controllers/Account/CreateController.php b/app/Http/Controllers/Account/CreateController.php index fa0610fd7f..202afd6cfe 100644 --- a/app/Http/Controllers/Account/CreateController.php +++ b/app/Http/Controllers/Account/CreateController.php @@ -44,11 +44,8 @@ class CreateController extends Controller { use ModelInformation; - /** @var AttachmentHelperInterface Helper for attachments. */ - private $attachments; - - /** @var AccountRepositoryInterface The account repository */ - private $repository; + private AttachmentHelperInterface $attachments; + private AccountRepositoryInterface $repository; /** * CreateController constructor. diff --git a/app/Http/Controllers/Budget/AvailableBudgetController.php b/app/Http/Controllers/Budget/AvailableBudgetController.php index 72a6239d7a..e5d8d0f57a 100644 --- a/app/Http/Controllers/Budget/AvailableBudgetController.php +++ b/app/Http/Controllers/Budget/AvailableBudgetController.php @@ -58,7 +58,7 @@ class AvailableBudgetController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.budgets')); + app('view')->share('title', (string)trans('firefly.budgets')); app('view')->share('mainTitleIcon', 'fa-pie-chart'); $this->abRepository = app(AvailableBudgetRepositoryInterface::class); $this->currencyRepos = app(CurrencyRepositoryInterface::class); @@ -95,7 +95,7 @@ class AvailableBudgetController extends Controller return redirect(route('available-budgets.edit', [$first->id])); } - $page = (int) ($request->get('page') ?? 1); + $page = (int)($request->get('page') ?? 1); return prefixView('budgets.available-budgets.create', compact('start', 'end', 'page', 'currency')); } @@ -129,7 +129,7 @@ class AvailableBudgetController extends Controller ); - $page = (int) ($request->get('page') ?? 1); + $page = (int)($request->get('page') ?? 1); return prefixView('budgets.available-budgets.create-alternative', compact('start', 'end', 'page', 'currencies')); } @@ -157,7 +157,8 @@ class AvailableBudgetController extends Controller */ public function edit(AvailableBudget $availableBudget, Carbon $start, Carbon $end) { - $availableBudget->amount = number_format((float) $availableBudget->amount, $availableBudget->transactionCurrency->decimal_places, '.', ''); + $availableBudget->amount = number_format((float)$availableBudget->amount, $availableBudget->transactionCurrency->decimal_places, '.', ''); + return prefixView('budgets.available-budgets.edit', compact('availableBudget', 'start', 'end')); } @@ -179,7 +180,7 @@ class AvailableBudgetController extends Controller } // validate amount - $amount = (string) $request->get('amount'); + $amount = (string)$request->get('amount'); if ('' === $amount) { session()->flash('error', trans('firefly.invalid_amount')); @@ -192,7 +193,7 @@ class AvailableBudgetController extends Controller } // find currency - $currency = $this->currencyRepos->find((int) $request->get('currency_id')); + $currency = $this->currencyRepos->find((int)$request->get('currency_id')); if (null === $currency) { session()->flash('error', trans('firefly.invalid_currency')); @@ -205,10 +206,10 @@ class AvailableBudgetController extends Controller if (null === $existing) { $this->abRepository->store( [ - 'amount' => $amount, - 'currency' => $currency, - 'start' => $start, - 'end' => $end, + 'amount' => $amount, + 'currency_id' => $currency->id, + 'start' => $start, + 'end' => $end, ] ); } @@ -233,7 +234,7 @@ class AvailableBudgetController extends Controller public function update(Request $request, AvailableBudget $availableBudget, Carbon $start, Carbon $end) { // validate amount - $amount = (string) $request->get('amount'); + $amount = (string)$request->get('amount'); if ('' === $amount) { session()->flash('error', trans('firefly.invalid_amount')); diff --git a/app/Http/Requests/BillStoreRequest.php b/app/Http/Requests/BillStoreRequest.php index c0cb421ff4..10eb7c88a3 100644 --- a/app/Http/Requests/BillStoreRequest.php +++ b/app/Http/Requests/BillStoreRequest.php @@ -41,17 +41,17 @@ class BillStoreRequest extends FormRequest public function getBillData(): array { return [ - 'name' => $this->string('name'), - 'amount_min' => $this->string('amount_min'), - 'currency_id' => $this->integer('transaction_currency_id'), - 'currency_code' => '', - 'amount_max' => $this->string('amount_max'), - 'date' => $this->date('date'), - 'repeat_freq' => $this->string('repeat_freq'), - 'skip' => $this->integer('skip'), - 'notes' => $this->nlString('notes'), - 'active' => $this->boolean('active'), - 'object_group' => $this->string('object_group'), + 'name' => $this->string('name'), + 'amount_min' => $this->string('amount_min'), + 'currency_id' => $this->integer('transaction_currency_id'), + 'currency_code' => '', + 'amount_max' => $this->string('amount_max'), + 'date' => $this->date('date'), + 'repeat_freq' => $this->string('repeat_freq'), + 'skip' => $this->integer('skip'), + 'notes' => $this->nlString('notes'), + 'active' => $this->boolean('active'), + 'object_group_title' => $this->string('object_group'), ]; } diff --git a/app/Http/Requests/BillUpdateRequest.php b/app/Http/Requests/BillUpdateRequest.php index 36e2ec8a82..6d09666903 100644 --- a/app/Http/Requests/BillUpdateRequest.php +++ b/app/Http/Requests/BillUpdateRequest.php @@ -42,17 +42,17 @@ class BillUpdateRequest extends FormRequest public function getBillData(): array { return [ - 'name' => $this->string('name'), - 'amount_min' => $this->string('amount_min'), - 'currency_id' => $this->integer('transaction_currency_id'), - 'currency_code' => '', - 'amount_max' => $this->string('amount_max'), - 'date' => $this->date('date'), - 'repeat_freq' => $this->string('repeat_freq'), - 'skip' => $this->integer('skip'), - 'notes' => $this->nlString('notes'), - 'active' => $this->boolean('active'), - 'object_group' => $this->string('object_group'), + 'name' => $this->string('name'), + 'amount_min' => $this->string('amount_min'), + 'currency_id' => $this->integer('transaction_currency_id'), + 'currency_code' => '', + 'amount_max' => $this->string('amount_max'), + 'date' => $this->date('date'), + 'repeat_freq' => $this->string('repeat_freq'), + 'skip' => $this->integer('skip'), + 'notes' => $this->nlString('notes'), + 'active' => $this->boolean('active'), + 'object_group_title' => $this->string('object_group'), ]; } diff --git a/app/Http/Requests/BudgetFormStoreRequest.php b/app/Http/Requests/BudgetFormStoreRequest.php index ea3a6c189c..60555fa624 100644 --- a/app/Http/Requests/BudgetFormStoreRequest.php +++ b/app/Http/Requests/BudgetFormStoreRequest.php @@ -44,12 +44,12 @@ class BudgetFormStoreRequest extends FormRequest public function getBudgetData(): array { return [ - 'name' => $this->string('name'), - 'active' => $this->boolean('active'), - 'auto_budget_type' => $this->integer('auto_budget_type'), - 'transaction_currency_id' => $this->integer('auto_budget_currency_id'), - 'auto_budget_amount' => $this->string('auto_budget_amount'), - 'auto_budget_period' => $this->string('auto_budget_period'), + 'name' => $this->string('name'), + 'active' => $this->boolean('active'), + 'auto_budget_type' => $this->integer('auto_budget_type'), + 'currency_id' => $this->integer('auto_budget_currency_id'), + 'auto_budget_amount' => $this->string('auto_budget_amount'), + 'auto_budget_period' => $this->string('auto_budget_period'), ]; } diff --git a/app/Http/Requests/BudgetFormUpdateRequest.php b/app/Http/Requests/BudgetFormUpdateRequest.php index c75534f297..d7728fcd2a 100644 --- a/app/Http/Requests/BudgetFormUpdateRequest.php +++ b/app/Http/Requests/BudgetFormUpdateRequest.php @@ -45,12 +45,12 @@ class BudgetFormUpdateRequest extends FormRequest public function getBudgetData(): array { return [ - 'name' => $this->string('name'), - 'active' => $this->boolean('active'), - 'auto_budget_type' => $this->integer('auto_budget_type'), - 'transaction_currency_id' => $this->integer('auto_budget_currency_id'), - 'auto_budget_amount' => $this->string('auto_budget_amount'), - 'auto_budget_period' => $this->string('auto_budget_period'), + 'name' => $this->string('name'), + 'active' => $this->boolean('active'), + 'auto_budget_type' => $this->integer('auto_budget_type'), + 'currency_id' => $this->integer('auto_budget_currency_id'), + 'auto_budget_amount' => $this->string('auto_budget_amount'), + 'auto_budget_period' => $this->string('auto_budget_period'), ]; } diff --git a/app/Http/Requests/PiggyBankStoreRequest.php b/app/Http/Requests/PiggyBankStoreRequest.php index e933a2fc27..bf5eac7c5e 100644 --- a/app/Http/Requests/PiggyBankStoreRequest.php +++ b/app/Http/Requests/PiggyBankStoreRequest.php @@ -47,7 +47,7 @@ class PiggyBankStoreRequest extends FormRequest 'targetamount' => $this->string('targetamount'), 'targetdate' => $this->date('targetdate'), 'notes' => $this->nlString('notes'), - 'object_group' => $this->string('object_group'), + 'object_group_title' => $this->string('object_group'), ]; } diff --git a/app/Http/Requests/PiggyBankUpdateRequest.php b/app/Http/Requests/PiggyBankUpdateRequest.php index 51161e60d0..9719ba8a32 100644 --- a/app/Http/Requests/PiggyBankUpdateRequest.php +++ b/app/Http/Requests/PiggyBankUpdateRequest.php @@ -42,13 +42,13 @@ class PiggyBankUpdateRequest extends FormRequest public function getPiggyBankData(): array { return [ - 'name' => $this->string('name'), - 'startdate' => $this->date('startdate'), - 'account_id' => $this->integer('account_id'), - 'targetamount' => $this->string('targetamount'), - 'targetdate' => $this->date('targetdate'), - 'notes' => $this->nlString('notes'), - 'object_group' => $this->string('object_group'), + 'name' => $this->string('name'), + 'startdate' => $this->date('startdate'), + 'account_id' => $this->integer('account_id'), + 'targetamount' => $this->string('targetamount'), + 'targetdate' => $this->date('targetdate'), + 'notes' => $this->nlString('notes'), + 'object_group_title' => $this->string('object_group'), ]; } diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index ea0d2675c5..5e4173ca2a 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -335,6 +335,9 @@ class BudgetRepository implements BudgetRepositoryInterface if ('none' === $type) { return $newBudget; } + if (0 === $type) { + return $newBudget; + } if ('reset' === $type) { $type = AutoBudget::AUTO_BUDGET_RESET; @@ -343,7 +346,8 @@ class BudgetRepository implements BudgetRepositoryInterface $type = AutoBudget::AUTO_BUDGET_ROLLOVER; } - $repos = app(CurrencyRepositoryInterface::class); + $repos = app(CurrencyRepositoryInterface::class); + $currency = null; if (array_key_exists('currency_id', $data)) { $currency = $repos->findNull((int)$data['currency_id']); } @@ -420,6 +424,7 @@ class BudgetRepository implements BudgetRepositoryInterface if (null === $autoBudget && array_key_exists('auto_budget_type', $data) && array_key_exists('auto_budget_amount', $data) + && 0 !== $data['auto_budget_type'] ) { // only create if all are here: $autoBudget = new AutoBudget; @@ -428,7 +433,7 @@ class BudgetRepository implements BudgetRepositoryInterface } // update existing type - if (array_key_exists('auto_budget_type', $data)) { + if (array_key_exists('auto_budget_type', $data) && 0 !== $data['auto_budget_type']) { $autoBudgetType = $data['auto_budget_type']; if ('reset' === $autoBudgetType) { $autoBudget->auto_budget_type = AutoBudget::AUTO_BUDGET_RESET; @@ -442,10 +447,10 @@ class BudgetRepository implements BudgetRepositoryInterface return $budget; } } - if (array_key_exists('auto_budget_amount', $data)) { + if (array_key_exists('auto_budget_amount', $data) && null !== $autoBudget) { $autoBudget->amount = $data['auto_budget_amount']; } - if (array_key_exists('auto_budget_period', $data)) { + if (array_key_exists('auto_budget_period', $data) && null !== $autoBudget) { $autoBudget->period = $data['auto_budget_period']; } if (null !== $autoBudget) { diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.php index 8c83111d22..a07412118a 100644 --- a/app/Repositories/Rule/RuleRepository.php +++ b/app/Repositories/Rule/RuleRepository.php @@ -258,29 +258,6 @@ class RuleRepository implements RuleRepositoryInterface return $filtered; } - /** - * @param Rule $rule - * - * @return bool - */ - public function moveDown(Rule $rule): bool - { - $order = $rule->order; - - // find the rule with order+1 and give it order-1 - $other = $rule->ruleGroup->rules()->where('order', $order + 1)->first(); - if ($other) { - --$other->order; - $other->save(); - } - - ++$rule->order; - $rule->save(); - $this->resetRuleOrder($rule->ruleGroup); - - return true; - } - /** * @inheritDoc */ @@ -295,29 +272,6 @@ class RuleRepository implements RuleRepositoryInterface return $rule; } - /** - * @param Rule $rule - * - * @return bool - */ - public function moveUp(Rule $rule): bool - { - $order = $rule->order; - - // find the rule with order-1 and give it order+1 - $other = $rule->ruleGroup->rules()->where('order', $order - 1)->first(); - if ($other) { - ++$other->order; - $other->save(); - } - - --$rule->order; - $rule->save(); - $this->resetRuleOrder($rule->ruleGroup); - - return true; - } - /** * @param Rule $rule * @param array $ids diff --git a/app/Repositories/Rule/RuleRepositoryInterface.php b/app/Repositories/Rule/RuleRepositoryInterface.php index 1e25e11541..e3f722d61a 100644 --- a/app/Repositories/Rule/RuleRepositoryInterface.php +++ b/app/Repositories/Rule/RuleRepositoryInterface.php @@ -123,13 +123,6 @@ interface RuleRepositoryInterface */ public function getUpdateRules(): Collection; - /** - * @param Rule $rule - * - * @return bool - */ - public function moveDown(Rule $rule): bool; - /** * @param Rule $rule * @param RuleGroup $ruleGroup @@ -139,13 +132,6 @@ interface RuleRepositoryInterface */ public function moveRule(Rule $rule, RuleGroup $ruleGroup, int $order): Rule; - /** - * @param Rule $rule - * - * @return bool - */ - public function moveUp(Rule $rule): bool; - /** * @param Rule $rule * @param array $ids diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.php index 6981d3cb7d..40ba48ad53 100644 --- a/app/Repositories/RuleGroup/RuleGroupRepository.php +++ b/app/Repositories/RuleGroup/RuleGroupRepository.php @@ -277,52 +277,6 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface return (int)$this->user->ruleGroups()->max('order'); } - /** - * @param RuleGroup $ruleGroup - * - * @return bool - */ - public function moveDown(RuleGroup $ruleGroup): bool - { - $order = $ruleGroup->order; - - // find the rule with order+1 and give it order-1 - $other = $this->user->ruleGroups()->where('order', $order + 1)->first(); - if ($other) { - --$other->order; - $other->save(); - } - - ++$ruleGroup->order; - $ruleGroup->save(); - $this->resetRuleGroupOrder(); - - return true; - } - - /** - * @param RuleGroup $ruleGroup - * - * @return bool - */ - public function moveUp(RuleGroup $ruleGroup): bool - { - $order = $ruleGroup->order; - - // find the rule with order-1 and give it order+1 - $other = $this->user->ruleGroups()->where('order', $order - 1)->first(); - if ($other) { - ++$other->order; - $other->save(); - } - - --$ruleGroup->order; - $ruleGroup->save(); - $this->resetRuleGroupOrder(); - - return true; - } - /** * @return bool */ diff --git a/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php b/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php index 84f8fbc436..0e0295eb09 100644 --- a/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php +++ b/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php @@ -128,20 +128,6 @@ interface RuleGroupRepositoryInterface */ public function maxOrder(): int; - /** - * @param RuleGroup $ruleGroup - * - * @return bool - */ - public function moveDown(RuleGroup $ruleGroup): bool; - - /** - * @param RuleGroup $ruleGroup - * - * @return bool - */ - public function moveUp(RuleGroup $ruleGroup): bool; - /** * @return bool */ diff --git a/app/Support/Request/AppendsLocationData.php b/app/Support/Request/AppendsLocationData.php index a5e7b8769a..45240e9b7a 100644 --- a/app/Support/Request/AppendsLocationData.php +++ b/app/Support/Request/AppendsLocationData.php @@ -155,16 +155,39 @@ trait AppendsLocationData */ private function isValidPOST(?string $prefix): bool { - $longitudeKey = $this->getLocationKey($prefix, 'longitude'); - $latitudeKey = $this->getLocationKey($prefix, 'latitude'); - $zoomLevelKey = $this->getLocationKey($prefix, 'zoom_level'); + Log::debug('Now in isValidPOST()'); + $longitudeKey = $this->getLocationKey($prefix, 'longitude'); + $latitudeKey = $this->getLocationKey($prefix, 'latitude'); + $zoomLevelKey = $this->getLocationKey($prefix, 'zoom_level'); + $hasLocationKey = $this->getLocationKey($prefix, 'has_location'); + // fields must not be null: + if (null !== $this->get($longitudeKey) && null !== $this->get($latitudeKey) && null !== $this->get($zoomLevelKey)) { + Log::debug('All fields present'); + // if is POST and route contains API, this is enough: + if ('POST' === $this->method() && $this->routeIs('*.store') && $this->routeIs('api.v1.*')) { + Log::debug('Is API location'); - return ('POST' === $this->method() && $this->routeIs('*.store')) - && ( - null !== $this->get($longitudeKey) - && null !== $this->get($latitudeKey) - && null !== $this->get($zoomLevelKey) - ); + return true; + } + // if is POST and route does not contain API, must also have "store_location" = true + if ('POST' === $this->method() && $this->routeIs('*.store') && !$this->routeIs('api.v1.*') && $hasLocationKey) { + $hasLocation = $this->boolean($hasLocationKey); + if (true === $hasLocation) { + Log::debug('Is form location'); + + return true; + } + Log::debug('Is not form location'); + + return false; + } + Log::debug('Is not POST API or POST form'); + + return false; + } + Log::debug('Fields not present'); + + return false; } /** diff --git a/resources/views/v1/list/piggy-banks.twig b/resources/views/v1/list/piggy-banks.twig index 12f0bc8d1f..e0b70d660a 100644 --- a/resources/views/v1/list/piggy-banks.twig +++ b/resources/views/v1/list/piggy-banks.twig @@ -44,7 +44,6 @@ {% if piggy.attachments.count() > 0 %} {% endif %} - {% for rep in rt.repetitions %} {% for occ in rep.occurrences %} + {% if loop.index0 < 2 %}
  • {{ occ.formatLocalized(monthAndDayFormat) }}
  • + {% endif %} {% endfor %} {% endfor %}