Customer Copy
Branch: {{ $serviceOrder->branch->name }} ,{{ $serviceOrder->branch->address }} , {{ $serviceOrder->branch->phone }}

Billed To:

Customer Name: {{ $serviceOrder->customer->name }}

Phone Number: {{ $serviceOrder->customer->mobile_no }}

Invoice No: {{ $serviceOrder->invoice->invoice_id }}

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 {{ number_format((float)($serviceOrder->total_cost ?? 0), 2) }} SR

Service Rate: SR {{ number_format((float)($serviceOrder->total_cost ?? 0), 2) }}

@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

Previous Paid: SR {{ number_format($previousPaid, 2) }}

Current 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

Service Charge Deduction: SR {{ number_format((float)$serviceChargeDeduction, 2) }}

Refund: SR {{ number_format((float)$refundAmount, 2) }}

@endif
Office Copy
Branch: {{ $serviceOrder->branch->name }}

Billed To:

Customer Name: {{ $serviceOrder->customer->name }}

Phone Number: {{ $serviceOrder->customer->mobile_no }}

Invoice No: {{ $serviceOrder->invoice->invoice_id }}

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 {{ number_format((float)($serviceOrder->total_cost ?? 0), 2) }} SR

Service Rate: SR {{ number_format((float)($serviceOrder->total_cost ?? 0), 2) }}

@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

Previous Paid: SR {{ number_format($previousPaid, 2) }}

Current 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

Service Charge Deduction: SR{{ number_format((float)$serviceChargeDeduction, 2) }}

Refund: SR {{ number_format((float)$refundAmount, 2) }}

@endif