Add a shop sales dashboard with 30-day charts.

Portal Retail gets a Sales page for paid/fulfilled volume, daily bars, and top products so the storefront can show performance without a third-party analytics tool.

Closes #3
This commit is contained in:
2026-09-06 10:34:45 -05:00
parent b2029b6c0f
commit 9f2d349974
10 changed files with 513 additions and 1 deletions
+11
View File
@@ -9,6 +9,13 @@ from core.registry import (
def register() -> None:
register_feature("shop")
register_public_nav(section="shop", label="Shop", url_name="shop:list", order=30)
register_portal_nav(
section="shop_sales",
label="Sales",
url_name="shop_portal:sales",
group="Retail",
order=5,
)
register_portal_nav(
section="shop_products",
label="Products",
@@ -30,7 +37,9 @@ def _dashboard(request) -> dict:
from django.db.models import Q
from shop.models import Order, Product
from shop.stats import sales_summary
sales = sales_summary()
return {
"open_shop_orders": Order.objects.filter(
status__in=[Order.Status.OPEN, Order.Status.PAID]
@@ -43,4 +52,6 @@ def _dashboard(request) -> dict:
.filter(Q(colors__stock_qty__lte=3) | Q(colors__isnull=True, stock_qty__lte=3))
.distinct()
.count(),
"shop_sales_30d": sales["order_count"],
"shop_revenue_30d": sales["revenue"],
}