Commit 4dc3ccbf authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(membership): retroactive wizard assigns wrong person_id to dependents

JS form sends 1-based person_index (child_1, child_2) but PHP used it
directly as a 0-based array subscript into personIdMap, causing child_1
to get child_2's ID and child_2 to fall through to name-based resolution
(which could fail or duplicate). Convert to 0-based before array lookup.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 1173eb1b
...@@ -384,14 +384,18 @@ final class RetroactiveMembershipService ...@@ -384,14 +384,18 @@ final class RetroactiveMembershipService
if ($personType === 'member') { if ($personType === 'member') {
$personId = $memberId; $personId = $memberId;
} elseif (isset($personIdMap[$personType][$personIndex])) { } else {
$personId = $personIdMap[$personType][$personIndex]; // JS sends 1-based indices (child_1, child_2), convert to 0-based array index
$arrayIndex = max(0, $personIndex - 1);
if (isset($personIdMap[$personType][$arrayIndex])) {
$personId = $personIdMap[$personType][$arrayIndex];
} else { } else {
$personId = self::resolveDependentId($db, $memberId, $personType, $sub['person_name'] ?? ''); $personId = self::resolveDependentId($db, $memberId, $personType, $sub['person_name'] ?? '');
if ($personId === null) { if ($personId === null) {
continue; continue;
} }
} }
}
$sub['person_id'] = $personId; $sub['person_id'] = $personId;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment