feat: add negotiation price to marketing sales calculations and update header label for discounts

This commit is contained in:
Yoga Pangestu 2026-08-15 20:03:08 +07:00
parent dd3a2aa1eb
commit 25a316ccf0
2 changed files with 3 additions and 2 deletions

View File

@ -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();

View File

@ -1014,7 +1014,7 @@ export default function Analysis({
<th className="px-4 py-3 text-right font-medium text-muted-foreground">Produk Terjual</th>
<th className="px-4 py-3 text-right font-medium text-muted-foreground">Total Pendapatan</th>
<th className="px-4 py-3 text-right font-medium text-muted-foreground">Total Subtotal</th>
<th className="px-4 py-3 text-right font-medium text-muted-foreground">Total Diskon</th>
<th className="px-4 py-3 text-right font-medium text-muted-foreground">Total Diskon & Potongan Nego</th>
<th className="px-4 py-3 text-right font-medium text-muted-foreground">Rata-rata Order</th>
</tr>
</thead>