Files

44 lines
1.8 KiB
PHP

<table>
<thead>
<tr>
<th>{{ __('SL') }}.</th>
<th>{{ __('Product') }}</th>
<th>{{ __('Code') }}</th>
<th>{{ __('Category') }}</th>
<th>{{ __('Cost') }}</th>
<th>{{ __('Qty') }}</th>
<th>{{ __('Sale') }}</th>
<th>{{ __('Stock Value') }}</th>
</tr>
</thead>
<tbody>
@foreach ($products as $product)
@php
$total_stock = $product->stocks->sum('productStock');
$firstStock = $product->stocks->first();
$total_value = $product->stocks->sum(function ($stock) {
return $stock->productPurchasePrice * $stock->productStock;
});
@endphp
<tr>
<td>{{ $loop->index + 1 }}</td>
<td>{{ $product->productName }}</td>
<td class="text-start">{{ $product->productCode }}</td>
<td class="text-start">{{ $product->category->categoryName ?? '' }}</td>
@usercan('stocks.price')
<td class="text-start">
{{ currency_format(optional($firstStock)->productPurchasePrice, currency: business_currency()) }}
</td>
@endusercan
<td class="{{ $total_stock <= $product->alert_qty ? 'text-danger' : 'text-success' }} text-start">
{{ $total_stock }}
</td>
<td class="text-center">
{{ currency_format(optional($firstStock)->productSalePrice, currency: business_currency()) }}
</td>
<td class="text-end">{{ currency_format($total_value, currency: business_currency()) }}</td>
</tr>
@endforeach
</tbody>
</table>