@extends('layouts.app') @section('title','التحصيل الشهري') @section('content') @php $monthNames=[1=>'يناير',2=>'فبراير',3=>'مارس',4=>'أبريل',5=>'مايو',6=>'يونيو',7=>'يوليو',8=>'أغسطس',9=>'سبتمبر',10=>'أكتوبر',11=>'نوفمبر',12=>'ديسمبر']; $columns=$period ? $period->accounts->flatMap->lines->unique('charge_definition_id')->values() : collect(); $paidCount=$period?->accounts->where('payment_status','paid')->count()??0; $totalCount=$period?->accounts->count()??0; $unpaidCount=$period?->accounts->where('payment_status','unpaid')->count()??0; $totalDue=$period?->accounts->sum('total_due')??0; $totalPaid=$period?->accounts->where('payment_status','paid')->sum('total_due')??0; $receiptCount=$period?->accounts->flatMap->receipts->where('status','active')->count()??0; $shareableAccounts=$period?->accounts->sortBy(fn($account)=>str_pad($account->apartment_number,8,'0',STR_PAD_LEFT))->values()??collect(); $usedSharedIds=$period?->sharedCharges->pluck('charge_definition_id')??collect(); $sharedDefinitions=$period ? \App\Models\ChargeDefinition::with('apartments')->where('building_id',$building->id)->where('calculation_type','shared')->where('active',1)->whereNotIn('id',$usedSharedIds)->orderBy('display_order')->orderBy('id')->get() : collect(); $participantPresets=[]; foreach($sharedDefinitions as $definition){ $apartmentIds=$definition->apartments->pluck('id'); if($apartmentIds->isNotEmpty()) $participantPresets[$definition->id]=$shareableAccounts->whereIn('apartment_id',$apartmentIds)->pluck('id')->values(); } @endphp
المحاسبة الشهرية

التحصيل الشهري

الرسوم والمصروفات والسداد والإيصالات في مساحة عمل واحدة.

V{{ config('app.version') }} @if($period && $receiptCount)معاينة وطباعة الإيصالاتتحميل كل الإيصالات PDF - 4 في الصفحة@endif
@if(!$period)

لم يتم إنشاء حساب {{ $monthNames[$month] }} {{ $year }}

سيتم إنشاء حساب مستقل لكل شقة من بنود {{ $building->name }} فقط.

@csrf
@else
إجمالي المستحق{{ number_format($totalDue,2) }}جنيه مصري
المحصل{{ number_format($totalPaid,2) }}{{ $paidCount }} من {{ $totalCount }} وحدة
غير المحصل{{ number_format($totalDue-$totalPaid,2) }}{{ $totalCount-$paidCount }} وحدة
حالة الشهر{{ $period->status==='draft'?'مسودة قابلة للتعديل':'تم اعتماد الرسوم' }}{{ $building->name }} — {{ $monthNames[$month] }} {{ $year }}
{{ $period->status==='draft'?'✎':'✓' }}{{ $period->status==='draft'?'يمكنك تعديل البنود والمبالغ الآن':'الرسوم مقفلة ويمكن تسجيل السداد' }}
@if($period->status==='draft')
@csrf
@else
@csrf
@endif
توزيع مرن حسب الشقق

المصروفات المشتركة

لكل بند قائمة شقق مستقلة تحفظ تلقائيًا للأشهر التالية.

إدارة بنود {{ $building->name }}
@if($period->status==='draft')
@csrf

إضافة مصروف مشترك

اختر بندًا محفوظًا أو اكتب بندًا جديدًا لهذا المبنى.

اتركه فارغًا عند اختيار بند محفوظ.
حصة الشقة القياسية0.00جنيه
@include('monthly._participant-picker',['accounts'=>$shareableAccounts,'selectedAccountIds'=>$shareableAccounts->pluck('id'),'presets'=>$participantPresets,'definitionSelectId'=>'shared-definition'])
@endif @if($period->sharedCharges->isNotEmpty())
@foreach($period->sharedCharges as $shared) @php $participantIds=$shared->participants->pluck('id'); if($participantIds->isEmpty()) $participantIds=$shareableAccounts->pluck('id'); @endphp
{{ abs((float)$shared->difference)<0.01?'✓':'!' }}

{{ $shared->chargeDefinition?->name }}

{{ $participantIds->count() }} شقة مشاركة

{{ abs((float)$shared->difference)<0.01?'متطابق':'يوجد فرق' }}
الإجمالي{{ number_format($shared->total_amount,2) }}
الحصة القياسية{{ number_format($shared->standard_allocation,2) }}
الموزع{{ number_format($shared->distributed_total,2) }}
الفرق{{ number_format($shared->difference,2) }}
@if($period->status==='draft')
تعديل المبلغ أو الشقق المشاركة
@csrf @method('put')
الحصة القياسية{{ number_format($shared->standard_allocation,2) }}
@include('monthly._participant-picker',['accounts'=>$shareableAccounts,'selectedAccountIds'=>$participantIds,'presets'=>[],'definitionSelectId'=>null])
@csrf @method('delete')
@endif
@endforeach
@endif @if($period->status==='finalized' && $unpaidCount)
@csrf

تسجيل نقدي جماعي

حدد الشقق غير المسددة من الجدول، ثم سجلها كلها في عملية واحدة.

0شقة مختارة
@endif

حسابات الشقق

القيم الصفرية ظاهرة بوضوح، والشرطة تعني أن البند لا يطبق على هذه الشقة.

{{ $totalCount }} وحدة
@if($period->status==='finalized')@endif@foreach($columns as $column)@endforeach @forelse($period->accounts as $account) @if($period->status==='finalized')@endif @foreach($columns as $column) @php $line=$account->lines->firstWhere('charge_definition_id',$column->charge_definition_id); @endphp @endforeach @empty@endforelse
اختيارالشقةالمسؤول{{ $column->name_snapshot }}الإجماليالحالةالإجراء
لا توجد شقق نشطة لهذا الشهر.
@endif @endsection @section('scripts') @endsection