update total sales in dashboard

This commit is contained in:
efrilm 2025-10-15 18:55:35 +07:00
parent 3e0d75a4d0
commit cd784624c9

View File

@ -207,7 +207,7 @@ func (r *AnalyticsRepositoryImpl) GetDashboardOverview(ctx context.Context, orga
query := r.db.WithContext(ctx).
Table("orders o").
Select(`
COALESCE(SUM(CASE WHEN o.is_void = false THEN o.total_amount ELSE 0 END), 0) as total_sales,
COALESCE(SUM(CASE WHEN o.is_void = false AND o.is_refund = false AND o.payment_status = 'completed' THEN o.total_amount ELSE 0 END), 0) as total_sales,
COUNT(CASE WHEN o.is_void = false THEN o.id END) as total_orders,
CASE
WHEN COUNT(CASE WHEN o.is_void = false THEN o.id END) > 0