1
0

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) <noreply@anthropic.com>
This commit is contained in:
2026-04-05 20:00:50 +02:00
parent 4a62ed07e9
commit 422746d141

View File

@@ -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;