@extends('admin.layouts.wholesale-live') @section('page-title', 'Parties Ledger') @push('scripts')@endpush @section('wholesale-actions') @if($party && auth()->user()->hasPermission('wholesale.payments'))Receive Payment@endif @if($report)@endif @endsection @section('wholesale-content')
@if($report)

{{ $brand['name'] }} · Party statement

{{ $party->name }} · {{ $party->phone }}

{{ $from ?? 'Beginning' }} → {{ $to ?? 'All dates' }}

Statement page {{ $report['rows']->currentPage() }} of {{ $report['rows']->lastPage() }}

@foreach(['opening' => 'Brought forward', 'debit' => 'Range debit', 'credit' => 'Range credit', 'closing' => 'Closing balance due'] as $key => $label)
{{ $label }} (BDT)
{{ number_format($report[$key] / 100, 2) }}
@endforeach
@if($report['rows']->first())

Balance carried into this page: BDT {{ number_format(((int) $report['rows']->first()->balance - (int) $report['rows']->first()->debit + (int) $report['rows']->first()->credit) / 100, 2) }}. Range totals above cover all matching pages.

@endif
@forelse($report['rows'] as $row) @empty@endforelse
Party ledger with debit, credit and running balance
DateReference / DetailsDebit (BDT)Credit (BDT)Balance due (BDT)
{{ $row->event_date }} @if($row->kind === 'opening')Opening due @elseif($row->kind === 'payment') @if(auth()->user()->hasPermission('wholesale.payments'))RC{{ str_pad((string) $row->event_id, 6, '0', STR_PAD_LEFT) }}@else RC{{ str_pad((string) $row->event_id, 6, '0', STR_PAD_LEFT) }} @endif Payment received @else WH{{ str_pad((string) $row->event_id, 6, '0', STR_PAD_LEFT) }}{{ $row->kind === 'initial' ? 'Payment with invoice' : 'Wholesale invoice' }} @endif {{ number_format($row->debit / 100, 2) }}{{ number_format($row->credit / 100, 2) }}{{ number_format($row->balance / 100, 2) }}
No transactions in this date range.
{{ $report['rows']->firstItem() ?? 0 }}–{{ $report['rows']->lastItem() ?? 0 }} of {{ $report['rows']->total() }}
@if($report['rows']->previousPageUrl())Previous@endif @if($report['rows']->nextPageUrl())Next@endif
@else

Choose a saved Party to view its ledger.

@endif @endsection