Files

42 lines
2.0 KiB
PHP

<table>
<thead>
<tr>
<th>{{ __('SL') }}.</th>
<th class="text-start">{{ __('Party Name') }}</th>
<th class="text-start">{{ __('Sale Amount') }}</th>
<th class="text-start">{{ __('Profit') }}</th>
<th class="text-start">{{ __('Loss') }}</th>
</tr>
</thead>
<tbody>
@foreach ($parties as $party)
@php
$profit = $party->sales?->where('lossProfit', '>', 0)->sum('lossProfit') ?? 0;
$loss = $party->sales?->where('lossProfit', '<', 0)->sum('lossProfit') ?? 0;
@endphp
<tr>
<td>{{ $loop->iteration }}</td>
<td class="text-start">{{ $party->name }}</td>
<td class="text-start">{{ currency_format($party->sales?->sum('totalAmount'), currency: business_currency()) }}</td>
<td class="text-start text-success">{{ $profit > 0 ? currency_format($profit, currency: business_currency()) : 0 }}</td>
<td class="text-start text-danger">{{ $loss < 0 ? currency_format(abs($loss), currency: business_currency()) : 0 }}</td>
</tr>
@endforeach
</tbody>
@if ($parties->count() > 0)
<tr>
<td class="text-start fw-bold">{{__('Total')}}</td>
<td></td>
<td class="text-start fw-bold">{{ currency_format($parties->sum(fn($party) => $party->sales?->sum('totalAmount') ?? 0), currency: business_currency()) }}</td>
<td class="text-start fw-bold">
{{ currency_format($parties->sum(fn($party) => $party->sales?->where('lossProfit', '>', 0)->sum('lossProfit') ?? 0), currency: business_currency()) }}
</td>
<td class="text-start fw-bold text-danger">
{{ currency_format(abs($parties->sum(fn($party) => $party->sales?->where('lossProfit', '<', 0)->sum('lossProfit') ?? 0)), currency: business_currency()) }}
</td>
<td></td>
</tr>
@endif
</table>