Billed To:
Customer Name: {{ $serviceOrder->customer->name }}
Phone Number: {{ $serviceOrder->customer->mobile_no }}
Invoice No: {{ Str::of($serviceOrder->invoice_id)->replace('-', '') }}
Date: {{ $serviceOrder->created_at->format('Y-m-d H:i') }}
| Description | Quantity | Unit Price | Total | |
|---|---|---|---|---|
| {{ $serviceOrder->service->name }} | 1 | {{ number_format((float)($serviceOrder->service->cost ?? 0), 2) }} SR | @if (auth()->user()->isAdmin() || auth()->user()->branch_id == $serviceOrder->branch_id){{ number_format((float)($serviceOrder->total_cost ?? 0), 2) }} SR | @elseN/A | @endif
Service Rate: SR {{ number_format((float)($serviceOrder->total_cost ?? 0), 2) }}
@elseService Rate: N/A
@endif @if(!$serviceOrder->is_cancel) @php $payments = $serviceOrder->invoice->payments->sortBy('payment_date'); $totalPayments = (float)($payments->sum('amount') ?? 0); $lastPayment = $payments->last(); $previousPaid = $lastPayment ? (float)($totalPayments - $lastPayment->amount) : 0; $currentPaid = $lastPayment ? (float)$lastPayment->amount : 0; $currentDate = $lastPayment ? $lastPayment->payment_date->format('Y-m-d') : ''; $dueAmount = (float)($serviceOrder->total_cost ?? 0) - $totalPayments; @endphp @if (auth()->user()->isAdmin() || auth()->user()->branch_id == $serviceOrder->branch_id)Previous Paid: SR {{ number_format($previousPaid, 2) }}
@elsePrevious Paid: N/A
@endifCurrent Paid ({{ $currentDate }}): SR{{ number_format($currentPaid, 2) }}
@if($dueAmount > 0)Due Amount: SR {{ number_format($dueAmount, 2) }}
@endif @endif @if($serviceOrder->is_cancel) @php $serviceChargeDeduction = \DB::table('vouchers')->where('invoice_id', $serviceOrder->invoice->invoice_id)->where('transaction_type', 'service_charge_deduction')->sum('amount'); $refundAmount = \DB::table('vouchers')->where('invoice_id', $serviceOrder->invoice->invoice_id)->where('transaction_type', 'refund')->sum('amount'); @endphp @if (auth()->user()->isAdmin() || auth()->user()->branch_id == $serviceOrder->branch_id)Service Charge Deduction: SR{{ number_format((float)$serviceChargeDeduction, 2) }}
Refund: SR {{ number_format((float)$refundAmount, 2) }}
@elseService Charge Deduction: N/A
Refund: N/A
@endif @endifBilled To:
Customer Name: {{ $serviceOrder->customer->name }}
Phone Number: {{ $serviceOrder->customer->mobile_no }}
Invoice No: {{ Str::of($serviceOrder->invoice_id)->replace('-', '') }}
Date: {{ $serviceOrder->created_at->format('Y-m-d H:i') }}
| Description | Quantity | Unit Price | Total | |
|---|---|---|---|---|
| {{ $serviceOrder->service->name }} | 1 | {{ number_format((float)($serviceOrder->service->cost ?? 0), 2) }} SR | @if (auth()->user()->isAdmin() || auth()->user()->branch_id == $serviceOrder->branch_id){{ number_format((float)($serviceOrder->total_cost ?? 0), 2) }} SR | @elseN/A | @endif
Service Rate: SR {{ number_format((float)($serviceOrder->total_cost ?? 0), 2) }}
@elseService Rate: N/A
@endif @if(!$serviceOrder->is_cancel) @php $payments = $serviceOrder->invoice->payments->sortBy('payment_date'); $totalPayments = (float)($payments->sum('amount') ?? 0); $lastPayment = $payments->last(); $previousPaid = $lastPayment ? (float)($totalPayments - $lastPayment->amount) : 0; $currentPaid = $lastPayment ? (float)$lastPayment->amount : 0; $currentDate = $lastPayment ? $lastPayment->payment_date->format('Y-m-d') : ''; $dueAmount = (float)($serviceOrder->total_cost ?? 0) - $totalPayments; @endphp @if (auth()->user()->isAdmin() || auth()->user()->branch_id == $serviceOrder->branch_id)Previous Paid: SR {{ number_format($previousPaid, 2) }}
@elsePrevious Paid: N/A
@endifCurrent Paid ({{ $currentDate }}): SR {{ number_format($currentPaid, 2) }}
@if($dueAmount > 0)Due Amount: SR {{ number_format($dueAmount, 2) }}
@endif @endif @if($serviceOrder->is_cancel) @php $serviceChargeDeduction = \DB::table('vouchers')->where('invoice_id', $serviceOrder->invoice->invoice_id)->where('transaction_type', 'service_charge_deduction')->sum('amount'); $refundAmount = \DB::table('vouchers')->where('invoice_id', $serviceOrder->invoice->invoice_id)->where('transaction_type', 'refund')->sum('amount'); @endphp @if (auth()->user()->isAdmin() || auth()->user()->branch_id == $serviceOrder->branch_id)Service Charge Deduction: SR{{ number_format((float)$serviceChargeDeduction, 2) }}
Refund: SR {{ number_format((float)$refundAmount, 2) }}
@elseService Charge Deduction: N/A
Refund: N/A
@endif @endif