Implement dynamic payment columns for Table 1
This commit is contained in:
@@ -80,26 +80,21 @@
|
||||
<th>Cashier</th>
|
||||
<th>Customer</th>
|
||||
<th>Grand Total</th>
|
||||
<th>Cash</th>
|
||||
<th>Card 1</th>
|
||||
<th>Card 2</th>
|
||||
<th>Card 3</th>
|
||||
<th>Online Transfer</th>
|
||||
<th>Link Pay</th>
|
||||
@foreach($paymentOptions as $option)
|
||||
<th>{{ $option->name }}</th>
|
||||
@endforeach
|
||||
<th>Due Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
// යටින් පෙන්නන්න ඕන එකතුවට බින්දුවෙන් විචල්යයන් හදාගන්නවා
|
||||
$tot_grand = 0;
|
||||
$tot_cash = 0;
|
||||
$tot_card1 = 0;
|
||||
$tot_card2 = 0;
|
||||
$tot_card3 = 0;
|
||||
$tot_online = 0;
|
||||
$tot_link = 0;
|
||||
$tot_due = 0;
|
||||
// Initialize dynamic option totals
|
||||
$option_totals = [];
|
||||
foreach ($paymentOptions as $opt) {
|
||||
$option_totals[$opt->id] = 0;
|
||||
}
|
||||
@endphp
|
||||
|
||||
@foreach ($sales_data as $sale)
|
||||
@@ -109,25 +104,22 @@
|
||||
<td>{{ $sale->cashier }}</td>
|
||||
<td>{{ $sale->customer }}</td>
|
||||
<td class="text-right">{{ number_format($sale->grand_total, 2) }}</td>
|
||||
<td class="text-right">{{ number_format($sale->cash, 2) }}</td>
|
||||
<td class="text-right">{{ number_format($sale->card1, 2) }}</td>
|
||||
<td class="text-right">{{ number_format($sale->card2, 2) }}</td>
|
||||
<td class="text-right">{{ number_format($sale->card3, 2) }}</td>
|
||||
<td class="text-right">{{ number_format($sale->online_transfer, 2) }}</td>
|
||||
<td class="text-right">{{ number_format($sale->link_pay, 2) }}</td>
|
||||
|
||||
@foreach($paymentOptions as $option)
|
||||
<td class="text-right">{{ number_format($sale->methods[$option->id] ?? 0, 2) }}</td>
|
||||
@endforeach
|
||||
|
||||
<td class="text-right">{{ number_format($sale->due_amount, 2) }}</td>
|
||||
</tr>
|
||||
|
||||
@php
|
||||
// ටේබල් එක යටින් පෙන්වන්න ඔක්කොම එකතු කරනවා
|
||||
$tot_grand += $sale->grand_total;
|
||||
$tot_cash += $sale->cash;
|
||||
$tot_card1 += $sale->card1;
|
||||
$tot_card2 += $sale->card2;
|
||||
$tot_card3 += $sale->card3;
|
||||
$tot_online += $sale->online_transfer;
|
||||
$tot_link += $sale->link_pay;
|
||||
$tot_due += $sale->due_amount;
|
||||
|
||||
// Accumulate dynamic option totals
|
||||
foreach ($paymentOptions as $opt) {
|
||||
$option_totals[$opt->id] += ($sale->methods[$opt->id] ?? 0);
|
||||
}
|
||||
@endphp
|
||||
@endforeach
|
||||
</tbody>
|
||||
@@ -135,12 +127,11 @@
|
||||
<tr>
|
||||
<td colspan="4" class="text-right">Total</td>
|
||||
<td class="text-right">{{ number_format($tot_grand, 2) }}</td>
|
||||
<td class="text-right">{{ number_format($tot_cash, 2) }}</td>
|
||||
<td class="text-right">{{ number_format($tot_card1, 2) }}</td>
|
||||
<td class="text-right">{{ number_format($tot_card2, 2) }}</td>
|
||||
<td class="text-right">{{ number_format($tot_card3, 2) }}</td>
|
||||
<td class="text-right">{{ number_format($tot_online, 2) }}</td>
|
||||
<td class="text-right">{{ number_format($tot_link, 2) }}</td>
|
||||
|
||||
@foreach($paymentOptions as $option)
|
||||
<td class="text-right">{{ number_format($option_totals[$option->id], 2) }}</td>
|
||||
@endforeach
|
||||
|
||||
<td class="text-right">{{ number_format($tot_due, 2) }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
Reference in New Issue
Block a user