@extends('admin.admin_dashboard') @section('customcss') @endsection @section('admin') @php $installmentPaymentMap = $bill->payments ->where('status', 'posted') ->whereNotNull('installment_id') ->sortByDesc('payment_date') ->groupBy('installment_id') ->map(fn($items) => $items->first()) ->all(); $nowBangladesh = now()->timezone('+06:00'); $rawOldDate = old('payment_date'); if (!$rawOldDate || str_contains((string)$rawOldDate, '12:00 AM') || str_contains((string)$rawOldDate, '12:00 am')) { $oldPaymentDateDisplay = $nowBangladesh->format('d - m - Y h:i A'); } else { $oldPaymentDateDisplay = $rawOldDate; } $defaultIsoPaymentDate = $nowBangladesh->format('Y-m-d\TH:i:s'); $lastPostedPayment = $bill->payments->where('status', 'posted')->sortByDesc('payment_date')->first(); @endphp
@if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif @if($errors->any())
    @foreach($errors->all() as $error)
  • {{ $error }}
  • @endforeach
@endif
Bill Details
Bill No: {{ $bill->bill_no }}
Date: {{ optional($bill->bill_date)->format('d - m - Y') }}
Category: {{ $bill->category?->name }}
Status: {{ strtoupper($bill->status) }}
Total: {{ number_format((float)$bill->total_amount, 2) }}
Paid: {{ number_format((float)$bill->paid_amount, 2) }}
Remaining: {{ number_format((float)$bill->remaining_amount, 2) }}
Vendor: {{ $bill->vendor_name ?: '-' }}
@if($lastPostedPayment)
Payment Date: {{ optional($lastPostedPayment->payment_date)->format('d - m - Y h:i A') }} ({{ strtoupper($lastPostedPayment->paid_from_method_key ?? 'Cash') }})
@endif @if($bill->remark)
Remark:
{{ $bill->remark }}
@endif
Print Voucher @can('expense_bill.update') @if($bill->status === 'draft') Edit Bill @endif @endcan @can('expense_bill.approve') @if($bill->status === 'draft')
@csrf
@endif @endcan @can('expense_bill.update') @if($bill->status === 'draft')
@csrf
@endif @endcan

{{-- Documents --}}
Supporting Documents @if($bill->documents->count() > 0) {{ $bill->documents->count() }} @endif
@if($bill->documents->count() > 0)
@foreach($bill->documents as $doc) @php $ext = strtolower(pathinfo($doc->file_path, PATHINFO_EXTENSION)); $iconClass = match($ext) { 'pdf' => 'fa-file-pdf text-danger', 'jpg', 'jpeg', 'png', 'webp' => 'fa-file-image text-primary', 'doc', 'docx' => 'fa-file-word text-info', default => 'fa-file text-secondary' }; $filename = basename($doc->file_path); @endphp @endforeach
# Document / File Uploaded By Uploaded At Action
{{ $loop->iteration }} {{ $filename }} {{ $doc->uploader?->name ?? 'System' }} {{ optional($doc->created_at)->format('d - m - Y h:i A') ?? '-' }} @if($bill->status !== 'void') @can('deleteDocument', $bill)
@csrf @method('DELETE')
@endcan @endif
@else

No documents attached.

@endif {{-- Upload Additional Document Option (Allowed for draft, approved, partial, paid) --}} @if($bill->status !== 'void') @can('uploadDocument', $bill)
@csrf
Allowed: PDF, JPG, JPEG, PNG, WEBP, DOC, DOCX (Max: 4MB per file)
@endcan @endif
{{-- Installments --}}
Installments
@if($bill->installments->count() > 0) @if($bill->status === 'approved') {{-- Approved: only installments update allowed --}}
@csrf @method('PUT')
@foreach($bill->installments as $k => $inst) @endforeach
# Due Date Amount Due Paid Remaining Status Invoice
{{ $inst->installment_no }} {{ number_format((float)$inst->amount_paid, 2) }} {{ number_format((float)$inst->remaining_amount, 2) }} {{ strtoupper($inst->status) }} @if(isset($installmentPaymentMap[$inst->id])) @else - @endif
@else
@foreach($bill->installments as $inst) @endforeach
# Due Date Paid Date Amount Due Paid Remaining Status Invoice
{{ $inst->installment_no }} {{ optional($inst->due_date)->format('d - m - Y') }} @if(isset($installmentPaymentMap[$inst->id])) {{ optional($installmentPaymentMap[$inst->id]->payment_date)->format('d - m - Y h:i A') }} @else - @endif {{ number_format((float)$inst->amount_due, 2) }} {{ number_format((float)$inst->amount_paid, 2) }} {{ number_format((float)$inst->remaining_amount, 2) }} {{ strtoupper($inst->status) }} @if(isset($installmentPaymentMap[$inst->id])) @else - @endif
@if(in_array($bill->status, ['partial','paid']))

Payment started/paid, installment cannot be edited.

@endif @endif @else

No installment plan.

@endif
{{-- Payment Form --}}
Make Payment
@if(in_array($bill->status, ['approved','partial']))
@csrf
Format: dd - mm - yyyy h:i A (+6)
@if(!$bill->installments->count()) No installment plan for this bill @endif
@can('expense_bill.pay') @endcan
@else

Bill must be Approved to accept payment.

@endif
{{-- Payment history --}}
Payment History
@if($bill->payments->count() > 0)
@foreach($bill->payments as $p) @endforeach
# Payment No Date Method Amount Status Action
{{ $loop->iteration }} {{ $p->payment_no }} {{ optional($p->payment_date)->format('d - m - Y h:i A') }} {{ $methodNameMap[$p->paid_from_method_key] ?? strtoupper($p->paid_from_method_key) }} {{ number_format((float)$p->amount, 2) }} {{ strtoupper($p->status) }} @if($p->status !== 'void') @endif @can('expense_payment.void') @if($p->status !== 'void') @if(str_starts_with((string)$bill->bill_no, 'SALARY-') || str_contains((string)$bill->remark, 'Salary Batch Payment')) Payroll Linked @else
@csrf
@endif @endif @endcan
@else

No payments yet.

@endif
@endsection @section('customjs') @endsection