Commit c7acd73c authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(waiver): activate pending dependents after waiver completion

When a waiver completes, all dependents on the target member should be
marked as active since their fees are included in the waiver fee payment.
Previously only activated_by_payment_id was set but status remained
'pending_payment', leaving dependents stuck. Also ensures qualification_id
is transferred from source to target member.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 032d5f13
......@@ -70,6 +70,7 @@ final class WaiverProcessor
'status' => 'active',
'membership_type' => $sourceMember['membership_type'] ?? 'working',
'membership_value' => $sourceMember['membership_value'] ?? '0.00',
'qualification_id' => $sourceMember['qualification_id'] ?? null,
'activated_by_payment_id' => $waiverPaymentId,
'activated_at' => date('Y-m-d H:i:s'),
'transferred_from_waiver_id' => $waiverId,
......@@ -120,17 +121,17 @@ final class WaiverProcessor
], '`id` = ?', [(int) $sub['id']]);
}
// Also update dependent records to mark them as activated
// Activate all dependents — their fees are included in the waiver fee
$db->query(
"UPDATE spouses SET activated_by_payment_id = ?, updated_at = ? WHERE member_id = ? AND is_archived = 0 AND activated_by_payment_id IS NULL",
"UPDATE spouses SET status = 'active', activated_by_payment_id = ?, updated_at = ? WHERE member_id = ? AND is_archived = 0 AND status IN ('pending_payment','pending')",
[$waiverPaymentId, $ts, $targetMemberId]
);
$db->query(
"UPDATE children SET activated_by_payment_id = ?, updated_at = ? WHERE member_id = ? AND is_archived = 0 AND activated_by_payment_id IS NULL",
"UPDATE children SET status = 'active', activated_by_payment_id = ?, updated_at = ? WHERE member_id = ? AND is_archived = 0 AND status IN ('pending_payment','pending')",
[$waiverPaymentId, $ts, $targetMemberId]
);
$db->query(
"UPDATE temporary_members SET activated_by_payment_id = ?, updated_at = ? WHERE member_id = ? AND is_archived = 0 AND activated_by_payment_id IS NULL",
"UPDATE temporary_members SET status = 'active', activated_by_payment_id = ?, updated_at = ? WHERE member_id = ? AND is_archived = 0 AND status IN ('pending_payment','pending')",
[$waiverPaymentId, $ts, $targetMemberId]
);
} catch (\Throwable $e) {
......
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