@extends('layouts.app') @section('content')

Service Order Details: #{{ $serviceOrder->id }}

Print View

Service:

{{ $serviceOrder->service->name }} (SR{{ number_format((float)$serviceOrder->service->cost, 2) }})

Customer:

{{ $serviceOrder->customer->name }} ({{ $serviceOrder->customer->mobile_no }})

@if(auth()->user()->isAdmin())

Agent:

{{ $serviceOrder->agent ? $serviceOrder->agent->name : 'None' }}

@endif

Branch:

{{ $serviceOrder->branch->name }}

Status:

{{ ucfirst($serviceOrder->status) }}

@if(auth()->user()->isAdmin())

Total Cost:

SR{{ number_format((float)$serviceOrder->total_cost, 2) }}

@endif @if(auth()->user()->isAdmin())

Agent Commission:

SR{{ number_format((float)$serviceOrder->agent_commission, 2) }}

Commission Paid:

SR{{ number_format((float)$serviceOrder->agent_commission_paid, 2) }}

@endif

Deadline:

{{ $serviceOrder->deadline ? $serviceOrder->deadline->format('Y-m-d H:i') : '' }}

Created By:

{{ $serviceOrder->user->name }}

Created At:

{{ $serviceOrder->created_at->format('Y-m-d H:i') }}

@php $dueAmount = (float)($serviceOrder->total_cost - $serviceOrder->invoice->payments->sum('amount')); @endphp @if($dueAmount > 0)

Due Amount:

SR{{ number_format($dueAmount, 2) }}

Make Payment
@endif @if(auth()->user()->isAdmin())

Payment History

@if($serviceOrder->invoice->payments->isEmpty())

No payments recorded for this invoice.

@else
@php $totalCost = (float)$serviceOrder->total_cost; $cumulativePaid = 0; @endphp @foreach($serviceOrder->invoice->payments->sortBy('payment_date') as $payment) @php $cumulativePaid += (float)$payment->amount; $remainingDue = $totalCost - $cumulativePaid; @endphp @endforeach
Received Branch Received Amount Payment Date Payment Method Transaction ID Due
{{ $payment->branch->name ?? 'N/A' }} SR{{ number_format((float)$payment->amount, 2) }} {{ $payment->payment_date->format('Y-m-d H:i') }} {{ $payment->payment_method ?? 'N/A' }} {{ $payment->trx_id ?? 'N/A' }} SR{{ number_format($remainingDue, 2) }}
@endif
@endif
@endsection