Add a shop sales dashboard with 30-day charts (#8)

## Summary
- Closes #7
- Portal Retail **Sales** page: 30-day orders/revenue/units/AOV, daily charts, top products
- Home dashboard cards for 30-day shop sales and revenue when `FEATURE_SHOP` is on
- Stacks on #6 (shop catalog). Merge that first, then retarget `master` if needed.

## Test plan
- [ ] Sales page requires login; empty state with no paid orders
- [ ] Paid/fulfilled in the last 30 days counted; draft/open/cancelled/old excluded
- [ ] Top products ranked by units; home dashboard shows 30-day sales count
- [ ] `manage.py test shop core.tests_features`

Reviewed-on: #8
This commit was merged in pull request #8.
This commit is contained in:
2026-09-06 14:00:04 -07:00
parent 80a5f5dadf
commit 23897b8b62
10 changed files with 514 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",
@@ -28,7 +35,9 @@ def register() -> None:
def _dashboard(request) -> dict:
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]
@@ -39,4 +48,6 @@ def _dashboard(request) -> dict:
fulfillment=Product.Fulfillment.STOCKED,
stock_qty__lte=3,
).count(),
"shop_sales_30d": sales["order_count"],
"shop_revenue_30d": sales["revenue"],
}