تاریخ: {{ $b_cheque->date->format('d/m/Y') }}
محترمی جناب: {{ $b_cheque->supplier->supplier_name_urdu }}
حوالہ نمبر: {{ $b_cheque->bilty_no }}
گاڑی نمبر: {{ $b_cheque->goodReceiptTruck->truck_no }}
@php
$details = $b_cheque->details;
$maal = $b_cheque->items;
$totalBori = $maal->sum('bori');
$rows = collect([
(object) [
'item' => 'مزوری بوری',
'value' => number_format($details->labour_amount * $totalBori, 0) ?? '-',
],
(object) [
'item' => 'مزوری کَٹا',
'value' => number_format($details->total_katta * $details->labour_katta_amount, 0) ?? '-',
],
(object) ['item' => 'کرایہ محصول', 'value' => number_format($details->rent_recieve_amount, 0) ?? '-'],
(object) ['item' => 'مارکیٹ فیس', 'value' => number_format($details->market_fees_amount, 0) ?? '-'],
(object) ['item' => 'ڈاک خرج', 'value' => number_format($details->post_expense_amount, 0) ?? '-'],
(object) [
'item' => 'خرجہ متفرقات',
'value' => number_format($details->miscellaneous_expense_amount, 0) ?? '-',
],
(object) ['item' => 'نقد', 'value' => number_format($details->cash_amount, 0) ?? '-'],
(object) ['item' => 'کمیشن', 'value' => number_format($details->commission_amount, 0) ?? '-'],
]);
$prevChild = ['id' => null, 'name' => null];
$prevRate = null;
$prevMarka = null;
$sumBori = 0;
$sumWeight = 0;
$sumAmount = 0;
$bori = 0;
$weight = 0;
$total_amount = 0;
$printedItems = [];
$countIndex = 0;
$groupedData = []; // NEW: Store grouped data with correct marka
@endphp
| تفصیل خرج |
رقم |
مال |
بورے |
وزن |
بهاؤدر |
قیمت |
@foreach ($maal as $m)
@php
$currentChild = [
'id' => $m->child_cate,
'name' => is_array($m->productChildCate)
? $m->productChildCate['name_urdu']
: $m->productChildCate->name_urdu,
];
$currentRate = $m->rate;
$currentMarka = $m->marka;
$bori += $m->bori;
$weight += $m->weight;
$total_amount += $m->amount;
@endphp
@if ($prevChild['id'] === $currentChild['id'] && $prevRate === $currentRate && $prevMarka === $currentMarka)
@php
$sumBori += $m->bori;
$sumWeight += $m->weight;
$sumAmount += $m->amount;
@endphp
@else
@if ($prevChild['id'] !== null)
@php
// Store the grouped data with correct marka
$groupedData[] = [
'name' => $prevChild['name'],
'marka' => $prevMarka, // Correct marka stored here
'bori' => $sumBori,
'weight' => $sumWeight,
'rate' => $prevRate,
'amount' => $sumAmount,
'expense_item' => $rows[$countIndex]->item ?? '',
'expense_value' => $rows[$countIndex]->value ?? '',
];
$printedItems[] = $rows[$countIndex]->item ?? '';
$countIndex++;
@endphp
@endif
@php
$prevChild = $currentChild;
$prevRate = $currentRate;
$prevMarka = $currentMarka;
$sumBori = $m->bori;
$sumWeight = $m->weight;
$sumAmount = $m->amount;
@endphp
@endif
@endforeach
{{-- Last group --}}
@php
$groupedData[] = [
'name' => $prevChild['name'],
'marka' => $prevMarka, // Correct marka for last group
'bori' => $sumBori,
'weight' => $sumWeight,
'rate' => $prevRate,
'amount' => $sumAmount,
'expense_item' => $rows[$countIndex]->item ?? '',
'expense_value' => $rows[$countIndex]->value ?? '',
];
$printedItems[] = $rows[$countIndex]->item ?? '';
@endphp
{{-- Print all grouped data with correct marka --}}
@foreach ($groupedData as $group)
| {{ $group['expense_item'] }} |
{{ $group['expense_value'] }} |
{{ $group['name'] }} ({{ $group['marka'] }}) |
{{ $group['bori'] }} |
{{ $group['weight'] }} |
{{ number_format($group['rate'], 0) }} |
{{ number_format($group['amount'], 0) }} |
@endforeach
{{-- Print remaining rows without duplicates --}}
@foreach ($rows as $item)
@if (!in_array($item->item, $printedItems))
| {{ $item->item }} |
{{ $item->value }} |
|
|
|
|
|
@endif
@endforeach
{{-- Totals --}}
| کل خرجہ |
{{ number_format($details->total_expanse_amount, 0) }} |
|
|
|
|
|
|
|
|
{{ $bori }} |
{{ $weight }} |
|
|
| خام بکری |
{{ number_format($total_amount, 0) }} |
| کل خرجہ |
{{ number_format($details->total_expanse_amount, 0) }} |
| پختہ بکری |
{{ number_format($total_amount - $details->total_expanse_amount, 0) }} |