@php $grand_total_amount = 0; $grand_total_paid = 0; $grand_total_purchase = 0; $grand_total_due_amount = 0; @endphp @foreach ($transaction_purchases as $key => $purchase) @php $balance = abs($balances->where('account_id', $purchase->first()->account_id)->sum('debit_amount') - $balances->where('account_id', $purchase->first()->account_id)->sum('credit_amount')); $grand_total_paid += $total_paid = $purchase->sum('debit_amount'); $grand_total_purchase += $total_purchase = $purchase->sum('credit_amount'); $grand_total_amount += $total_amount = $balance + abs($purchase->sum('debit_amount') - $purchase->sum('credit_amount')); $grand_total_due_amount += $total_due_amount = abs($total_amount - $total_paid); @endphp @endforeach
Sl Supplier Payment Amount Purchase Amount Balance
{{ $loop->iteration }} {{ optional($purchase->first()->account)->name }} {{ number_format($total_paid, 2) }} {{ number_format($total_purchase, 2) }} {{ number_format($total_amount, 2) }}
Total {{ number_format($grand_total_paid, 2) }} {{ number_format($grand_total_purchase, 2) }} {{ number_format($grand_total_amount, 2) }}