Files

66 lines
4.2 KiB
PHP
Raw Permalink Normal View History

2026-03-15 17:08:23 +07:00
<div class="responsive-table m-0">
<table class="table" id="datatable">
<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>
<th class="d-print-none">{{ __('Action') }}</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>{{ $parties->firstItem() + $loop->index }}</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 {{ $profit > 0 ? 'text-success' : '' }}">{{ $profit > 0 ? currency_format($profit, currency: business_currency()) : currency_format(0, currency: business_currency()) }}</td>
<td class="text-start {{ $loss < 0 ? 'text-danger' : '' }}">{{ $loss < 0 ? currency_format(abs($loss), currency: business_currency()) : currency_format(0, currency: business_currency()) }}</td>
<td class="d-print-none">
<div class="dropdown table-action">
<button type="button" data-bs-toggle="dropdown">
<i class="far fa-ellipsis-v"></i>
</button>
<ul class="dropdown-menu">
<li>
<a href="#" class="view-party-loss-profit-btn" data-bs-toggle="modal" data-bs-target="#view-party-loss-profit-modal"
data-url="{{ route('business.party-loss-profit.view', $party->id) }}">
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16.158 8.28375C16.386 8.60348 16.5 8.76338 16.5 9C16.5 9.23662 16.386 9.39652 16.158 9.71625C15.1334 11.1529 12.5169 14.25 9 14.25C5.48309 14.25 2.86657 11.1529 1.84203 9.71625C1.61401 9.39652 1.5 9.23662 1.5 9C1.5 8.76338 1.61401 8.60348 1.84203 8.28375C2.86657 6.84708 5.48309 3.75 9 3.75C12.5169 3.75 15.1334 6.84708 16.158 8.28375Z" stroke="#4B5563" stroke-width="1.2"/>
<path d="M11.25 9C11.25 7.75732 10.2427 6.75 9 6.75C7.75732 6.75 6.75 7.75732 6.75 9C6.75 10.2427 7.75732 11.25 9 11.25C10.2427 11.25 11.25 10.2427 11.25 9Z" stroke="#4B5563" stroke-width="1.2"/>
</svg>
{{ __('View Details') }}
</a>
</li>
</ul>
</div>
</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>
</div>
<div class="mt-3">
{{ $parties->links('vendor.pagination.bootstrap-5') }}
</div>