diff --git a/Http/Controllers/DailySalePaymentReportModuleController.php b/Http/Controllers/DailySalePaymentReportModuleController.php index 6b757c9..410016d 100644 --- a/Http/Controllers/DailySalePaymentReportModuleController.php +++ b/Http/Controllers/DailySalePaymentReportModuleController.php @@ -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) diff --git a/Resources/views/index.blade.php b/Resources/views/index.blade.php index 7c4fc76..b8b3ea5 100644 --- a/Resources/views/index.blade.php +++ b/Resources/views/index.blade.php @@ -174,9 +174,9 @@ Total - 0.00 + {{ number_format($creditTotals['grand_total'], 2) }} @foreach ($paymentOptions as $option) - 0.00 + {{ number_format($creditTotals['methods'][$option->id] ?? 0, 2) }} @endforeach