credit sale collection tfoot

This commit is contained in:
SUM2046
2026-07-03 15:51:47 +05:30
parent b7b2ba7b56
commit f8e6dbb81e
2 changed files with 21 additions and 4 deletions

View File

@@ -23,7 +23,18 @@ class DailySalePaymentReportModuleController extends Controller
->orderBy('id')
->get(['id', 'name']);
$creditCollections = $this->getCreditSaleCollections($report_date);
$creditCollections = $this->getCreditSaleCollections($report_date);
$creditTotals = [
'grand_total' => $creditCollections->sum('grand_total'),
'methods' => [],
];
foreach ($paymentOptions as $option) {
$creditTotals['methods'][$option->id] = $creditCollections->sum(
fn($row) => $row['methods'][$option->id] ?? 0
);
}
$sales = DB::table('sales')
@@ -97,7 +108,13 @@ class DailySalePaymentReportModuleController extends Controller
];
}
return view('dailysalepaymentreportmodule::index', compact('sales_data', 'report_date', 'paymentOptions', 'creditCollections'));
return view('dailysalepaymentreportmodule::index', compact(
'sales_data',
'report_date',
'paymentOptions',
'creditCollections',
'creditTotals',
));
}
private function getCreditSaleCollections($date)

View File

@@ -174,9 +174,9 @@
<tfoot style="background-color: #cdd4da; font-weight: bold;">
<tr>
<td colspan="4" class="text-right">Total</td>
<td>0.00</td>
<td>{{ number_format($creditTotals['grand_total'], 2) }}</td>
@foreach ($paymentOptions as $option)
<td>0.00</td>
<td>{{ number_format($creditTotals['methods'][$option->id] ?? 0, 2) }}</td>
@endforeach
</tr>
</tfoot>