admin: fix timestamps, per-day stats, reset, delete drinks/bars
- store created_at as UTC ISO; display/group in Europe/Berlin - stats grouped by business day (sales night past midnight, 5am cutoff) - add "Statistik zurücksetzen" - allow deleting drinks/tresen (refused if referenced by sales) - CSV exports local wall-clock time
This commit is contained in:
parent
22577a0a65
commit
40cdc98f82
1 changed files with 210 additions and 9 deletions
|
|
@ -108,8 +108,8 @@ export function registerPublicRoutes(app: FastifyInstance, db: DB) {
|
|||
const clientIp = req.ip ?? null;
|
||||
|
||||
const insertTx = db.prepare(
|
||||
`INSERT INTO transactions (bar_id, total_cents, crew, pfand_returns, client_ip, client_uuid)
|
||||
VALUES (?, ?, ?, ?, ?, ?)`
|
||||
`INSERT INTO transactions (bar_id, created_at, total_cents, crew, pfand_returns, client_ip, client_uuid)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)`
|
||||
);
|
||||
const insertItem = db.prepare(
|
||||
`INSERT INTO transaction_items
|
||||
|
|
@ -117,8 +117,9 @@ export function registerPublicRoutes(app: FastifyInstance, db: DB) {
|
|||
VALUES (?, ?, ?, ?, ?, 0)`
|
||||
);
|
||||
|
||||
const createdAt = new Date().toISOString();
|
||||
const txId = db.transaction(() => {
|
||||
const info = insertTx.run(bar_id, paidTotal, crew ? 1 : 0, pfand_returns, clientIp, client_uuid);
|
||||
const info = insertTx.run(bar_id, createdAt, paidTotal, crew ? 1 : 0, pfand_returns, clientIp, client_uuid);
|
||||
const id = Number(info.lastInsertRowid);
|
||||
for (const p of priced) {
|
||||
insertItem.run(id, p.drink_id, p.qty, p.unit_price_cents, p.pfand_cents_per_unit);
|
||||
|
|
|
|||
Loading…
Reference in a new issue