@php $i=$total=$dif=0; end($adata); $lastKey = key($adata); @endphp @foreach($adata as $k => $row) @php $i++; $total += round($row->amount,2); $rowamt = $row->amount; @endphp @if($k==$lastKey) @if($total > $amount) @php $dif = $total - $amount; $rowamt = $row->amount-$dif; @endphp @elseif($total < $amount) @php $dif = $amount - $total; $rowamt = $row->amount+$dif; @endphp @endif @endif @endforeach
#JV No. JV Date Amount Description
{{$i}} {{$row->jvno}} {{date('d-m-Y',strtotime($row->date))}} {{number_format($rowamt,2)}} {{$row->desc}}