feat: one way to count sales in every report; exports for Excel; the report kit and Today on v2 (platform-v2 step 6.12a)
- services/sales.py: sold = active + paid lines; a line's value net of what
was refunded of it; system lines (the delivery fee) counted apart as fees;
cost/profit with has_gap. Products, categories, tables, traffic, revenue
trends, business days (list and current), per-waiter sales, order history
totals and the printed products/categories/tables reports all use it (they
used to differ: closed-only vs all orders, fee as a product, refunds never
subtracted)
- the overview's day summary values lines with their price change (discounts
were valued at full price)
- services/csv_export.py: UTF-8 BOM, times in venue time with the zone in the
header, ';' and decimal commas for a Greek venue (',' and '.' otherwise);
every report export uses it; orders export has products / fees / refunded
- fix: /api/reports/shift/orders with business_day_id crashed (no window)
- manager: src/pages/reports/kit (page with tabs, period picker, panels,
figures, sortable table, export button, order dialog reusing the order
page's parts, hour chart on tokens) and reports/today on it; v1 Today removed
- tests: test_sales_accounting.py (a day with a fee and a partial refund adds
up the same in every report), test_reports_export.py (Excel format),
reports.test.mjs, e2e manager.mjs (Today, order dialog, export, Greek)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1161,6 +1161,34 @@ try {
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-schedule.png'), fullPage: true })
|
||||
await page.keyboard.press('Escape')
|
||||
|
||||
// ── 6.12a: Reports → Today on the kit; an export for Excel ──────────────────
|
||||
const rp = 'reports:'
|
||||
const current = (await api('GET', '/api/reports/business-days/current', { token: boss })).business_day
|
||||
await page.goto(`${APP}/reports/today`)
|
||||
const todayRevenue = page.getByTestId('today-revenue')
|
||||
await todayRevenue.waitFor({ timeout: 10_000 }).catch(() => {})
|
||||
r.check(`${rp} Today shows the day's revenue as the backend counts it`, !!current
|
||||
&& (await todayRevenue.textContent()).replace(/[\s,]/g, '').includes(current.revenue.toFixed(2)), `${current?.revenue} vs ${await todayRevenue.textContent().catch(() => '')}`)
|
||||
const firstOrder = page.getByTestId('today-order').first()
|
||||
if (await firstOrder.waitFor({ timeout: 8000 }).then(() => true).catch(() => false)) {
|
||||
await firstOrder.click()
|
||||
r.check(`${rp} an order opens with its lines and totals`, await page.getByTestId('report-order-dialog').waitFor({ timeout: 8000 }).then(() => true).catch(() => false)
|
||||
&& await page.getByTestId('order-dialog-totals').count() === 1)
|
||||
await page.keyboard.press('Escape')
|
||||
}
|
||||
const [download] = await Promise.all([page.waitForEvent('download', { timeout: 10_000 }), page.getByTestId('report-export').click()])
|
||||
const csvText = (await import('node:fs')).readFileSync(await download.path(), 'utf8')
|
||||
r.check(`${rp} the export is for Excel: UTF-8 mark, times in venue time with the zone in the header`,
|
||||
csvText.charCodeAt(0) === 0xFEFF && csvText.split(/\r?\n/)[0].includes('opened_at (Europe/Athens)') && /\d{4}-\d\d-\d\d \d\d:\d\d/.test(csvText), csvText.slice(0, 160))
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-report-today.png'), fullPage: true })
|
||||
await page.getByTestId('user-menu').click()
|
||||
await page.getByRole('menuitemradio', { name: 'Ελληνικά' }).click()
|
||||
await page.waitForFunction(() => document.querySelector('[data-testid="report-today"] h1')?.textContent === 'Σήμερα', null, { timeout: 5000 }).catch(() => {})
|
||||
r.check(`${rp} Today in Greek`, (await page.locator('[data-testid="report-today"] h1').textContent()) === 'Σήμερα' && (await todayRevenue.textContent()).includes('Έσοδα'))
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-report-today-el.png'), fullPage: true })
|
||||
await page.getByTestId('user-menu').click()
|
||||
await page.getByRole('menuitemradio', { name: 'English' }).click()
|
||||
|
||||
await api('PUT', '/api/platform/modules/connect_orders', { token: boss, body: { enabled: true } })
|
||||
await page.goto(`${APP}/online-orders`)
|
||||
await page.getByTestId('online-orders').waitFor({ timeout: 10_000 }).catch(() => {})
|
||||
|
||||
Reference in New Issue
Block a user