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 ...@@ -132,6 +132,7 @@ final class BillingService
$order = (int) $s['spouse_order']; $order = (int) $s['spouse_order'];
$fee = $s['addition_fee'] ?? '0.00'; $fee = $s['addition_fee'] ?? '0.00';
$isFirstFree = ($order === 1 && bccomp($fee, '0', 2) <= 0); $isFirstFree = ($order === 1 && bccomp($fee, '0', 2) <= 0);
$isPaidViaStatus = ($s['status'] === 'active' && bccomp($fee, '0', 2) > 0);
$breakdown = null; $breakdown = null;
if (!empty($s['fee_breakdown_json'])) { if (!empty($s['fee_breakdown_json'])) {
...@@ -143,7 +144,7 @@ final class BillingService ...@@ -143,7 +144,7 @@ final class BillingService
'type' => 'spouse_fee', 'type' => 'spouse_fee',
'label' => 'زوجة #' . $order . ' — ' . $s['full_name_ar'], 'label' => 'زوجة #' . $order . ' — ' . $s['full_name_ar'],
'amount' => $isFirstFree ? '0.00' : $fee, 'amount' => $isFirstFree ? '0.00' : $fee,
'paid' => false, 'paid' => $isPaidViaStatus,
'included' => $isFirstFree, 'included' => $isFirstFree,
'included_note' => $isFirstFree ? 'مشمولة في قيمة العضوية' : null, 'included_note' => $isFirstFree ? 'مشمولة في قيمة العضوية' : null,
'entity_type' => 'spouses', 'entity_type' => 'spouses',
...@@ -167,6 +168,7 @@ final class BillingService ...@@ -167,6 +168,7 @@ final class BillingService
$fee = $c['addition_fee'] ?? '0.00'; $fee = $c['addition_fee'] ?? '0.00';
$classification = $c['classification'] ?? 'included'; $classification = $c['classification'] ?? 'included';
$isIncluded = ($classification === 'included' && bccomp($fee, '0', 2) <= 0); $isIncluded = ($classification === 'included' && bccomp($fee, '0', 2) <= 0);
$isPaidViaStatus = (($c['status'] ?? '') === 'active' && bccomp($fee, '0', 2) > 0);
$classLabel = match ($classification) { $classLabel = match ($classification) {
'included' => 'مشمول (بدون رسوم)', 'included' => 'مشمول (بدون رسوم)',
...@@ -185,7 +187,7 @@ final class BillingService ...@@ -185,7 +187,7 @@ final class BillingService
'type' => 'child_fee', 'type' => 'child_fee',
'label' => ($c['gender'] === 'male' ? 'ابن' : 'ابنة') . ' #' . $order . ' — ' . $c['full_name_ar'] . ' (' . (int) ($c['age_years'] ?? 0) . ' سنة)', 'label' => ($c['gender'] === 'male' ? 'ابن' : 'ابنة') . ' #' . $order . ' — ' . $c['full_name_ar'] . ' (' . (int) ($c['age_years'] ?? 0) . ' سنة)',
'amount' => $fee, 'amount' => $fee,
'paid' => false, 'paid' => $isPaidViaStatus,
'included' => $isIncluded, 'included' => $isIncluded,
'included_note' => $isIncluded ? 'مشمول — ' . $classLabel : $classLabel, 'included_note' => $isIncluded ? 'مشمول — ' . $classLabel : $classLabel,
'entity_type' => 'children', 'entity_type' => 'children',
...@@ -208,11 +210,14 @@ final class BillingService ...@@ -208,11 +210,14 @@ final class BillingService
if (!is_array($breakdown)) $breakdown = null; if (!is_array($breakdown)) $breakdown = null;
} }
$tFee = $t['addition_fee'] ?? '0.00';
$isPaidViaStatus = (($t['status'] ?? '') === 'active' && bccomp($tFee, '0', 2) > 0);
$items[] = [ $items[] = [
'type' => 'temp_fee', 'type' => 'temp_fee',
'label' => 'عضو مؤقت — ' . $t['full_name_ar'] . ' (' . $t['category'] . ')', 'label' => 'عضو مؤقت — ' . $t['full_name_ar'] . ' (' . $t['category'] . ')',
'amount' => $t['addition_fee'] ?? '0.00', 'amount' => $tFee,
'paid' => false, 'paid' => $isPaidViaStatus,
'included' => false, 'included' => false,
'entity_type' => 'temporary_members', 'entity_type' => 'temporary_members',
'entity_id' => (int) $t['id'], 'entity_id' => (int) $t['id'],
......
...@@ -44,11 +44,7 @@ final class FormFeeService ...@@ -44,11 +44,7 @@ final class FormFeeService
} }
$feeData = RuleEngine::get('FORM_ADDITION_FEE'); $feeData = RuleEngine::get('FORM_ADDITION_FEE');
$formAmount = ($feeData && isset($feeData['amount'])) ? $feeData['amount'] : ServicePrice::getPrice('SVC_ADDITION_FORM', '570.00'); return ($feeData && isset($feeData['amount'])) ? $feeData['amount'] : ServicePrice::getPrice('SVC_ADDITION_FORM', '570.00');
$annualSub = self::getAnnualSubscriptionForAddition();
return bcadd($formAmount, $annualSub, 2);
} }
/** /**
......
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