@extends('users.layouts.index') @section('content')

Generate Statement

PDF
@if(session('error'))
{{ session('error') }}
@endif @if(isset($allTransactions))
purewellness logo

Purewellness

P.O. Box 47419 - 00100

Nairobi, Kenya 00100

Start Date: {{ date('F d, Y', strtotime($startDate)) }}

End Date: {{ date('F d, Y', strtotime($endDate)) }}

Account #: {{ $selectedMeter->meter_number ?? $meters->first()->meter_number ?? 'N/A' }}

STATEMENT

{{ auth('client')->user()->name }}

{{ auth('client')->user()->building }}

{{ auth('client')->user()->location }}.

@php $totalDebits = 0; $totalCredits = 0; $runningBalance = 0; @endphp @forelse($allTransactions as $transaction) @php $isDebit = $transaction->type === 'invoice'; $amount = $transaction->amount; if($isDebit) { $totalDebits += $amount; $runningBalance += $amount; } else { $totalCredits += $amount; $runningBalance -= $amount; } @endphp @empty @endforelse
Date Description Reference Debit Credit Balance
{{ date('F d, Y', strtotime($transaction->created_at)) }} {{ ucfirst($transaction->type) }} # {{ $transaction->reference_number }} {{ $isDebit ? 'Ksh ' . number_format($amount, 2) : '-' }} {{ !$isDebit ? 'Ksh ' . number_format($amount, 2) : '-' }} Ksh {{ number_format(abs($runningBalance), 2) }}
No transactions found for the selected period.
Total Debits Total Credits Amount Due
Ksh {{ number_format($totalDebits, 2) }} Ksh {{ number_format($totalCredits, 2) }} Ksh {{ number_format(max(0, $runningBalance), 2) }}
@else

Please select a date range and click VIEW to generate your statement.

@endif @endsection