Commit 7add80a7 authored by Fares's avatar Fares

fix(members): remove non-existent payment_request_id join from insurance record

payments table uses related_entity_type/related_entity_id, not
payment_request_id. Simplified query to filter by payment_type directly.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 3af8e795
...@@ -929,12 +929,10 @@ class MemberController extends Controller ...@@ -929,12 +929,10 @@ class MemberController extends Controller
// Payments related to all procedures // Payments related to all procedures
$procedurePayments = $db->select( $procedurePayments = $db->select(
"SELECT p.*, pr.payment_type as request_type, pr.description_ar as request_description "SELECT p.*
FROM payments p FROM payments p
LEFT JOIN payment_requests pr ON pr.id = p.payment_request_id
WHERE p.member_id = ? AND p.is_voided = 0 WHERE p.member_id = ? AND p.is_voided = 0
AND (p.payment_type IN ('death_fee','waiver_fee','transfer_fee','separation_fee') AND p.payment_type IN ('death_fee','waiver_fee','transfer_fee','separation_fee')
OR pr.payment_type IN ('death_fee','waiver_fee','transfer_fee','separation_fee'))
ORDER BY p.payment_date DESC", ORDER BY p.payment_date DESC",
[$memberId] [$memberId]
); );
......
...@@ -225,7 +225,7 @@ if (!$hasAny): ...@@ -225,7 +225,7 @@ if (!$hasAny):
</thead> </thead>
<tbody> <tbody>
<?php foreach ($procedurePayments as $pp): <?php foreach ($procedurePayments as $pp):
$ppTypeLabel = match($pp['payment_type'] ?? $pp['request_type'] ?? '') { $ppTypeLabel = match($pp['payment_type'] ?? '') {
'death_fee' => 'رسوم وفاة', 'waiver_fee' => 'رسوم تنازل', 'death_fee' => 'رسوم وفاة', 'waiver_fee' => 'رسوم تنازل',
'transfer_fee' => 'رسوم نقل', 'separation_fee' => 'رسوم فصل', default => $pp['payment_type'] ?? '—', 'transfer_fee' => 'رسوم نقل', 'separation_fee' => 'رسوم فصل', default => $pp['payment_type'] ?? '—',
}; };
...@@ -236,7 +236,7 @@ if (!$hasAny): ...@@ -236,7 +236,7 @@ if (!$hasAny):
<tr> <tr>
<td style="font-weight:600;font-family:monospace;"><?= e($pp['receipt_number'] ?? '#' . $pp['id']) ?></td> <td style="font-weight:600;font-family:monospace;"><?= e($pp['receipt_number'] ?? '#' . $pp['id']) ?></td>
<td><span style="background:#EFF6FF;color:#1E40AF;padding:2px 6px;border-radius:3px;font-size:11px;"><?= $ppTypeLabel ?></span></td> <td><span style="background:#EFF6FF;color:#1E40AF;padding:2px 6px;border-radius:3px;font-size:11px;"><?= $ppTypeLabel ?></span></td>
<td style="font-size:12px;"><?= e($pp['request_description'] ?? $pp['description'] ?? '—') ?></td> <td style="font-size:12px;"><?= e($pp['description'] ?? '—') ?></td>
<td style="font-weight:700;color:#059669;"><?= money($pp['amount']) ?></td> <td style="font-weight:700;color:#059669;"><?= money($pp['amount']) ?></td>
<td><?= e(substr($pp['payment_date'] ?? $pp['created_at'] ?? '', 0, 16)) ?></td> <td><?= e(substr($pp['payment_date'] ?? $pp['created_at'] ?? '', 0, 16)) ?></td>
<td><?= $ppMethodLabel ?></td> <td><?= $ppMethodLabel ?></td>
......
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