@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') }}
{{ $loop->iteration }} {{ $party->name }} {{ currency_format($party->sales?->sum('totalAmount'), currency: business_currency()) }} {{ $profit > 0 ? currency_format($profit, currency: business_currency()) : 0 }} {{ $loss < 0 ? currency_format(abs($loss), currency: business_currency()) : 0 }}
{{__('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()) }}