From 25a316ccf0ac9837e8717dba938cf58fa403b816 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Sat, 15 Aug 2026 20:03:08 +0700 Subject: [PATCH] feat: add negotiation price to marketing sales calculations and update header label for discounts --- app/Services/AnalysisService.php | 3 ++- resources/js/pages/admin/analysis/index.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Services/AnalysisService.php b/app/Services/AnalysisService.php index ce27df9..1801bd0 100644 --- a/app/Services/AnalysisService.php +++ b/app/Services/AnalysisService.php @@ -745,6 +745,7 @@ public function getMarketingSales(?string $startDate, ?string $endDate, ?User $u ->selectRaw('COALESCE(SUM(orders.total_amount), 0) as total_revenue') ->selectRaw('COALESCE(SUM(orders.subtotal), 0) as total_subtotal') ->selectRaw('COALESCE(SUM(orders.discount), 0) as total_discount') + ->selectRaw('COALESCE(SUM(orders.nego_price), 0) as total_nego_price') ->groupBy('orders.marketing_id', 'user_profiles.full_name') ->get(); @@ -764,7 +765,7 @@ public function getMarketingSales(?string $startDate, ?string $endDate, ?User $u 'total_products_sold' => (int) ($productCounts[$item->marketing_id] ?? 0), 'total_revenue' => $totalRevenue, 'total_subtotal' => (int) $item->total_subtotal, - 'total_discount' => (int) $item->total_discount, + 'total_discount' => (int) $item->total_discount + (int) $item->total_nego_price, 'avg_order' => $totalOrders > 0 ? (int) ($totalRevenue / $totalOrders) : 0, ]; })->toArray(); diff --git a/resources/js/pages/admin/analysis/index.tsx b/resources/js/pages/admin/analysis/index.tsx index 3d66f7e..0d1ae15 100644 --- a/resources/js/pages/admin/analysis/index.tsx +++ b/resources/js/pages/admin/analysis/index.tsx @@ -1014,7 +1014,7 @@ export default function Analysis({ Produk Terjual Total Pendapatan Total Subtotal - Total Diskon + Total Diskon & Potongan Nego Rata-rata Order