@extends('garage.layouts.app') @section('title', 'View Voucher') @section('content') @php $typeColors = [ 'journal' => 'primary', 'receipt' => 'success', 'payment' => 'danger', 'contra' => 'info' ]; $typeColor = $typeColors[$voucher->voucher_type] ?? 'secondary'; $statusColors = [ 'draft' => 'warning', 'posted' => 'success', 'cancelled' => 'danger' ]; $statusColor = $statusColors[$voucher->status] ?? 'secondary'; $totalDebit = 0; $totalCredit = 0; @endphp

{{ $voucher->voucher_no }}

{{ ucfirst($voucher->voucher_type) }} {{ ucfirst($voucher->status) }}
Date{{ \Carbon\Carbon::parse($voucher->voucher_date)->format('M d, Y') }} Ref{{ $voucher->reference_no ?? '—' }} TotalPKR {{ number_format($voucher->total_amount, 2) }} By{{ $creator->name ?? '—' }}
@if((isset($saleSources) && $saleSources->count()) || (isset($purchaseSources) && $purchaseSources->count()))
@foreach(($saleSources ?? collect()) as $src) Sale #{{ $src->sale_id }} · {{ $src->sale_number }} ({{ $src->voucher_type }} · {{ $src->link_kind }}) @endforeach @foreach(($purchaseSources ?? collect()) as $src) PO #{{ $src->purchase_order_id }} · {{ $src->purchase_order_number }} ({{ $src->voucher_type }} · {{ $src->link_kind }}) @endforeach
@endif
@if(!empty($relatedSale?->receipt_voucher_id)) Receipt @elseif(!empty($canMakeReceipt) && !empty($relatedSale?->id)) Make receipt @endif @if(in_array($voucher->status, ['draft','posted'])) Edit @endif @if($voucher->status === 'draft')
@csrf
@endif @if($voucher->status !== 'cancelled')
@csrf
@endif Back
@if($voucher->narration)
{{ $voucher->narration }}
@endif
@foreach($transactions as $index => $transaction) @php if ($transaction->transaction_type === 'debit') { $totalDebit += (float) $transaction->amount; } else { $totalCredit += (float) $transaction->amount; } @endphp @endforeach
# Ledger Type Amount Narration
{{ $index + 1 }}
@if(!empty($transaction->garage_ledger_id)) {{ $transaction->ledger_name }} @else {{ $transaction->ledger_name }} @endif @if(!empty($transaction->sub_ledger_code) || !empty($transaction->sub_ledger_title)) / @if(!empty($transaction->garage_sub_ledger_id)) {{ trim(($transaction->sub_ledger_code ?? '').' '.($transaction->sub_ledger_title ?? '')) }} @else {{ trim(($transaction->sub_ledger_code ?? '').' '.($transaction->sub_ledger_title ?? '')) }} @endif @endif
@if($transaction->ledger_code)
Code: {{ $transaction->ledger_code }}
@endif
@if($transaction->transaction_type === 'debit') Dr @else Cr @endif PKR {{ number_format($transaction->amount, 2) }} {{ $transaction->narration ?? '—' }}
Debit PKR {{ number_format($totalDebit, 2) }}
Credit PKR {{ number_format($totalCredit, 2) }}
Balance PKR {{ number_format(abs($totalDebit - $totalCredit), 2) }} {{ abs($totalDebit - $totalCredit) < 0.01 ? '(Balanced)' : '(Unbalanced)' }}
@endsection