From 422746d14163bb6f82820436731d3dc22cf4e002 Mon Sep 17 00:00:00 2001 From: fs Date: Sun, 5 Apr 2026 20:00:50 +0200 Subject: [PATCH] fix(helpdesk): resolve all support actor codes instead of requiring exactly one per ticket The previous logic only resolved support user codes to full names when exactly one unique support code existed per ticket. Tickets with multiple support codes (e.g. after reassignment) left all codes unresolved, showing abbreviations like 'NKS' or 'FA' instead of full names. Now: every support-role actor code in a ticket is mapped to that ticket's Support_User_Name. For the debitor feed, codes are mapped on first encounter to avoid conflicts from reassigned tickets. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Service/TicketCommunicationService.php | 33 ++++++------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/modules/helpdesk/lib/Module/Helpdesk/Service/TicketCommunicationService.php b/modules/helpdesk/lib/Module/Helpdesk/Service/TicketCommunicationService.php index 77d5188..0c85c1e 100644 --- a/modules/helpdesk/lib/Module/Helpdesk/Service/TicketCommunicationService.php +++ b/modules/helpdesk/lib/Module/Helpdesk/Service/TicketCommunicationService.php @@ -924,7 +924,7 @@ class TicketCommunicationService return []; } - $supportCodes = []; + $result = []; foreach ([...$odataEntries, ...$soapEntries] as $entry) { $actorRole = trim((string) ($entry['actor_role'] ?? '')); if ($actorRole !== 'support') { @@ -932,17 +932,11 @@ class TicketCommunicationService } $actor = strtoupper(trim((string) ($entry['actor'] ?? ''))); if ($actor !== '' && !$this->isContactActorId($actor) && mb_strlen($actor) <= 10) { - $supportCodes[$actor] = true; + $result[$actor] = $supportUserName; } } - if (count($supportCodes) !== 1) { - return []; - } - - $code = array_keys($supportCodes)[0]; - - return [$code => $supportUserName]; + return $result; } /** @@ -962,8 +956,11 @@ class TicketCommunicationService return []; } - // Group support actor codes per ticket - $codesByTicket = []; + // Map support actor codes to names using ticket assignment data. + // For each entry with a support role, look up the ticket's Support_User_Name + // and map the actor code to that name. This handles tickets with multiple + // support codes (e.g. after reassignment) robustly. + $result = []; foreach ($entries as $entry) { $actorRole = trim((string) ($entry['actor_role'] ?? '')); if ($actorRole !== 'support') { @@ -977,20 +974,10 @@ class TicketCommunicationService if ($ticketNo === '') { continue; } - $codesByTicket[$ticketNo][$actor] = true; - } - - $result = []; - foreach ($codesByTicket as $ticketNo => $codes) { - if (count($codes) !== 1) { - continue; - } $supportUserName = $supportUserNamesByTicket[$ticketNo] ?? ''; - if ($supportUserName === '') { - continue; + if ($supportUserName !== '' && !isset($result[$actor])) { + $result[$actor] = $supportUserName; } - $code = array_keys($codes)[0]; - $result[$code] = $supportUserName; } return $result;