Commit 016b6717 authored by Fares's avatar Fares

fix(payments): split inherited vs own payments in member history

For members who received membership via waiver or death transfer, the
payment history now shows two separate sections:
- "مدفوعات العضوية الحالية" (current membership payments)
- "مدفوعات العضوية السابقة (موروثة)" (inherited from previous owner)

The split uses ownership_transfer_date (or activated_at as fallback).
Also added missing Arabic labels for hourly_booking and early_settlement.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent cfa6456e
...@@ -520,13 +520,19 @@ class PaymentController extends Controller ...@@ -520,13 +520,19 @@ class PaymentController extends Controller
$payments = Payment::getForMember((int) $memberId, true); $payments = Payment::getForMember((int) $memberId, true);
$summary = BalanceCalculator::getSummary((int) $memberId); $summary = BalanceCalculator::getSummary((int) $memberId);
// Determine ownership transfer date to split inherited vs own payments
$ownershipDate = $member['ownership_transfer_date'] ?? $member['activated_at'] ?? null;
$hasTransfer = !empty($member['transferred_from_waiver_id']) || !empty($member['transferred_from_death_id']);
return $this->view('Payments.Views.history', [ return $this->view('Payments.Views.history', [
'rows' => $payments, 'rows' => $payments,
'member' => $member, 'member' => $member,
'summary' => $summary, 'summary' => $summary,
'memberView' => true, 'memberView' => true,
'pagination' => ['last_page' => 1, 'current_page' => 1], 'pagination' => ['last_page' => 1, 'current_page' => 1],
'filters' => [], 'filters' => [],
'hasTransfer' => $hasTransfer,
'ownershipDate' => $ownershipDate,
]); ]);
} }
......
...@@ -171,6 +171,9 @@ class Payment extends Model ...@@ -171,6 +171,9 @@ class Payment extends Model
'seasonal_fee' => 'رسوم عضوية موسمية', 'seasonal_fee' => 'رسوم عضوية موسمية',
'companion_surcharge' => 'رسوم ملحقين إضافيين', 'companion_surcharge' => 'رسوم ملحقين إضافيين',
'reinstatement_fee' => 'رسوم إعادة العضوية', 'reinstatement_fee' => 'رسوم إعادة العضوية',
'hourly_booking' => 'حجز بالساعة',
'early_settlement' => 'تسوية مبكرة',
'booking_fee' => 'رسوم حجز',
'sale' => 'مبيعات', 'sale' => 'مبيعات',
'other' => 'أخرى', 'other' => 'أخرى',
default => $type, default => $type,
......
...@@ -81,7 +81,32 @@ ...@@ -81,7 +81,32 @@
<?php $__template->include('Payments.Views._partials.payment-summary', ['summary' => $summary]); ?> <?php $__template->include('Payments.Views._partials.payment-summary', ['summary' => $summary]); ?>
<?php endif; ?> <?php endif; ?>
<div class="card"> <?php
// Split payments into own vs inherited (from previous owner) if this is a transferred membership
$ownPayments = $rows;
$inheritedPayments = [];
if (!empty($memberView) && !empty($hasTransfer) && !empty($ownershipDate)) {
$cutoff = substr((string) $ownershipDate, 0, 10);
$ownPayments = [];
$inheritedPayments = [];
foreach ($rows as $r) {
$pDate = substr($r['payment_date'] ?? '', 0, 10);
if ($pDate >= $cutoff) {
$ownPayments[] = $r;
} else {
$inheritedPayments[] = $r;
}
}
}
?>
<div class="card" style="margin-bottom:20px;">
<?php if (!empty($memberView) && !empty($hasTransfer) && !empty($inheritedPayments)): ?>
<div style="padding:12px 20px;background:#F0FDF4;border-bottom:2px solid #059669;">
<strong style="color:#059669;">مدفوعات العضوية الحالية</strong>
<span style="color:#6B7280;font-size:12px;margin-right:10px;">(من <?= e(substr((string) $ownershipDate, 0, 10)) ?>)</span>
</div>
<?php endif; ?>
<div class="table-responsive"> <div class="table-responsive">
<table class="data-table"> <table class="data-table">
<thead><tr> <thead><tr>
...@@ -90,7 +115,7 @@ ...@@ -90,7 +115,7 @@
<th>النوع</th><th>المبلغ</th><th>الطريقة</th><th>الإيصال</th><th>الحالة</th><th>الإجراءات</th> <th>النوع</th><th>المبلغ</th><th>الطريقة</th><th>الإيصال</th><th>الحالة</th><th>الإجراءات</th>
</tr></thead> </tr></thead>
<tbody> <tbody>
<?php foreach ($rows as $r): ?> <?php foreach ($ownPayments as $r): ?>
<tr style="<?= ($r['is_voided'] ?? false) ? 'opacity:0.5;text-decoration:line-through;' : '' ?>"> <tr style="<?= ($r['is_voided'] ?? false) ? 'opacity:0.5;text-decoration:line-through;' : '' ?>">
<td style="font-size:12px;white-space:nowrap;"><?= e($r['payment_date'] ?? '') ?></td> <td style="font-size:12px;white-space:nowrap;"><?= e($r['payment_date'] ?? '') ?></td>
<?php if (empty($memberView)): ?><td><a href="/members/<?= (int) $r['member_id'] ?>" style="color:#0D7377;"><?= e($r['member_name'] ?? $r['full_name_ar'] ?? '—') ?></a></td><?php endif; ?> <?php if (empty($memberView)): ?><td><a href="/members/<?= (int) $r['member_id'] ?>" style="color:#0D7377;"><?= e($r['member_name'] ?? $r['full_name_ar'] ?? '—') ?></a></td><?php endif; ?>
...@@ -102,10 +127,40 @@ ...@@ -102,10 +127,40 @@
<td><a href="/payments/<?= (int) $r['id'] ?>" class="btn btn-sm btn-outline">عرض</a></td> <td><a href="/payments/<?= (int) $r['id'] ?>" class="btn btn-sm btn-outline">عرض</a></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
<?php if (empty($rows)): ?><tr><td colspan="<?= empty($memberView) ? 8 : 7 ?>" style="text-align:center;padding:40px;color:#6B7280;">لا توجد مدفوعات</td></tr><?php endif; ?> <?php if (empty($ownPayments)): ?><tr><td colspan="<?= empty($memberView) ? 8 : 7 ?>" style="text-align:center;padding:40px;color:#6B7280;">لا توجد مدفوعات</td></tr><?php endif; ?>
</tbody>
</table>
</div>
</div>
<?php if (!empty($memberView) && !empty($inheritedPayments)): ?>
<div class="card">
<div style="padding:12px 20px;background:#FFF7ED;border-bottom:2px solid #D97706;">
<strong style="color:#D97706;">مدفوعات العضوية السابقة (موروثة)</strong>
<span style="color:#6B7280;font-size:12px;margin-right:10px;">(قبل انتقال الملكية)</span>
</div>
<div class="table-responsive">
<table class="data-table">
<thead><tr>
<th>التاريخ</th>
<th>النوع</th><th>المبلغ</th><th>الطريقة</th><th>الإيصال</th><th>الحالة</th><th>الإجراءات</th>
</tr></thead>
<tbody>
<?php foreach ($inheritedPayments as $r): ?>
<tr style="opacity:0.7;<?= ($r['is_voided'] ?? false) ? 'text-decoration:line-through;' : '' ?>">
<td style="font-size:12px;white-space:nowrap;"><?= e($r['payment_date'] ?? '') ?></td>
<td style="font-size:13px;"><?= e(\App\Modules\Payments\Models\Payment::getPaymentTypeLabel($r['payment_type'])) ?></td>
<td style="font-weight:700;direction:ltr;text-align:right;"><?= money($r['amount']) ?></td>
<td style="font-size:13px;"><?= e(\App\Modules\Payments\Models\Payment::getPaymentMethodLabel($r['payment_method'])) ?></td>
<td style="font-size:12px;direction:ltr;text-align:right;"><?= e($r['receipt_number'] ?? '—') ?></td>
<td><?php if ($r['is_voided'] ?? false): ?><span style="color:#DC2626;font-weight:600;">ملغاة</span><?php else: ?><span style="color:#059669;font-weight:600;">سارية</span><?php endif; ?></td>
<td><a href="/payments/<?= (int) $r['id'] ?>" class="btn btn-sm btn-outline">عرض</a></td>
</tr>
<?php endforeach; ?>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php endif; ?>
<?php $__template->endSection(); ?> <?php $__template->endSection(); ?>
\ No newline at end of file
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