Commit 805bfc36 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix subscription revenue widget — pro-rata allocation from invoice items

The old query only found 30 enrollments (those with invoice_id set) and
showed 33K (9.3%). The correct approach identifies subscription line items
via invoice_items.itemable_type IS NULL (218 items), then pro-rates each
payment by the subscription portion of that invoice's total. Result: 174K
(48.5%) which matches actual subscription collections including bundled
invoices and installment payments.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 0ec2da41
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<span class="w-2.5 h-2.5 rounded-full {{ match($loop->index % 6) { 0 => 'bg-emerald-500', 1 => 'bg-blue-500', 2 => 'bg-purple-500', 3 => 'bg-amber-500', 4 => 'bg-pink-500', 5 => 'bg-cyan-500', default => 'bg-gray-500' } }}"></span> <span class="w-2.5 h-2.5 rounded-full {{ match($loop->index % 6) { 0 => 'bg-emerald-500', 1 => 'bg-blue-500', 2 => 'bg-purple-500', 3 => 'bg-amber-500', 4 => 'bg-pink-500', 5 => 'bg-cyan-500', default => 'bg-gray-500' } }}"></span>
<span class="text-sm font-medium text-gray-700">{{ $activity->activity_name }}</span> <span class="text-sm font-medium text-gray-700">{{ $activity->activity_name }}</span>
<span class="text-xs text-gray-400">({{ $activity->enrollment_count }} {{ __('اشتراك') }})</span> <span class="text-xs text-gray-400">({{ $activity->subscriber_count }} {{ __('مشترك') }})</span>
</div> </div>
<span class="text-sm font-bold text-gray-800" dir="ltr">{{ number_format($activity->total / 100, 0) }} {{ __('ج.م') }}</span> <span class="text-sm font-bold text-gray-800" dir="ltr">{{ number_format($activity->total / 100, 0) }} {{ __('ج.م') }}</span>
</div> </div>
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
</div> </div>
<div class="flex-1 min-w-0"> <div class="flex-1 min-w-0">
<p class="text-sm font-medium text-gray-800 truncate">{{ $program->program_name }}</p> <p class="text-sm font-medium text-gray-800 truncate">{{ $program->program_name }}</p>
<p class="text-xs text-gray-500">{{ $program->activity_name }} &mdash; {{ $program->enrollment_count }} {{ __('اشتراك') }}</p> <p class="text-xs text-gray-500">{{ $program->activity_name }} &mdash; {{ $program->subscriber_count }} {{ __('مشترك') }}</p>
</div> </div>
<span class="text-sm font-bold text-gray-700 whitespace-nowrap" dir="ltr">{{ number_format($program->total / 100, 0) }} {{ __('ج.م') }}</span> <span class="text-sm font-bold text-gray-700 whitespace-nowrap" dir="ltr">{{ number_format($program->total / 100, 0) }} {{ __('ج.م') }}</span>
</div> </div>
......
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