Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix https://github.com/firefly-iii/firefly-iii/issues/7749
James Colea45a050e7d20
diff --git a/app/Helpers/Collector/Extensions/CollectorProperties.php b/app/Helpers/Collector/Extensions/CollectorProperties.phpindex 328b920256..4735c40275 100644--- a/app/Helpers/Collector/Extensions/CollectorProperties.php+++ b/app/Helpers/Collector/Extensions/CollectorProperties.php@@ -33,6 +33,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;trait CollectorProperties{public const TEST = 'Test';+ private bool $expandGroupSearch;private array $fields;private bool $hasAccountInfo;private bool $hasBillInformation;diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.phpindex cbbb97e89d..e6753daa01 100644--- a/app/Helpers/Collector/GroupCollector.php+++ b/app/Helpers/Collector/GroupCollector.php@@ -76,6 +76,7 @@ class GroupCollector implements GroupCollectorInterface$this->hasNotesInformation = false;$this->hasJoinedTagTables = false;$this->hasJoinedAttTables = false;+ $this->expandGroupSearch = false;$this->hasJoinedMetaTables = false;$this->integerFields = ['transaction_group_id',@@ -454,6 +455,14 @@ class GroupCollector implements GroupCollectorInterfacereturn $this;}+ /**+ * @return bool+ */+ public function getExpandGroupSearch(): bool+ {+ return $this->expandGroupSearch;+ }+/*** Return the transaction journals without group information. Is useful in some instances.*@@ -480,10 +489,16 @@ class GroupCollector implements GroupCollectorInterface* Return the groups.** @return Collection- * @throws FireflyException*/public function getGroups(): Collection{+ if ($this->expandGroupSearch) {+ // get group ID's for the query:+ $groupIds = $this->getCollectedGroupIds();+ // add to query:+ $this->query->orWhereIn('transaction_journals.transaction_group_id', $groupIds);+ }+$result = $this->query->get($this->fields);// now to parse this into an array.@@ -505,6 +520,14 @@ class GroupCollector implements GroupCollectorInterfacereturn $collection;}+ /**+ * @return array+ */+ private function getCollectedGroupIds(): array+ {+ return $this->query->get(['transaction_journals.transaction_group_id'])->pluck('transaction_group_id')->toArray();+ }+/*** @param Collection $collection*@@ -516,7 +539,7 @@ class GroupCollector implements GroupCollectorInterface$groups = [];/** @var TransactionJournal $augumentedJournal */foreach ($collection as $augumentedJournal) {- $groupId = $augumentedJournal->transaction_group_id;+ $groupId = (int)$augumentedJournal->transaction_group_id;if (!array_key_exists($groupId, $groups)) {// make new array@@ -871,6 +894,14 @@ class GroupCollector implements GroupCollectorInterfacereturn $this;}+ /**+ * @param bool $expandGroupSearch+ */+ public function setExpandGroupSearch(bool $expandGroupSearch): void+ {+ $this->expandGroupSearch = $expandGroupSearch;+ }+/*** @inheritDoc*/diff --git a/app/Helpers/Collector/GroupCollectorInterface.php b/app/Helpers/Collector/GroupCollectorInterface.phpindex 887b199593..c8dabf0e82 100644--- a/app/Helpers/Collector/GroupCollectorInterface.php+++ b/app/Helpers/Collector/GroupCollectorInterface.php@@ -583,6 +583,11 @@ interface GroupCollectorInterface*/public function foreignAmountMore(string $amount): GroupCollectorInterface;+ /**+ * @return bool+ */+ public function getExpandGroupSearch(): bool;+/*** Return the transaction journals without group information. Is useful in some instances.*@@ -1072,6 +1077,11 @@ interface GroupCollectorInterface*/public function setDestinationAccounts(Collection $accounts): GroupCollectorInterface;+ /**+ * @param bool $expandGroupSearch+ */+ public function setExpandGroupSearch(bool $expandGroupSearch);+/*** Look for specific external ID's.*@@ -1502,4 +1512,6 @@ interface GroupCollectorInterface* @return GroupCollectorInterface*/public function yearIsNot(string $year): GroupCollectorInterface;++}diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.phpindex 7a1b28cb8f..062ef715de 100644--- a/app/Http/Controllers/Account/ShowController.php+++ b/app/Http/Controllers/Account/ShowController.php@@ -131,6 +131,12 @@ class ShowController extends Controller->setLimit($pageSize)->setPage($page)->withAccountInformation()->withCategoryInformation()->setRange($start, $end);++ // this search will not include transaction groups where this asset account (or liability)+ // is just part of ONE of the journals. To force this:+ $collector->setExpandGroupSearch(true);++$groups = $collector->getPaginatedGroups();$groups->setPath(route('accounts.show', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]));