diff --git a/local_backend/routers/business_day.py b/local_backend/routers/business_day.py
index fab265a..da50ee4 100644
--- a/local_backend/routers/business_day.py
+++ b/local_backend/routers/business_day.py
@@ -1,3 +1,4 @@
+from core.access.deps import require
from core.timeutil import business_date_of, parse_api_datetime, utcnow
from fastapi import APIRouter, Depends, status
from sqlalchemy import func
@@ -209,7 +210,7 @@ def patch_business_day(
def delete_business_day(
day_id: int,
db: Session = Depends(get_db),
- user: User = Depends(require_manager),
+ user: User = Depends(require("core.settings.manage")),
):
"""Permanently delete a business day. Only allowed when it has no shifts."""
day = db.query(BusinessDay).filter(BusinessDay.id == day_id).first()
diff --git a/local_backend/routers/shifts.py b/local_backend/routers/shifts.py
index 7c66bc6..43ed30d 100644
--- a/local_backend/routers/shifts.py
+++ b/local_backend/routers/shifts.py
@@ -1,3 +1,4 @@
+from core.access.deps import require
from core.access.check import holds
from core.timeutil import utcnow
from fastapi import APIRouter, Depends, status
@@ -391,7 +392,7 @@ def get_shift(
def delete_shift(
shift_id: int,
db: Session = Depends(get_db),
- user: User = Depends(require_manager),
+ user: User = Depends(require("core.settings.manage")),
):
"""Permanently delete a shift, its breaks, and all orders opened during that shift."""
from models.order import Order, OrderItem, OrderAuditLog, OrderWaiter
diff --git a/manager_dashboard/src/App.jsx b/manager_dashboard/src/App.jsx
index caf5c9e..f1d369a 100644
--- a/manager_dashboard/src/App.jsx
+++ b/manager_dashboard/src/App.jsx
@@ -46,9 +46,9 @@ import StockPage from './pages/inventory/StockPage'
// Reports
import TodayPage from './pages/reports/today/TodayReport'
-import StorePage from './pages/reports/StorePage'
+import StorePage from './pages/reports/store/StorePage'
import StaffReportPage from './pages/reports/StaffReportPage'
-import ProductsReportPage from './pages/reports/ProductsReportPage'
+import ProductsReportPage from './pages/reports/products/ProductsReport'
import PrepZonesPage from './pages/reports/PrepZonesPage'
import ExpensesReportPage from './pages/reports/ExpensesReportPage'
import TechnicalPage from './pages/reports/TechnicalPage'
diff --git a/manager_dashboard/src/pages/reports/ProductsReportPage.jsx b/manager_dashboard/src/pages/reports/ProductsReportPage.jsx
deleted file mode 100644
index b99754b..0000000
--- a/manager_dashboard/src/pages/reports/ProductsReportPage.jsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { useState } from 'react'
-import { TabBar } from '../../ui/Tabs'
-import ProductPerformance from './restaurant/ProductPerformance'
-import CategoryPerformance from './restaurant/CategoryPerformance'
-
-const TABS = [
- { id: 'products', label: 'Απόδοση Προϊόντων', Component: ProductPerformance },
- { id: 'categories', label: 'Κατηγορίες', Component: CategoryPerformance },
-]
-
-export default function ProductsReportPage() {
- const [active, setActive] = useState('products')
- const tab = TABS.find(t => t.id === active) || TABS[0]
- const { Component } = tab
-
- return (
-
- )
-}
diff --git a/manager_dashboard/src/pages/reports/StorePage.jsx b/manager_dashboard/src/pages/reports/StorePage.jsx
deleted file mode 100644
index 2e1bba4..0000000
--- a/manager_dashboard/src/pages/reports/StorePage.jsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { useState } from 'react'
-import { TabBar } from '../../ui/Tabs'
-import WorkDaySummary from './restaurant/WorkDaySummary'
-import OrderHistory from './restaurant/OrderHistory'
-import TrafficAnalytics from './restaurant/TrafficAnalytics'
-import RevenueTrends from './restaurant/RevenueTrends'
-import TableAnalytics from './restaurant/TableAnalytics'
-
-const TABS = [
- { id: 'workday', label: 'Ημέρες Λειτουργίας', Component: WorkDaySummary },
- { id: 'orders', label: 'Ιστορικό Παραγγελιών', Component: OrderHistory },
- { id: 'traffic', label: 'Κίνηση', Component: TrafficAnalytics },
- { id: 'trends', label: 'Τάσεις Εσόδων', Component: RevenueTrends },
- { id: 'tables', label: 'Τραπέζια', Component: TableAnalytics },
-]
-
-export default function StorePage() {
- const [active, setActive] = useState('workday')
- const tab = TABS.find(t => t.id === active) || TABS[0]
- const { Component } = tab
-
- return (
-
- )
-}
diff --git a/manager_dashboard/src/pages/reports/kit/HourChart.jsx b/manager_dashboard/src/pages/reports/kit/HourChart.jsx
index f4e8ca6..c80e095 100644
--- a/manager_dashboard/src/pages/reports/kit/HourChart.jsx
+++ b/manager_dashboard/src/pages/reports/kit/HourChart.jsx
@@ -15,7 +15,7 @@ export default function HourChart({ series, nowHour = null, height = 220 }) {
formatMoney(v, { decimals: 0 })} width={56} />
formatMoney(v)}
contentStyle={{ background: 'var(--x-surface)', border: '1px solid var(--x-line)', borderRadius: 8, color: 'var(--x-ink)' }} />
-
+
{data.map(d => nowHour ? 'var(--x-surface-3)' : 'var(--x-accent)'} />)}
|
diff --git a/manager_dashboard/src/pages/reports/kit/PrintDialog.jsx b/manager_dashboard/src/pages/reports/kit/PrintDialog.jsx
new file mode 100644
index 0000000..f0ebc8d
--- /dev/null
+++ b/manager_dashboard/src/pages/reports/kit/PrintDialog.jsx
@@ -0,0 +1,58 @@
+// Print a report on a receipt printer (plan step 6.12b; replaces the v1 print modals): which
+// printer, and "Summary" (only what sold) or "Full" (every product, unsold ones too). The
+// printout uses the same numbers as the screen (backend services/sales.py). "Print this page"
+// uses the browser (to paper or a PDF).
+import { useState } from 'react'
+import toast from 'react-hot-toast'
+import { Printer } from 'lucide-react'
+import { errorMessage } from '@xenia/api'
+import { useTranslation } from '@xenia/i18n'
+import { Button, Dialog, Field, Select, cx } from '@xenia/ui'
+import client from '../../../api/client'
+import { useLiveQuery } from '../../../live/useLiveQuery'
+
+export default function PrintDialog({ endpoint, body, modes = ['smart', 'full'], onClose }) {
+ const { t } = useTranslation('manager')
+ const { data: printers = [] } = useLiveQuery({ queryKey: ['meta-printers'], queryFn: () => client.get('/api/reports/meta/printers').then(r => r.data.printers), staleTime: 300_000 })
+ const [printer, setPrinter] = useState('')
+ const [mode, setMode] = useState(modes[0])
+ const [busy, setBusy] = useState(false)
+ const chosen = printer || (printers[0] ? String(printers[0].id) : '')
+
+ async function send() {
+ setBusy(true)
+ try {
+ await client.post(endpoint, { ...body, printer_id: Number(chosen), mode })
+ toast.success(t('reports.print.sent'))
+ onClose()
+ } catch (err) { toast.error(errorMessage(err, t)) } finally { setBusy(false) }
+ }
+
+ return (
+
+ )
+}
diff --git a/manager_dashboard/src/pages/reports/kit/charts.jsx b/manager_dashboard/src/pages/reports/kit/charts.jsx
new file mode 100644
index 0000000..1c0b6a8
--- /dev/null
+++ b/manager_dashboard/src/pages/reports/kit/charts.jsx
@@ -0,0 +1,45 @@
+// The reports' charts on the tokens (plan step 6.12b): a revenue (and profit) line over dates,
+// and bar lists (top products, weekdays, categories' share) drawn with plain CSS, so they read
+// in both themes and print.
+import { CartesianGrid, Legend, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
+import { useFormat, useTranslation } from '@xenia/i18n'
+import { cx } from '@xenia/ui'
+
+/** points: [{ label, revenue, profit? }] */
+export function TrendChart({ points, showProfit = false, height = 240 }) {
+ const { t } = useTranslation('manager')
+ const { formatMoney } = useFormat()
+ return (
+
+
+
+
+
+ formatMoney(v, { decimals: 0 })} width={64} />
+ formatMoney(v)} contentStyle={{ background: 'var(--x-surface)', border: '1px solid var(--x-line)', borderRadius: 8, color: 'var(--x-ink)' }} />
+ {showProfit && }
+
+ {showProfit && }
+
+
+
+ )
+}
+
+/** rows: [{ key, label, value, sub? }] → horizontal bars scaled to the largest; `format` for the value. */
+export function BarList({ rows, format = v => v, highlight, testId }) {
+ const max = Math.max(1e-9, ...rows.map(r => r.value))
+ return (
+
+ {rows.map(r => (
+ -
+ {r.label}
+
+
+
+ {format(r.value)}{r.sub ? · {r.sub} : null}
+
+ ))}
+
+ )
+}
diff --git a/manager_dashboard/src/pages/reports/kit/reportLogic.js b/manager_dashboard/src/pages/reports/kit/reportLogic.js
index ad93d98..4da754d 100644
--- a/manager_dashboard/src/pages/reports/kit/reportLogic.js
+++ b/manager_dashboard/src/pages/reports/kit/reportLogic.js
@@ -26,6 +26,12 @@ export function periodParams(p) {
return out
}
+/** A period → the body of a receipt-printer report (POST /api/reports/print/*). */
+export function printBody(p) {
+ const q = periodParams(p)
+ return { business_day_id: q.business_day_id ? Number(q.business_day_id) : null, from_dt: q.from ?? null, to_dt: q.to ?? null }
+}
+
/** A period's part of a file name: "2026-11-01_2026-11-19" or "day-12". */
export const periodSlug = p => (p.mode === 'day' ? `day-${p.dayId || 'all'}` : `${p.from}_${p.to}`)
diff --git a/manager_dashboard/src/pages/reports/products/ProductsReport.jsx b/manager_dashboard/src/pages/reports/products/ProductsReport.jsx
new file mode 100644
index 0000000..5516260
--- /dev/null
+++ b/manager_dashboard/src/pages/reports/products/ProductsReport.jsx
@@ -0,0 +1,137 @@
+// Reports → Products (plan step 6.12b; replaces the v1 product and category performance views):
+// what sold, by product and by category, net of refunds (the delivery fee is not a product),
+// with cost, profit and margin where products have a cost, and waste; top products as bars;
+// export and print on a receipt printer.
+import { useState } from 'react'
+import { Printer } from 'lucide-react'
+import { useFormat, useTranslation } from '@xenia/i18n'
+import { Button, Select } from '@xenia/ui'
+import client from '../../../api/client'
+import { useLiveQuery } from '../../../live/useLiveQuery'
+import { BarList } from '../kit/charts'
+import { ExportButton, Failed, Loading, MoneyCell, Panel, ReportPage, Stat, Table } from '../kit/parts'
+import { PeriodPicker } from '../kit/Period'
+import PrintDialog from '../kit/PrintDialog'
+import { defaultPeriod, margin, periodParams, periodSlug, printBody, ratio } from '../kit/reportLogic'
+
+export default function ProductsReport() {
+ const { t } = useTranslation('manager')
+ const tabs = [
+ { id: 'products', label: t('reports.products'), Component: ProductsTab },
+ { id: 'categories', label: t('reports.prod.categories'), Component: CategoriesTab },
+ ]
+ return
+}
+
+const METRICS = ['revenue', 'qty_sold', 'trackable_profit']
+
+function ProductsTab() {
+ const { t } = useTranslation('manager')
+ const fmt = useFormat()
+ const [period, setPeriod] = useState(() => defaultPeriod(fmt.venueToday()))
+ const [category, setCategory] = useState('')
+ const [metric, setMetric] = useState('revenue')
+ const [printing, setPrinting] = useState(false)
+ const params = { ...periodParams(period), ...(category ? { category_id: category } : {}) }
+ const { data, isPending, error, refetch } = useLiveQuery({ queryKey: ['report-products', params], queryFn: () => client.get('/api/reports/products/performance', { params }).then(r => r.data.products) })
+ const { data: cats = [] } = useLiveQuery({ queryKey: ['categories'], queryFn: () => client.get('/api/products/categories').then(r => r.data), staleTime: 60_000 })
+ const rows = data ?? []
+ const sold = rows.filter(r => r.qty_sold > 0)
+ const total = sold.reduce((s, r) => s + r.revenue, 0)
+ const units = sold.reduce((s, r) => s + r.qty_sold, 0)
+ const refunded = rows.reduce((s, r) => s + (r.refunded ?? 0), 0)
+ const profit = rows.reduce((s, r) => s + r.trackable_profit, 0)
+ const anyCost = rows.some(r => r.total_cost > 0)
+ const gap = rows.some(r => r.has_gap)
+ const anyWaste = rows.some(r => r.waste_qty > 0)
+ const qty = q => fmt.formatNumber(q, { maxDecimals: 3 })
+ const columns = [
+ { key: 'product_name', label: t('reports.prod.product'), render: r => {r.product_name} },
+ { key: 'qty_sold', label: t('reports.prod.units'), align: 'right', render: r => qty(r.qty_sold) },
+ { key: 'revenue', label: t('reports.revenue'), align: 'right', render: r => fmt.formatMoney(r.revenue) },
+ { key: 'refunded', label: t('reports.refunded'), align: 'right', render: r => (r.refunded ? {fmt.formatMoney(r.refunded)} : '') },
+ ...(anyCost ? [
+ { key: 'total_cost', label: t('reports.cost'), align: 'right', render: r => (r.total_cost ? fmt.formatMoney(r.total_cost) : '') },
+ { key: 'trackable_profit', label: t('reports.profit'), align: 'right', render: r => (r.total_cost ? : '') },
+ { key: 'margin', label: t('reports.prod.margin'), align: 'right', sort: r => margin(r.trackable_profit, r.revenue - r.uncosted_revenue),
+ render: r => { const m = margin(r.trackable_profit, r.revenue - r.uncosted_revenue); return m != null && r.total_cost ? fmt.formatPercent(m, { maxDecimals: 0 }) : '' } },
+ ] : []),
+ ...(anyWaste ? [{ key: 'waste_qty', label: t('reports.prod.waste'), align: 'right', tip: t('reports.prod.wasteTip'),
+ render: r => (r.waste_qty ? `${qty(r.waste_qty)}${r.waste_cost ? ` · ${fmt.formatMoney(r.waste_cost)}` : ''}` : '') }] : []),
+ { key: 'share', label: t('reports.prod.share'), align: 'right', sort: r => r.revenue, render: r => fmt.formatPercent(ratio(r.revenue, total), { maxDecimals: 1 }) },
+ { key: 'order_count', label: t('reports.orders'), align: 'right' },
+ ]
+ const top = [...sold].sort((a, b) => (b[metric] ?? 0) - (a[metric] ?? 0)).slice(0, 10)
+
+ return (
+
+
+
+ } onClick={() => setPrinting(true)}>{t('reports.print.button')}
+ } />
+