@foreach ($parties as $party) @php $profit = $party->sales?->where('lossProfit', '>', 0)->sum('lossProfit') ?? 0; $loss = $party->sales?->where('lossProfit', '<', 0)->sum('lossProfit') ?? 0; @endphp @endforeach @if ($parties->count() > 0) @endif
{{ __('SL') }}. {{ __('Party Name') }} {{ __('Sale Amount') }} {{ __('Profit') }} {{ __('Loss') }} {{ __('Action') }}
{{ $parties->firstItem() + $loop->index }} {{ $party->name }} {{ currency_format($party->sales?->sum('totalAmount'), currency: business_currency()) }} {{ $profit > 0 ? currency_format($profit, currency: business_currency()) : currency_format(0, currency: business_currency()) }} {{ $loss < 0 ? currency_format(abs($loss), currency: business_currency()) : currency_format(0, currency: business_currency()) }}
{{__('Total')}} {{ currency_format($parties->sum(fn($party) => $party->sales?->sum('totalAmount') ?? 0), currency: business_currency()) }} {{ currency_format($parties->sum(fn($party) => $party->sales?->where('lossProfit', '>', 0)->sum('lossProfit') ?? 0), currency: business_currency()) }} {{ currency_format(abs($parties->sum(fn($party) => $party->sales?->where('lossProfit', '<', 0)->sum('lossProfit') ?? 0)), currency: business_currency()) }}
{{ $parties->links('vendor.pagination.bootstrap-5') }}