@extends('garage.layouts.app') @section('title', 'Sub-ledger statement') @section('content') @php $bal = 0.0; $totalDr = 0.0; $totalCr = 0.0; $name = trim(($sub->sub_code ? $sub->sub_code.' · ' : '').($sub->title ?? 'Sub-ledger')); $parent = trim(($sub->customer_ledger_code ? $sub->customer_ledger_code.' · ' : '').($sub->customer_ledger_name ?? '')); $print = request()->boolean('print'); foreach ($rows as $rr) { $d = $rr->transaction_type === 'debit' ? (float) $rr->amount : 0.0; $c = $rr->transaction_type === 'credit' ? (float) $rr->amount : 0.0; $totalDr += $d; $totalCr += $c; $bal += ($d - $c); } $closingAbs = abs($bal); $closingSide = $bal >= 0 ? 'Dr' : 'Cr'; $runBal = 0.0; @endphp

Sub-ledger statement

{{ $name }}
@if($parent !== '')
Parent ledger: {{ $parent }}
@endif
From{{ $from ?: '—' }} To{{ $to ?: '—' }} Total Dr{{ number_format($totalDr, 2) }} Total Cr{{ number_format($totalCr, 2) }} Closing{{ number_format($closingAbs, 2) }} {{ $closingSide }}
@forelse($rows as $r) @php $dr = $r->transaction_type === 'debit' ? (float) $r->amount : 0.0; $cr = $r->transaction_type === 'credit' ? (float) $r->amount : 0.0; $runBal += ($dr - $cr); $ledgerLine = trim(($r->ledger_code ? $r->ledger_code.' · ' : '').($r->ledger_name ?? '')); @endphp @empty @endforelse @if(count($rows)) @endif
Date Voucher Type Ledger Ref Dr Cr Balance Narration
{{ $r->voucher_date }} {{ $r->voucher_no }} {{ $r->voucher_type }} {{ $ledgerLine !== '' ? $ledgerLine : '—' }} @include('garage.reports.partials.statement-reference-cell', ['row' => $r]) {{ $dr ? number_format($dr, 2) : '—' }} {{ $cr ? number_format($cr, 2) : '—' }} {{ number_format(abs($runBal), 2) }} {{ $runBal >= 0 ? 'Dr' : 'Cr' }} {{ $r->narration ?: '—' }}
No transactions.
Totals {{ number_format($totalDr, 2) }} {{ number_format($totalCr, 2) }} {{ number_format($closingAbs, 2) }} {{ $closingSide }} Closing balance
@endsection @push('scripts') @endpush