@php
$totalQty = collect($sales)->sum(function ($sale) {
return (float) preg_replace('/[^\d.\-]/', '', $sale['total_qty']);
});
$totalValue = collect($sales)->sum(function ($sale) {
return (float) preg_replace('/[^\d.\-]/', '', $sale['total_value']);
});
$totalCost = collect($sales)->sum(function ($sale) {
return (float) preg_replace('/[^\d.\-]/', '', $sale['total_cost']);
});
$totalProfit = collect($sales)->sum(function ($sale) {
return (float) preg_replace('/[^\d.\-]/', '', $sale['total_profit_loss']);
});
@endphp
| Date |
Bill No. |
Total Qty |
Sale Value |
Purchase Cost |
Profit/Loss |
Profit/Loss % |
Action |
@foreach ($sales as $sale)
{{-- Summary Row --}}
| {{ \Carbon\Carbon::parse($sale['date'])->format('d-m-Y') }} |
{{ $sale['bill_no'] }} |
{{ $sale['total_qty'] }} |
{{ $sale['total_value'] }} |
{{ $sale['total_cost'] }} |
{{ $sale['total_profit_loss'] }} |
{{ $sale['total_profit_percent'] }} |
|
{{-- Detail Items Row --}}
| Part No. |
Item Name |
Brand |
Qty
|
Sale Value |
Purchase Cost |
Profit/Loss |
Profit/Loss % |
@foreach ($sale['items'] as $item)
|
{{ $item['product_part_no'] }} |
{{ $item['item_name'] }} |
{{ $item['brand_name'] }} |
{{ $item['qty'] }} |
{{ $item['value'] }} |
{{ $item['cost'] }}
|
{{ $item['profit_loss'] }} |
{{ $item['profit_loss_percent'] }} |
@endforeach
|
@endforeach
Total Qty
{{ $totalQty }}
Sale Value
{{ $totalValue }}
Purchase Cost
{{ $totalCost }}
Total Profit/Loss
{{ $totalProfit }}
Total Profit/Loss %
{{ $totalValue > 0 ? number_format(($totalProfit / $totalValue) * 100, 2) . '%' : '0%' }}