Commit 073c866d authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix paid dependents showing as unpaid and correct addition form fee to 570

- BillingService now marks dependents as paid when their DB status is active
  (handles combined membership payment where no individual addition_fee payment exists)
- Remove annual subscription from addition form fee calculation (570 only, not 827)
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 32e8dda5
......@@ -132,6 +132,7 @@ final class BillingService
$order = (int) $s['spouse_order'];
$fee = $s['addition_fee'] ?? '0.00';
$isFirstFree = ($order === 1 && bccomp($fee, '0', 2) <= 0);
$isPaidViaStatus = ($s['status'] === 'active' && bccomp($fee, '0', 2) > 0);
$breakdown = null;
if (!empty($s['fee_breakdown_json'])) {
......@@ -143,7 +144,7 @@ final class BillingService
'type' => 'spouse_fee',
'label' => 'زوجة #' . $order . ' — ' . $s['full_name_ar'],
'amount' => $isFirstFree ? '0.00' : $fee,
'paid' => false,
'paid' => $isPaidViaStatus,
'included' => $isFirstFree,
'included_note' => $isFirstFree ? 'مشمولة في قيمة العضوية' : null,
'entity_type' => 'spouses',
......@@ -167,6 +168,7 @@ final class BillingService
$fee = $c['addition_fee'] ?? '0.00';
$classification = $c['classification'] ?? 'included';
$isIncluded = ($classification === 'included' && bccomp($fee, '0', 2) <= 0);
$isPaidViaStatus = (($c['status'] ?? '') === 'active' && bccomp($fee, '0', 2) > 0);
$classLabel = match ($classification) {
'included' => 'مشمول (بدون رسوم)',
......@@ -185,7 +187,7 @@ final class BillingService
'type' => 'child_fee',
'label' => ($c['gender'] === 'male' ? 'ابن' : 'ابنة') . ' #' . $order . ' — ' . $c['full_name_ar'] . ' (' . (int) ($c['age_years'] ?? 0) . ' سنة)',
'amount' => $fee,
'paid' => false,
'paid' => $isPaidViaStatus,
'included' => $isIncluded,
'included_note' => $isIncluded ? 'مشمول — ' . $classLabel : $classLabel,
'entity_type' => 'children',
......@@ -208,11 +210,14 @@ final class BillingService
if (!is_array($breakdown)) $breakdown = null;
}
$tFee = $t['addition_fee'] ?? '0.00';
$isPaidViaStatus = (($t['status'] ?? '') === 'active' && bccomp($tFee, '0', 2) > 0);
$items[] = [
'type' => 'temp_fee',
'label' => 'عضو مؤقت — ' . $t['full_name_ar'] . ' (' . $t['category'] . ')',
'amount' => $t['addition_fee'] ?? '0.00',
'paid' => false,
'amount' => $tFee,
'paid' => $isPaidViaStatus,
'included' => false,
'entity_type' => 'temporary_members',
'entity_id' => (int) $t['id'],
......
......@@ -44,11 +44,7 @@ final class FormFeeService
}
$feeData = RuleEngine::get('FORM_ADDITION_FEE');
$formAmount = ($feeData && isset($feeData['amount'])) ? $feeData['amount'] : ServicePrice::getPrice('SVC_ADDITION_FORM', '570.00');
$annualSub = self::getAnnualSubscriptionForAddition();
return bcadd($formAmount, $annualSub, 2);
return ($feeData && isset($feeData['amount'])) ? $feeData['amount'] : ServicePrice::getPrice('SVC_ADDITION_FORM', '570.00');
}
/**
......
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