Template
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 FEATURE_SHOP sites can see store performance without a third-party analytics tool. Closes #7
This commit is contained in:
@@ -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"],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user