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,12 +384,16 @@ final class RetroactiveMembershipService
if ($personType === 'member') {
$personId = $memberId;
} elseif (isset($personIdMap[$personType][$personIndex])) {
$personId = $personIdMap[$personType][$personIndex];
} else {
$personId = self::resolveDependentId($db, $memberId, $personType, $sub['person_name'] ?? '');
if ($personId === null) {
continue;
// 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 {
$personId = self::resolveDependentId($db, $memberId, $personType, $sub['person_name'] ?? '');
if ($personId === null) {
continue;
}
}
}
......
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