Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix https://github.com/firefly-iii/firefly-iii/issues/11847
James Cole70b12354e8c5
diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.phpindex 9b3c9e6e1b..6c68c38c83 100644--- a/app/Helpers/Collector/GroupCollector.php+++ b/app/Helpers/Collector/GroupCollector.php@@ -779,8 +779,9 @@ class GroupCollector implements GroupCollectorInterface$newArray = $newJournal->toArray();if (array_key_exists('attachment_id', $newArray)) {$attachmentId = (int) $newJournal['attachment_id'];-- $existingJournal['attachments'][$attachmentId] = ['id' => $attachmentId];+ if(0 !== $attachmentId) {+ $existingJournal['attachments'][$attachmentId] = ['id' => $attachmentId];+ }}return $existingJournal;diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.phpindex 1e357ffca0..0af4ca9201 100644--- a/app/Http/Controllers/TagController.php+++ b/app/Http/Controllers/TagController.php@@ -246,12 +246,17 @@ class TagController extends Controller/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);+ // collect transaction journal IDs in repository,+ // this makes the collector faster and more accurate.+ $journalIds = $this->repository->getJournalIds($tag);+$collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)+ ->setJournalIds($journalIds)->withAccountInformation()- ->setTag($tag)+ // ->setTag($tag)->withBudgetInformation()->withCategoryInformation()->withAttachmentInformation()@@ -296,6 +301,10 @@ class TagController extends Controller$path = route('tags.show', [$tag->id, 'all']);$location = $this->repository->getLocation($tag);+ // collect transaction journal IDs in repository,+ // this makes the collector faster and more accurate.+ $journalIds = $this->repository->getJournalIds($tag);+/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);$collector@@ -303,7 +312,7 @@ class TagController extends Controller->setLimit($pageSize)->setPage($page)->withAccountInformation()- ->setTag($tag)+ ->setJournalIds($journalIds)->withBudgetInformation()->withCategoryInformation()->withAttachmentInformation()diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.phpindex 6e0d13c766..39d79c13e7 100644--- a/app/Repositories/Tag/TagRepository.php+++ b/app/Repositories/Tag/TagRepository.php@@ -451,4 +451,10 @@ class TagRepository implements TagRepositoryInterface, UserGroupInterfacereturn $tag;}++ #[\Override]+ public function getJournalIds(Tag $tag): array+ {+ return $tag->transactionJournals->pluck('id')->toArray();+ }}diff --git a/app/Repositories/Tag/TagRepositoryInterface.php b/app/Repositories/Tag/TagRepositoryInterface.phpindex 1ef24a22fc..c66cd0688b 100644--- a/app/Repositories/Tag/TagRepositoryInterface.php+++ b/app/Repositories/Tag/TagRepositoryInterface.php@@ -71,6 +71,8 @@ interface TagRepositoryInterfacepublic function getAttachments(Tag $tag): Collection;+ public function getJournalIds(Tag $tag): array;+/*** Return location, or NULL.*/