From de9efb0727f394bb26f29ae9efae003c63042882 Mon Sep 17 00:00:00 2001 From: JC5 Date: Mon, 15 Sep 2025 05:23:47 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Auto=20commit=20for=20release=20?= =?UTF-8?q?'develop'=20on=202025-09-15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/Budget/StoreController.php | 16 +-- .../Models/Budget/UpdateController.php | 16 +-- .../Models/BudgetLimit/StoreController.php | 24 ++-- .../Models/BudgetLimit/UpdateController.php | 2 +- .../Requests/Models/Budget/StoreRequest.php | 36 +++--- .../Requests/Models/Budget/UpdateRequest.php | 36 +++--- .../Models/BudgetLimit/StoreRequest.php | 42 +++--- .../Models/BudgetLimit/UpdateRequest.php | 26 ++-- .../Models/Transaction/StoreRequest.php | 2 +- app/Handlers/Observer/BudgetLimitObserver.php | 6 +- app/Handlers/Observer/BudgetObserver.php | 10 +- app/Models/Account.php | 25 ++-- app/Models/AccountMeta.php | 3 +- app/Models/AccountType.php | 30 ++--- app/Models/Attachment.php | 6 +- app/Models/AuditLogEntry.php | 4 +- app/Models/AutoBudget.php | 12 +- app/Models/AvailableBudget.php | 16 +-- app/Models/Bill.php | 16 +-- app/Models/Budget.php | 8 +- app/Models/BudgetLimit.php | 13 +- app/Models/Category.php | 6 +- app/Models/Configuration.php | 3 +- app/Models/CurrencyExchangeRate.php | 8 +- app/Models/GroupMembership.php | 2 +- app/Models/InvitedUser.php | 2 +- app/Models/Location.php | 2 +- app/Models/Note.php | 2 +- app/Models/ObjectGroup.php | 7 +- app/Models/PiggyBank.php | 13 +- app/Models/PiggyBankEvent.php | 6 +- app/Models/PiggyBankRepetition.php | 17 +-- app/Models/Preference.php | 8 +- app/Models/Recurrence.php | 8 +- app/Models/RecurrenceMeta.php | 4 +- app/Models/RecurrenceRepetition.php | 18 +-- app/Models/RecurrenceTransaction.php | 16 +-- app/Models/RecurrenceTransactionMeta.php | 4 +- app/Models/Rule.php | 10 +- app/Models/RuleAction.php | 4 +- app/Models/RuleGroup.php | 6 +- app/Models/RuleTrigger.php | 4 +- app/Models/Tag.php | 6 +- app/Models/Transaction.php | 12 +- app/Models/TransactionCurrency.php | 4 +- app/Models/TransactionGroup.php | 9 +- app/Models/TransactionJournal.php | 10 +- app/Models/TransactionJournalLink.php | 17 +-- app/Models/TransactionJournalMeta.php | 7 +- app/Models/TransactionType.php | 16 +-- app/Models/UserGroup.php | 6 +- app/Models/Webhook.php | 4 +- app/Models/WebhookAttempt.php | 6 +- app/Models/WebhookDelivery.php | 2 +- app/Models/WebhookMessage.php | 8 +- app/Models/WebhookResponse.php | 2 +- app/Models/WebhookTrigger.php | 2 +- app/Providers/EventServiceProvider.php | 4 +- .../Budget/BudgetLimitRepository.php | 122 +++++++++--------- .../Budget/BudgetLimitRepositoryInterface.php | 2 +- app/Repositories/Budget/BudgetRepository.php | 4 +- .../Enrichments/BudgetLimitEnrichment.php | 24 ++-- composer.lock | 28 ++-- config/firefly.php | 4 +- package-lock.json | 26 ++-- 65 files changed, 416 insertions(+), 408 deletions(-) diff --git a/app/Api/V1/Controllers/Models/Budget/StoreController.php b/app/Api/V1/Controllers/Models/Budget/StoreController.php index 3e4954f474..66a8f36153 100644 --- a/app/Api/V1/Controllers/Models/Budget/StoreController.php +++ b/app/Api/V1/Controllers/Models/Budget/StoreController.php @@ -67,24 +67,24 @@ class StoreController extends Controller */ public function store(StoreRequest $request): JsonResponse { - $data = $request->getAll(); - $data['fire_webhooks'] = $data['fire_webhooks'] ?? true; - $budget = $this->repository->store($data); + $data = $request->getAll(); + $data['fire_webhooks'] ??= true; + $budget = $this->repository->store($data); $budget->refresh(); - $manager = $this->getManager(); + $manager = $this->getManager(); // enrich /** @var User $admin */ - $admin = auth()->user(); - $enrichment = new BudgetEnrichment(); + $admin = auth()->user(); + $enrichment = new BudgetEnrichment(); $enrichment->setUser($admin); - $budget = $enrichment->enrichSingle($budget); + $budget = $enrichment->enrichSingle($budget); /** @var BudgetTransformer $transformer */ $transformer = app(BudgetTransformer::class); $transformer->setParameters($this->parameters); - $resource = new Item($budget, $transformer, 'budgets'); + $resource = new Item($budget, $transformer, 'budgets'); return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE); } diff --git a/app/Api/V1/Controllers/Models/Budget/UpdateController.php b/app/Api/V1/Controllers/Models/Budget/UpdateController.php index 8ec009b7e1..54bddb72a6 100644 --- a/app/Api/V1/Controllers/Models/Budget/UpdateController.php +++ b/app/Api/V1/Controllers/Models/Budget/UpdateController.php @@ -59,23 +59,23 @@ class UpdateController extends Controller public function update(UpdateRequest $request, Budget $budget): JsonResponse { - $data = $request->getAll(); - $data['fire_webhooks'] = $data['fire_webhooks'] ?? true; - $budget = $this->repository->update($budget, $data); - $manager = $this->getManager(); + $data = $request->getAll(); + $data['fire_webhooks'] ??= true; + $budget = $this->repository->update($budget, $data); + $manager = $this->getManager(); // enrich /** @var User $admin */ - $admin = auth()->user(); - $enrichment = new BudgetEnrichment(); + $admin = auth()->user(); + $enrichment = new BudgetEnrichment(); $enrichment->setUser($admin); - $budget = $enrichment->enrichSingle($budget); + $budget = $enrichment->enrichSingle($budget); /** @var BudgetTransformer $transformer */ $transformer = app(BudgetTransformer::class); $transformer->setParameters($this->parameters); - $resource = new Item($budget, $transformer, 'budgets'); + $resource = new Item($budget, $transformer, 'budgets'); return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE); } diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.php b/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.php index 910502662c..3b16016efa 100644 --- a/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.php +++ b/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.php @@ -67,27 +67,27 @@ class StoreController extends Controller */ public function store(StoreRequest $request, Budget $budget): JsonResponse { - $data = $request->getAll(); - $data['start_date'] = $data['start']; - $data['end_date'] = $data['end']; - $data['fire_webhooks'] = $data['fire_webhooks'] ?? true; - $data['budget_id'] = $budget->id; + $data = $request->getAll(); + $data['start_date'] = $data['start']; + $data['end_date'] = $data['end']; + $data['fire_webhooks'] ??= true; + $data['budget_id'] = $budget->id; - $budgetLimit = $this->blRepository->store($data); - $manager = $this->getManager(); + $budgetLimit = $this->blRepository->store($data); + $manager = $this->getManager(); // enrich /** @var User $admin */ - $admin = auth()->user(); - $enrichment = new BudgetLimitEnrichment(); + $admin = auth()->user(); + $enrichment = new BudgetLimitEnrichment(); $enrichment->setUser($admin); - $budgetLimit = $enrichment->enrichSingle($budgetLimit); + $budgetLimit = $enrichment->enrichSingle($budgetLimit); /** @var BudgetLimitTransformer $transformer */ - $transformer = app(BudgetLimitTransformer::class); + $transformer = app(BudgetLimitTransformer::class); $transformer->setParameters($this->parameters); - $resource = new Item($budgetLimit, $transformer, 'budget_limits'); + $resource = new Item($budgetLimit, $transformer, 'budget_limits'); return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE); } diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php b/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php index cca3953140..3517062e2b 100644 --- a/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php +++ b/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php @@ -77,7 +77,7 @@ class UpdateController extends Controller throw new FireflyException('20028: The budget limit does not belong to the budget.'); } $data = $request->getAll(); - $data['fire_webhooks'] = $data['fire_webhooks'] ?? true; + $data['fire_webhooks'] ??= true; $data['budget_id'] = $budget->id; $budgetLimit = $this->blRepository->update($budgetLimit, $data); $manager = $this->getManager(); diff --git a/app/Api/V1/Requests/Models/Budget/StoreRequest.php b/app/Api/V1/Requests/Models/Budget/StoreRequest.php index fc17d164dd..fd36873cbb 100644 --- a/app/Api/V1/Requests/Models/Budget/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Budget/StoreRequest.php @@ -48,20 +48,20 @@ class StoreRequest extends FormRequest public function getAll(): array { $fields = [ - 'name' => ['name', 'convertString'], - 'active' => ['active', 'boolean'], - 'order' => ['active', 'convertInteger'], - 'notes' => ['notes', 'convertString'], + 'name' => ['name', 'convertString'], + 'active' => ['active', 'boolean'], + 'order' => ['active', 'convertInteger'], + 'notes' => ['notes', 'convertString'], // auto budget currency: - 'currency_id' => ['auto_budget_currency_id', 'convertInteger'], - 'currency_code' => ['auto_budget_currency_code', 'convertString'], - 'auto_budget_type' => ['auto_budget_type', 'convertString'], - 'auto_budget_amount' => ['auto_budget_amount', 'convertString'], - 'auto_budget_period' => ['auto_budget_period', 'convertString'], + 'currency_id' => ['auto_budget_currency_id', 'convertInteger'], + 'currency_code' => ['auto_budget_currency_code', 'convertString'], + 'auto_budget_type' => ['auto_budget_type', 'convertString'], + 'auto_budget_amount' => ['auto_budget_amount', 'convertString'], + 'auto_budget_period' => ['auto_budget_period', 'convertString'], // webhooks - 'fire_webhooks' => ['fire_webhooks','boolean'] + 'fire_webhooks' => ['fire_webhooks', 'boolean'], ]; return $this->getAllData($fields); @@ -73,15 +73,15 @@ class StoreRequest extends FormRequest public function rules(): array { return [ - 'name' => 'required|min:1|max:255|uniqueObjectForUser:budgets,name', - 'active' => [new IsBoolean()], - 'currency_id' => 'exists:transaction_currencies,id', - 'currency_code' => 'exists:transaction_currencies,code', - 'notes' => 'nullable|min:1|max:32768', + 'name' => 'required|min:1|max:255|uniqueObjectForUser:budgets,name', + 'active' => [new IsBoolean()], + 'currency_id' => 'exists:transaction_currencies,id', + 'currency_code' => 'exists:transaction_currencies,code', + 'notes' => 'nullable|min:1|max:32768', // auto budget info - 'auto_budget_type' => 'in:reset,rollover,adjusted,none', - 'auto_budget_amount' => ['required_if:auto_budget_type,reset', 'required_if:auto_budget_type,rollover', 'required_if:auto_budget_type,adjusted', new IsValidPositiveAmount()], - 'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly|required_if:auto_budget_type,reset|required_if:auto_budget_type,rollover|required_if:auto_budget_type,adjusted', + 'auto_budget_type' => 'in:reset,rollover,adjusted,none', + 'auto_budget_amount' => ['required_if:auto_budget_type,reset', 'required_if:auto_budget_type,rollover', 'required_if:auto_budget_type,adjusted', new IsValidPositiveAmount()], + 'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly|required_if:auto_budget_type,reset|required_if:auto_budget_type,rollover|required_if:auto_budget_type,adjusted', // webhooks 'fire_webhooks' => [new IsBoolean()], diff --git a/app/Api/V1/Requests/Models/Budget/UpdateRequest.php b/app/Api/V1/Requests/Models/Budget/UpdateRequest.php index 3a89dbaa15..870cc3294f 100644 --- a/app/Api/V1/Requests/Models/Budget/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Budget/UpdateRequest.php @@ -50,18 +50,18 @@ class UpdateRequest extends FormRequest { // this is the way: $fields = [ - 'name' => ['name', 'convertString'], - 'active' => ['active', 'boolean'], - 'order' => ['order', 'convertInteger'], - 'notes' => ['notes', 'convertString'], - 'currency_id' => ['auto_budget_currency_id', 'convertInteger'], - 'currency_code' => ['auto_budget_currency_code', 'convertString'], - 'auto_budget_type' => ['auto_budget_type', 'convertString'], - 'auto_budget_amount' => ['auto_budget_amount', 'convertString'], - 'auto_budget_period' => ['auto_budget_period', 'convertString'], + 'name' => ['name', 'convertString'], + 'active' => ['active', 'boolean'], + 'order' => ['order', 'convertInteger'], + 'notes' => ['notes', 'convertString'], + 'currency_id' => ['auto_budget_currency_id', 'convertInteger'], + 'currency_code' => ['auto_budget_currency_code', 'convertString'], + 'auto_budget_type' => ['auto_budget_type', 'convertString'], + 'auto_budget_amount' => ['auto_budget_amount', 'convertString'], + 'auto_budget_period' => ['auto_budget_period', 'convertString'], // webhooks - 'fire_webhooks' => ['fire_webhooks','boolean'] + 'fire_webhooks' => ['fire_webhooks', 'boolean'], ]; $allData = $this->getAllData($fields); if (array_key_exists('auto_budget_type', $allData)) { @@ -86,14 +86,14 @@ class UpdateRequest extends FormRequest $budget = $this->route()->parameter('budget'); return [ - 'name' => sprintf('min:1|max:100|uniqueObjectForUser:budgets,name,%d', $budget->id), - 'active' => [new IsBoolean()], - 'notes' => 'nullable|min:1|max:32768', - 'auto_budget_type' => 'in:reset,rollover,adjusted,none', - 'auto_budget_currency_id' => 'exists:transaction_currencies,id', - 'auto_budget_currency_code' => 'exists:transaction_currencies,code', - 'auto_budget_amount' => ['nullable', new IsValidPositiveAmount()], - 'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly', + 'name' => sprintf('min:1|max:100|uniqueObjectForUser:budgets,name,%d', $budget->id), + 'active' => [new IsBoolean()], + 'notes' => 'nullable|min:1|max:32768', + 'auto_budget_type' => 'in:reset,rollover,adjusted,none', + 'auto_budget_currency_id' => 'exists:transaction_currencies,id', + 'auto_budget_currency_code' => 'exists:transaction_currencies,code', + 'auto_budget_amount' => ['nullable', new IsValidPositiveAmount()], + 'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly', // webhooks 'fire_webhooks' => [new IsBoolean()], diff --git a/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php b/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php index 2afabc38f3..1a705223de 100644 --- a/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php +++ b/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php @@ -25,9 +25,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Models\BudgetLimit; use Carbon\Carbon; -use FireflyIII\Exceptions\FireflyException; use FireflyIII\Factory\TransactionCurrencyFactory; -use FireflyIII\Models\Budget; use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsValidPositiveAmount; use FireflyIII\Support\Facades\Amount; @@ -69,12 +67,12 @@ class StoreRequest extends FormRequest public function rules(): array { return [ - 'start' => 'required|before:end|date', - 'end' => 'required|after:start|date', - 'amount' => ['required', new IsValidPositiveAmount()], - 'currency_id' => 'numeric|exists:transaction_currencies,id', - 'currency_code' => 'min:3|max:51|exists:transaction_currencies,code', - 'notes' => 'nullable|min:0|max:32768', + 'start' => 'required|before:end|date', + 'end' => 'required|after:start|date', + 'amount' => ['required', new IsValidPositiveAmount()], + 'currency_id' => 'numeric|exists:transaction_currencies,id', + 'currency_code' => 'min:3|max:51|exists:transaction_currencies,code', + 'notes' => 'nullable|min:0|max:32768', // webhooks 'fire_webhooks' => [new IsBoolean()], @@ -86,36 +84,36 @@ class StoreRequest extends FormRequest */ public function withValidator(Validator $validator): void { - $budget = $this->route()->parameter('budget'); + $budget = $this->route()->parameter('budget'); $validator->after( static function (Validator $validator) use ($budget): void { - if(0 !== count($validator->failed())) { + if (0 !== count($validator->failed())) { return; } - $data = $validator->getData(); + $data = $validator->getData(); // if no currency has been provided, use the user's default currency: /** @var TransactionCurrencyFactory $factory */ - $factory = app(TransactionCurrencyFactory::class); - $currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null); + $factory = app(TransactionCurrencyFactory::class); + $currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null); if (null === $currency) { $currency = Amount::getPrimaryCurrency(); } - $currency->enabled = true; + $currency->enabled = true; $currency->save(); // validator already concluded start and end are valid dates: - $start = Carbon::parse($data['start'], config('app.timezone')); - $end = Carbon::parse($data['end'], config('app.timezone')); + $start = Carbon::parse($data['start'], config('app.timezone')); + $end = Carbon::parse($data['end'], config('app.timezone')); // find limit with same date range and currency. - $limit = $budget->budgetlimits() - ->where('budget_limits.start_date', $start->format('Y-m-d')) - ->where('budget_limits.end_date', $end->format('Y-m-d')) - ->where('budget_limits.transaction_currency_id', $currency->id) - ->first(['budget_limits.*']) + $limit = $budget->budgetlimits() + ->where('budget_limits.start_date', $start->format('Y-m-d')) + ->where('budget_limits.end_date', $end->format('Y-m-d')) + ->where('budget_limits.transaction_currency_id', $currency->id) + ->first(['budget_limits.*']) ; - if(null !== $limit) { + if (null !== $limit) { $validator->errors()->add('start', trans('validation.limit_exists')); } } diff --git a/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php b/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php index 4f877b4865..5262ab4427 100644 --- a/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php @@ -47,15 +47,15 @@ class UpdateRequest extends FormRequest public function getAll(): array { $fields = [ - 'start' => ['start', 'date'], - 'end' => ['end', 'date'], - 'amount' => ['amount', 'convertString'], - 'currency_id' => ['currency_id', 'convertInteger'], - 'currency_code' => ['currency_code', 'convertString'], - 'notes' => ['notes', 'stringWithNewlines'], + 'start' => ['start', 'date'], + 'end' => ['end', 'date'], + 'amount' => ['amount', 'convertString'], + 'currency_id' => ['currency_id', 'convertInteger'], + 'currency_code' => ['currency_code', 'convertString'], + 'notes' => ['notes', 'stringWithNewlines'], // webhooks - 'fire_webhooks' => ['fire_webhooks','boolean'] + 'fire_webhooks' => ['fire_webhooks', 'boolean'], ]; if (false === $this->has('notes')) { // ignore notes, not submitted. @@ -71,12 +71,12 @@ class UpdateRequest extends FormRequest public function rules(): array { return [ - 'start' => 'date|after:1970-01-02|before:2038-01-17', - 'end' => 'date|after:1970-01-02|before:2038-01-17', - 'amount' => ['nullable', new IsValidPositiveAmount()], - 'currency_id' => 'numeric|exists:transaction_currencies,id', - 'currency_code' => 'min:3|max:51|exists:transaction_currencies,code', - 'notes' => 'nullable|min:0|max:32768', + 'start' => 'date|after:1970-01-02|before:2038-01-17', + 'end' => 'date|after:1970-01-02|before:2038-01-17', + 'amount' => ['nullable', new IsValidPositiveAmount()], + 'currency_id' => 'numeric|exists:transaction_currencies,id', + 'currency_code' => 'min:3|max:51|exists:transaction_currencies,code', + 'notes' => 'nullable|min:0|max:32768', // webhooks 'fire_webhooks' => [new IsBoolean()], diff --git a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php b/app/Api/V1/Requests/Models/Transaction/StoreRequest.php index 6e85264031..4ad8a851cb 100644 --- a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Transaction/StoreRequest.php @@ -183,7 +183,7 @@ class StoreRequest extends FormRequest // basic fields for group: 'group_title' => 'min:1|max:1000|nullable', 'error_if_duplicate_hash' => [new IsBoolean()], - 'fire_webhooks' => [new IsBoolean()], + 'fire_webhooks' => [new IsBoolean()], 'apply_rules' => [new IsBoolean()], // location rules diff --git a/app/Handlers/Observer/BudgetLimitObserver.php b/app/Handlers/Observer/BudgetLimitObserver.php index 4fb16a06fa..3c6558f0e9 100644 --- a/app/Handlers/Observer/BudgetLimitObserver.php +++ b/app/Handlers/Observer/BudgetLimitObserver.php @@ -51,7 +51,7 @@ class BudgetLimitObserver if (true === $singleton->getPreference('fire_webhooks_bl_store')) { - $user = $budgetLimit->budget->user; + $user = $budgetLimit->budget->user; /** @var MessageGeneratorInterface $engine */ $engine = app(MessageGeneratorInterface::class); @@ -75,7 +75,7 @@ class BudgetLimitObserver $userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($budgetLimit->budget->user->userGroup); $budgetLimit->native_amount = null; if ($budgetLimit->transactionCurrency->id !== $userCurrency->id) { - $converter = new ExchangeRateConverter(); + $converter = new ExchangeRateConverter(); $converter->setUserGroup($budgetLimit->budget->user->userGroup); $converter->setIgnoreSettings(true); $budgetLimit->native_amount = $converter->convert($budgetLimit->transactionCurrency, $userCurrency, today(), $budgetLimit->amount); @@ -94,7 +94,7 @@ class BudgetLimitObserver $singleton = PreferencesSingleton::getInstance(); if (true === $singleton->getPreference('fire_webhooks_bl_update')) { - $user = $budgetLimit->budget->user; + $user = $budgetLimit->budget->user; /** @var MessageGeneratorInterface $engine */ $engine = app(MessageGeneratorInterface::class); diff --git a/app/Handlers/Observer/BudgetObserver.php b/app/Handlers/Observer/BudgetObserver.php index 9030c4f955..2a78e1f4be 100644 --- a/app/Handlers/Observer/BudgetObserver.php +++ b/app/Handlers/Observer/BudgetObserver.php @@ -51,7 +51,7 @@ class BudgetObserver if (true === $singleton->getPreference('fire_webhooks_budget_create')) { // fire event. - $user = $budget->user; + $user = $budget->user; /** @var MessageGeneratorInterface $engine */ $engine = app(MessageGeneratorInterface::class); @@ -72,7 +72,7 @@ class BudgetObserver $singleton = PreferencesSingleton::getInstance(); if (true === $singleton->getPreference('fire_webhooks_budget_update')) { - $user = $budget->user; + $user = $budget->user; /** @var MessageGeneratorInterface $engine */ $engine = app(MessageGeneratorInterface::class); @@ -89,10 +89,10 @@ class BudgetObserver { Log::debug('Observe "deleting" of a budget.'); - $user = $budget->user; + $user = $budget->user; /** @var MessageGeneratorInterface $engine */ - $engine = app(MessageGeneratorInterface::class); + $engine = app(MessageGeneratorInterface::class); $engine->setUser($user); $engine->setObjects(new Collection()->push($budget)); $engine->setTrigger(WebhookTrigger::DESTROY_BUDGET); @@ -100,7 +100,7 @@ class BudgetObserver Log::debug(sprintf('send event RequestedSendWebhookMessages from %s', __METHOD__)); event(new RequestedSendWebhookMessages()); - $repository = app(AttachmentRepositoryInterface::class); + $repository = app(AttachmentRepositoryInterface::class); $repository->setUser($budget->user); /** @var Attachment $attachment */ diff --git a/app/Models/Account.php b/app/Models/Account.php index aedc24f00b..e76ba418ee 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -50,9 +50,9 @@ class Account extends Model use ReturnsIntegerUserIdTrait; use SoftDeletes; - protected $fillable = ['user_id', 'user_group_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban', 'native_virtual_balance']; + protected $fillable = ['user_id', 'user_group_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban', 'native_virtual_balance']; - protected $hidden = ['encrypted']; + protected $hidden = ['encrypted']; private bool $joinedAccountTypes = false; /** @@ -66,10 +66,10 @@ class Account extends Model $accountId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|Account $account */ - $account = $user->accounts()->with(['accountType'])->find($accountId); + $account = $user->accounts()->with(['accountType'])->find($accountId); if (null !== $account) { return $account; } @@ -126,7 +126,7 @@ class Account extends Model public function setVirtualBalanceAttribute(mixed $value): void { - $value = (string)$value; + $value = (string)$value; if ('' === $value) { $value = null; } @@ -146,7 +146,7 @@ class Account extends Model protected function accountId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } @@ -158,8 +158,9 @@ class Account extends Model return Attribute::make(get: function () { /** @var null|AccountMeta $metaValue */ $metaValue = $this->accountMeta() - ->where('name', 'account_number') - ->first(); + ->where('name', 'account_number') + ->first() + ; return null !== $metaValue ? $metaValue->data : ''; }); @@ -176,7 +177,7 @@ class Account extends Model protected function accountTypeId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } @@ -220,14 +221,14 @@ class Account extends Model protected function iban(): Attribute { return Attribute::make( - get: static fn($value) => null === $value ? null : trim(str_replace(' ', '', (string)$value)), + get: static fn ($value) => null === $value ? null : trim(str_replace(' ', '', (string)$value)), ); } protected function order(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } @@ -237,7 +238,7 @@ class Account extends Model protected function virtualBalance(): Attribute { return Attribute::make( - get: static fn($value) => (string)$value, + get: static fn ($value) => (string)$value, ); } } diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.php index ef87a0a508..a91e5eb778 100644 --- a/app/Models/AccountMeta.php +++ b/app/Models/AccountMeta.php @@ -27,6 +27,7 @@ use FireflyIII\Support\Models\ReturnsIntegerIdTrait; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; + use function Safe\json_decode; use function Safe\json_encode; @@ -52,6 +53,6 @@ class AccountMeta extends Model protected function data(): Attribute { - return Attribute::make(get: fn(mixed $value) => (string)json_decode((string)$value, true), set: fn(mixed $value) => ['data' => json_encode($value)]); + return Attribute::make(get: fn (mixed $value) => (string)json_decode((string)$value, true), set: fn (mixed $value) => ['data' => json_encode($value)]); } } diff --git a/app/Models/AccountType.php b/app/Models/AccountType.php index b147593f38..d4b82b45fd 100644 --- a/app/Models/AccountType.php +++ b/app/Models/AccountType.php @@ -34,39 +34,39 @@ class AccountType extends Model #[Deprecated] /** @deprecated */ - public const string ASSET = 'Asset account'; + public const string ASSET = 'Asset account'; #[Deprecated] /** @deprecated */ - public const string BENEFICIARY = 'Beneficiary account'; + public const string BENEFICIARY = 'Beneficiary account'; #[Deprecated] /** @deprecated */ - public const string CASH = 'Cash account'; + public const string CASH = 'Cash account'; #[Deprecated] /** @deprecated */ - public const string CREDITCARD = 'Credit card'; + public const string CREDITCARD = 'Credit card'; #[Deprecated] /** @deprecated */ - public const string DEBT = 'Debt'; + public const string DEBT = 'Debt'; #[Deprecated] /** @deprecated */ - public const string DEFAULT = 'Default account'; + public const string DEFAULT = 'Default account'; #[Deprecated] /** @deprecated */ - public const string EXPENSE = 'Expense account'; + public const string EXPENSE = 'Expense account'; #[Deprecated] /** @deprecated */ - public const string IMPORT = 'Import account'; + public const string IMPORT = 'Import account'; #[Deprecated] /** @deprecated */ - public const string INITIAL_BALANCE = 'Initial balance account'; + public const string INITIAL_BALANCE = 'Initial balance account'; #[Deprecated] /** @deprecated */ @@ -74,27 +74,27 @@ class AccountType extends Model #[Deprecated] /** @deprecated */ - public const string LOAN = 'Loan'; + public const string LOAN = 'Loan'; #[Deprecated] /** @deprecated */ - public const string MORTGAGE = 'Mortgage'; + public const string MORTGAGE = 'Mortgage'; #[Deprecated] /** @deprecated */ - public const string RECONCILIATION = 'Reconciliation account'; + public const string RECONCILIATION = 'Reconciliation account'; #[Deprecated] /** @deprecated */ - public const string REVENUE = 'Revenue account'; + public const string REVENUE = 'Revenue account'; protected $casts - = [ + = [ 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; - protected $fillable = ['type']; + protected $fillable = ['type']; public function accounts(): HasMany { diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php index dd468558ab..0323697cb8 100644 --- a/app/Models/Attachment.php +++ b/app/Models/Attachment.php @@ -56,10 +56,10 @@ class Attachment extends Model $attachmentId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|Attachment $attachment */ - $attachment = $user->attachments()->find($attachmentId); + $attachment = $user->attachments()->find($attachmentId); if (null !== $attachment) { return $attachment; } @@ -100,7 +100,7 @@ class Attachment extends Model protected function attachableId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } diff --git a/app/Models/AuditLogEntry.php b/app/Models/AuditLogEntry.php index baf532bfb0..fded5ca815 100644 --- a/app/Models/AuditLogEntry.php +++ b/app/Models/AuditLogEntry.php @@ -48,7 +48,7 @@ class AuditLogEntry extends Model protected function auditableId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } @@ -66,7 +66,7 @@ class AuditLogEntry extends Model protected function changerId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/AutoBudget.php b/app/Models/AutoBudget.php index d1aa6475c9..73dad3c6aa 100644 --- a/app/Models/AutoBudget.php +++ b/app/Models/AutoBudget.php @@ -45,17 +45,17 @@ class AutoBudget extends Model #[Deprecated] /** @deprecated */ - public const int AUTO_BUDGET_RESET = 1; + public const int AUTO_BUDGET_RESET = 1; #[Deprecated] /** @deprecated */ public const int AUTO_BUDGET_ROLLOVER = 2; protected $casts - = [ + = [ 'amount' => 'string', 'native_amount' => 'string', ]; - protected $fillable = ['budget_id', 'amount', 'period', 'native_amount']; + protected $fillable = ['budget_id', 'amount', 'period', 'native_amount']; public function budget(): BelongsTo { @@ -70,14 +70,14 @@ class AutoBudget extends Model protected function amount(): Attribute { return Attribute::make( - get: static fn($value) => (string)$value, + get: static fn ($value) => (string)$value, ); } protected function budgetId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } @@ -91,7 +91,7 @@ class AutoBudget extends Model protected function transactionCurrencyId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/AvailableBudget.php b/app/Models/AvailableBudget.php index f3f63b4e06..109abd0307 100644 --- a/app/Models/AvailableBudget.php +++ b/app/Models/AvailableBudget.php @@ -55,10 +55,10 @@ class AvailableBudget extends Model $availableBudgetId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|AvailableBudget $availableBudget */ - $availableBudget = $user->availableBudgets()->find($availableBudgetId); + $availableBudget = $user->availableBudgets()->find($availableBudgetId); if (null !== $availableBudget) { return $availableBudget; } @@ -80,7 +80,7 @@ class AvailableBudget extends Model protected function amount(): Attribute { return Attribute::make( - get: static fn($value) => (string)$value, + get: static fn ($value) => (string)$value, ); } @@ -103,23 +103,23 @@ class AvailableBudget extends Model protected function endDate(): Attribute { return Attribute::make( - get: fn(string $value) => Carbon::parse($value), - set: fn(Carbon $value) => $value->format('Y-m-d'), + get: fn (string $value) => Carbon::parse($value), + set: fn (Carbon $value) => $value->format('Y-m-d'), ); } protected function startDate(): Attribute { return Attribute::make( - get: fn(string $value) => Carbon::parse($value), - set: fn(Carbon $value) => $value->format('Y-m-d'), + get: fn (string $value) => Carbon::parse($value), + set: fn (Carbon $value) => $value->format('Y-m-d'), ); } protected function transactionCurrencyId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/Bill.php b/app/Models/Bill.php index a84552ba82..b57d98df1d 100644 --- a/app/Models/Bill.php +++ b/app/Models/Bill.php @@ -46,7 +46,7 @@ class Bill extends Model use SoftDeletes; protected $fillable - = [ + = [ 'name', 'match', 'amount_min', @@ -81,10 +81,10 @@ class Bill extends Model $billId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|Bill $bill */ - $bill = $user->bills()->find($billId); + $bill = $user->bills()->find($billId); if (null !== $bill) { return $bill; } @@ -151,7 +151,7 @@ class Bill extends Model protected function amountMax(): Attribute { return Attribute::make( - get: static fn($value) => (string)$value, + get: static fn ($value) => (string)$value, ); } @@ -161,7 +161,7 @@ class Bill extends Model protected function amountMin(): Attribute { return Attribute::make( - get: static fn($value) => (string)$value, + get: static fn ($value) => (string)$value, ); } @@ -189,7 +189,7 @@ class Bill extends Model protected function order(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } @@ -199,14 +199,14 @@ class Bill extends Model protected function skip(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } protected function transactionCurrencyId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/Budget.php b/app/Models/Budget.php index 1a1c2bb9dc..4375c6c2a7 100644 --- a/app/Models/Budget.php +++ b/app/Models/Budget.php @@ -46,7 +46,7 @@ class Budget extends Model protected $fillable = ['user_id', 'user_group_id', 'name', 'active', 'order', 'user_group_id']; - protected $hidden = ['encrypted']; + protected $hidden = ['encrypted']; /** * Route binder. Converts the key in the URL to the specified object (or throw 404). @@ -59,10 +59,10 @@ class Budget extends Model $budgetId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|Budget $budget */ - $budget = $user->budgets()->find($budgetId); + $budget = $user->budgets()->find($budgetId); if (null !== $budget) { return $budget; } @@ -125,7 +125,7 @@ class Budget extends Model protected function order(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.php index a646d4d1e2..66f12753c6 100644 --- a/app/Models/BudgetLimit.php +++ b/app/Models/BudgetLimit.php @@ -50,9 +50,10 @@ class BudgetLimit extends Model if (auth()->check()) { $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) - ->first(['budget_limits.*']); + ->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id') + ->where('budgets.user_id', auth()->user()->id) + ->first(['budget_limits.*']) + ; if (null !== $budgetLimit) { return $budgetLimit; } @@ -85,14 +86,14 @@ class BudgetLimit extends Model protected function amount(): Attribute { return Attribute::make( - get: static fn($value) => (string)$value, + get: static fn ($value) => (string)$value, ); } protected function budgetId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } @@ -112,7 +113,7 @@ class BudgetLimit extends Model protected function transactionCurrencyId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/Category.php b/app/Models/Category.php index 1726c1110c..018fbdbef4 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -45,7 +45,7 @@ class Category extends Model protected $fillable = ['user_id', 'user_group_id', 'name']; - protected $hidden = ['encrypted']; + protected $hidden = ['encrypted']; /** * Route binder. Converts the key in the URL to the specified object (or throw 404). @@ -58,10 +58,10 @@ class Category extends Model $categoryId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|Category $category */ - $category = $user->categories()->find($categoryId); + $category = $user->categories()->find($categoryId); if (null !== $category) { return $category; } diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index 49e7559236..3fd2d82a19 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -27,6 +27,7 @@ use FireflyIII\Support\Models\ReturnsIntegerIdTrait; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; + use function Safe\json_decode; use function Safe\json_encode; @@ -51,6 +52,6 @@ class Configuration extends Model */ protected function data(): Attribute { - return Attribute::make(get: fn($value) => json_decode((string)$value), set: fn($value) => ['data' => json_encode($value)]); + return Attribute::make(get: fn ($value) => json_decode((string)$value), set: fn ($value) => ['data' => json_encode($value)]); } } diff --git a/app/Models/CurrencyExchangeRate.php b/app/Models/CurrencyExchangeRate.php index fc919dbf80..c484ae2cc5 100644 --- a/app/Models/CurrencyExchangeRate.php +++ b/app/Models/CurrencyExchangeRate.php @@ -73,28 +73,28 @@ class CurrencyExchangeRate extends Model protected function fromCurrencyId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } protected function rate(): Attribute { return Attribute::make( - get: static fn($value) => (string)$value, + get: static fn ($value) => (string)$value, ); } protected function toCurrencyId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } protected function userRate(): Attribute { return Attribute::make( - get: static fn($value) => (string)$value, + get: static fn ($value) => (string)$value, ); } } diff --git a/app/Models/GroupMembership.php b/app/Models/GroupMembership.php index e16178fa9b..52f6cf9b24 100644 --- a/app/Models/GroupMembership.php +++ b/app/Models/GroupMembership.php @@ -66,7 +66,7 @@ class GroupMembership extends Model protected function userRoleId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/InvitedUser.php b/app/Models/InvitedUser.php index 272096faa8..81e945b5e9 100644 --- a/app/Models/InvitedUser.php +++ b/app/Models/InvitedUser.php @@ -48,7 +48,7 @@ class InvitedUser extends Model $attemptId = (int)$value; /** @var null|InvitedUser $attempt */ - $attempt = self::find($attemptId); + $attempt = self::find($attemptId); if (null !== $attempt) { return $attempt; } diff --git a/app/Models/Location.php b/app/Models/Location.php index 2e971b6f67..b8f2b31151 100644 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -81,7 +81,7 @@ class Location extends Model protected function locatableId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/Note.php b/app/Models/Note.php index 71d0531976..2adeacc457 100644 --- a/app/Models/Note.php +++ b/app/Models/Note.php @@ -56,7 +56,7 @@ class Note extends Model protected function noteableId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/ObjectGroup.php b/app/Models/ObjectGroup.php index 71a4d9b9ba..189e543a41 100644 --- a/app/Models/ObjectGroup.php +++ b/app/Models/ObjectGroup.php @@ -51,8 +51,9 @@ class ObjectGroup extends Model $objectGroupId = (int)$value; /** @var null|ObjectGroup $objectGroup */ - $objectGroup = self::where('object_groups.id', $objectGroupId) - ->where('object_groups.user_id', auth()->user()->id)->first(); + $objectGroup = self::where('object_groups.id', $objectGroupId) + ->where('object_groups.user_id', auth()->user()->id)->first() + ; if (null !== $objectGroup) { return $objectGroup; } @@ -104,7 +105,7 @@ class ObjectGroup extends Model protected function order(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index c493198b09..d4eb25a787 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -54,9 +54,10 @@ class PiggyBank extends Model if (auth()->check()) { $piggyBankId = (int)$value; $piggyBank = self::where('piggy_banks.id', $piggyBankId) - ->leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id') - ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id') - ->where('accounts.user_id', auth()->user()->id)->first(['piggy_banks.*']); + ->leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id') + ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id') + ->where('accounts.user_id', auth()->user()->id)->first(['piggy_banks.*']) + ; if (null !== $piggyBank) { return $piggyBank; } @@ -122,7 +123,7 @@ class PiggyBank extends Model protected function accountId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } @@ -145,7 +146,7 @@ class PiggyBank extends Model protected function order(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } @@ -155,7 +156,7 @@ class PiggyBank extends Model protected function targetAmount(): Attribute { return Attribute::make( - get: static fn($value) => (string)$value, + get: static fn ($value) => (string)$value, ); } } diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.php index 81578a9544..3395e3df53 100644 --- a/app/Models/PiggyBankEvent.php +++ b/app/Models/PiggyBankEvent.php @@ -38,7 +38,7 @@ class PiggyBankEvent extends Model protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'date_tz', 'amount', 'native_amount']; - protected $hidden = ['amount_encrypted']; + protected $hidden = ['amount_encrypted']; public function piggyBank(): BelongsTo { @@ -64,7 +64,7 @@ class PiggyBankEvent extends Model protected function amount(): Attribute { return Attribute::make( - get: static fn($value) => (string)$value, + get: static fn ($value) => (string)$value, ); } @@ -82,7 +82,7 @@ class PiggyBankEvent extends Model protected function piggyBankId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.php index fa6d9823ed..41af799266 100644 --- a/app/Models/PiggyBankRepetition.php +++ b/app/Models/PiggyBankRepetition.php @@ -68,7 +68,7 @@ class PiggyBankRepetition extends Model protected function currentAmount(): Attribute { return Attribute::make( - get: static fn($value) => (string)$value, + get: static fn ($value) => (string)$value, ); } @@ -81,7 +81,7 @@ class PiggyBankRepetition extends Model protected function piggyBankId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } @@ -97,11 +97,12 @@ class PiggyBankRepetition extends Model $q->orWhereNull('start_date'); } ) - ->where( - static function (EloquentBuilder $q) use ($date): void { - $q->where('target_date', '>=', $date->format('Y-m-d 00:00:00')); - $q->orWhereNull('target_date'); - } - ); + ->where( + static function (EloquentBuilder $q) use ($date): void { + $q->where('target_date', '>=', $date->format('Y-m-d 00:00:00')); + $q->orWhereNull('target_date'); + } + ) + ; } } diff --git a/app/Models/Preference.php b/app/Models/Preference.php index f357f17cc7..151e5bbd35 100644 --- a/app/Models/Preference.php +++ b/app/Models/Preference.php @@ -46,7 +46,7 @@ class Preference extends Model { if (auth()->check()) { /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); // some preferences do not have an administration ID. // some need it, to make sure the correct one is selected. @@ -54,8 +54,8 @@ class Preference extends Model $userGroupId = 0 === $userGroupId ? null : $userGroupId; /** @var null|Preference $preference */ - $preference = null; - $items = config('firefly.admin_specific_prefs'); + $preference = null; + $items = config('firefly.admin_specific_prefs'); if (null !== $userGroupId && in_array($value, $items, true)) { // find a preference with a specific user_group_id $preference = $user->preferences()->where('user_group_id', $userGroupId)->where('name', $value)->first(); @@ -73,7 +73,7 @@ class Preference extends Model /** @var Preference $preference */ return $preference; } - $default = config('firefly.default_preferences'); + $default = config('firefly.default_preferences'); if (array_key_exists($value, $default)) { $preference = new self(); $preference->name = $value; diff --git a/app/Models/Recurrence.php b/app/Models/Recurrence.php index 724ccdb06f..b3fa7a3a8c 100644 --- a/app/Models/Recurrence.php +++ b/app/Models/Recurrence.php @@ -46,7 +46,7 @@ class Recurrence extends Model use SoftDeletes; protected $fillable - = ['user_id', 'user_group_id', 'transaction_type_id', 'title', 'description', 'first_date', 'first_date_tz', 'repeat_until', 'repeat_until_tz', 'latest_date', 'latest_date_tz', 'repetitions', 'apply_rules', 'active']; + = ['user_id', 'user_group_id', 'transaction_type_id', 'title', 'description', 'first_date', 'first_date_tz', 'repeat_until', 'repeat_until_tz', 'latest_date', 'latest_date_tz', 'repetitions', 'apply_rules', 'active']; protected $table = 'recurrences'; @@ -61,10 +61,10 @@ class Recurrence extends Model $recurrenceId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|Recurrence $recurrence */ - $recurrence = $user->recurrences()->find($recurrenceId); + $recurrence = $user->recurrences()->find($recurrenceId); if (null !== $recurrence) { return $recurrence; } @@ -139,7 +139,7 @@ class Recurrence extends Model protected function transactionTypeId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/RecurrenceMeta.php b/app/Models/RecurrenceMeta.php index fddd2e8292..d031e0b883 100644 --- a/app/Models/RecurrenceMeta.php +++ b/app/Models/RecurrenceMeta.php @@ -37,7 +37,7 @@ class RecurrenceMeta extends Model protected $fillable = ['recurrence_id', 'name', 'value']; - protected $table = 'recurrences_meta'; + protected $table = 'recurrences_meta'; public function recurrence(): BelongsTo { @@ -58,7 +58,7 @@ class RecurrenceMeta extends Model protected function recurrenceId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/RecurrenceRepetition.php b/app/Models/RecurrenceRepetition.php index 920f8d93a1..52d8259877 100644 --- a/app/Models/RecurrenceRepetition.php +++ b/app/Models/RecurrenceRepetition.php @@ -38,7 +38,7 @@ class RecurrenceRepetition extends Model #[Deprecated] /** @deprecated */ - public const int WEEKEND_DO_NOTHING = 1; + public const int WEEKEND_DO_NOTHING = 1; #[Deprecated] /** @deprecated */ @@ -46,14 +46,14 @@ class RecurrenceRepetition extends Model #[Deprecated] /** @deprecated */ - public const int WEEKEND_TO_FRIDAY = 3; + public const int WEEKEND_TO_FRIDAY = 3; #[Deprecated] /** @deprecated */ - public const int WEEKEND_TO_MONDAY = 4; + public const int WEEKEND_TO_MONDAY = 4; protected $casts - = [ + = [ 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime', @@ -63,9 +63,9 @@ class RecurrenceRepetition extends Model 'weekend' => 'int', ]; - protected $fillable = ['recurrence_id', 'weekend', 'repetition_type', 'repetition_moment', 'repetition_skip']; + protected $fillable = ['recurrence_id', 'weekend', 'repetition_type', 'repetition_moment', 'repetition_skip']; - protected $table = 'recurrences_repetitions'; + protected $table = 'recurrences_repetitions'; public function recurrence(): BelongsTo { @@ -82,21 +82,21 @@ class RecurrenceRepetition extends Model protected function recurrenceId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } protected function repetitionSkip(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } protected function weekend(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/RecurrenceTransaction.php b/app/Models/RecurrenceTransaction.php index 4c1a5f6f2c..c2d91a54ad 100644 --- a/app/Models/RecurrenceTransaction.php +++ b/app/Models/RecurrenceTransaction.php @@ -40,7 +40,7 @@ class RecurrenceTransaction extends Model use SoftDeletes; protected $fillable - = [ + = [ 'recurrence_id', 'transaction_currency_id', 'foreign_currency_id', @@ -91,7 +91,7 @@ class RecurrenceTransaction extends Model protected function amount(): Attribute { return Attribute::make( - get: static fn($value) => (string)$value, + get: static fn ($value) => (string)$value, ); } @@ -110,42 +110,42 @@ class RecurrenceTransaction extends Model protected function destinationId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } protected function foreignAmount(): Attribute { return Attribute::make( - get: static fn($value) => (string)$value, + get: static fn ($value) => (string)$value, ); } protected function recurrenceId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } protected function sourceId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } protected function transactionCurrencyId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } protected function userId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/RecurrenceTransactionMeta.php b/app/Models/RecurrenceTransactionMeta.php index 5f2644b0f6..442da02559 100644 --- a/app/Models/RecurrenceTransactionMeta.php +++ b/app/Models/RecurrenceTransactionMeta.php @@ -37,7 +37,7 @@ class RecurrenceTransactionMeta extends Model protected $fillable = ['rt_id', 'name', 'value']; - protected $table = 'rt_meta'; + protected $table = 'rt_meta'; public function recurrenceTransaction(): BelongsTo { @@ -58,7 +58,7 @@ class RecurrenceTransactionMeta extends Model protected function rtId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/Rule.php b/app/Models/Rule.php index a8de1ea45b..7755e00984 100644 --- a/app/Models/Rule.php +++ b/app/Models/Rule.php @@ -55,10 +55,10 @@ class Rule extends Model $ruleId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|Rule $rule */ - $rule = $user->rules()->find($ruleId); + $rule = $user->rules()->find($ruleId); if (null !== $rule) { return $rule; } @@ -110,20 +110,20 @@ class Rule extends Model protected function description(): Attribute { - return Attribute::make(set: fn($value) => ['description' => e($value)]); + return Attribute::make(set: fn ($value) => ['description' => e($value)]); } protected function order(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } protected function ruleGroupId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/RuleAction.php b/app/Models/RuleAction.php index 3603c6cc65..0bb29a5236 100644 --- a/app/Models/RuleAction.php +++ b/app/Models/RuleAction.php @@ -80,14 +80,14 @@ class RuleAction extends Model protected function order(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } protected function ruleId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.php index d53155d888..99f6655f63 100644 --- a/app/Models/RuleGroup.php +++ b/app/Models/RuleGroup.php @@ -55,10 +55,10 @@ class RuleGroup extends Model $ruleGroupId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|RuleGroup $ruleGroup */ - $ruleGroup = $user->ruleGroups()->find($ruleGroupId); + $ruleGroup = $user->ruleGroups()->find($ruleGroupId); if (null !== $ruleGroup) { return $ruleGroup; } @@ -94,7 +94,7 @@ class RuleGroup extends Model protected function order(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/RuleTrigger.php b/app/Models/RuleTrigger.php index 9fedd62399..c3de8048ba 100644 --- a/app/Models/RuleTrigger.php +++ b/app/Models/RuleTrigger.php @@ -53,14 +53,14 @@ class RuleTrigger extends Model protected function order(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } protected function ruleId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 22572b8a06..c9fc2f134b 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -45,7 +45,7 @@ class Tag extends Model protected $fillable = ['user_id', 'user_group_id', 'tag', 'date', 'date_tz', 'description', 'tag_mode']; - protected $hidden = ['zoomLevel', 'zoom_level', 'latitude', 'longitude']; + protected $hidden = ['zoomLevel', 'zoom_level', 'latitude', 'longitude']; /** * Route binder. Converts the key in the URL to the specified object (or throw 404). @@ -58,10 +58,10 @@ class Tag extends Model $tagId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|Tag $tag */ - $tag = $user->tags()->find($tagId); + $tag = $user->tags()->find($tagId); if (null !== $tag) { return $tag; } diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index e0b521d30f..e33cb0a1ac 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -44,7 +44,7 @@ class Transaction extends Model use SoftDeletes; protected $fillable - = [ + = [ 'account_id', 'transaction_journal_id', 'description', @@ -113,7 +113,7 @@ class Transaction extends Model protected function accountId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } @@ -151,14 +151,14 @@ class Transaction extends Model protected function amount(): Attribute { return Attribute::make( - get: static fn($value) => (string)$value, + get: static fn ($value) => (string)$value, ); } protected function balanceDirty(): Attribute { return Attribute::make( - get: static fn($value) => 1 === (int)$value, + get: static fn ($value) => 1 === (int)$value, ); } @@ -201,14 +201,14 @@ class Transaction extends Model protected function foreignAmount(): Attribute { return Attribute::make( - get: static fn($value) => (string)$value, + get: static fn ($value) => (string)$value, ); } protected function transactionJournalId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.php index 7ecfbd18db..6f02375355 100644 --- a/app/Models/TransactionCurrency.php +++ b/app/Models/TransactionCurrency.php @@ -40,7 +40,7 @@ class TransactionCurrency extends Model public ?bool $userGroupEnabled = null; public ?bool $userGroupNative = null; - protected $fillable = ['name', 'code', 'symbol', 'decimal_places', 'enabled']; + protected $fillable = ['name', 'code', 'symbol', 'decimal_places', 'enabled']; /** * Route binder. Converts the key in the URL to the specified object (or throw 404). @@ -115,7 +115,7 @@ class TransactionCurrency extends Model protected function decimalPlaces(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/TransactionGroup.php b/app/Models/TransactionGroup.php index ec8bf0faae..81e7aac2e6 100644 --- a/app/Models/TransactionGroup.php +++ b/app/Models/TransactionGroup.php @@ -55,13 +55,14 @@ class TransactionGroup extends Model $groupId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); app('log')->debug(sprintf('User authenticated as %s', $user->email)); /** @var null|TransactionGroup $group */ - $group = $user->transactionGroups() - ->with(['transactionJournals', 'transactionJournals.transactions']) - ->where('transaction_groups.id', $groupId)->first(['transaction_groups.*']); + $group = $user->transactionGroups() + ->with(['transactionJournals', 'transactionJournals.transactions']) + ->where('transaction_groups.id', $groupId)->first(['transaction_groups.*']) + ; if (null !== $group) { app('log')->debug(sprintf('Found group #%d.', $group->id)); diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index dde97c2fce..3aa0099446 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -57,7 +57,7 @@ class TransactionJournal extends Model use SoftDeletes; protected $fillable - = [ + = [ 'user_id', 'user_group_id', 'transaction_type_id', @@ -84,10 +84,10 @@ class TransactionJournal extends Model $journalId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|TransactionJournal $journal */ - $journal = $user->transactionJournals()->where('transaction_journals.id', $journalId)->first(['transaction_journals.*']); + $journal = $user->transactionJournals()->where('transaction_journals.id', $journalId)->first(['transaction_journals.*']); if (null !== $journal) { return $journal; } @@ -230,14 +230,14 @@ class TransactionJournal extends Model protected function order(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } protected function transactionTypeId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } diff --git a/app/Models/TransactionJournalLink.php b/app/Models/TransactionJournalLink.php index 4880d15c39..ab1a40c260 100644 --- a/app/Models/TransactionJournalLink.php +++ b/app/Models/TransactionJournalLink.php @@ -46,11 +46,12 @@ class TransactionJournalLink extends Model if (auth()->check()) { $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') - ->where('t_a.user_id', auth()->user()->id) - ->where('t_b.user_id', auth()->user()->id) - ->first(['journal_links.*']); + ->leftJoin('transaction_journals as t_a', 't_a.id', '=', 'source_id') + ->leftJoin('transaction_journals as t_b', 't_b.id', '=', 'destination_id') + ->where('t_a.user_id', auth()->user()->id) + ->where('t_b.user_id', auth()->user()->id) + ->first(['journal_links.*']) + ; if (null !== $link) { return $link; } @@ -93,21 +94,21 @@ class TransactionJournalLink extends Model protected function destinationId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } protected function linkTypeId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } protected function sourceId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/TransactionJournalMeta.php b/app/Models/TransactionJournalMeta.php index 7dd67b6f86..4a748bfb8b 100644 --- a/app/Models/TransactionJournalMeta.php +++ b/app/Models/TransactionJournalMeta.php @@ -28,6 +28,7 @@ use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; + use function Safe\json_decode; use function Safe\json_encode; @@ -38,7 +39,7 @@ class TransactionJournalMeta extends Model protected $fillable = ['transaction_journal_id', 'name', 'data', 'hash']; - protected $table = 'journal_meta'; + protected $table = 'journal_meta'; public function transactionJournal(): BelongsTo { @@ -56,7 +57,7 @@ class TransactionJournalMeta extends Model protected function data(): Attribute { - return Attribute::make(get: fn($value) => json_decode((string)$value, false), set: function ($value) { + return Attribute::make(get: fn ($value) => json_decode((string)$value, false), set: function ($value) { $data = json_encode($value); return ['data' => $data, 'hash' => hash('sha256', $data)]; @@ -66,7 +67,7 @@ class TransactionJournalMeta extends Model protected function transactionJournalId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.php index 4062911fae..cac754f110 100644 --- a/app/Models/TransactionType.php +++ b/app/Models/TransactionType.php @@ -38,11 +38,11 @@ class TransactionType extends Model #[Deprecated] /** @deprecated */ - public const string DEPOSIT = 'Deposit'; + public const string DEPOSIT = 'Deposit'; #[Deprecated] /** @deprecated */ - public const string INVALID = 'Invalid'; + public const string INVALID = 'Invalid'; #[Deprecated] /** @deprecated */ @@ -50,27 +50,27 @@ class TransactionType extends Model #[Deprecated] /** @deprecated */ - public const string OPENING_BALANCE = 'Opening balance'; + public const string OPENING_BALANCE = 'Opening balance'; #[Deprecated] /** @deprecated */ - public const string RECONCILIATION = 'Reconciliation'; + public const string RECONCILIATION = 'Reconciliation'; #[Deprecated] /** @deprecated */ - public const string TRANSFER = 'Transfer'; + public const string TRANSFER = 'Transfer'; #[Deprecated] /** @deprecated */ - public const string WITHDRAWAL = 'Withdrawal'; + public const string WITHDRAWAL = 'Withdrawal'; protected $casts - = [ + = [ 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime', ]; - protected $fillable = ['type']; + protected $fillable = ['type']; /** * Route binder. Converts the key in the URL to the specified object (or throw 404). diff --git a/app/Models/UserGroup.php b/app/Models/UserGroup.php index 7b20a2980e..0c142b69cb 100644 --- a/app/Models/UserGroup.php +++ b/app/Models/UserGroup.php @@ -50,16 +50,16 @@ class UserGroup extends Model $userGroupId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|UserGroup $userGroup */ - $userGroup = self::find($userGroupId); + $userGroup = self::find($userGroupId); if (null === $userGroup) { throw new NotFoundHttpException(); } // need at least ready only to be aware of the user group's existence, // but owner/full role (in the group) or global owner role may overrule this. - $access = $user->hasRoleInGroupOrOwner($userGroup, UserRoleEnum::READ_ONLY) || $user->hasRole('owner'); + $access = $user->hasRoleInGroupOrOwner($userGroup, UserRoleEnum::READ_ONLY) || $user->hasRole('owner'); if ($access) { return $userGroup; } diff --git a/app/Models/Webhook.php b/app/Models/Webhook.php index 5b19fe269c..ab7e477e37 100644 --- a/app/Models/Webhook.php +++ b/app/Models/Webhook.php @@ -137,10 +137,10 @@ class Webhook extends Model $webhookId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|Webhook $webhook */ - $webhook = $user->webhooks()->find($webhookId); + $webhook = $user->webhooks()->find($webhookId); if (null !== $webhook) { return $webhook; } diff --git a/app/Models/WebhookAttempt.php b/app/Models/WebhookAttempt.php index c38fd15fe1..a2de5dac3b 100644 --- a/app/Models/WebhookAttempt.php +++ b/app/Models/WebhookAttempt.php @@ -48,10 +48,10 @@ class WebhookAttempt extends Model $attemptId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|WebhookAttempt $attempt */ - $attempt = self::find($attemptId); + $attempt = self::find($attemptId); if (null !== $attempt && $attempt->webhookMessage->webhook->user_id === $user->id) { return $attempt; } @@ -68,7 +68,7 @@ class WebhookAttempt extends Model protected function webhookMessageId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/WebhookDelivery.php b/app/Models/WebhookDelivery.php index 614a5cb3c2..33acf3b9b7 100644 --- a/app/Models/WebhookDelivery.php +++ b/app/Models/WebhookDelivery.php @@ -41,7 +41,7 @@ class WebhookDelivery extends Model protected function key(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/WebhookMessage.php b/app/Models/WebhookMessage.php index cae9a4a73f..dbccb97cbd 100644 --- a/app/Models/WebhookMessage.php +++ b/app/Models/WebhookMessage.php @@ -50,10 +50,10 @@ class WebhookMessage extends Model $messageId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|WebhookMessage $message */ - $message = self::find($messageId); + $message = self::find($messageId); if (null !== $message && $message->webhook->user_id === $user->id) { return $message; } @@ -89,14 +89,14 @@ class WebhookMessage extends Model protected function sent(): Attribute { return Attribute::make( - get: static fn($value) => (bool)$value, + get: static fn ($value) => (bool)$value, ); } protected function webhookId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/WebhookResponse.php b/app/Models/WebhookResponse.php index 5c8cb45311..7b3e785a73 100644 --- a/app/Models/WebhookResponse.php +++ b/app/Models/WebhookResponse.php @@ -41,7 +41,7 @@ class WebhookResponse extends Model protected function key(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Models/WebhookTrigger.php b/app/Models/WebhookTrigger.php index 7d9a6ea1fa..b7ccd7cfc5 100644 --- a/app/Models/WebhookTrigger.php +++ b/app/Models/WebhookTrigger.php @@ -41,7 +41,7 @@ class WebhookTrigger extends Model protected function key(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index a63903a280..1b221013f5 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -216,7 +216,5 @@ class EventServiceProvider extends ServiceProvider * Register any events for your application. */ #[Override] - public function boot(): void - { - } + public function boot(): void {} } diff --git a/app/Repositories/Budget/BudgetLimitRepository.php b/app/Repositories/Budget/BudgetLimitRepository.php index 857052b081..ab80405609 100644 --- a/app/Repositories/Budget/BudgetLimitRepository.php +++ b/app/Repositories/Budget/BudgetLimitRepository.php @@ -298,7 +298,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup Log::debug('No existing budget limit, create a new one'); // this is a lame trick to communicate with the observer. - $singleton = PreferencesSingleton::getInstance(); + $singleton = PreferencesSingleton::getInstance(); $singleton->setPreference('fire_webhooks_bl_store', $data['fire_webhooks'] ?? true); // or create one and return it. @@ -381,7 +381,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup $currency->save(); // this is a lame trick to communicate with the observer. - $singleton = PreferencesSingleton::getInstance(); + $singleton = PreferencesSingleton::getInstance(); $singleton->setPreference('fire_webhooks_bl_update', $data['fire_webhooks'] ?? true); $budgetLimit->transaction_currency_id = $currency->id; @@ -395,63 +395,63 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup return $budgetLimit; } -// public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, string $amount): ?BudgetLimit -// { -// // count the limits: -// $limits = $budget->budgetlimits() -// ->where('budget_limits.start_date', $start->format('Y-m-d 00:00:00')) -// ->where('budget_limits.end_date', $end->format('Y-m-d 00:00:00')) -// ->count('budget_limits.*') -// ; -// Log::debug(sprintf('Found %d budget limits.', $limits)); -// -// // there might be a budget limit for these dates: -// /** @var null|BudgetLimit $limit */ -// $limit = $budget->budgetlimits() -// ->where('budget_limits.start_date', $start->format('Y-m-d 00:00:00')) -// ->where('budget_limits.end_date', $end->format('Y-m-d 00:00:00')) -// ->first(['budget_limits.*']) -// ; -// -// // if more than 1 limit found, delete the others: -// if ($limits > 1 && null !== $limit) { -// Log::debug(sprintf('Found more than 1, delete all except #%d', $limit->id)); -// $budget->budgetlimits() -// ->where('budget_limits.start_date', $start->format('Y-m-d 00:00:00')) -// ->where('budget_limits.end_date', $end->format('Y-m-d 00:00:00')) -// ->where('budget_limits.id', '!=', $limit->id)->delete() -// ; -// } -// -// // delete if amount is zero. -// // Returns 0 if the two operands are equal, -// // 1 if the left_operand is larger than the right_operand, -1 otherwise. -// if (null !== $limit && bccomp($amount, '0') <= 0) { -// Log::debug(sprintf('%s is zero, delete budget limit #%d', $amount, $limit->id)); -// $limit->delete(); -// -// return null; -// } -// // update if exists: -// if (null !== $limit) { -// Log::debug(sprintf('Existing budget limit is #%d, update this to amount %s', $limit->id, $amount)); -// $limit->amount = $amount; -// $limit->save(); -// -// return $limit; -// } -// Log::debug('No existing budget limit, create a new one'); -// // or create one and return it. -// $limit = new BudgetLimit(); -// $limit->budget()->associate($budget); -// $limit->start_date = $start->startOfDay(); -// $limit->start_date_tz = $start->format('e'); -// $limit->end_date = $end->startOfDay(); -// $limit->end_date_tz = $end->format('e'); -// $limit->amount = $amount; -// $limit->save(); -// Log::debug(sprintf('Created new budget limit with ID #%d and amount %s', $limit->id, $amount)); -// -// return $limit; -// } + // public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, string $amount): ?BudgetLimit + // { + // // count the limits: + // $limits = $budget->budgetlimits() + // ->where('budget_limits.start_date', $start->format('Y-m-d 00:00:00')) + // ->where('budget_limits.end_date', $end->format('Y-m-d 00:00:00')) + // ->count('budget_limits.*') + // ; + // Log::debug(sprintf('Found %d budget limits.', $limits)); + // + // // there might be a budget limit for these dates: + // /** @var null|BudgetLimit $limit */ + // $limit = $budget->budgetlimits() + // ->where('budget_limits.start_date', $start->format('Y-m-d 00:00:00')) + // ->where('budget_limits.end_date', $end->format('Y-m-d 00:00:00')) + // ->first(['budget_limits.*']) + // ; + // + // // if more than 1 limit found, delete the others: + // if ($limits > 1 && null !== $limit) { + // Log::debug(sprintf('Found more than 1, delete all except #%d', $limit->id)); + // $budget->budgetlimits() + // ->where('budget_limits.start_date', $start->format('Y-m-d 00:00:00')) + // ->where('budget_limits.end_date', $end->format('Y-m-d 00:00:00')) + // ->where('budget_limits.id', '!=', $limit->id)->delete() + // ; + // } + // + // // delete if amount is zero. + // // Returns 0 if the two operands are equal, + // // 1 if the left_operand is larger than the right_operand, -1 otherwise. + // if (null !== $limit && bccomp($amount, '0') <= 0) { + // Log::debug(sprintf('%s is zero, delete budget limit #%d', $amount, $limit->id)); + // $limit->delete(); + // + // return null; + // } + // // update if exists: + // if (null !== $limit) { + // Log::debug(sprintf('Existing budget limit is #%d, update this to amount %s', $limit->id, $amount)); + // $limit->amount = $amount; + // $limit->save(); + // + // return $limit; + // } + // Log::debug('No existing budget limit, create a new one'); + // // or create one and return it. + // $limit = new BudgetLimit(); + // $limit->budget()->associate($budget); + // $limit->start_date = $start->startOfDay(); + // $limit->start_date_tz = $start->format('e'); + // $limit->end_date = $end->startOfDay(); + // $limit->end_date_tz = $end->format('e'); + // $limit->amount = $amount; + // $limit->save(); + // Log::debug(sprintf('Created new budget limit with ID #%d and amount %s', $limit->id, $amount)); + // + // return $limit; + // } } diff --git a/app/Repositories/Budget/BudgetLimitRepositoryInterface.php b/app/Repositories/Budget/BudgetLimitRepositoryInterface.php index 7d8ccde5bb..defb1c7d49 100644 --- a/app/Repositories/Budget/BudgetLimitRepositoryInterface.php +++ b/app/Repositories/Budget/BudgetLimitRepositoryInterface.php @@ -81,5 +81,5 @@ interface BudgetLimitRepositoryInterface public function update(BudgetLimit $budgetLimit, array $data): BudgetLimit; - //public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, string $amount): ?BudgetLimit; + // public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, string $amount): ?BudgetLimit; } diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index b893334320..8aaaa40b8a 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -286,7 +286,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface Log::debug('Now in update()'); // this is a lame trick to communicate with the observer. - $singleton = PreferencesSingleton::getInstance(); + $singleton = PreferencesSingleton::getInstance(); $singleton->setPreference('fire_webhooks_budget_update', $data['fire_webhooks'] ?? true); $oldName = $budget->name; @@ -730,7 +730,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface $order = $this->getMaxOrder(); // this is a lame trick to communicate with the observer. - $singleton = PreferencesSingleton::getInstance(); + $singleton = PreferencesSingleton::getInstance(); $singleton->setPreference('fire_webhooks_budget_create', $data['fire_webhooks'] ?? true); try { diff --git a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php index c0af1e7735..0ba9e1f1a3 100644 --- a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php +++ b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php @@ -95,8 +95,8 @@ class BudgetLimitEnrichment implements EnrichmentInterface private function collectIds(): void { - $this->start = $this->collection->min('start_date') ?? Carbon::now()->startOfMonth(); - $this->end = $this->collection->max('end_date') ?? Carbon::now()->endOfMonth(); + $this->start = $this->collection->min('start_date') ?? Carbon::now()->startOfMonth(); + $this->end = $this->collection->max('end_date') ?? Carbon::now()->endOfMonth(); /** @var BudgetLimit $limit */ foreach ($this->collection as $limit) { @@ -113,9 +113,10 @@ class BudgetLimitEnrichment implements EnrichmentInterface private function collectNotes(): void { $notes = Note::query()->whereIn('noteable_id', $this->ids) - ->whereNotNull('notes.text') - ->where('notes.text', '!=', '') - ->where('noteable_type', BudgetLimit::class)->get(['notes.noteable_id', 'notes.text'])->toArray(); + ->whereNotNull('notes.text') + ->where('notes.text', '!=', '') + ->where('noteable_type', BudgetLimit::class)->get(['notes.noteable_id', 'notes.text'])->toArray() + ; foreach ($notes as $note) { $this->notes[(int)$note['noteable_id']] = (string)$note['text']; } @@ -144,12 +145,12 @@ class BudgetLimitEnrichment implements EnrichmentInterface private function collectBudgets(): void { - $budgetIds = $this->collection->pluck('budget_id')->unique()->toArray(); - $budgets = Budget::whereIn('id', $budgetIds)->get(); + $budgetIds = $this->collection->pluck('budget_id')->unique()->toArray(); + $budgets = Budget::whereIn('id', $budgetIds)->get(); $repository = app(OperationsRepository::class); $repository->setUser($this->user); - $expenses = $repository->collectExpenses($this->start, $this->end, null, $budgets, null); + $expenses = $repository->collectExpenses($this->start, $this->end, null, $budgets, null); /** @var BudgetLimit $budgetLimit */ foreach ($this->collection as $budgetLimit) { @@ -180,13 +181,13 @@ class BudgetLimitEnrichment implements EnrichmentInterface private function stringifyIds(): void { - $this->expenses = array_map(fn($first) => array_map(function ($second) { + $this->expenses = array_map(fn ($first) => array_map(function ($second) { $second['currency_id'] = (string)($second['currency_id'] ?? 0); return $second; }, $first), $this->expenses); - $this->pcExpenses = array_map(fn($first) => array_map(function ($second) { + $this->pcExpenses = array_map(fn ($first) => array_map(function ($second) { $second['currency_id'] = (string)($second['currency_id'] ?? 0); return $second; @@ -195,8 +196,9 @@ class BudgetLimitEnrichment implements EnrichmentInterface private function filterToBudget(array $expenses, int $budget): array { - $result = array_filter($expenses, fn(array $item) => (int)$item['budget_id'] === $budget); + $result = array_filter($expenses, fn (array $item) => (int)$item['budget_id'] === $budget); Log::debug(sprintf('filterToBudget for budget #%d, from %d to %d items', $budget, count($expenses), count($result))); + return $result; } } diff --git a/composer.lock b/composer.lock index 50beadca73..3bc0182e4b 100644 --- a/composer.lock +++ b/composer.lock @@ -11819,16 +11819,16 @@ }, { "name": "phpunit/phpunit", - "version": "12.3.10", + "version": "12.3.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "0d401d0df2e3c1703be425ecdc2d04f5c095938d" + "reference": "6a62f2b394e042884e4997ddc8b8db1ce56a0009" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0d401d0df2e3c1703be425ecdc2d04f5c095938d", - "reference": "0d401d0df2e3c1703be425ecdc2d04f5c095938d", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6a62f2b394e042884e4997ddc8b8db1ce56a0009", + "reference": "6a62f2b394e042884e4997ddc8b8db1ce56a0009", "shasum": "" }, "require": { @@ -11847,7 +11847,7 @@ "phpunit/php-invoker": "^6.0.0", "phpunit/php-text-template": "^5.0.0", "phpunit/php-timer": "^8.0.0", - "sebastian/cli-parser": "^4.0.0", + "sebastian/cli-parser": "^4.1.0", "sebastian/comparator": "^7.1.3", "sebastian/diff": "^7.0.0", "sebastian/environment": "^8.0.3", @@ -11896,7 +11896,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/12.3.10" + "source": "https://github.com/sebastianbergmann/phpunit/tree/12.3.11" }, "funding": [ { @@ -11920,7 +11920,7 @@ "type": "tidelift" } ], - "time": "2025-09-11T10:35:19+00:00" + "time": "2025-09-14T06:21:44+00:00" }, { "name": "rector/rector", @@ -11984,16 +11984,16 @@ }, { "name": "sebastian/cli-parser", - "version": "4.1.0", + "version": "4.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "8fd93be538992d556aaa45c74570129448a42084" + "reference": "90f41072d220e5c40df6e8635f5dafba2d9d4d04" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/8fd93be538992d556aaa45c74570129448a42084", - "reference": "8fd93be538992d556aaa45c74570129448a42084", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/90f41072d220e5c40df6e8635f5dafba2d9d4d04", + "reference": "90f41072d220e5c40df6e8635f5dafba2d9d4d04", "shasum": "" }, "require": { @@ -12005,7 +12005,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "4.1-dev" + "dev-main": "4.2-dev" } }, "autoload": { @@ -12029,7 +12029,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", "security": "https://github.com/sebastianbergmann/cli-parser/security/policy", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/4.1.0" + "source": "https://github.com/sebastianbergmann/cli-parser/tree/4.2.0" }, "funding": [ { @@ -12049,7 +12049,7 @@ "type": "tidelift" } ], - "time": "2025-09-13T14:16:18+00:00" + "time": "2025-09-14T09:36:45+00:00" }, { "name": "sebastian/comparator", diff --git a/config/firefly.php b/config/firefly.php index eecaf07c61..9ebbd995ed 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -78,8 +78,8 @@ return [ 'running_balance_column' => env('USE_RUNNING_BALANCE', false), // see cer.php for exchange rates feature flag. ], - 'version' => 'develop/2025-09-13', - 'build_time' => 1757782204, + 'version' => 'develop/2025-09-15', + 'build_time' => 1757906521, 'api_version' => '2.1.0', // field is no longer used. 'db_version' => 26, diff --git a/package-lock.json b/package-lock.json index 211a5d750c..46e4e426d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3159,13 +3159,13 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "24.3.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.3.3.tgz", - "integrity": "sha512-GKBNHjoNw3Kra1Qg5UXttsY5kiWMEfoHq2TmXb+b1rcm6N7B3wTrFYIf/oSZ1xNQ+hVVijgLkiDZh7jRRsh+Gw==", + "version": "24.4.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.4.0.tgz", + "integrity": "sha512-gUuVEAK4/u6F9wRLznPUU4WGUacSEBDPoC2TrBkw3GAnOLHBL45QdfHOXp1kJ4ypBGLxTOB+t7NJLpKoC3gznQ==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": "~7.10.0" + "undici-types": "~7.11.0" } }, "node_modules/@types/node-forge": { @@ -3949,9 +3949,9 @@ } }, "node_modules/axios": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.12.1.tgz", - "integrity": "sha512-Kn4kbSXpkFHCGE6rBFNwIv0GQs4AvDT80jlveJDKFxjbTYMUeB4QtsdPCv6H8Cm19Je7IU6VFtRl2zWZI0rudQ==", + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.12.2.tgz", + "integrity": "sha512-vMJzPewAlRyOgxV2dU0Cuz2O8zzzx9VYtbJOaBgXFeLc4IV/Eg50n4LowmehOOR61S8ZMpc2K5Sa7g6A4jfkUw==", "dev": true, "license": "MIT", "dependencies": { @@ -5375,9 +5375,9 @@ "license": "MIT" }, "node_modules/debug": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", - "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", "dev": true, "license": "MIT", "dependencies": { @@ -11357,9 +11357,9 @@ } }, "node_modules/undici-types": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.10.0.tgz", - "integrity": "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==", + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.11.0.tgz", + "integrity": "sha512-kt1ZriHTi7MU+Z/r9DOdAI3ONdaR3M3csEaRc6ewa4f4dTvX4cQCbJ4NkEn0ohE4hHtq85+PhPSTY+pO/1PwgA==", "dev": true, "license": "MIT" },