@if(session()->has('success'))
{{ session()->get('success') }}
@endif
@php $sl = ($data->currentPage() - 1) * $data->perPage(); @endphp
@foreach($data AS $value)
@php
$opening = (float)($value->previous_due ?? 0);
$sales = (float)($value->total_sales ?? 0);
$purchases = (float)($value->total_purchases ?? 0);
$payment = (float)($value->total_collections ?? 0);
// Fetching purchase payments (amount paid to supplier)
$purchase_payments = (float)($value->total_purchase_payments ?? 0);
// New balance calculation formula
$balance = ($opening + $sales + $purchase_payments) - ($payment + $purchases);
$limit = (float)($value->credit_amount_limit ?? 0);
$isOverLimit = ($limit > 0 && $balance > $limit);
@endphp
| {!! ++$sl !!} |
{!! $value->name !!}
@if($isOverLimit)
@endif
|
{!! $value->mobile !!} |
{!! $value->address !!} |
@if($value->customer_type)
{!! $value->customer_type !!}
@else
Regular
@endif
|
{!! number_format($opening, 2) !!} |
{!! number_format($limit, 2) !!} |
{!! number_format($balance, 2) !!}
|
@if($value->id != 1)
@endif
|
@endforeach