diff --git a/app/Api/V1/Controllers/Search/TransactionController.php b/app/Api/V1/Controllers/Search/TransactionController.php index d95ca1a7c7..09a25674d7 100644 --- a/app/Api/V1/Controllers/Search/TransactionController.php +++ b/app/Api/V1/Controllers/Search/TransactionController.php @@ -49,7 +49,7 @@ class TransactionController extends Controller parent::__construct(); $this->middleware(function ($request, $next) { /** @var User $admin */ - $admin = auth()->user(); + $admin = auth()->user(); $this->repository = app(JournalRepositoryInterface::class); $this->repository->setUser($admin); @@ -58,15 +58,14 @@ class TransactionController extends Controller }); } - public function count(CountRequest $request, SearchInterface $searcher): JsonResponse { $count = 0; $includeDeleted = $request->attributes->get('include_deleted', false); - $externalId = (string)$request->attributes->get('external_identifier'); - $internalRef = (string)$request->attributes->get('internal_reference'); - $notes = (string) $request->attributes->get('notes'); - $description = (string) $request->attributes->get('description'); + $externalId = (string) $request->attributes->get('external_identifier'); + $internalRef = (string) $request->attributes->get('internal_reference'); + $notes = (string) $request->attributes->get('notes'); + $description = (string) $request->attributes->get('description'); Log::debug(sprintf('Include deleted? %s', var_export($includeDeleted, true))); if ('' !== $externalId) { $count += $this->repository->countByMeta('external_identifier', $externalId, $includeDeleted); @@ -78,14 +77,13 @@ class TransactionController extends Controller } if ('' !== $notes) { $count += $this->repository->countByNotes($notes, $includeDeleted); - Log::debug(sprintf('Search for transactions with notes LIKE "%s", count is now %d',$notes, $count)); + Log::debug(sprintf('Search for transactions with notes LIKE "%s", count is now %d', $notes, $count)); } if ('' !== $description) { $count += $this->repository->countByDescription($description, $includeDeleted); Log::debug(sprintf('Search for transactions with description "%s", count is now %d', $description, $count)); } - return response()->json(['count' => $count]); } @@ -95,31 +93,31 @@ class TransactionController extends Controller */ public function search(TransactionSearchRequest $request, SearchInterface $searcher): JsonResponse { - $manager = $this->getManager(); - $fullQuery = (string)$request->attributes->get('query'); - $page = $request->attributes->get('page'); - $pageSize = $request->attributes->get('limit'); + $manager = $this->getManager(); + $fullQuery = (string) $request->attributes->get('query'); + $page = $request->attributes->get('page'); + $pageSize = $request->attributes->get('limit'); $searcher->parseQuery($fullQuery); $searcher->setPage($page); $searcher->setLimit($pageSize); - $groups = $searcher->searchTransactions(); - $parameters = ['search' => $fullQuery]; - $url = route('api.v1.search.transactions') . '?' . http_build_query($parameters); + $groups = $searcher->searchTransactions(); + $parameters = ['search' => $fullQuery]; + $url = route('api.v1.search.transactions').'?'.http_build_query($parameters); $groups->setPath($url); // enrich - $enrichment = new TransactionGroupEnrichment(); + $enrichment = new TransactionGroupEnrichment(); $enrichment->setUser(auth()->user()); $transactions = $enrichment->enrich($groups->getCollection()); /** @var TransactionGroupTransformer $transformer */ - $transformer = app(TransactionGroupTransformer::class); + $transformer = app(TransactionGroupTransformer::class); $transformer->setParameters($this->parameters); - $resource = new Collection($transactions, $transformer, 'transactions'); + $resource = new Collection($transactions, $transformer, 'transactions'); $resource->setPaginator(new IlluminatePaginatorAdapter($groups)); - $array = $manager->createData($resource)->toArray(); + $array = $manager->createData($resource)->toArray(); return response()->json($array)->header('Content-Type', self::CONTENT_TYPE); } diff --git a/app/Api/V1/Requests/Search/CountRequest.php b/app/Api/V1/Requests/Search/CountRequest.php index efd34f43e3..8708b30fd6 100644 --- a/app/Api/V1/Requests/Search/CountRequest.php +++ b/app/Api/V1/Requests/Search/CountRequest.php @@ -31,12 +31,6 @@ use Override; class CountRequest extends AggregateFormRequest { - #[Override] - protected function getRequests(): array - { - return []; - } - public function rules(): array { return [ @@ -61,4 +55,10 @@ class CountRequest extends AggregateFormRequest $this->attributes->set('internal_reference', $this->convertString('internal_reference')); }); } + + #[Override] + protected function getRequests(): array + { + return []; + } } diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 704efdd3ed..7162b56479 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -48,6 +48,47 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac { use UserGroupTrait; + #[Override] + public function countByDescription(string $value, bool $includeDeleted): int + { + $search = $this->user->transactionJournals()->where('description', $value); + if ($includeDeleted) { + $search->withTrashed(); + } + + return $search->count(); + } + + #[Override] + public function countByMeta(string $field, string $value, bool $includeDeleted): int + { + $search = TransactionJournalMeta::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id') + ->where('name', $field) + ->where('data', json_encode($value)) + ->where('transaction_journals.user_id', $this->user->id) + ; + if ($includeDeleted) { + $search->withTrashed(); + } + + return $search->count(); + } + + #[Override] + public function countByNotes(string $value, bool $includeDeleted): int + { + $search = Note::where('noteable_type', TransactionJournal::class) + ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'notes.noteable_id') + ->where('transaction_journals.user_id', $this->user->id) + ->where('text', 'LIKE', sprintf('%%%s%%', $value)) + ; + if ($includeDeleted) { + $search->withTrashed(); + } + + return $search->count(); + } + public function destroyGroup(TransactionGroup $transactionGroup): void { /** @var TransactionGroupDestroyService $service */ @@ -77,7 +118,8 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac ->transactionJournals() ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id') ->whereIn('transaction_types.type', $types) - ->get(['transaction_journals.*']); + ->get(['transaction_journals.*']) + ; } /** @@ -88,7 +130,8 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac return $this->user ->transactionJournals() ->orderBy('date', 'ASC') - ->first(['transaction_journals.*']); + ->first(['transaction_journals.*']) + ; } #[Override] @@ -113,7 +156,7 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac */ public function getJournalTotal(TransactionJournal $journal): string { - $cache = new CacheProperties(); + $cache = new CacheProperties(); $cache->addProperty($journal->id); $cache->addProperty('amount-positive'); if ($cache->has()) { @@ -122,7 +165,7 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac // saves on queries: $amount = $journal->transactions()->where('amount', '>', 0)->get()->sum('amount'); - $amount = (string)$amount; + $amount = (string) $amount; $cache->store($amount); return $amount; @@ -133,7 +176,8 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac return $this->user ->transactionJournals() ->orderBy('date', 'DESC') - ->first(['transaction_journals.*']); + ->first(['transaction_journals.*']) + ; } public function getLinkNoteText(TransactionJournalLink $link): string @@ -141,7 +185,7 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac /** @var null|Note $note */ $note = $link->notes()->first(); - return (string)$note?->text; + return (string) $note?->text; } /** @@ -184,7 +228,8 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac return $this->userGroup ->transactionJournals() ->where('completed', false) - ->get(['transaction_journals.*']); + ->get(['transaction_journals.*']) + ; } #[Override] @@ -208,7 +253,8 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac $query = $this->user ->transactionJournals() ->orderBy('date', 'DESC') - ->orderBy('description', 'ASC'); + ->orderBy('description', 'ASC') + ; if ('' !== $search) { $query->whereLike('description', sprintf('%%%s%%', $search)); } @@ -268,41 +314,4 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac return $journal; } - - #[\Override] - public function countByMeta(string $field, string $value, bool $includeDeleted): int - { - $search = TransactionJournalMeta:: - leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id') - ->where('name', $field)->where('data', json_encode($value)) - ->where('transaction_journals.user_id', $this->user->id); - if ($includeDeleted) { - $search->withTrashed(); - } - return $search->count(); - } - - #[\Override] - public function countByNotes(string $value, bool $includeDeleted): int - { - $search = Note:: - where('noteable_type', TransactionJournal::class) - ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'notes.noteable_id') - ->where('transaction_journals.user_id', $this->user->id) - ->where('text', 'LIKE', sprintf('%%%s%%', $value)); - if ($includeDeleted) { - $search->withTrashed(); - } - return $search->count(); - } - - #[\Override] - public function countByDescription(string $value, bool $includeDeleted): int - { - $search = $this->user->transactionJournals()->where('description', $value); - if ($includeDeleted) { - $search->withTrashed(); - } - return $search->count(); - } } diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.php index deda82c392..15ffa3252f 100644 --- a/app/Repositories/Journal/JournalRepositoryInterface.php +++ b/app/Repositories/Journal/JournalRepositoryInterface.php @@ -47,15 +47,17 @@ use Illuminate\Support\Collection; */ interface JournalRepositoryInterface { + public function countByDescription(string $value, bool $includeDeleted): int; + + public function countByMeta(string $field, string $value, bool $includeDeleted): int; + + public function countByNotes(string $value, bool $includeDeleted): int; + /** * Deletes a transaction group. */ public function destroyGroup(TransactionGroup $transactionGroup): void; - public function countByMeta(string $field, string $value, bool $includeDeleted): int; - public function countByNotes(string $value, bool $includeDeleted): int; - public function countByDescription(string $value, bool $includeDeleted): int; - /** * Deletes a journal. */ diff --git a/app/Support/Export/ExportDataGenerator.php b/app/Support/Export/ExportDataGenerator.php index 6ad2d2b5a4..cbc93b90d4 100644 --- a/app/Support/Export/ExportDataGenerator.php +++ b/app/Support/Export/ExportDataGenerator.php @@ -184,6 +184,8 @@ class ExportDataGenerator // @phpstan-ignore-line + // @phpstan-ignore-line + public function __construct() { $this->accounts = new Collection(); diff --git a/config/firefly.php b/config/firefly.php index 8e6240ac4e..f54a42a9c1 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -78,8 +78,8 @@ return [ 'running_balance_column' => (bool)envNonEmpty('USE_RUNNING_BALANCE', true), // this is only the default value, is not used. // see cer.php for exchange rates feature flag. ], - 'version' => 'develop/2026-02-21', - 'build_time' => 1771701730, + 'version' => 'develop/2026-02-22', + 'build_time' => 1771741082, 'api_version' => '2.1.0', // field is no longer used. 'db_version' => 28, // field is no longer used. diff --git a/package-lock.json b/package-lock.json index 0fff45ca1b..568d951e94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4597,9 +4597,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001770", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001770.tgz", - "integrity": "sha512-x/2CLQ1jHENRbHg5PSId2sXq1CIO1CISvwWAj027ltMVG2UNgW+w9oH2+HzgEIRFembL8bUlXtfbBHR1fCg2xw==", + "version": "1.0.30001772", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001772.tgz", + "integrity": "sha512-mIwLZICj+ntVTw4BT2zfp+yu/AqV6GMKfJVJMx3MwPxs+uk/uj2GLl2dH8LQbjiLDX66amCga5nKFyDgRR43kg==", "dev": true, "funding": [ { @@ -8328,9 +8328,9 @@ "license": "MIT" }, "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.3.tgz", + "integrity": "sha512-M2GCs7Vk83NxkUyQV1bkABc4yxgz9kILhHImZiBPAZ9ybuvCb0/H7lEl5XvIg3g+9d4eNotkZA5IWwYl0tibaA==", "dev": true, "license": "ISC", "dependencies": {