From a436a53b10cdf5d9abc23049026fd951a82ff5b1 Mon Sep 17 00:00:00 2001 From: Korca Date: Mon, 15 Jun 2026 10:32:29 +0200 Subject: [PATCH] fix: parent-aware kontrola profilu v SelectAccount listeneru MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Listener po výběru účtu validoval aktivní profil jen přes přímou shodu účtu, takže výběr subúčtu (kde uživatel nemá vlastní profil) resetoval selectedAccount na první aktivní profil. To bylo nekonzistentní s: - Identity::getProfile(), které je parent-aware (subúčet -> profil rodiče), - SelectAccountFormTrait::getAccountPairs(), které subúčty přes getSubaccounts() aktivně nabízí. Majitel holdingu má profil jen na nadřazeném účtu, ale potřebuje přepínat i na jeho subúčty. Kontrola nově uznává aktivní profil i na nadřazeném účtu. --- src/Model/Listeners/SelectAccountListenerTrait.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Model/Listeners/SelectAccountListenerTrait.php b/src/Model/Listeners/SelectAccountListenerTrait.php index fb853ac..0f0dc0b 100644 --- a/src/Model/Listeners/SelectAccountListenerTrait.php +++ b/src/Model/Listeners/SelectAccountListenerTrait.php @@ -56,11 +56,18 @@ public function onFlushCallback(OnFlushEventArgs $args): void $this->entitiesToRecompute[] = $identity; } - // 2) nemá full data přístup, má nastavený selectedAccount, ale odpovídající profil je neaktivní + // 2) nemá full data přístup, má nastavený selectedAccount, ale nemá pro něj + // (ani pro jeho nadřazený účet) aktivní profil. Parent-aware shoda je konzistentní + // s Identity::getProfile() i s tím, že SelectAccountForm nabízí přes getSubaccounts() + // i subúčty - majitel holdingu má profil jen na nadřazeném účtu. if (!$hasFullData && $selectedAccount) { + $parentAccount = $selectedAccount->getParent(); $profileIsActive = false; foreach ($identity->getProfiles() as $_profile) { - if ($_profile->getAccount() === $selectedAccount && $_profile->getIsActive()) { + if ( + $_profile->getIsActive() + && ($_profile->getAccount() === $selectedAccount || $_profile->getAccount() === $parentAccount) + ) { $profileIsActive = true; break; }