To: {{ $patron?->legal_name ?? $target_name }} @if($patron && $patron->addresses->isNotEmpty()) @php $pAddr = $patron->addresses->first(); @endphp {{ $pAddr->line_1 ?? '' }}@if($pAddr->line_2), {{ $pAddr->line_2 }}@endif
{{ $pAddr->city ?? '' }} - {{ $pAddr->zipcode ?? '' }}
@else , -
@endif GSTIN/UIN # : {{ $patron?->gstin ?? '' }}
Contact #: {{ $patron ? ($patron->mobile_number ?? ($patron->contacts?->first()?->mobile ?? '0')) : '0' }}
Address: {{ $plant->name ?? 'DEMO LOGIN' }} @if($plant && $plant->addresses->isNotEmpty()) @php $plAddr = $plant->addresses->first(); @endphp {{ $plAddr->line_1 ?? '' }}
@if($plAddr->line_2){{ $plAddr->line_2 }}
@endif {{ $plAddr->city ?? '' }}, {{ $plAddr->state->state_name ?? $plAddr->state_code ?? '' }} - {{ $plAddr->zipcode ?? '' }}
@else 3/150, Akkiyampatti (Po),
Sendamangalam (Tk),
Namakkal (Dt), Tamil Nadu - 637409
@endif GSTIN/UIN #: {{ $plant->gstin ?? '' }}
MSME - UDYAM- {{ $plant->msme_no ?? '' }}

Patron Statement of Accounts


{{ $start }} to {{ $end }}
@php // Net balance due calculation: $net_balance_due = $opening_balance; foreach($transactions as $trx) { $net_balance_due += ($trx['debit'] - $trx['credit']); } @endphp
Account Summary
Opening Balance {{ $opening_balance < 0 ? 'Cr' : 'Dr' }} ₹ {{ number_format(abs($opening_balance), 2) }}
Invoiced(Tax) {{ $invoiced_tax > 0 ? '₹ ' . number_format($invoiced_tax, 2) : '0' }}
Invoiced(Non-Tax) {{ $invoiced_nontax > 0 ? '₹ ' . number_format($invoiced_nontax, 2) : '0' }}
Total Invoiced Amount {{ ($invoiced_tax + $invoiced_nontax) > 0 ? '₹ ' . number_format($invoiced_tax + $invoiced_nontax, 2) : '0' }}
Sales Discount {{ $sales_discount > 0 ? '₹ ' . number_format($sales_discount, 2) : '0' }}
Purchased {{ $purchased > 0 ? '₹ ' . number_format($purchased, 2) : '0' }}
Amount Received {{ $amount_received > 0 ? '₹ ' . number_format($amount_received, 2) : '0' }}
Amount Paid {{ $amount_paid > 0 ? '₹ ' . number_format($amount_paid, 2) : '0' }}
Credits {{ $credits > 0 ? '₹ ' . number_format($credits, 2) : '0' }}
Balance Due {{ $net_balance_due < 0 ? 'Cr' : 'Dr' }} ₹ {{ number_format(abs($net_balance_due), 2) }}
@php $running_balance = $opening_balance; @endphp @foreach($transactions as $index => $trx) @php $running_balance += ($trx['debit'] - $trx['credit']); // Determine readable transaction name $trx_name = ''; $trx_type = ''; if ($trx['voucher_type'] == 'PURCHASE') { $trx_name = 'Bill'; $trx_type = 'Bills'; } elseif ($trx['voucher_type'] == 'SALES') { $trx_name = 'Invoice'; $trx_type = 'Invoices'; } elseif ($trx['voucher_type'] == 'PAYMENT') { $trx_name = 'Payment'; $trx_type = 'Payments'; } elseif ($trx['voucher_type'] == 'RECEIPT') { $trx_name = 'Receipt'; $trx_type = 'Receipts'; } else { $trx_name = ucfirst(strtolower($trx['voucher_type'])); $trx_type = $trx_name . 's'; } // Format details string $due_suffix = $trx['due_date'] ? "due on " . \Carbon\Carbon::parse($trx['due_date'])->format('Y-m-d') : ""; $details_str = "# " . $trx['voucher_no'] . ($due_suffix ? " - " . $due_suffix : "") . " /"; @endphp @endforeach
S/No Date Transactions Details Type Invoice/(Bill) (Receipt)/Payment Discount Balance
1 {{ $start }} ***Opening Balance*** / - @if($opening_balance < 0) (₹ {{ number_format(abs($opening_balance), 2) }}) @elseif($opening_balance > 0) ₹ {{ number_format($opening_balance, 2) }} @else 0 @endif 0 0 {{ $opening_balance < 0 ? 'Cr' : 'Dr' }} ₹ {{ number_format(abs($opening_balance), 2) }}
{{ $index + 2 }} {{ \Carbon\Carbon::parse($trx['date'])->format('d-m-Y') }} {{ $trx_name }} {{ $details_str }} {{ $trx_type }} @if($trx['voucher_type'] == 'PURCHASE') (₹ {{ number_format($trx['credit'], 2) }}) @elseif($trx['voucher_type'] == 'SALES') ₹ {{ number_format($trx['debit'], 2) }} @else 0 @endif @if($trx['voucher_type'] == 'RECEIPT') (₹ {{ number_format($trx['credit'], 2) }}) @elseif($trx['voucher_type'] == 'PAYMENT') ₹ {{ number_format($trx['debit'], 2) }} @else 0 @endif 0 {{ $running_balance < 0 ? 'Cr' : 'Dr' }} ₹ {{ number_format(abs($running_balance), 2) }}
Balance Due {{ $net_balance_due < 0 ? 'Cr' : 'Dr' }} ₹ {{ number_format(abs($net_balance_due), 2) }}