Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72e175ab73 | ||
|
|
0a353c5f97 | ||
|
|
f87f9ff23c | ||
|
|
e3f4f3eeee | ||
|
|
e708202f3a | ||
|
|
99145e83da | ||
|
|
33a5125abc | ||
|
|
cd8218689c |
+6
-3
@@ -30,11 +30,12 @@ Every page's root is `<Page>` from `@xenia/ui`. It provides:
|
||||
</Page>
|
||||
```
|
||||
|
||||
- `top={<Tabs … />}` keeps a tab strip above the scrolling part (Online orders, Settings). The tab is kept in the address (`?tab=`).
|
||||
- `top={<Tabs … />}` keeps a tab strip above the scrolling part (Online orders, Settings). The tab is kept in the address (`?tab=`). Tabs that don't fit **wrap onto another row**; they are never hidden in a sideways scroll (6F.0, owner 2026-11-23).
|
||||
- `header={<PageHeader … />}` with `top`: the page's title and description come **first**, then the tabs (Offers & pricing). Each tab then starts with its own head: title, description, its "New" button at the top right.
|
||||
- `fit`: the page is exactly the screen's height and doesn't scroll; its `Pane`s do, each on its own (Products). Put them in an element with `x-page__fill`. Phones scroll as usual.
|
||||
- The scrollbar's room is always kept (`scrollbar-gutter: stable`), so a short tab is exactly as wide as a long one.
|
||||
- `width="form"` for settings and forms (centred at `--x-page-form-max`, 880 px). Lists, tables and dashboards use the default (full).
|
||||
- Every page is full width, **Settings included** (6F.0, owner 2026-11-23: an 880 px Settings page looked narrower than the rest and cut its tabs). Settings and other pages of cards put them in `<Columns>`: cards flow top to bottom, then into the next column, each column at least 34rem (two on 1080p, three on an ultrawide, one on a laptop or phone); `x-columns__wide` / `<ColumnsWide>` spans all columns (an intro row, a wide editor). `width="form"` (880 px, centred) stays only for a single form that reads better narrow; no page uses it now.
|
||||
- A settings row (`SettingRow`) keeps its control in a 16rem box on the right: selects and inputs fill it, switches and buttons sit at its right edge.
|
||||
- **Never** put `p-*`, `max-w-*`, `mx-auto`, `h-full` or `overflow-*` on a page's root, and never nest a second width limit inside it.
|
||||
- Checked by `tests/e2e/manager_layout.mjs` (1920×1080 and 3440×1440: every page fills / is centred, and scrolls). Add a new page to its `PAGES` list.
|
||||
|
||||
@@ -45,13 +46,15 @@ Every page is on `<Page>` except Inventory → Stock (a placeholder). Two-column
|
||||
| Need | Use | Notes |
|
||||
|---|---|---|
|
||||
| A page | `Page`, `PageHeader` | §2 |
|
||||
| Cards in columns (settings) | `Columns`, `ColumnsWide` | §2; a card never splits across two columns |
|
||||
| Filters / actions over a list | `Toolbar`, `ToolbarSpacer` | every control in it the same height; the search box grows |
|
||||
| Search | `SearchInput` | icon, clear button; `onChange(text)` |
|
||||
| Choose one / several | `Dropdown` (`multiple`) | **never a native `<select>` in a toolbar.** Multi: value is an array, `[]` = all (`allLabel`). Options can carry a `dot` (a zone's colour) and a `hint`. Search box from 9 options. Same heights as `Input`. Native `Select` stays only inside forms where the phone's own picker is better |
|
||||
| A small panel under a button | `Popover` (`open`, `anchor` = the button's ref, `onClose`) | a colour picker, an "Add…" menu. Drawn over everything (portal), flips above, stays inside the window: **never an `absolute` panel inside a section** (it is clipped and makes the section scroll) |
|
||||
| A colour (a venue's: data) | `ColourField` (`auto`, `opacity`, `presets`) | a field with its swatch and code; its panel (over the page) has 12 ready colours, the picker, the opacity (`#rrggbbaa`) and the code. `auto` = a first choice that leaves it to something else ("As the slide"). **Never** a bare `<input type="color">` |
|
||||
| An icon from a set | `IconPicker` (`icons` = { key: component }) | a field showing the icon; a grid of the set over the page, "No icon" first |
|
||||
| A whole number (seconds, counts) | `NumberInput` (`min`, `max`, `suffix`) | − / + on its sides, as tall as an input; it may be emptied while typing (`onChange(null)`): the form shows the error and blocks saving. **Never** clamp on every key (the user can't clear the field) |
|
||||
| Money, a weight, any number with decimals | `MoneyInput` (€, cents), `DecimalInput` (`decimals`, `allowNegative`, `suffix`) | typed with a comma **or** a dot ("12,50", "1.234,50"); reports a number, `null` when empty, `NaN` when it isn't a number (show the error). **Never** `type="number"` with a decimal step, `parseFloat` or `.replace(',', '.')`: they drop the comma a Greek keypad types (6F.2; guarded by `packages/i18n/tests/typed-numbers.test.mjs`). Fields kept as text read it with `parseNumber` |
|
||||
| A whole number (seconds, counts) | `NumberInput` (`min`, `max`, `suffix`) | − / + on its sides, as tall as an input; it may be emptied while typing (`onChange(null)`): the form shows the error and blocks saving. **Never** clamp on every key (the user can't clear the field). With a `min` below 0 a minus may be typed in front |
|
||||
| A note in a box (what works, a caution) | `Notice` (`tone`, `title`, `icon`, `items` = [{ tone, label, text }]) | a tinted box with a bar on its left; `items` are points with a tone dot and a bold label. **Never** a local `bg-info-soft` paragraph rebuilt per page |
|
||||
| A slider with its value | `Slider` (`suffix`) | framed and as tall as the fields beside it; the value sits as close to it as the frame's padding. **Never** a bare `<input type="range">` |
|
||||
| Fields that should wrap | `FieldRow` (`min`, `shade` on every other row) | each field keeps its least width; a row that wraps is framed (and tinted with `shade`), a row on one line looks like any row |
|
||||
|
||||
@@ -221,6 +221,15 @@ CODES: dict[str, tuple[int, str]] = {
|
||||
"order.item_not_found": (404, "That item isn't on the order any more."),
|
||||
"order.item_paid": (400, "This item is already paid."),
|
||||
"order.item_not_active": (400, "Only items still on the order can be changed."),
|
||||
"order.price_change_off": (403, "Changing prices by hand is turned off for this venue."),
|
||||
"order.one_more_off": (400, "\"One more\" isn't turned on for this product."),
|
||||
"order.one_more_line": (400, "This line can't be ordered again with one tap."),
|
||||
"order.quantity_change_off": (403, "Changing quantities is turned off for this venue."),
|
||||
"order.quantity_remove_off": (403, "Quantities can only go up at this venue."),
|
||||
"order.quantity_invalid": (400, "Choose a whole number from 1 to {max}."),
|
||||
"order.quantity_line": (400, "This line's quantity can't be changed here."),
|
||||
"order.price_change_sent_off": (403, "Prices can only be changed before the items are sent."),
|
||||
"order.price_reason_required": (400, "Say why the price changes."),
|
||||
"order.nothing_paid": (404, "There are no paid items to undo."),
|
||||
"order.cannot_close": (400, "This order can't be closed now ({status})."),
|
||||
"order.no_active_items": (400, "None of these items are on the order any more."),
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
"""Prices changed by hand, on the record (owner 2026-11-23, plan 6F.3).
|
||||
|
||||
- price_event_log: approved_by_user_id, stage (cart | sent | served), quantity, for the new
|
||||
event type manual_price (services/price_changes.py).
|
||||
- The keys ordering.prices.modify_sent (everyone who holds ordering.prices.modify today: nobody
|
||||
loses what they could do) and ordering.prices.view_changes (owners and store managers).
|
||||
|
||||
Revision ID: 0047_price_changes
|
||||
Revises: 0046_media_folders
|
||||
Create Date: 2026-11-23 12:00:00
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = '0047_price_changes'
|
||||
down_revision = '0046_media_folders'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
with op.batch_alter_table('price_event_log') as b:
|
||||
b.add_column(sa.Column('approved_by_user_id', sa.Integer(), nullable=True))
|
||||
b.add_column(sa.Column('stage', sa.String(), nullable=True))
|
||||
b.add_column(sa.Column('quantity', sa.Float(), nullable=True))
|
||||
b.create_foreign_key('fk_price_event_approved_by', 'users', ['approved_by_user_id'], ['id'])
|
||||
bind = op.get_bind()
|
||||
bind.execute(sa.text("insert or ignore into user_permissions (user_id, key) "
|
||||
"select user_id, 'ordering.prices.modify_sent' from user_permissions where key = 'ordering.prices.modify'"))
|
||||
# a venue that changed a role's default for modify gets the same for modify_sent
|
||||
bind.execute(sa.text("insert or ignore into role_permissions (role, key, granted) "
|
||||
"select role, 'ordering.prices.modify_sent', granted from role_permissions where key = 'ordering.prices.modify'"))
|
||||
bind.execute(sa.text("insert or ignore into user_permissions (user_id, key) "
|
||||
"select id, 'ordering.prices.view_changes' from users where role in ('owner', 'store_manager')"))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
bind.execute(sa.text("delete from user_permissions where key in ('ordering.prices.modify_sent', 'ordering.prices.view_changes')"))
|
||||
bind.execute(sa.text("delete from role_permissions where key = 'ordering.prices.modify_sent'"))
|
||||
with op.batch_alter_table('price_event_log') as b:
|
||||
b.drop_constraint('fk_price_event_approved_by', type_='foreignkey')
|
||||
b.drop_column('quantity')
|
||||
b.drop_column('stage')
|
||||
b.drop_column('approved_by_user_id')
|
||||
@@ -0,0 +1,121 @@
|
||||
"""Moves on the record (owner 2026-11-23, plan 6F.4, services/moves.py).
|
||||
|
||||
- order_moves / order_move_items: every table transfer, lines moved, orders merged, with its lines.
|
||||
- order_items.split_from_id: the line a line was cut from (a split), so its path follows it.
|
||||
- Backfill from the audit log written before 6F.4 (notes "Transferred from table A to table B",
|
||||
"Moved to order #N (table T)", "Items merged from order #N (table T)"): one move each, marked
|
||||
note='backfill'. A transfer's lines are the order's lines added before it; quantities unknown.
|
||||
|
||||
Revision ID: 0048_order_moves
|
||||
Revises: 0047_price_changes
|
||||
Create Date: 2026-11-23 15:00:00
|
||||
"""
|
||||
import json
|
||||
import re
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from core.timeutil import UTCDateTime
|
||||
|
||||
revision = '0048_order_moves'
|
||||
down_revision = '0047_price_changes'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
_TABLE = r"(?:table )?(\d+|None)"
|
||||
|
||||
|
||||
def _int(v):
|
||||
return int(v) if v not in (None, "None", "") else None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
'order_moves',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('kind', sa.String(), nullable=False),
|
||||
sa.Column('from_order_id', sa.Integer(), sa.ForeignKey('orders.id'), nullable=True),
|
||||
sa.Column('to_order_id', sa.Integer(), sa.ForeignKey('orders.id'), nullable=True),
|
||||
sa.Column('from_table_id', sa.Integer(), sa.ForeignKey('tables.id'), nullable=True),
|
||||
sa.Column('to_table_id', sa.Integer(), sa.ForeignKey('tables.id'), nullable=True),
|
||||
sa.Column('by_user_id', sa.Integer(), sa.ForeignKey('users.id'), nullable=True),
|
||||
sa.Column('approved_by_user_id', sa.Integer(), sa.ForeignKey('users.id'), nullable=True),
|
||||
sa.Column('business_day_id', sa.Integer(), sa.ForeignKey('business_days.id'), nullable=True),
|
||||
sa.Column('at', UTCDateTime(), nullable=False),
|
||||
sa.Column('note', sa.Text(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
)
|
||||
for col in ('id', 'kind', 'from_order_id', 'to_order_id', 'business_day_id', 'at'):
|
||||
op.create_index(f'ix_order_moves_{col}', 'order_moves', [col])
|
||||
op.create_table(
|
||||
'order_move_items',
|
||||
sa.Column('move_id', sa.Integer(), sa.ForeignKey('order_moves.id', ondelete='CASCADE'), nullable=False),
|
||||
sa.Column('item_id', sa.Integer(), sa.ForeignKey('order_items.id'), nullable=False),
|
||||
sa.Column('quantity', sa.Float(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('move_id', 'item_id'),
|
||||
)
|
||||
op.create_index('ix_order_move_items_item_id', 'order_move_items', ['item_id'])
|
||||
with op.batch_alter_table('order_items') as b:
|
||||
b.add_column(sa.Column('split_from_id', sa.Integer(), nullable=True))
|
||||
b.create_index('ix_order_items_split_from_id', ['split_from_id'])
|
||||
b.create_foreign_key('fk_order_items_split_from', 'order_items', ['split_from_id'], ['id'])
|
||||
_backfill(op.get_bind())
|
||||
|
||||
|
||||
def _backfill(bind) -> None:
|
||||
rows = bind.execute(sa.text(
|
||||
"select a.id, a.order_id, a.event_type, a.waiter_id, a.item_ids, a.note, a.created_at, o.table_id, o.business_day_id "
|
||||
"from order_audit_log a join orders o on o.id = a.order_id "
|
||||
"where a.event_type in ('TABLE_TRANSFER', 'ITEMS_MOVED_OUT', 'ITEMS_ADDED') and a.note is not null order by a.id")).fetchall()
|
||||
existing_items = {r[0] for r in bind.execute(sa.text("select id from order_items")).fetchall()}
|
||||
existing_orders = {r[0] for r in bind.execute(sa.text("select id from orders")).fetchall()}
|
||||
|
||||
def add(kind, frm, to, ft, tt, by, at, day, items):
|
||||
res = bind.execute(sa.text(
|
||||
"insert into order_moves (kind, from_order_id, to_order_id, from_table_id, to_table_id, by_user_id, business_day_id, at, note) "
|
||||
"values (:k, :fo, :to, :ft, :tt, :by, :day, :at, 'backfill')"),
|
||||
{'k': kind, 'fo': frm if frm in existing_orders else None, 'to': to if to in existing_orders else None,
|
||||
'ft': ft, 'tt': tt, 'by': by, 'day': day, 'at': at})
|
||||
mid = res.lastrowid
|
||||
for iid in sorted({i for i in items if i in existing_items}):
|
||||
bind.execute(sa.text("insert or ignore into order_move_items (move_id, item_id, quantity) values (:m, :i, null)"),
|
||||
{'m': mid, 'i': iid})
|
||||
|
||||
def ids(raw):
|
||||
try:
|
||||
v = json.loads(raw or '[]')
|
||||
return [int(x) for x in v if isinstance(x, int)]
|
||||
except (ValueError, TypeError):
|
||||
return []
|
||||
|
||||
for (_id, order_id, kind, by, item_ids, note, at, table_id, day) in rows:
|
||||
if kind == 'TABLE_TRANSFER':
|
||||
m = re.match(rf"Transferred from table (\d+|None) to table (\d+|None)", note)
|
||||
if not m:
|
||||
continue
|
||||
items = [r[0] for r in bind.execute(sa.text(
|
||||
"select id from order_items where order_id = :o and added_at <= :at"), {'o': order_id, 'at': at}).fetchall()]
|
||||
add('table_transfer', order_id, order_id, _int(m.group(1)), _int(m.group(2)), by, at, day, items)
|
||||
elif kind == 'ITEMS_MOVED_OUT':
|
||||
m = re.match(rf"Moved to order #(\d+) \({_TABLE}\)", note)
|
||||
if not m:
|
||||
continue
|
||||
add('items_moved', order_id, int(m.group(1)), table_id, _int(m.group(2)), by, at, day, ids(item_ids))
|
||||
elif kind == 'ITEMS_ADDED':
|
||||
m = re.match(rf"Items merged from order #(\d+) \({_TABLE}\)", note)
|
||||
if not m:
|
||||
continue
|
||||
add('orders_merged', int(m.group(1)), order_id, _int(m.group(2)), table_id, by, at, day, ids(item_ids))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
with op.batch_alter_table('order_items') as b:
|
||||
b.drop_constraint('fk_order_items_split_from', type_='foreignkey')
|
||||
b.drop_index('ix_order_items_split_from_id')
|
||||
b.drop_column('split_from_id')
|
||||
op.drop_index('ix_order_move_items_item_id', 'order_move_items')
|
||||
op.drop_table('order_move_items')
|
||||
for col in ('id', 'kind', 'from_order_id', 'to_order_id', 'business_day_id', 'at'):
|
||||
op.drop_index(f'ix_order_moves_{col}', 'order_moves')
|
||||
op.drop_table('order_moves')
|
||||
@@ -0,0 +1,30 @@
|
||||
"""One more and quantity changes (owner 2026-11-23, plan 6F.5).
|
||||
|
||||
- products.one_more_enabled (off: the owner turns it on per product).
|
||||
- The key ordering.items.change_quantity for owners and store managers (the venue's setting
|
||||
orders.quantity_change starts 'off').
|
||||
|
||||
Revision ID: 0049_one_more
|
||||
Revises: 0048_order_moves
|
||||
Create Date: 2026-11-23 18:00:00
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = '0049_one_more'
|
||||
down_revision = '0048_order_moves'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
with op.batch_alter_table('products') as b:
|
||||
b.add_column(sa.Column('one_more_enabled', sa.Boolean(), nullable=False, server_default='0'))
|
||||
op.get_bind().execute(sa.text("insert or ignore into user_permissions (user_id, key) "
|
||||
"select id, 'ordering.items.change_quantity' from users where role in ('owner', 'store_manager')"))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.get_bind().execute(sa.text("delete from user_permissions where key = 'ordering.items.change_quantity'"))
|
||||
with op.batch_alter_table('products') as b:
|
||||
b.drop_column('one_more_enabled')
|
||||
@@ -133,6 +133,9 @@ class OrderItem(Base):
|
||||
# Deal binding — which deal created this item, and which original item it's linked to
|
||||
deal_id = Column(Integer, ForeignKey("deals.id"), nullable=True)
|
||||
linked_item_id = Column(Integer, ForeignKey("order_items.id"), nullable=True)
|
||||
# the line this one was cut from (6F.4): a split, a lowered quantity, a split payment; its moves
|
||||
# before the cut are this line's too (services/moves.py)
|
||||
split_from_id = Column(Integer, ForeignKey("order_items.id"), nullable=True, index=True)
|
||||
|
||||
order = relationship("Order", back_populates="items")
|
||||
product = relationship("Product", back_populates="order_items")
|
||||
@@ -261,3 +264,34 @@ def _snapshot_item_names(session, flush_context, instances):
|
||||
cat = session.get(Category, obj.category_id)
|
||||
obj.category_name = cat.name if cat else None
|
||||
|
||||
|
||||
class OrderMove(Base):
|
||||
"""Something moved between tables or orders (owner 2026-11-23, plan 6F.4, services/moves.py):
|
||||
a whole order to another table (`table_transfer`), chosen lines to another order
|
||||
(`items_moved`), or one order joined into another (`orders_merged`). Never deleted."""
|
||||
__tablename__ = "order_moves"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
kind = Column(String, nullable=False, index=True) # table_transfer | items_moved | orders_merged
|
||||
from_order_id = Column(Integer, ForeignKey("orders.id"), nullable=True, index=True)
|
||||
to_order_id = Column(Integer, ForeignKey("orders.id"), nullable=True, index=True)
|
||||
from_table_id = Column(Integer, ForeignKey("tables.id"), nullable=True)
|
||||
to_table_id = Column(Integer, ForeignKey("tables.id"), nullable=True)
|
||||
by_user_id = Column(Integer, ForeignKey("users.id"), nullable=True)
|
||||
approved_by_user_id = Column(Integer, ForeignKey("users.id"), nullable=True)
|
||||
business_day_id = Column(Integer, ForeignKey("business_days.id"), nullable=True, index=True)
|
||||
at = Column(UTCDateTime, default=utcnow, nullable=False, index=True)
|
||||
note = Column(Text, nullable=True) # the importer / backfill: where it came from
|
||||
|
||||
items = relationship("OrderMoveItem", back_populates="move", cascade="all, delete-orphan")
|
||||
|
||||
|
||||
class OrderMoveItem(Base):
|
||||
"""A line that went with a move, and how much of it (its quantity at the time)."""
|
||||
__tablename__ = "order_move_items"
|
||||
|
||||
move_id = Column(Integer, ForeignKey("order_moves.id", ondelete="CASCADE"), primary_key=True)
|
||||
item_id = Column(Integer, ForeignKey("order_items.id"), primary_key=True, index=True)
|
||||
quantity = Column(Float, nullable=True)
|
||||
|
||||
move = relationship("OrderMove", back_populates="items")
|
||||
|
||||
@@ -227,6 +227,7 @@ class PriceEventLog(Base):
|
||||
# deal_offer_dismissed — waiter dismissed the deal offer
|
||||
# waiter_discount — manual waiter discount applied
|
||||
# free_item_added — free item added to order as result of a deal
|
||||
# manual_price — a price changed by hand (6F.3, services/price_changes.py)
|
||||
|
||||
modifier_id = Column(Integer, ForeignKey("price_modifiers.id"), nullable=True)
|
||||
deal_id = Column(Integer, ForeignKey("deals.id"), nullable=True)
|
||||
@@ -236,10 +237,15 @@ class PriceEventLog(Base):
|
||||
price_after = Column(Float, nullable=True)
|
||||
delta_amount = Column(Float, nullable=True) # price_after - price_before; negative = discount
|
||||
|
||||
# Waiter discount fields
|
||||
# Waiter discount fields (also manual_price: who changed it, and the reason)
|
||||
applied_by_user_id = Column(Integer, ForeignKey("users.id"), nullable=True)
|
||||
waiter_note = Column(Text, nullable=True)
|
||||
|
||||
# manual_price (6F.3, services/price_changes.py): a price changed by hand
|
||||
approved_by_user_id = Column(Integer, ForeignKey("users.id"), nullable=True) # a manager's PIN (D-10)
|
||||
stage = Column(String, nullable=True) # cart | sent | served
|
||||
quantity = Column(Float, nullable=True) # the line's quantity at the time
|
||||
|
||||
# Snapshot of the conditions that evaluated to True when the event fired.
|
||||
# JSON object: {"condition_type": evaluated_value, ...}
|
||||
# e.g. {"day_of_week": 5, "time_range": "21:45", "price_group_active": true}
|
||||
@@ -255,6 +261,7 @@ class PriceEventLog(Base):
|
||||
modifier = relationship("PriceModifier", foreign_keys=[modifier_id])
|
||||
deal = relationship("Deal", foreign_keys=[deal_id])
|
||||
applied_by = relationship("User", foreign_keys=[applied_by_user_id])
|
||||
approved_by = relationship("User", foreign_keys=[approved_by_user_id])
|
||||
|
||||
|
||||
class WaiterDiscountSettings(Base):
|
||||
|
||||
@@ -82,6 +82,8 @@ class Product(Base):
|
||||
|
||||
# Quick Add: allow adding 1 unit directly from product list without opening config modal
|
||||
quick_add_enabled = Column(Boolean, default=True, nullable=False)
|
||||
# "One more" (6F.5): a sent line of this product shows +1 (re-order the same, printed as new)
|
||||
one_more_enabled = Column(Boolean, default=False, nullable=False, server_default="0")
|
||||
|
||||
# Service item: non-inventoried table-service items (cutlery, glasses, etc.)
|
||||
is_service_item = Column(Boolean, default=False, nullable=False)
|
||||
|
||||
@@ -11,7 +11,10 @@ MODULE = Module(
|
||||
Perm('ordering.orders.open', 'Open orders and add items', roles=('owner', 'store_manager', 'barista', 'barman', 'waiter')),
|
||||
Perm('ordering.orders.close', 'Take payments and close orders', roles=('owner', 'store_manager', 'barista', 'barman', 'waiter')),
|
||||
Perm('ordering.orders.cancel', 'Cancel items already sent', roles=('owner', 'store_manager'), overridable=True),
|
||||
Perm('ordering.prices.modify', "Change an item's price", roles=('owner',), overridable=True),
|
||||
Perm('ordering.prices.modify', "Change an item's price before it is sent", roles=('owner',), overridable=True),
|
||||
Perm('ordering.prices.modify_sent', "Change the price of an item already sent or served", roles=('owner',), overridable=True),
|
||||
Perm('ordering.items.change_quantity', "Change a sent line's quantity (no new ticket)", roles=('owner', 'store_manager'), overridable=True),
|
||||
Perm('ordering.prices.view_changes', 'See the prices changed by hand (who, when, why)', roles=('owner', 'store_manager')),
|
||||
Perm('ordering.refunds', 'Refund payments from other shifts', roles=('owner', 'store_manager'), overridable=True),
|
||||
Perm('ordering.payments.revert', 'Turn paid items back to unpaid', roles=('owner', 'store_manager'), overridable=True),
|
||||
Perm('ordering.business_day.manage', 'Open and close the business day', roles=('owner', 'store_manager', 'staff_manager')),
|
||||
@@ -22,6 +25,10 @@ MODULE = Module(
|
||||
SettingDef('orders.auto_close_on_full_payment', 'false', "Automatically close the table order when all items have been paid: 'true' | 'false'", type='bool'),
|
||||
SettingDef('orders.close_with_unpaid', 'false', "Allow closing an order that still has unpaid items (they are written off as unpaid): 'true' | 'false'. When 'false', closing asks for the payment first (plan step 4.8).", type='bool'),
|
||||
SettingDef('orders.bypass_kds_serve', 'false', "Skip KDS pending/serve flow — new orders and items are immediately marked as served: 'true' | 'false'", type='bool'),
|
||||
SettingDef('orders.quantity_change', 'off', "Changing a sent line's quantity without sending it again (6F.5): 'off' | 'add_only' | 'add_and_remove' (lowering cancels the difference; also needs ordering.orders.cancel). Who may: ordering.items.change_quantity.", type='enum', choices=('off', 'add_only', 'add_and_remove')),
|
||||
SettingDef('orders.price_change', 'anytime', "Changing a line's price by hand (6F.3): 'off' | 'before_sending' (only in the cart) | 'anytime' (also a sent or served line). Who may: the keys ordering.prices.modify / modify_sent.", type='enum', choices=('off', 'before_sending', 'anytime')),
|
||||
SettingDef('orders.price_change_reason', 'false', "A price changed by hand needs a reason: 'true' | 'false' (6F.3).", type='bool'),
|
||||
SettingDef('orders.price_change_reasons', '[]', 'JSON array of quick reasons offered when a price is changed by hand (6F.3); [] = the built-in ones.', type='json'),
|
||||
SettingDef('orders.courses', '[]', 'JSON array of course objects [{id, name, color}] defining available courses', type='json'),
|
||||
SettingDef('orders.courses_enabled', 'false', "Enable per-item course assignment when ordering: 'true' | 'false'", type='bool'),
|
||||
SettingDef('orders.quick_notes', '["Χωρίς αλάτι","Βγάλτε γρήγορα","Αλλεργία!","Κόψτε σε μικρά κομμάτια","Έξτρα χαρτοπετσέτες"]', 'JSON array of quick-note strings shown in the waiter note tab', type='json'),
|
||||
|
||||
@@ -33,11 +33,12 @@ MODULE = Module(
|
||||
ConfigField('orientation', 'enum', default='landscape', choices=('landscape', 'portrait')),
|
||||
ConfigField('rotation', 'int', default=0, choices=(0, 90, 180, 270)),
|
||||
# its picture (6R.13): a slide of another shape keeps its shape (bands) or fills the picture;
|
||||
# px cut off each edge of the TV's window (set by Signage > Screens > Calibrate)
|
||||
# px cut off each edge of the TV's window (set by Signage > Screens > Calibrate); below 0 the
|
||||
# picture reaches past that edge of the window the TV reported (owner 2026-11-23)
|
||||
ConfigField('fit', 'enum', default='keep', choices=('keep', 'stretch'), group='picture'),
|
||||
ConfigField('area_left', 'int', default=0, min=0, max=4000, group='picture'),
|
||||
ConfigField('area_top', 'int', default=0, min=0, max=4000, group='picture'),
|
||||
ConfigField('area_right', 'int', default=0, min=0, max=4000, group='picture'),
|
||||
ConfigField('area_bottom', 'int', default=0, min=0, max=4000, group='picture'),
|
||||
ConfigField('area_left', 'int', default=0, min=-2000, max=4000, group='picture'),
|
||||
ConfigField('area_top', 'int', default=0, min=-2000, max=4000, group='picture'),
|
||||
ConfigField('area_right', 'int', default=0, min=-2000, max=4000, group='picture'),
|
||||
ConfigField('area_bottom', 'int', default=0, min=-2000, max=4000, group='picture'),
|
||||
)),
|
||||
)
|
||||
|
||||
+201
-21
@@ -343,7 +343,8 @@ def get_order(order_id: int, db: Session = Depends(get_db), user: User = Depends
|
||||
"id": i.id,
|
||||
"order_id": i.order_id,
|
||||
"product_id": i.product_id,
|
||||
"product": {"id": i.product.id, "name": i.product.name} if i.product else None,
|
||||
"product": {"id": i.product.id, "name": i.product.name, "unit_type": i.product.unit_type or "piece",
|
||||
"one_more_enabled": bool(i.product.one_more_enabled)} if i.product else None, # 6F.5: +1
|
||||
"product_name": i.product_name, "category_id": i.category_id, "category_name": i.category_name,
|
||||
"added_by": i.added_by,
|
||||
"added_by_name": name_map.get(i.added_by),
|
||||
@@ -366,6 +367,9 @@ def get_order(order_id: int, db: Session = Depends(get_db), user: User = Depends
|
||||
"system_key": i.system_key, # the delivery fee line (phase 3S, S.5)
|
||||
"source": i.source, # waiter | counter | qr | online (4.8)
|
||||
"course_id": i.course_id,
|
||||
"deal_id": i.deal_id, "linked_item_id": i.linked_item_id,
|
||||
"split_from_id": i.split_from_id, # 6F.4: the line it was cut from
|
||||
"cancel_reason": i.cancel_reason,
|
||||
}
|
||||
|
||||
def fmt_log(l):
|
||||
@@ -584,20 +588,27 @@ def add_items(order_id: int, body: AddLinesRequest, request: Request, db: Sessio
|
||||
raise XeniaError("order.not_yours")
|
||||
lines, manual = _resolve_lines(db, body.lines, of_order(order))
|
||||
approval = None
|
||||
reasons = [None] * len(lines)
|
||||
if any(manual) or any(line.discount_pct for line in lines):
|
||||
from services import price_changes # the venue's switch and the reason first (6F.3)
|
||||
reasons = [price_changes.check(db, sent=False, reason=(raw or {}).get("price_reason") if isinstance(raw, dict) else None,
|
||||
by_hand=bool(hand)) if hand or line.discount_pct else None
|
||||
for raw, line, hand in zip(body.lines, lines, manual)]
|
||||
approval = _need(request, db, user, "ordering.prices.modify", target=f"order {order_id} new items")
|
||||
discounts = [0.0] * len(lines)
|
||||
if any(line.discount_pct for line in lines):
|
||||
priced = pos_cart.price_lines(db, lines, order.order_type or "here", pos_cart.order_cart(order), point=of_order(order))
|
||||
discounts = [pos_cart.discount_adjustment(unit, line.discount_pct) for line, (unit, _) in zip(lines, priced)]
|
||||
items = []
|
||||
for raw, line, hand, disc in zip(body.lines, lines, manual, discounts):
|
||||
for raw, line, hand, disc, reason in zip(body.lines, lines, manual, discounts, reasons):
|
||||
adj = round(hand + disc, 2)
|
||||
items.append(OrderItemInput(
|
||||
product_id=line.product.id, quantity=line.quantity,
|
||||
selected_options=[SelectedOptionInput(**e) for e in line.entries] or None,
|
||||
removed_ingredients=line.removed or None, notes=line.notes, price_adjustment=adj or None,
|
||||
is_service_item=raw.get("is_service_item") is True, course_id=raw.get("course_id"),
|
||||
price_reason=reason if adj else None,
|
||||
price_approved_by=approval.approved_by if approval is not None and adj else None,
|
||||
))
|
||||
result = add_priced_items(order_id, AddItemsRequest(items=items, order_note=body.order_note,
|
||||
customer_count=body.customer_count), db, user)
|
||||
@@ -708,6 +719,11 @@ def add_priced_items(order_id: int, body: AddItemsRequest, db: Session, user: Us
|
||||
db.add(item)
|
||||
db.flush()
|
||||
new_item_ids.append(item.id)
|
||||
if item.price_adjustment: # a price changed by hand in the cart (6F.3)
|
||||
from services import price_changes
|
||||
price_changes.record(db, item=item, before=unit_price, after=unit_price + item.price_adjustment,
|
||||
user_id=user.id, stage="cart", reason=item_in.price_reason,
|
||||
approved_by=item_in.price_approved_by)
|
||||
|
||||
# Stamp order_id on events and queue them — written after commit
|
||||
if price_events:
|
||||
@@ -1485,6 +1501,9 @@ def transfer_order(
|
||||
order.table_id = body.target_table_id
|
||||
_audit(db, order_id, "TABLE_TRANSFER", waiter_id=user.id,
|
||||
note=f"Transferred from table {old_table_id} to table {body.target_table_id}")
|
||||
from services import moves # 6F.4: the whole order and its lines, on the record
|
||||
moves.record(db, kind="table_transfer", source=order, target=order, items=list(order.items), user_id=user.id,
|
||||
from_table_id=old_table_id, to_table_id=body.target_table_id)
|
||||
db.commit()
|
||||
db.refresh(order)
|
||||
broadcast_sync("order_updated", {"order_id": order.id, "table_id": order.table_id, "old_table_id": old_table_id, "status": order.status, "action": "transferred"})
|
||||
@@ -1527,6 +1546,8 @@ def merge_order(
|
||||
raise XeniaError("order.same_order")
|
||||
|
||||
# Move all items to target order
|
||||
from services import moves # 6F.4
|
||||
moves.record(db, kind="orders_merged", source=source, target=target, items=list(source.items), user_id=user.id)
|
||||
moved_item_ids = []
|
||||
for item in source.items:
|
||||
item.order_id = target.id
|
||||
@@ -1601,21 +1622,7 @@ def split_item(
|
||||
|
||||
# Reduce original item
|
||||
item.quantity -= body.quantity
|
||||
|
||||
# Create split-off item
|
||||
new_item = OrderItem(
|
||||
source=item.source,
|
||||
order_id=order_id,
|
||||
product_id=item.product_id,
|
||||
added_by=item.added_by,
|
||||
quantity=body.quantity,
|
||||
unit_price=item.unit_price,
|
||||
selected_options=item.selected_options,
|
||||
removed_ingredients=item.removed_ingredients,
|
||||
notes=item.notes,
|
||||
status="active",
|
||||
printed=item.printed,
|
||||
)
|
||||
new_item = cut_part(item, body.quantity)
|
||||
db.add(new_item)
|
||||
db.commit()
|
||||
db.refresh(item)
|
||||
@@ -1623,10 +1630,141 @@ def split_item(
|
||||
return [item, new_item]
|
||||
|
||||
|
||||
def cut_part(item, quantity, **changes):
|
||||
"""A new line cut from `item` (a split, a lowered quantity, 6F.4/6F.5): everything the line was
|
||||
(product, price and its change, choices, note, kitchen state, course, cost, names, source) for
|
||||
`quantity`, linked by split_from_id so its moves follow it. Not added to the session."""
|
||||
fields = dict(
|
||||
source=item.source, order_id=item.order_id, product_id=item.product_id, added_by=item.added_by,
|
||||
quantity=quantity, unit_price=item.unit_price, selected_options=item.selected_options,
|
||||
removed_ingredients=item.removed_ingredients, notes=item.notes, status="active", printed=item.printed,
|
||||
split_from_id=item.id, kds_status=item.kds_status, course_id=item.course_id,
|
||||
price_adjustment=item.price_adjustment, unit_cost=item.unit_cost, product_name=item.product_name,
|
||||
category_id=item.category_id, category_name=item.category_name,
|
||||
) # added_at = now: the moment it was cut (services/moves.py reads it)
|
||||
fields.update(changes)
|
||||
return OrderItem(**fields)
|
||||
|
||||
|
||||
# ─── One more of a line, and a line's quantity (6F.5) ────────────────────────
|
||||
|
||||
class AgainRequest(BaseModel):
|
||||
quantity: int = Field(default=1, ge=1, le=50)
|
||||
|
||||
|
||||
@router.post("/{order_id}/items/{item_id}/again", response_model=AddItemsResponse)
|
||||
def order_again(order_id: int, item_id: int, body: AgainRequest, request: Request, db: Session = Depends(get_db),
|
||||
user: User = Depends(get_current_user)):
|
||||
""""One more" (6F.5): a new line just like this one (product, choices, removed ingredients, note,
|
||||
course) for `quantity`, priced by the server now and sent like any new line (kitchen ticket,
|
||||
KDS). Only for products with one_more_enabled, counted in pieces, from an active, paid or
|
||||
tabbed line that isn't a deal's or the system's. Needs ordering.orders.open."""
|
||||
from core.access.context import current_device
|
||||
from schemas.order import OrderItemInput, SelectedOptionInput
|
||||
_need(request, db, user, "ordering.orders.open", target=f"order:{order_id}")
|
||||
order = db.get(Order, order_id)
|
||||
if order is None:
|
||||
raise XeniaError("order.not_found", order_id=order_id)
|
||||
if not _can_access_order(order, user, db):
|
||||
raise XeniaError("order.not_yours")
|
||||
item = db.query(OrderItem).filter(OrderItem.id == item_id, OrderItem.order_id == order_id).first()
|
||||
if item is None:
|
||||
raise XeniaError("order.item_not_found")
|
||||
product = item.product
|
||||
if product is None or not product.one_more_enabled:
|
||||
raise XeniaError("order.one_more_off")
|
||||
if item.status not in ("active", "paid", "tabbed") or item.deal_id or item.linked_item_id \
|
||||
or product.system_key or (product.unit_type or "piece") != "piece":
|
||||
raise XeniaError("order.one_more_line")
|
||||
try:
|
||||
options = [SelectedOptionInput(**o) for o in json.loads(item.selected_options or "[]") if isinstance(o, dict)]
|
||||
removed = [str(x) for x in json.loads(item.removed_ingredients or "[]")]
|
||||
except (ValueError, TypeError):
|
||||
options, removed = [], []
|
||||
device = current_device(request, db)
|
||||
source = "counter" if device is not None and device.app_key == "pos_counter" else "waiter"
|
||||
result = add_priced_items(order_id, AddItemsRequest(items=[OrderItemInput(
|
||||
product_id=item.product_id, quantity=body.quantity, selected_options=options or None,
|
||||
removed_ingredients=removed or None, notes=item.notes, course_id=item.course_id, source=source,
|
||||
)]), db, user)
|
||||
_audit(db, order_id, "ITEM_REORDERED", waiter_id=user.id, item_ids=[item.id],
|
||||
note=f"{body.quantity:g} more of #{item.id}")
|
||||
db.commit()
|
||||
return result
|
||||
|
||||
|
||||
class QuantityRequest(BaseModel):
|
||||
quantity: int = Field(ge=1, le=999)
|
||||
print_cancellation: bool = False # lowering: send a cancellation to the kitchen (the app asks)
|
||||
|
||||
|
||||
@router.post("/{order_id}/items/{item_id}/quantity")
|
||||
def change_quantity(order_id: int, item_id: int, body: QuantityRequest, request: Request, background_tasks: BackgroundTasks,
|
||||
db: Session = Depends(get_db), user: User = Depends(get_current_user)):
|
||||
"""Change a sent line's quantity without sending it again (6F.5). The venue
|
||||
(orders.quantity_change: off | add_only | add_and_remove) and ordering.items.change_quantity
|
||||
decide; lowering also needs ordering.orders.cancel (or a manager's PIN each). Up: the line
|
||||
grows, nothing is printed. Down: the removed part becomes its own cancelled line ("quantity
|
||||
lowered", split_from_id = the line) and, when asked, a cancellation ticket goes to the kitchen.
|
||||
Only unpaid lines counted in pieces, not a deal's or the system's."""
|
||||
from models.settings import PosSettings
|
||||
order = db.get(Order, order_id)
|
||||
if order is None:
|
||||
raise XeniaError("order.not_found", order_id=order_id)
|
||||
if not _can_access_order(order, user, db):
|
||||
raise XeniaError("order.not_yours")
|
||||
row = db.query(PosSettings).filter(PosSettings.key == "orders.quantity_change").first()
|
||||
mode = row.value if row is not None and row.value in ("off", "add_only", "add_and_remove") else "off"
|
||||
if mode == "off":
|
||||
raise XeniaError("order.quantity_change_off")
|
||||
item = db.query(OrderItem).filter(OrderItem.id == item_id, OrderItem.order_id == order_id).first()
|
||||
if item is None:
|
||||
raise XeniaError("order.item_not_found")
|
||||
product = item.product
|
||||
if item.status != "active" or item.deal_id or item.linked_item_id or (product is not None and product.system_key) \
|
||||
or (item.unit_type or "piece") != "piece" or item.quantity != int(item.quantity):
|
||||
raise XeniaError("order.quantity_line")
|
||||
old = int(item.quantity)
|
||||
if body.quantity == old:
|
||||
return {"item_id": item.id, "quantity": old, "cancelled_item_id": None}
|
||||
lowering = body.quantity < old
|
||||
if lowering and mode != "add_and_remove":
|
||||
raise XeniaError("order.quantity_remove_off")
|
||||
approval = _need(request, db, user, "ordering.items.change_quantity", target=f"order:{order_id} item:{item_id}")
|
||||
cancel_approval = None
|
||||
if lowering and not holds(user, "core.dashboard.access") and not _waiter_can_cancel(user, db):
|
||||
cancel_approval = require_override(request, db, "ordering.orders.cancel", target=f"order:{order_id}")
|
||||
note = f"{old} → {body.quantity}" + (f" · {_approval_note(approval)}" if approval is not None else "")
|
||||
part = None
|
||||
if lowering:
|
||||
now = utcnow()
|
||||
part = cut_part(item, old - body.quantity, status="cancelled", cancelled_by=user.id, cancelled_at=now,
|
||||
cancel_reason="quantity lowered")
|
||||
db.add(part)
|
||||
item.quantity = body.quantity
|
||||
db.flush()
|
||||
_audit(db, order_id, "ITEM_CANCELLED", waiter_id=user.id, item_ids=[part.id],
|
||||
note=("quantity lowered" + (f" · {_approval_note(cancel_approval)}" if cancel_approval is not None else "")
|
||||
+ ("" if body.print_cancellation else " · no kitchen ticket")))
|
||||
else:
|
||||
item.quantity = body.quantity
|
||||
_audit(db, order_id, "QUANTITY_CHANGED", waiter_id=user.id, item_ids=[item.id], note=note)
|
||||
db.commit()
|
||||
broadcast_sync("order_updated", {"order_id": order_id, "table_id": order.table_id, "status": order.status,
|
||||
"action": "quantity_changed", "item_ids": [item.id]})
|
||||
if part is not None:
|
||||
broadcast_sync("order_updated", {"order_id": order_id, "table_id": order.table_id, "status": order.status,
|
||||
"action": "items_cancelled", "item_ids": [part.id]})
|
||||
if body.print_cancellation:
|
||||
background_tasks.add_task(print_cancellation_ticket, order_id, [part.id])
|
||||
return {"item_id": item.id, "quantity": item.quantity, "cancelled_item_id": part.id if part is not None else None}
|
||||
|
||||
|
||||
# ─── Adjust price on an existing item ────────────────────────────────────────
|
||||
|
||||
class PriceAdjustRequest(BaseModel):
|
||||
price_adjustment: float # delta from unit_price (can be negative)
|
||||
reason: Optional[str] = Field(default=None, max_length=200) # 6F.3: needed when the venue asks for one
|
||||
|
||||
|
||||
@router.patch("/{order_id}/items/{item_id}/price-adjust", response_model=OrderItemOut)
|
||||
@@ -1638,8 +1776,10 @@ def adjust_item_price(
|
||||
db: Session = Depends(get_db),
|
||||
user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Apply an on-the-fly price adjustment to an active order item. Without
|
||||
ordering.prices.modify a manager can approve it once (X-Xenia-Override, D-10)."""
|
||||
"""Change a sent line's price by hand (6F.3): the venue must allow it after sending
|
||||
(orders.price_change = anytime), it needs ordering.prices.modify_sent (a manager can approve it
|
||||
once, X-Xenia-Override, D-10) and, when the venue asks, a reason. Recorded as a manual_price
|
||||
event (before → after, who, the approver, the stage, the reason)."""
|
||||
item = db.query(OrderItem).filter(
|
||||
OrderItem.id == item_id, OrderItem.order_id == order_id
|
||||
).first()
|
||||
@@ -1651,15 +1791,51 @@ def adjust_item_price(
|
||||
order = db.query(Order).filter(Order.id == order_id).first()
|
||||
if not _can_access_order(order, user, db):
|
||||
raise XeniaError("order.not_yours")
|
||||
_need(request, db, user, "ordering.prices.modify", target=f"order:{order_id} item:{item_id}")
|
||||
from services import price_changes
|
||||
reason = price_changes.check(db, sent=True, reason=body.reason)
|
||||
approval = _need(request, db, user, "ordering.prices.modify_sent", target=f"order:{order_id} item:{item_id}")
|
||||
if not -10000 <= body.price_adjustment <= 10000 or item.unit_price + body.price_adjustment < 0:
|
||||
raise XeniaError("order.line.price", line=1, name=item.product_name)
|
||||
|
||||
item.price_adjustment = body.price_adjustment
|
||||
before = item.unit_price + (item.price_adjustment or 0.0)
|
||||
item.price_adjustment = round(body.price_adjustment, 2)
|
||||
price_changes.record(db, item=item, before=before, after=item.unit_price + item.price_adjustment, user_id=user.id,
|
||||
stage=price_changes.stage_of(item), reason=reason,
|
||||
approved_by=approval.approved_by if approval is not None else None)
|
||||
db.commit()
|
||||
db.refresh(item)
|
||||
broadcast_sync("order_updated", {"order_id": order_id, "table_id": order.table_id, "status": order.status, "action": "item_price_adjusted"})
|
||||
return item
|
||||
|
||||
|
||||
@router.get("/{order_id}/moves")
|
||||
def order_moves(order_id: int, db: Session = Depends(get_db), user: User = Depends(get_current_user)):
|
||||
"""Where an order and its lines came from (6F.4): {order: [the whole order's transfers and
|
||||
merges], items: {line id: [its moves, its parents' before it was split from them]}}. Each move:
|
||||
kind, at, from / to table (id, name) and order, who, the lines and quantities."""
|
||||
from services import moves
|
||||
order = db.get(Order, order_id)
|
||||
if order is None:
|
||||
raise XeniaError("order.not_found", order_id=order_id)
|
||||
if not _can_access_order(order, user, db):
|
||||
raise XeniaError("order.not_yours")
|
||||
return moves.for_order(db, order)
|
||||
|
||||
|
||||
@router.get("/{order_id}/price-changes")
|
||||
def order_price_changes(order_id: int, db: Session = Depends(get_db),
|
||||
user: User = Depends(require("ordering.prices.view_changes"))):
|
||||
"""The prices changed by hand on an order (6F.3), oldest first, for the waiter app and the
|
||||
counter: [{id, item_id, product_name, before, after, delta, quantity, stage, reason, by, approved_by, at}]."""
|
||||
from models.pricing import PriceEventLog
|
||||
from services import price_changes
|
||||
order = db.get(Order, order_id)
|
||||
if order is None:
|
||||
raise XeniaError("order.not_found", order_id=order_id)
|
||||
return [price_changes.event_out(ev, db) for ev in db.query(PriceEventLog).filter(
|
||||
PriceEventLog.order_id == order_id, PriceEventLog.event_type == price_changes.EVENT).order_by(PriceEventLog.id)]
|
||||
|
||||
|
||||
# ─── Waiter-applied manual discount ─────────────────────────────────────────
|
||||
|
||||
from schemas.pricing import ApplyDiscountRequest, ApplyDiscountResponse
|
||||
@@ -1925,6 +2101,8 @@ def move_items(
|
||||
if not items:
|
||||
raise XeniaError("order.no_active_items")
|
||||
|
||||
from services import moves # 6F.4
|
||||
moves.record(db, kind="items_moved", source=source, target=target, items=items, user_id=user.id)
|
||||
moved_ids = []
|
||||
for item in items:
|
||||
item.order_id = target.id
|
||||
@@ -2127,6 +2305,8 @@ def combine_items(order_id: int, body: CombineItemsRequest, request: Request, db
|
||||
rest_ids = [i.id for i in rest]
|
||||
db.query(PriceEventLog).filter(PriceEventLog.order_item_id.in_(rest_ids)).update(
|
||||
{PriceEventLog.order_item_id: keep.id}, synchronize_session=False)
|
||||
from services import moves # 6F.4
|
||||
moves.repoint(db, rest_ids, keep.id)
|
||||
for i in rest:
|
||||
db.delete(i)
|
||||
_audit(db, order_id, "ITEMS_COMBINED", waiter_id=user.id, item_ids=[keep.id] + rest_ids,
|
||||
|
||||
@@ -89,6 +89,7 @@ def _product_out(p, price: float, prices: dict | None = None) -> dict:
|
||||
"price": round(price, 2), "prices": {k: round(v, 2) for k, v in (prices or {}).items()},
|
||||
"sold_at": [sp for sp in sales_points.sold_at(p) if sp in sales_points.IN_PERSON],
|
||||
"base_price": round(p.base_price, 2), "unit_type": p.unit_type or "piece",
|
||||
"one_more": bool(p.one_more_enabled), # 6F.5
|
||||
"tags": _tags(p.tags),
|
||||
"allergens": allergens.of(p),
|
||||
"primary_category_id": p.primary_category_id,
|
||||
@@ -140,8 +141,10 @@ def pos_menu(request: Request, db: Session = Depends(get_db), user=Depends(requi
|
||||
by_point = {sp: pos_cart.unit_prices(db, products, sp) for sp in sales_points.IN_PERSON}
|
||||
default = pos_cart.point_for(settings["default_order_type"])
|
||||
cats = db.query(Category).order_by(Category.sort_order, Category.name).all()
|
||||
from services import price_changes
|
||||
return {
|
||||
"settings": settings,
|
||||
# + the venue's switch for prices changed by hand (6F.3): 'off' hides the line discount
|
||||
"settings": {**settings, "price_change": price_changes.mode(db)},
|
||||
"categories": [{"id": c.id, "name": c.name, "color": c.color, "parent_id": c.parent_id, "sort_order": c.sort_order}
|
||||
for c in cats],
|
||||
"products": [_product_out(p, by_point[default][i], {sp: by_point[sp][i] for sp in sales_points.IN_PERSON})
|
||||
@@ -209,7 +212,7 @@ def pos_sale(body: SaleBody, request: Request, db: Session = Depends(get_db), us
|
||||
orders_api._need(request, db, user, "ordering.orders.close", target="pos sale") # 4.3: taking payment is a key
|
||||
lines = [pos_cart.resolve_line(db, raw if isinstance(raw, dict) else {}, n) for n, raw in enumerate(body.lines)]
|
||||
groups = _payment_groups(body, len(lines))
|
||||
_check_discounts(request, db, user, lines)
|
||||
approved_by = _check_discounts(request, db, user, lines)
|
||||
_check_fiscal(db, {line.product for line in lines})
|
||||
priced = pos_cart.price_lines(db, lines, body.order_type)
|
||||
adjs = [pos_cart.discount_adjustment(unit, line.discount_pct) for line, (unit, _) in zip(lines, priced)]
|
||||
@@ -218,7 +221,7 @@ def pos_sale(body: SaleBody, request: Request, db: Session = Depends(get_db), us
|
||||
_check_cash(body.cash_given, cash_due)
|
||||
|
||||
order = orders_api.open_order(OrderCreate(table_id=None, order_type=body.order_type), db, user)
|
||||
added = orders_api.add_priced_items(order.id, AddItemsRequest(items=_items_in(lines, adjs)), db, user)
|
||||
added = orders_api.add_priced_items(order.id, AddItemsRequest(items=_items_in(lines, adjs, approved_by)), db, user)
|
||||
item_ids = [i.id for i in db.query(OrderItem).filter(OrderItem.order_id == order.id).order_by(OrderItem.id).all()]
|
||||
paid, fiscal = [], None
|
||||
for method, idx in groups:
|
||||
@@ -247,9 +250,16 @@ def _require_shift(db, user):
|
||||
|
||||
|
||||
def _check_discounts(request, db, user, lines):
|
||||
"""A % discount at the counter is a price change in the cart (6F.3): the venue's switch, then
|
||||
the key (or a manager's PIN). Returns the approving manager's id, else None. The reason isn't
|
||||
asked: the discount itself says what it is."""
|
||||
from core.access.context import authorize
|
||||
from services import price_changes
|
||||
if any(line.discount_pct for line in lines):
|
||||
authorize(request, db, user, "ordering.prices.modify", target="pos sale discount")
|
||||
price_changes.check(db, sent=False, by_hand=False)
|
||||
approval = authorize(request, db, user, "ordering.prices.modify", target="pos sale discount")
|
||||
return approval.approved_by if approval is not None else None
|
||||
return None
|
||||
|
||||
|
||||
def _check_fiscal(db, products):
|
||||
@@ -265,14 +275,17 @@ def _check_cash(cash_given, cash_due):
|
||||
raise XeniaError("pos.payment_invalid", reason="cash_short")
|
||||
|
||||
|
||||
def _items_in(lines, adjs):
|
||||
def _items_in(lines, adjs, approved_by=None):
|
||||
"""Resolved lines as orders.add_priced_items takes them (selected_options entries with the
|
||||
database's prices; a discount as the item's price_adjustment)."""
|
||||
database's prices; a discount as the item's price_adjustment, recorded as a manual_price event
|
||||
with "−N %" as its reason, 6F.3)."""
|
||||
from schemas.order import OrderItemInput, SelectedOptionInput
|
||||
return [OrderItemInput(
|
||||
product_id=line.product.id, quantity=line.quantity,
|
||||
selected_options=[SelectedOptionInput(**e) for e in line.entries] or None,
|
||||
removed_ingredients=line.removed or None, notes=line.notes, price_adjustment=adj or None, source="counter",
|
||||
price_reason=f"−{line.discount_pct:g} %" if adj and line.discount_pct else None,
|
||||
price_approved_by=approved_by if adj else None,
|
||||
) for line, adj in zip(lines, adjs)]
|
||||
|
||||
|
||||
@@ -407,13 +420,13 @@ def pos_table_items(table_id: int, body: TableItemsBody, request: Request, db: S
|
||||
elif not _in_zones(db, user, table):
|
||||
raise XeniaError("pos.table_not_yours", table=_table_name(table))
|
||||
lines = [pos_cart.resolve_line(db, raw if isinstance(raw, dict) else {}, n) for n, raw in enumerate(body.lines)]
|
||||
_check_discounts(request, db, user, lines)
|
||||
approved_by = _check_discounts(request, db, user, lines)
|
||||
existing = pos_cart.order_cart(order) if order is not None else None
|
||||
priced = pos_cart.price_lines(db, lines, (order.order_type or "here") if order is not None else "here", existing)
|
||||
adjs = [pos_cart.discount_adjustment(unit, line.discount_pct) for line, (unit, _) in zip(lines, priced)]
|
||||
if order is None:
|
||||
order = orders_api.open_order(OrderCreate(table_id=table_id, order_type="here"), db, user)
|
||||
added = orders_api.add_priced_items(order.id, AddItemsRequest(items=_items_in(lines, adjs)), db, user)
|
||||
added = orders_api.add_priced_items(order.id, AddItemsRequest(items=_items_in(lines, adjs, approved_by)), db, user)
|
||||
return {"order_id": order.id, "print_results": added.get("print_results", []), "deal_offers": added.get("deal_offers", [])}
|
||||
|
||||
|
||||
|
||||
@@ -527,12 +527,11 @@ def get_order_price_events(
|
||||
db: Session = Depends(get_db),
|
||||
user: User = Depends(get_current_user),
|
||||
):
|
||||
events = (
|
||||
db.query(PriceEventLog)
|
||||
.filter(PriceEventLog.order_id == order_id)
|
||||
.order_by(PriceEventLog.applied_at)
|
||||
.all()
|
||||
)
|
||||
from services import price_changes
|
||||
q = db.query(PriceEventLog).filter(PriceEventLog.order_id == order_id)
|
||||
if not price_changes.can_view(user): # prices changed by hand: ordering.prices.view_changes (6F.3)
|
||||
q = q.filter(PriceEventLog.event_type != price_changes.EVENT)
|
||||
events = q.order_by(PriceEventLog.applied_at).all()
|
||||
result = []
|
||||
for ev in events:
|
||||
out = PriceEventOut.model_validate(ev)
|
||||
@@ -541,7 +540,9 @@ def get_order_price_events(
|
||||
if ev.deal:
|
||||
out.deal_name = ev.deal.name
|
||||
if ev.applied_by:
|
||||
out.applied_by_username = ev.applied_by.username
|
||||
out.applied_by_username = ev.applied_by.nickname or ev.applied_by.username
|
||||
if ev.approved_by:
|
||||
out.approved_by_username = ev.approved_by.nickname or ev.approved_by.username
|
||||
result.append(out)
|
||||
return result
|
||||
|
||||
|
||||
@@ -1872,6 +1872,133 @@ def print_prep_zone(
|
||||
# Phase 2L — Discount audit report
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@router.get("/moves")
|
||||
def moves_report(
|
||||
from_dt: Optional[str] = Query(default=None, alias="from"),
|
||||
to_dt: Optional[str] = Query(default=None, alias="to"),
|
||||
business_day_id: Optional[int] = None,
|
||||
kind: Optional[str] = None,
|
||||
by: Optional[int] = None,
|
||||
table_id: Optional[int] = None,
|
||||
db: Session = Depends(get_db),
|
||||
user: User = Depends(require_reports),
|
||||
):
|
||||
"""Moves between tables and orders (6F.4) in a period or a business day: each move (kind, from /
|
||||
to table and order, who, the lines with their quantity and value), counts per kind and per
|
||||
person. `table_id`: moves from or to that table."""
|
||||
from models.order import OrderMove, OrderItem
|
||||
from services import moves
|
||||
q = db.query(OrderMove)
|
||||
if business_day_id:
|
||||
q = q.filter(OrderMove.business_day_id == business_day_id)
|
||||
elif from_dt and to_dt:
|
||||
q = q.filter(OrderMove.at >= history_since(from_dt, 'reports'), OrderMove.at <= parse_api_datetime(to_dt))
|
||||
if kind:
|
||||
q = q.filter(OrderMove.kind == kind)
|
||||
if by:
|
||||
q = q.filter(OrderMove.by_user_id == by)
|
||||
if table_id:
|
||||
q = q.filter((OrderMove.from_table_id == table_id) | (OrderMove.to_table_id == table_id))
|
||||
rows = q.order_by(OrderMove.at.desc()).all()
|
||||
tables, users = moves._names(db)
|
||||
item_ids = {i.item_id for m in rows for i in m.items}
|
||||
lines = {i.id: i for i in db.query(OrderItem).filter(OrderItem.id.in_(item_ids)).all()} if item_ids else {}
|
||||
names = {i.id: i.product_name for i in lines.values()}
|
||||
out, by_kind, by_person = [], {}, {}
|
||||
for m in rows:
|
||||
row = moves.move_out(m, tables, users, names)
|
||||
row["at"] = _dt(m.at)
|
||||
row["value"] = round(sum(((lines[i.item_id].unit_price or 0) + (lines[i.item_id].price_adjustment or 0)) * (i.quantity or lines[i.item_id].quantity or 0)
|
||||
for i in m.items if i.item_id in lines), 2)
|
||||
out.append(row)
|
||||
by_kind[m.kind] = by_kind.get(m.kind, 0) + 1
|
||||
p = by_person.setdefault(m.by_user_id, {"user_id": m.by_user_id, "name": row["by"], "count": 0})
|
||||
p["count"] += 1
|
||||
return {"moves": out, "count": len(out), "by_kind": by_kind,
|
||||
"by_person": sorted(by_person.values(), key=lambda x: -x["count"])}
|
||||
|
||||
|
||||
@router.get("/moves/export")
|
||||
def moves_export(
|
||||
from_dt: Optional[str] = Query(default=None, alias="from"),
|
||||
to_dt: Optional[str] = Query(default=None, alias="to"),
|
||||
business_day_id: Optional[int] = None,
|
||||
kind: Optional[str] = None,
|
||||
by: Optional[int] = None,
|
||||
table_id: Optional[int] = None,
|
||||
db: Session = Depends(get_db),
|
||||
user: User = Depends(require_reports),
|
||||
):
|
||||
data = moves_report(from_dt=from_dt, to_dt=to_dt, business_day_id=business_day_id, kind=kind, by=by, table_id=table_id, db=db, user=user)
|
||||
rows = [{"id": m["id"], "at": m["at"], "kind": m["kind"], "from_table": m["from_table"] or "", "to_table": m["to_table"] or "",
|
||||
"from_order": m["from_order_id"], "to_order": m["to_order_id"], "by": m["by"] or "",
|
||||
"lines": "; ".join(f"{i.get('name') or i['item_id']} ×{i['quantity'] if i['quantity'] is not None else '?'}" for i in m["items"]),
|
||||
"value": m["value"]} for m in data["moves"]]
|
||||
fields = ["id", "at", "kind", "from_table", "to_table", "from_order", "to_order", "by", "lines", "value"]
|
||||
return csv_export.response(db, rows, fields, f"moves-{(from_dt or '')[:10]}.csv", times=("at",))
|
||||
|
||||
|
||||
@router.get("/price-changes")
|
||||
def price_changes_report(
|
||||
from_dt: Optional[str] = Query(default=None, alias="from"),
|
||||
to_dt: Optional[str] = Query(default=None, alias="to"),
|
||||
business_day_id: Optional[int] = None,
|
||||
applied_by: Optional[int] = None,
|
||||
db: Session = Depends(get_db),
|
||||
user: User = Depends(require_reports),
|
||||
):
|
||||
"""Prices changed by hand (6F.3) in a period or a business day: each change (the line, before →
|
||||
after, the difference for its quantity, the stage, who, the approving manager, why, the table),
|
||||
totals per person. Needs ordering.prices.view_changes besides the reports key."""
|
||||
from core.access.check import holds
|
||||
from models.pricing import PriceEventLog
|
||||
from services import price_changes
|
||||
if not holds(user, "ordering.prices.view_changes"):
|
||||
raise XeniaError("access.denied", key="ordering.prices.view_changes")
|
||||
q = db.query(PriceEventLog).filter(PriceEventLog.event_type == price_changes.EVENT)
|
||||
if business_day_id:
|
||||
q = q.join(Order, Order.id == PriceEventLog.order_id).filter(Order.business_day_id == business_day_id)
|
||||
elif from_dt and to_dt:
|
||||
q = q.filter(PriceEventLog.applied_at >= history_since(from_dt, 'reports'),
|
||||
PriceEventLog.applied_at <= parse_api_datetime(to_dt))
|
||||
if applied_by:
|
||||
q = q.filter(PriceEventLog.applied_by_user_id == applied_by)
|
||||
events = q.order_by(PriceEventLog.applied_at.desc()).all()
|
||||
tables_map = {t.id: (t.label or f"T{t.number}") for t in db.query(Table).all()}
|
||||
orders_map = {o.id: o for o in db.query(Order).filter(Order.id.in_({e.order_id for e in events})).all()} if events else {}
|
||||
rows, by_person, total = [], {}, 0.0
|
||||
for ev in events:
|
||||
row = price_changes.event_out(ev, db)
|
||||
row["at"] = _dt(ev.applied_at)
|
||||
order = orders_map.get(ev.order_id)
|
||||
row["table_name"] = tables_map.get(order.table_id) if order is not None and order.table_id else None
|
||||
row["value"] = round((ev.delta_amount or 0.0) * (ev.quantity or 1.0), 2)
|
||||
total += row["value"]
|
||||
p = by_person.setdefault(ev.applied_by_user_id, {"user_id": ev.applied_by_user_id, "name": row["by"], "count": 0, "total_value": 0.0})
|
||||
p["count"] += 1
|
||||
p["total_value"] = round(p["total_value"] + row["value"], 2)
|
||||
rows.append(row)
|
||||
return {"changes": rows, "total_value": round(total, 2), "count": len(rows),
|
||||
"by_person": sorted(by_person.values(), key=lambda x: x["total_value"])}
|
||||
|
||||
|
||||
@router.get("/price-changes/export")
|
||||
def price_changes_export(
|
||||
from_dt: Optional[str] = Query(default=None, alias="from"),
|
||||
to_dt: Optional[str] = Query(default=None, alias="to"),
|
||||
business_day_id: Optional[int] = None,
|
||||
applied_by: Optional[int] = None,
|
||||
db: Session = Depends(get_db),
|
||||
user: User = Depends(require_reports),
|
||||
):
|
||||
data = price_changes_report(from_dt=from_dt, to_dt=to_dt, business_day_id=business_day_id, applied_by=applied_by, db=db, user=user)
|
||||
rows = [{"id": c["id"], "order_id": c["order_id"], "table": c["table_name"] or "", "product": c["product_name"] or "",
|
||||
"quantity": c["quantity"], "before": c["before"], "after": c["after"], "value": c["value"], "stage": c["stage"] or "",
|
||||
"by": c["by"] or "", "approved_by": c["approved_by"] or "", "reason": c["reason"] or "", "at": c["at"]} for c in data["changes"]]
|
||||
fields = ["id", "order_id", "table", "product", "quantity", "before", "after", "value", "stage", "by", "approved_by", "reason", "at"]
|
||||
return csv_export.response(db, rows, fields, f"price-changes-{(from_dt or '')[:10]}.csv", times=("at",))
|
||||
|
||||
|
||||
@router.get("/discounts")
|
||||
def discounts_report(
|
||||
from_dt: Optional[str] = Query(default=None, alias="from"),
|
||||
|
||||
@@ -57,6 +57,7 @@ REVIEWS = "signage.reviews" # the venue's reviews, typed in by hand
|
||||
MAX_WIDGETS = "signage.max_widgets" # widgets a slide may hold (owner review 6: Performance; 10 recommended)
|
||||
MAX_WIDGETS_CAP = 50 # never more, whatever the setting
|
||||
AREA_MAX = 4000 # px a screen's picture area may cut off one edge (6R.13)
|
||||
AREA_OUT = 2000 # px it may reach past an edge of the window the TV reported (owner 2026-11-23)
|
||||
AREA_KEYS = ("area_left", "area_top", "area_right", "area_bottom")
|
||||
CALIBRATE_S = 15 * 60 # a calibration nobody ends stops by itself
|
||||
_viewports: dict = {} # device id → {width, height, ratio} (what the TV reported; memory only)
|
||||
@@ -199,19 +200,24 @@ class MenuList(_Strict):
|
||||
return out
|
||||
|
||||
|
||||
BOX_MAX = 400 # % of the slide a widget's box may reach (owner 2026-11-23)
|
||||
|
||||
|
||||
class Box(_Strict):
|
||||
"""Where a widget moved by hand sits (2026-11-21): % of the slide's (or its stack place's) width /
|
||||
height. Owner review 6: it may run off the slide, as long as a strip of it (5 %) stays on it to
|
||||
grab it back; a text, clock, QR… is as big as its content (its height sets the size)."""
|
||||
x: float = Field(ge=-100, le=100)
|
||||
y: float = Field(ge=-100, le=100)
|
||||
w: float = Field(ge=1, le=100)
|
||||
h: float = Field(ge=1, le=100)
|
||||
grab it back; a text, clock, QR… is as big as its content (its height sets the size). Owner
|
||||
2026-11-23: up to four times the slide (a picture made larger than the slide is cut off at its
|
||||
edges, zoomed in)."""
|
||||
x: float = Field(ge=-BOX_MAX, le=100)
|
||||
y: float = Field(ge=-BOX_MAX, le=100)
|
||||
w: float = Field(ge=1, le=BOX_MAX)
|
||||
h: float = Field(ge=1, le=BOX_MAX)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def _inside(self):
|
||||
self.w = round(min(self.w, 100), 2)
|
||||
self.h = round(min(self.h, 100), 2)
|
||||
self.w = round(self.w, 2)
|
||||
self.h = round(self.h, 2)
|
||||
self.x = round(min(max(self.x, 5 - self.w), 95), 2)
|
||||
self.y = round(min(max(self.y, 5 - self.h), 95), 2)
|
||||
return self
|
||||
@@ -328,6 +334,7 @@ class Widget(_Strict):
|
||||
gallery_seconds: int = Field(default=5, ge=3, le=120)
|
||||
gallery_transition: Literal["fade", "slide", "zoom", "none"] = "fade"
|
||||
gallery_fit: Literal["cover", "contain"] = "cover"
|
||||
title_position: Literal["above", "below"] = "above" # its title (`text`) above or below the pictures (owner 2026-11-23)
|
||||
# more settings (6R.17), every widget: on the element that places it
|
||||
opacity: int = Field(default=100, ge=10, le=100)
|
||||
rotation: int = Field(default=0, ge=-180, le=180)
|
||||
@@ -578,10 +585,10 @@ class ScreenBody(BaseModel):
|
||||
orientation: Optional[Orientation] = None
|
||||
rotation: Optional[Literal[0, 90, 180, 270]] = None
|
||||
# its picture area (6R.13): px cut off each edge of the TV's window; how a slide of another shape fits
|
||||
area_left: Optional[int] = Field(default=None, ge=0, le=AREA_MAX)
|
||||
area_top: Optional[int] = Field(default=None, ge=0, le=AREA_MAX)
|
||||
area_right: Optional[int] = Field(default=None, ge=0, le=AREA_MAX)
|
||||
area_bottom: Optional[int] = Field(default=None, ge=0, le=AREA_MAX)
|
||||
area_left: Optional[int] = Field(default=None, ge=-AREA_OUT, le=AREA_MAX)
|
||||
area_top: Optional[int] = Field(default=None, ge=-AREA_OUT, le=AREA_MAX)
|
||||
area_right: Optional[int] = Field(default=None, ge=-AREA_OUT, le=AREA_MAX)
|
||||
area_bottom: Optional[int] = Field(default=None, ge=-AREA_OUT, le=AREA_MAX)
|
||||
fit: Optional[Literal["keep", "stretch"]] = None
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ class OrderItemInput(BaseModel):
|
||||
is_service_item: bool = False # priceless: print-once ephemeral; priced: saved as real item
|
||||
course_id: Optional[int] = None
|
||||
source: Optional[str] = None # set by the server (4.8): waiter | counter | qr | online
|
||||
# a price changed by hand (6F.3), set by the server: the reason and the approving manager
|
||||
price_reason: Optional[str] = None
|
||||
price_approved_by: Optional[int] = None
|
||||
|
||||
|
||||
class AddItemsRequest(BaseModel):
|
||||
@@ -37,6 +40,8 @@ class AddItemsRequest(BaseModel):
|
||||
class ProductNameOut(BaseModel):
|
||||
id: int
|
||||
name: str
|
||||
one_more_enabled: bool = False # 6F.5: the line shows +1
|
||||
unit_type: Optional[str] = None
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
@@ -68,6 +73,7 @@ class OrderItemOut(BaseModel):
|
||||
source: Optional[str] = None # waiter | counter | qr | online (4.8); None = before 4.8
|
||||
deal_id: Optional[int] = None
|
||||
linked_item_id: Optional[int] = None
|
||||
split_from_id: Optional[int] = None # 6F.4: the line it was cut from
|
||||
system_key: Optional[str] = None # a line the system added: "delivery_fee" (phase 3S, S.5)
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
@@ -308,10 +308,15 @@ class PriceEventOut(BaseModel):
|
||||
conditions_snapshot: Optional[dict]
|
||||
selected_item_ids: Optional[List[int]]
|
||||
applied_at: datetime
|
||||
# manual_price (6F.3)
|
||||
approved_by_user_id: Optional[int] = None
|
||||
stage: Optional[str] = None
|
||||
quantity: Optional[float] = None
|
||||
# Resolved names (joined at query time)
|
||||
modifier_name: Optional[str] = None
|
||||
deal_name: Optional[str] = None
|
||||
applied_by_username: Optional[str] = None
|
||||
approved_by_username: Optional[str] = None
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
@@ -386,6 +386,7 @@ class ProductBase(BaseModel):
|
||||
cost_breakdown: Optional[List[CostBreakdownItem]] = None
|
||||
# Quick Add
|
||||
quick_add_enabled: bool = True
|
||||
one_more_enabled: bool = False # 6F.5
|
||||
# Tags
|
||||
tags: Optional[List[str]] = None
|
||||
# The EU allergens (plan step 6.3): {key: "contains" | "may_contain"}, core/allergens.py
|
||||
@@ -437,6 +438,7 @@ class ProductUpdate(BaseModel):
|
||||
cost_breakdown: Optional[List[CostBreakdownItem]] = None
|
||||
# Quick Add
|
||||
quick_add_enabled: Optional[bool] = None
|
||||
one_more_enabled: Optional[bool] = None # 6F.5
|
||||
# Tags
|
||||
tags: Optional[List[str]] = None
|
||||
allergens: Optional[Dict[str, str]] = None # None = unchanged, {} = none
|
||||
@@ -510,6 +512,7 @@ class ProductOut(ProductBase):
|
||||
'cost_simple': data.cost_simple,
|
||||
'cost_breakdown': parsed,
|
||||
'quick_add_enabled': getattr(data, 'quick_add_enabled', True),
|
||||
'one_more_enabled': bool(getattr(data, 'one_more_enabled', False)),
|
||||
'tags': json.loads(data.tags) if isinstance(getattr(data, 'tags', None), str) else (getattr(data, 'tags', None) or []),
|
||||
'allergens': _allergens_of(data),
|
||||
'translations': _menu_tr_of(data),
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
"""Moves on the record (owner 2026-11-23, plan step 6F.4).
|
||||
|
||||
Every move between tables or orders is an `OrderMove` row with the lines that went
|
||||
(`OrderMoveItem`: the line and its quantity then):
|
||||
- `table_transfer`: the whole order went to another (free) table (POST /api/orders/{id}/transfer);
|
||||
- `items_moved`: chosen lines went to another open order (POST /api/orders/{id}/move-items);
|
||||
- `orders_merged`: an order was joined into another (POST /api/orders/{id}/merge).
|
||||
|
||||
A line keeps its id when it moves, so its path is its own moves. A line cut from another
|
||||
(`OrderItem.split_from_id`: a split, later a lowered quantity or a split payment) also carries
|
||||
the moves its parent had **before** the cut, however many times that happened. Combining lines
|
||||
moves the removed lines' moves to the line that stays (routers/orders.combine_items).
|
||||
|
||||
Readers: GET /api/orders/{id}/moves (the order's path and each line's), Reports → Moves
|
||||
(GET /api/reports/moves). The old OrderAuditLog rows stay as they were.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
KINDS = ("table_transfer", "items_moved", "orders_merged")
|
||||
|
||||
|
||||
def record(db, *, kind: str, source, target, items, user_id: int | None, from_table_id=None, to_table_id=None,
|
||||
approved_by: int | None = None):
|
||||
"""One move (flushed with the caller's commit). `source` / `target`: orders; `items`: lines."""
|
||||
from models.order import OrderMove, OrderMoveItem
|
||||
assert kind in KINDS, kind
|
||||
move = OrderMove(
|
||||
kind=kind, from_order_id=getattr(source, "id", None), to_order_id=getattr(target, "id", None),
|
||||
from_table_id=from_table_id if from_table_id is not None else getattr(source, "table_id", None),
|
||||
to_table_id=to_table_id if to_table_id is not None else getattr(target, "table_id", None),
|
||||
by_user_id=user_id, approved_by_user_id=approved_by,
|
||||
business_day_id=getattr(target, "business_day_id", None) or getattr(source, "business_day_id", None),
|
||||
)
|
||||
move.items = [OrderMoveItem(item_id=i.id, quantity=i.quantity) for i in items]
|
||||
db.add(move)
|
||||
return move
|
||||
|
||||
|
||||
def repoint(db, from_ids, to_id: int) -> None:
|
||||
"""Lines removed by a combine: their moves (and children) now belong to the line kept."""
|
||||
from models.order import OrderItem, OrderMoveItem
|
||||
from_ids = [i for i in from_ids if i != to_id]
|
||||
if not from_ids:
|
||||
return
|
||||
for mi in db.query(OrderMoveItem).filter(OrderMoveItem.item_id.in_(from_ids)).all():
|
||||
taken = db.query(OrderMoveItem).filter(OrderMoveItem.move_id == mi.move_id, OrderMoveItem.item_id == to_id).first()
|
||||
if taken is None:
|
||||
db.add(OrderMoveItem(move_id=mi.move_id, item_id=to_id, quantity=mi.quantity))
|
||||
else:
|
||||
taken.quantity = (taken.quantity or 0) + (mi.quantity or 0)
|
||||
db.delete(mi)
|
||||
db.query(OrderItem).filter(OrderItem.split_from_id.in_(from_ids)).update(
|
||||
{OrderItem.split_from_id: to_id}, synchronize_session=False)
|
||||
|
||||
|
||||
def _lineage(db, item):
|
||||
"""[(line id, moves up to when) …]: the line itself (all its moves), then each parent up to the
|
||||
moment the child was cut from it."""
|
||||
from models.order import OrderItem
|
||||
out, seen = [(item.id, None)], {item.id}
|
||||
child = item
|
||||
while child.split_from_id and child.split_from_id not in seen:
|
||||
parent = db.get(OrderItem, child.split_from_id)
|
||||
if parent is None:
|
||||
break
|
||||
out.append((parent.id, child.added_at))
|
||||
seen.add(parent.id)
|
||||
child = parent
|
||||
return out
|
||||
|
||||
|
||||
def item_moves(db, item) -> list:
|
||||
"""The moves a line went through, oldest first (its parents' before it was cut from them)."""
|
||||
from models.order import OrderMove, OrderMoveItem
|
||||
found = {}
|
||||
for line_id, until in _lineage(db, item):
|
||||
q = db.query(OrderMove).join(OrderMoveItem, OrderMoveItem.move_id == OrderMove.id).filter(OrderMoveItem.item_id == line_id)
|
||||
if until is not None:
|
||||
q = q.filter(OrderMove.at <= until)
|
||||
for m in q.all():
|
||||
found[m.id] = m
|
||||
return sorted(found.values(), key=lambda m: (m.at, m.id))
|
||||
|
||||
|
||||
def order_moves(db, order) -> list:
|
||||
"""The whole order's path: table transfers and merges into it, and the orders merged into it
|
||||
(their own transfers too), oldest first."""
|
||||
from models.order import OrderMove
|
||||
ids, todo, found = set(), [order.id], {}
|
||||
while todo:
|
||||
oid = todo.pop()
|
||||
if oid in ids:
|
||||
continue
|
||||
ids.add(oid)
|
||||
for m in db.query(OrderMove).filter(OrderMove.to_order_id == oid,
|
||||
OrderMove.kind.in_(("table_transfer", "orders_merged"))).all():
|
||||
found[m.id] = m
|
||||
if m.kind == "orders_merged" and m.from_order_id:
|
||||
todo.append(m.from_order_id)
|
||||
return sorted(found.values(), key=lambda m: (m.at, m.id))
|
||||
|
||||
|
||||
def _names(db):
|
||||
from models.table import Table
|
||||
from models.user import User
|
||||
tables = {t.id: (t.label or f"T{t.number}") for t in db.query(Table).all()}
|
||||
users = {u.id: (u.nickname or u.full_name or u.username) for u in db.query(User).all()}
|
||||
return tables, users
|
||||
|
||||
|
||||
def move_out(m, tables, users, item_names=None) -> dict:
|
||||
return {
|
||||
"id": m.id, "kind": m.kind, "at": m.at,
|
||||
"from_order_id": m.from_order_id, "to_order_id": m.to_order_id,
|
||||
"from_table_id": m.from_table_id, "to_table_id": m.to_table_id,
|
||||
"from_table": tables.get(m.from_table_id), "to_table": tables.get(m.to_table_id),
|
||||
"by_id": m.by_user_id, "by": users.get(m.by_user_id),
|
||||
"approved_by": users.get(m.approved_by_user_id),
|
||||
"items": [{"item_id": i.item_id, "quantity": i.quantity,
|
||||
**({"name": item_names.get(i.item_id)} if item_names is not None else {})} for i in m.items],
|
||||
}
|
||||
|
||||
|
||||
def for_order(db, order) -> dict:
|
||||
"""GET /api/orders/{id}/moves: {order: [moves of the whole order], items: {line id: [moves]}}
|
||||
(only lines that moved)."""
|
||||
tables, users = _names(db)
|
||||
per_item = {}
|
||||
for item in order.items:
|
||||
ms = item_moves(db, item)
|
||||
if ms:
|
||||
per_item[str(item.id)] = [move_out(m, tables, users) for m in ms]
|
||||
return {"order": [move_out(m, tables, users) for m in order_moves(db, order)], "items": per_item}
|
||||
@@ -0,0 +1,124 @@
|
||||
"""Prices changed by hand, on the record (owner 2026-11-23, plan step 6F.3).
|
||||
|
||||
Who may change a line's price, in three levels like every permission:
|
||||
- the venue (setting `orders.price_change`): `off` | `before_sending` (only in the cart, before
|
||||
the line is sent) | `anytime` (also a line already sent or served; the default, as before 6F.3);
|
||||
- the keys: `ordering.prices.modify` (in the cart; the counter's % discount too) and
|
||||
`ordering.prices.modify_sent` (a line already sent), role defaults per venue, changed per person;
|
||||
both may be approved once by a manager's PIN (D-10);
|
||||
- `orders.price_change_reason`: when on, a by-hand price needs a reason (the venue's quick
|
||||
reasons, `orders.price_change_reasons`, or typed).
|
||||
|
||||
Every change writes one `PriceEventLog` row, `event_type = "manual_price"`: the line, its unit price
|
||||
before and after, the change, the quantity, who, the approving manager, the stage
|
||||
(cart | sent | served) and the reason (`waiter_note`), plus an `OrderAuditLog` `PRICE_CHANGED`.
|
||||
Rows are never deleted; combining lines moves them to the kept line (orders.combine_items).
|
||||
Who sees them: `ordering.prices.view_changes` (GET /api/pricing/events/order/{id},
|
||||
GET /api/orders/{id}/items/{item}/price-changes, Reports → Cancellations, discounts and price changes).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
from core.errors import XeniaError
|
||||
|
||||
EVENT = "manual_price"
|
||||
MODES = ("off", "before_sending", "anytime")
|
||||
STAGES = ("cart", "sent", "served")
|
||||
REASON_MAX = 200
|
||||
|
||||
|
||||
def _setting(db, key: str, default: str) -> str:
|
||||
from models.settings import PosSettings
|
||||
row = db.query(PosSettings).filter(PosSettings.key == key).first()
|
||||
return row.value if row is not None and row.value not in (None, "") else default
|
||||
|
||||
|
||||
def mode(db) -> str:
|
||||
v = _setting(db, "orders.price_change", "anytime")
|
||||
return v if v in MODES else "anytime"
|
||||
|
||||
|
||||
def reason_required(db) -> bool:
|
||||
return _setting(db, "orders.price_change_reason", "false") == "true"
|
||||
|
||||
|
||||
def quick_reasons(db) -> list[str]:
|
||||
try:
|
||||
v = json.loads(_setting(db, "orders.price_change_reasons", "[]"))
|
||||
except ValueError:
|
||||
return []
|
||||
return [str(x).strip() for x in v if isinstance(x, str) and x.strip()] if isinstance(v, list) else []
|
||||
|
||||
|
||||
def clean_reason(reason) -> str | None:
|
||||
text = " ".join(str(reason or "").split())[:REASON_MAX]
|
||||
return text or None
|
||||
|
||||
|
||||
def check(db, *, sent: bool, reason=None, by_hand: bool = True) -> str | None:
|
||||
"""Refuse a price change the venue doesn't allow (order.price_change_off /
|
||||
order.price_change_sent_off) or one without its reason (order.price_reason_required, only for
|
||||
a price typed by hand: the counter's % discount has none). Returns the cleaned reason."""
|
||||
m = mode(db)
|
||||
if m == "off":
|
||||
raise XeniaError("order.price_change_off")
|
||||
if sent and m != "anytime":
|
||||
raise XeniaError("order.price_change_sent_off")
|
||||
text = clean_reason(reason)
|
||||
if by_hand and text is None and reason_required(db):
|
||||
raise XeniaError("order.price_reason_required")
|
||||
return text
|
||||
|
||||
|
||||
def stage_of(item) -> str:
|
||||
"""Where a line is when its price changes: in the cart (being added), sent, or served."""
|
||||
if item is None or getattr(item, "id", None) is None:
|
||||
return "cart"
|
||||
return "served" if getattr(item, "kds_status", None) == "served" else "sent"
|
||||
|
||||
|
||||
def record(db, *, item, before: float, after: float, user_id: int | None, stage: str,
|
||||
reason: str | None = None, approved_by: int | None = None, audit: bool = True):
|
||||
"""One manual_price event for `item` (flushed with the caller's commit) and its audit row."""
|
||||
from models.order import OrderAuditLog
|
||||
from models.pricing import PriceEventLog
|
||||
before, after = round(float(before), 2), round(float(after), 2)
|
||||
if abs(after - before) < 0.005:
|
||||
return None
|
||||
ev = PriceEventLog(
|
||||
order_id=item.order_id, order_item_id=item.id, event_type=EVENT,
|
||||
price_before=before, price_after=after, delta_amount=round(after - before, 2),
|
||||
applied_by_user_id=user_id, approved_by_user_id=approved_by, waiter_note=reason,
|
||||
stage=stage if stage in STAGES else "cart", quantity=item.quantity,
|
||||
)
|
||||
db.add(ev)
|
||||
if audit:
|
||||
db.add(OrderAuditLog(order_id=item.order_id, event_type="PRICE_CHANGED", waiter_id=user_id,
|
||||
item_ids=json.dumps([item.id]),
|
||||
note=f"{before:.2f} → {after:.2f}" + (f" · {reason}" if reason else "")
|
||||
+ (f" · approved by user {approved_by}" if approved_by else "")))
|
||||
return ev
|
||||
|
||||
|
||||
def _name(user) -> str | None:
|
||||
return (user.nickname or user.full_name or user.username) if user is not None else None
|
||||
|
||||
|
||||
def event_out(ev, db) -> dict:
|
||||
"""One manual_price event for the apps and the reports."""
|
||||
item = ev.order_item
|
||||
return {
|
||||
"id": ev.id, "order_id": ev.order_id, "item_id": ev.order_item_id,
|
||||
"product_name": item.product_name if item is not None else None,
|
||||
"before": ev.price_before, "after": ev.price_after, "delta": ev.delta_amount,
|
||||
"quantity": ev.quantity, "stage": ev.stage, "reason": ev.waiter_note,
|
||||
"by_id": ev.applied_by_user_id, "by": _name(ev.applied_by),
|
||||
"approved_by_id": ev.approved_by_user_id, "approved_by": _name(ev.approved_by),
|
||||
"at": ev.applied_at,
|
||||
}
|
||||
|
||||
|
||||
def can_view(user) -> bool:
|
||||
from core.access.check import holds
|
||||
return holds(user, "ordering.prices.view_changes")
|
||||
@@ -0,0 +1,140 @@
|
||||
"""Moves on the record (owner 2026-11-23, plan 6F.4, services/moves.py).
|
||||
|
||||
A table transfer, lines moved to another order and two orders merged each leave one move with its
|
||||
lines; a line's path survives being moved three times, being split (the part carries the moves made
|
||||
before the split, not after) and being combined; the order shows where it came from; Reports →
|
||||
Moves lists them.
|
||||
"""
|
||||
import pytest
|
||||
|
||||
from tests.test_waiter_keys import shop # noqa: F401 (fixture)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _no_printing(monkeypatch):
|
||||
import routers.orders as orders
|
||||
monkeypatch.setattr(orders, "route_and_print_sync", lambda *a, **k: [])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def floor(db, shop):
|
||||
"""Four free tables and the shop's waiter's order put on the first."""
|
||||
from models.table import Table, TableGroup
|
||||
g = TableGroup(name="Hall")
|
||||
db.add(g)
|
||||
db.flush()
|
||||
ts = [Table(number=n, group_id=g.id, is_active=True) for n in (1, 2, 3, 4)]
|
||||
db.add_all(ts)
|
||||
db.flush()
|
||||
shop["order"].table_id = ts[0].id
|
||||
shop["order"].status = "open"
|
||||
for i in shop["items"]:
|
||||
i.status = "active"
|
||||
db.commit()
|
||||
return ts
|
||||
|
||||
|
||||
def new_order(db, shop, table, n=1):
|
||||
from models.order import Order, OrderItem
|
||||
o = Order(opened_by=shop["waiter"].id, table_id=table.id, status="open")
|
||||
db.add(o)
|
||||
db.flush()
|
||||
items = [OrderItem(order_id=o.id, product_id=shop["items"][0].product_id, added_by=shop["waiter"].id, quantity=1, unit_price=4.0)
|
||||
for _ in range(n)]
|
||||
db.add_all(items)
|
||||
db.commit()
|
||||
return o, items
|
||||
|
||||
|
||||
def test_a_transfer_is_one_move_with_its_lines(client, db, shop, floor):
|
||||
o = shop["order"]
|
||||
r = client.post(f"/api/orders/{o.id}/transfer", headers=shop["h"], json={"target_table_id": floor[1].id})
|
||||
assert r.status_code == 200, r.text
|
||||
got = client.get(f"/api/orders/{o.id}/moves", headers=shop["h"]).json()
|
||||
[m] = got["order"]
|
||||
assert m["kind"] == "table_transfer" and (m["from_table_id"], m["to_table_id"]) == (floor[0].id, floor[1].id)
|
||||
assert m["from_table"] == "T1" and m["to_table"] == "T2" and m["by_id"] == shop["waiter"].id
|
||||
assert {i["item_id"] for i in m["items"]} == {i.id for i in shop["items"]}
|
||||
assert set(got["items"]) == {str(i.id) for i in shop["items"]}
|
||||
|
||||
|
||||
def test_a_line_moved_three_times_shows_every_step(client, db, shop, floor):
|
||||
o1 = shop["order"]
|
||||
o2, _ = new_order(db, shop, floor[1])
|
||||
o3, _ = new_order(db, shop, floor[2])
|
||||
line = shop["items"][0]
|
||||
for src, dst in ((o1, o2), (o2, o3), (o3, o1)):
|
||||
r = client.post(f"/api/orders/{src.id}/move-items", headers=shop["h"], json={"item_ids": [line.id], "target_order_id": dst.id})
|
||||
assert r.status_code == 200, r.text
|
||||
path = client.get(f"/api/orders/{o1.id}/moves", headers=shop["h"]).json()["items"][str(line.id)]
|
||||
assert [(m["from_table"], m["to_table"]) for m in path] == [("T1", "T2"), ("T2", "T3"), ("T3", "T1")]
|
||||
assert all(m["kind"] == "items_moved" for m in path)
|
||||
|
||||
|
||||
def test_a_split_part_keeps_the_moves_before_the_split_only(client, db, shop, floor):
|
||||
o1 = shop["order"]
|
||||
o2, _ = new_order(db, shop, floor[1])
|
||||
o3, _ = new_order(db, shop, floor[2])
|
||||
line = shop["items"][0]
|
||||
line.quantity = 3
|
||||
line.price_adjustment = -0.5
|
||||
line.kds_status = "served"
|
||||
db.commit()
|
||||
client.post(f"/api/orders/{o1.id}/move-items", headers=shop["h"], json={"item_ids": [line.id], "target_order_id": o2.id})
|
||||
r = client.post(f"/api/orders/{o2.id}/items/{line.id}/split", headers=shop["h"], json={"quantity": 1})
|
||||
assert r.status_code == 200, r.text
|
||||
part = [x for x in r.json() if x["id"] != line.id][0]
|
||||
assert part["split_from_id"] == line.id
|
||||
# the part keeps what the line was (its price change, the kitchen state)
|
||||
from models.order import OrderItem
|
||||
db.expire_all()
|
||||
p = db.get(OrderItem, part["id"])
|
||||
assert p.price_adjustment == -0.5 and p.kds_status == "served"
|
||||
# the original moves on; the part stays
|
||||
client.post(f"/api/orders/{o2.id}/move-items", headers=shop["h"], json={"item_ids": [line.id], "target_order_id": o3.id})
|
||||
part_path = client.get(f"/api/orders/{o2.id}/moves", headers=shop["h"]).json()["items"][str(part["id"])]
|
||||
assert [(m["from_table"], m["to_table"]) for m in part_path] == [("T1", "T2")]
|
||||
line_path = client.get(f"/api/orders/{o3.id}/moves", headers=shop["h"]).json()["items"][str(line.id)]
|
||||
assert [(m["from_table"], m["to_table"]) for m in line_path] == [("T1", "T2"), ("T2", "T3")]
|
||||
|
||||
|
||||
def test_a_merge_brings_the_other_orders_path(client, db, shop, floor):
|
||||
o1 = shop["order"]
|
||||
o2, lines2 = new_order(db, shop, floor[1])
|
||||
client.post(f"/api/orders/{o2.id}/transfer", headers=shop["h"], json={"target_table_id": floor[3].id})
|
||||
r = client.post(f"/api/orders/{o2.id}/merge", headers=shop["h"], json={"target_order_id": o1.id})
|
||||
assert r.status_code == 200, r.text
|
||||
got = client.get(f"/api/orders/{o1.id}/moves", headers=shop["h"]).json()
|
||||
assert [m["kind"] for m in got["order"]] == ["table_transfer", "orders_merged"]
|
||||
merged = got["order"][1]
|
||||
assert (merged["from_order_id"], merged["to_order_id"], merged["from_table"], merged["to_table"]) == (o2.id, o1.id, "T4", "T1")
|
||||
assert [m["kind"] for m in got["items"][str(lines2[0].id)]] == ["table_transfer", "orders_merged"]
|
||||
|
||||
|
||||
def test_combining_lines_keeps_their_moves(client, db, shop, floor):
|
||||
o1 = shop["order"]
|
||||
o2, _ = new_order(db, shop, floor[1])
|
||||
a, b = shop["items"][0], shop["items"][1]
|
||||
client.post(f"/api/orders/{o1.id}/move-items", headers=shop["h"], json={"item_ids": [a.id, b.id], "target_order_id": o2.id})
|
||||
r = client.post(f"/api/orders/{o2.id}/items/combine", headers=shop["h"], json={"item_ids": [a.id, b.id]})
|
||||
assert r.status_code == 200, r.text
|
||||
from models.order import OrderMoveItem
|
||||
db.expire_all()
|
||||
[mi] = db.query(OrderMoveItem).all()
|
||||
assert mi.item_id == a.id and mi.quantity == 2
|
||||
|
||||
|
||||
def test_the_moves_report(client, db, shop, floor, make_user, login):
|
||||
o1 = shop["order"]
|
||||
o2, _ = new_order(db, shop, floor[1])
|
||||
client.post(f"/api/orders/{o1.id}/move-items", headers=shop["h"], json={"item_ids": [shop["items"][0].id], "target_order_id": o2.id})
|
||||
client.post(f"/api/orders/{o2.id}/transfer", headers=shop["h"], json={"target_table_id": floor[2].id})
|
||||
boss = login(make_user(role="owner"))
|
||||
rep = client.get("/api/reports/moves", headers=boss).json()
|
||||
assert rep["count"] == 2 and rep["by_kind"] == {"items_moved": 1, "table_transfer": 1}
|
||||
moved = next(m for m in rep["moves"] if m["kind"] == "items_moved")
|
||||
assert moved["value"] == 4.0 and moved["items"][0]["name"] and rep["by_person"][0]["count"] == 2
|
||||
assert client.get(f"/api/reports/moves?table_id={floor[2].id}", headers=boss).json()["count"] == 1
|
||||
assert client.get("/api/reports/moves?kind=table_transfer", headers=boss).json()["count"] == 1
|
||||
csv = client.get("/api/reports/moves/export", headers=boss)
|
||||
assert csv.status_code == 200 and "items_moved" in csv.text
|
||||
@@ -0,0 +1,123 @@
|
||||
"""One more, and a sent line's quantity (owner 2026-11-23, plan 6F.5).
|
||||
|
||||
- POST /api/orders/{id}/items/{item}/again: a new line like the old one, priced now, printed as new;
|
||||
only with the product's one_more_enabled, from active / paid / tabbed lines in pieces.
|
||||
- POST /api/orders/{id}/items/{item}/quantity: the venue's switch (off | add_only | add_and_remove),
|
||||
the key ordering.items.change_quantity; up changes the line only (no ticket); down cuts a
|
||||
cancelled part ("quantity lowered") and prints a cancellation only when asked.
|
||||
"""
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.test_live import err
|
||||
from tests.test_waiter_keys import shop # noqa: F401 (fixture)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def printed(monkeypatch):
|
||||
"""What went to the kitchen: new lines (route_and_print_sync) and cancellations."""
|
||||
import routers.orders as orders
|
||||
got = {"tickets": [], "cancellations": []}
|
||||
monkeypatch.setattr(orders, "route_and_print_sync", lambda *a, **k: (got["tickets"].append(a), [])[1])
|
||||
monkeypatch.setattr(orders, "print_cancellation_ticket", lambda order_id, ids: got["cancellations"].append(list(ids)))
|
||||
return got
|
||||
|
||||
|
||||
def setting(db, key, value):
|
||||
from models.settings import PosSettings
|
||||
row = db.query(PosSettings).filter(PosSettings.key == key).first()
|
||||
if row is None:
|
||||
db.add(PosSettings(key=key, value=value))
|
||||
else:
|
||||
row.value = value
|
||||
db.commit()
|
||||
|
||||
|
||||
def lines(db, order_id):
|
||||
from models.order import OrderItem
|
||||
db.expire_all()
|
||||
return db.query(OrderItem).filter(OrderItem.order_id == order_id).order_by(OrderItem.id).all()
|
||||
|
||||
|
||||
def test_one_more_needs_the_products_switch(client, db, shop, printed):
|
||||
o, item = shop["order"], shop["items"][0]
|
||||
url = f"/api/orders/{o.id}/items/{item.id}/again"
|
||||
assert err(client.post(url, headers=shop["h"], json={})) == "order.one_more_off"
|
||||
item.product.one_more_enabled = True
|
||||
item.notes = "no ice"
|
||||
item.selected_options = json.dumps([{"id": None, "name": "Sweet", "price_delta": 0.0, "type": "quick"}])
|
||||
db.commit()
|
||||
before = len(lines(db, o.id))
|
||||
r = client.post(url, headers=shop["h"], json={"quantity": 2})
|
||||
assert r.status_code == 200, r.text
|
||||
new = lines(db, o.id)[-1]
|
||||
assert len(lines(db, o.id)) == before + 1 and new.id != item.id
|
||||
assert (new.product_id, new.quantity, new.notes, new.status) == (item.product_id, 2, "no ice", "active")
|
||||
assert json.loads(new.selected_options)[0]["name"] == "Sweet" and new.unit_price == 4.0
|
||||
assert len(printed["tickets"]) == 1 # sent to the kitchen like any new line
|
||||
# from a paid line too; never from a cancelled one
|
||||
paid = shop["items"][2]
|
||||
assert client.post(f"/api/orders/{o.id}/items/{paid.id}/again", headers=shop["h"], json={}).status_code == 200
|
||||
paid.status = "cancelled"
|
||||
db.commit()
|
||||
assert err(client.post(f"/api/orders/{o.id}/items/{paid.id}/again", headers=shop["h"], json={})) == "order.one_more_line"
|
||||
|
||||
|
||||
def test_one_more_needs_ordering_orders_open(client, db, shop, login, printed):
|
||||
o, item = shop["order"], shop["items"][0]
|
||||
item.product.one_more_enabled = True
|
||||
db.commit()
|
||||
h = login(shop["new_waiter"](remove=("ordering.orders.open",)), client="waiter")
|
||||
assert err(client.post(f"/api/orders/{o.id}/items/{item.id}/again", headers=h, json={})) == "access.denied"
|
||||
|
||||
|
||||
def test_quantity_follows_the_venue_and_the_key(client, db, shop, login, printed):
|
||||
o, item = shop["order"], shop["items"][0]
|
||||
url = f"/api/orders/{o.id}/items/{item.id}/quantity"
|
||||
assert err(client.post(url, headers=shop["h"], json={"quantity": 3})) == "order.quantity_change_off"
|
||||
setting(db, "orders.quantity_change", "add_only")
|
||||
# a waiter without the key: a manager may approve it
|
||||
assert err(client.post(url, headers=shop["h"], json={"quantity": 3})) == "access.override_possible"
|
||||
h = login(shop["new_waiter"](add=("ordering.items.change_quantity",)), client="waiter")
|
||||
r = client.post(url, headers=h, json={"quantity": 3})
|
||||
assert r.status_code == 200, r.text
|
||||
assert lines(db, o.id)[0].quantity == 3 and printed["tickets"] == [] and printed["cancellations"] == []
|
||||
assert err(client.post(url, headers=h, json={"quantity": 2})) == "order.quantity_remove_off"
|
||||
from models.order import OrderAuditLog
|
||||
log = db.query(OrderAuditLog).filter(OrderAuditLog.event_type == "QUANTITY_CHANGED").one()
|
||||
assert log.note.startswith("1 → 3")
|
||||
|
||||
|
||||
def test_lowering_cancels_the_difference_and_asks_about_the_ticket(client, db, shop, login, printed):
|
||||
o, item = shop["order"], shop["items"][0]
|
||||
item.quantity = 5
|
||||
db.commit()
|
||||
setting(db, "orders.quantity_change", "add_and_remove")
|
||||
url = f"/api/orders/{o.id}/items/{item.id}/quantity"
|
||||
# the key, but not the cancel key: a manager's approval for the cancel part
|
||||
h = login(shop["new_waiter"](add=("ordering.items.change_quantity",), remove=("ordering.orders.cancel",)), client="waiter")
|
||||
assert err(client.post(url, headers=h, json={"quantity": 3})) == "access.override_possible"
|
||||
h = login(shop["new_waiter"](add=("ordering.items.change_quantity", "ordering.orders.cancel")), client="waiter")
|
||||
r = client.post(url, headers=h, json={"quantity": 3, "print_cancellation": False})
|
||||
assert r.status_code == 200, r.text
|
||||
part_id = r.json()["cancelled_item_id"]
|
||||
rows = {i.id: i for i in lines(db, o.id)}
|
||||
assert rows[item.id].quantity == 3 and rows[item.id].status == "active"
|
||||
part = rows[part_id]
|
||||
assert (part.quantity, part.status, part.cancel_reason, part.split_from_id) == (2, "cancelled", "quantity lowered", item.id)
|
||||
assert printed["cancellations"] == []
|
||||
r = client.post(url, headers=h, json={"quantity": 2, "print_cancellation": True})
|
||||
assert printed["cancellations"] == [[r.json()["cancelled_item_id"]]]
|
||||
|
||||
|
||||
def test_only_unpaid_lines_in_pieces(client, db, shop, printed, login):
|
||||
setting(db, "orders.quantity_change", "add_and_remove")
|
||||
o = shop["order"]
|
||||
paid = shop["items"][2]
|
||||
boss = login(shop["owner"])
|
||||
assert err(client.post(f"/api/orders/{o.id}/items/{paid.id}/quantity", headers=boss, json={"quantity": 2})) == "order.quantity_line"
|
||||
item = shop["items"][0]
|
||||
item.product.unit_type = "kg"
|
||||
db.commit()
|
||||
assert err(client.post(f"/api/orders/{o.id}/items/{item.id}/quantity", headers=boss, json={"quantity": 2})) == "order.quantity_line"
|
||||
@@ -94,7 +94,7 @@ def test_waiter_cancels_after_manager_pin(client, db, venue, login):
|
||||
|
||||
def test_token_is_bound_to_its_key(client, db, venue, make_user, login):
|
||||
v = venue
|
||||
token = approve(client, v["waiter_h"], "ordering.prices.modify", make_user(role="owner").username).json()["override_token"]
|
||||
token = approve(client, v["waiter_h"], "ordering.prices.modify_sent", make_user(role="owner").username).json()["override_token"]
|
||||
# used for another key: refused, and NOT burned
|
||||
r = cancel(client, v, v["items"][0], token)
|
||||
assert err(r) == "access.override_invalid"
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
"""Prices changed by hand, on the record (owner 2026-11-23, plan 6F.3, services/price_changes.py).
|
||||
|
||||
- The venue's switch `orders.price_change`: off refuses every by-hand price, before_sending refuses
|
||||
a sent line's, anytime allows both.
|
||||
- A sent line needs ordering.prices.modify_sent (modify alone is the cart); a manager's PIN is
|
||||
recorded as the approver.
|
||||
- `orders.price_change_reason`: a typed price needs a reason; the counter's % discount doesn't.
|
||||
- Every change is one manual_price event (before → after, quantity, who, stage, reason) and a
|
||||
PRICE_CHANGED audit row; only holders of ordering.prices.view_changes see them.
|
||||
"""
|
||||
import pytest
|
||||
|
||||
from conftest import TEST_PIN
|
||||
from tests.test_live import err, owner_h, pair # noqa: F401 (fixtures)
|
||||
from tests.test_order_lines import items_of, open_order
|
||||
from tests.test_pos import burger_line, menu, on_shift, till # noqa: F401 (fixtures)
|
||||
from tests.test_pos_tables import floor, phone # noqa: F401 (fixtures)
|
||||
from tests.test_waiter_keys import shop # noqa: F401 (fixture)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _no_printing(monkeypatch):
|
||||
import routers.orders as orders
|
||||
monkeypatch.setattr(orders, "route_and_print_sync", lambda *a, **k: [])
|
||||
|
||||
|
||||
def setting(db, key, value):
|
||||
from models.settings import PosSettings
|
||||
row = db.query(PosSettings).filter(PosSettings.key == key).first()
|
||||
if row is None:
|
||||
db.add(PosSettings(key=key, value=value))
|
||||
else:
|
||||
row.value = value
|
||||
db.commit()
|
||||
|
||||
|
||||
def manual_events(db, order_id=None):
|
||||
from models.pricing import PriceEventLog
|
||||
db.expire_all()
|
||||
q = db.query(PriceEventLog).filter(PriceEventLog.event_type == "manual_price")
|
||||
if order_id is not None:
|
||||
q = q.filter(PriceEventLog.order_id == order_id)
|
||||
return q.order_by(PriceEventLog.id).all()
|
||||
|
||||
|
||||
def test_a_sent_line_changed_by_hand_is_recorded(client, db, shop, login):
|
||||
o, item = shop["order"], shop["items"][0]
|
||||
item.kds_status = "served"
|
||||
db.commit()
|
||||
h = login(shop["new_waiter"](add=("ordering.prices.modify_sent",)), client="waiter")
|
||||
r = client.patch(f"/api/orders/{o.id}/items/{item.id}/price-adjust", headers=h,
|
||||
json={"price_adjustment": -1.5, "reason": " regular customer "})
|
||||
assert r.status_code == 200, r.text
|
||||
[ev] = manual_events(db, o.id)
|
||||
assert (ev.order_item_id, ev.price_before, ev.price_after, ev.delta_amount) == (item.id, 4.0, 2.5, -1.5)
|
||||
assert ev.stage == "served" and ev.quantity == 1 and ev.waiter_note == "regular customer" and ev.approved_by_user_id is None
|
||||
# a second change records from the changed price, the first stays
|
||||
r = client.patch(f"/api/orders/{o.id}/items/{item.id}/price-adjust", headers=h, json={"price_adjustment": 0})
|
||||
assert r.status_code == 200
|
||||
evs = manual_events(db, o.id)
|
||||
assert [(e.price_before, e.price_after) for e in evs] == [(4.0, 2.5), (2.5, 4.0)]
|
||||
from models.order import OrderAuditLog
|
||||
assert db.query(OrderAuditLog).filter(OrderAuditLog.order_id == o.id, OrderAuditLog.event_type == "PRICE_CHANGED").count() == 2
|
||||
|
||||
|
||||
def test_the_venue_switch(client, db, shop, login):
|
||||
o, item = shop["order"], shop["items"][0]
|
||||
url = f"/api/orders/{o.id}/items/{item.id}/price-adjust"
|
||||
boss = login(shop["owner"])
|
||||
setting(db, "orders.price_change", "before_sending")
|
||||
assert err(client.patch(url, headers=boss, json={"price_adjustment": -1})) == "order.price_change_sent_off"
|
||||
setting(db, "orders.price_change", "off")
|
||||
assert err(client.patch(url, headers=boss, json={"price_adjustment": -1})) == "order.price_change_off"
|
||||
setting(db, "orders.price_change", "anytime")
|
||||
assert client.patch(url, headers=boss, json={"price_adjustment": -1}).status_code == 200
|
||||
assert len(manual_events(db, o.id)) == 1
|
||||
|
||||
|
||||
def test_a_reason_when_the_venue_asks(client, db, shop, login):
|
||||
o, item = shop["order"], shop["items"][0]
|
||||
url = f"/api/orders/{o.id}/items/{item.id}/price-adjust"
|
||||
h = login(shop["new_waiter"](add=("ordering.prices.modify_sent",)), client="waiter")
|
||||
setting(db, "orders.price_change_reason", "true")
|
||||
assert err(client.patch(url, headers=h, json={"price_adjustment": -1})) == "order.price_reason_required"
|
||||
assert err(client.patch(url, headers=h, json={"price_adjustment": -1, "reason": " "})) == "order.price_reason_required"
|
||||
assert client.patch(url, headers=h, json={"price_adjustment": -1, "reason": "Burnt a bit"}).status_code == 200
|
||||
assert manual_events(db, o.id)[0].waiter_note == "Burnt a bit"
|
||||
|
||||
|
||||
def test_a_managers_pin_is_the_approver(client, db, shop, make_user, login):
|
||||
o, item = shop["order"], shop["items"][0]
|
||||
boss = make_user(role="owner")
|
||||
approved = client.post("/api/access/override", headers=shop["h"],
|
||||
json={"key": "ordering.prices.modify_sent", "username": boss.username, "pin": TEST_PIN})
|
||||
assert approved.status_code == 200, approved.text
|
||||
h = dict(shop["h"], **{"X-Xenia-Override": approved.json()["override_token"]})
|
||||
assert client.patch(f"/api/orders/{o.id}/items/{item.id}/price-adjust", headers=h, json={"price_adjustment": 1}).status_code == 200
|
||||
[ev] = manual_events(db, o.id)
|
||||
assert ev.approved_by_user_id == boss.id and ev.applied_by_user_id == shop["waiter"].id
|
||||
|
||||
|
||||
def test_a_price_typed_in_the_cart(client, db, menu, phone, floor, make_user, login):
|
||||
oid = open_order(client, phone["h"], floor["t1"])
|
||||
line = {"product_id": menu["coffee"].id, "quantity": 2, "price_adjustment": -0.5, "price_reason": "Friend of the house"}
|
||||
from models.user import WaiterZone
|
||||
w = make_user(role="waiter", add=("ordering.prices.modify",))
|
||||
db.add(WaiterZone(waiter_id=w.id, group_id=None))
|
||||
db.commit()
|
||||
h = login(w, "waiter")
|
||||
r = client.post(f"/api/orders/{oid}/items", headers=h, json={"lines": [line]})
|
||||
assert r.status_code == 200, r.text
|
||||
[item] = items_of(db, oid)
|
||||
[ev] = manual_events(db, oid)
|
||||
assert ev.order_item_id == item.id and ev.stage == "cart" and ev.quantity == 2
|
||||
assert (ev.price_before, ev.price_after) == (item.unit_price, item.unit_price - 0.5) and ev.waiter_note == "Friend of the house"
|
||||
# the venue asks for a reason: a typed price without one is refused, nothing is added
|
||||
setting(db, "orders.price_change_reason", "true")
|
||||
assert err(client.post(f"/api/orders/{oid}/items", headers=h, json={"lines": [{**line, "price_reason": None}]})) == "order.price_reason_required"
|
||||
assert len(items_of(db, oid)) == 1
|
||||
setting(db, "orders.price_change", "off")
|
||||
assert err(client.post(f"/api/orders/{oid}/items", headers=h, json={"lines": [line]})) == "order.price_change_off"
|
||||
|
||||
|
||||
def test_the_counters_discount_is_recorded_without_a_reason(client, db, menu, pair, make_user):
|
||||
from core.timeutil import business_date_of, utcnow
|
||||
from models.business_day import BusinessDay
|
||||
from models.shift import WaiterShift
|
||||
from tests.test_live import terminal_login
|
||||
token, _ = pair("pos_counter", "Till 2")
|
||||
boss = make_user(role="owner")
|
||||
h = {"X-Xenia-Device": token, "Authorization": f"Bearer {terminal_login(client, token, boss)}"}
|
||||
day = db.query(BusinessDay).filter(BusinessDay.status == "open").first() or BusinessDay(
|
||||
status="open", opened_at=utcnow(), business_date=business_date_of(utcnow()), opened_by_id=boss.id)
|
||||
db.add(day)
|
||||
db.flush()
|
||||
db.add(WaiterShift(waiter_id=boss.id, business_day_id=day.id))
|
||||
db.commit()
|
||||
setting(db, "orders.price_change_reason", "true")
|
||||
r = client.post("/api/pos/sales", headers=h, json={"lines": [{"product_id": menu["coffee"].id, "discount_pct": 10}], "payments": [{"method": "card"}]})
|
||||
assert r.status_code == 201, r.text
|
||||
[ev] = manual_events(db, r.json()["order_id"])
|
||||
assert ev.stage == "cart" and ev.waiter_note == "−10 %" and ev.delta_amount < 0
|
||||
|
||||
|
||||
def test_only_holders_see_the_changes(client, db, shop, make_user, login):
|
||||
o, item = shop["order"], shop["items"][0]
|
||||
h = login(shop["new_waiter"](add=("ordering.prices.modify_sent",)), client="waiter")
|
||||
client.patch(f"/api/orders/{o.id}/items/{item.id}/price-adjust", headers=h, json={"price_adjustment": -1, "reason": "x"})
|
||||
seer = login(make_user(role="store_manager"))
|
||||
blind = login(make_user(role="store_manager", remove=("ordering.prices.view_changes",)))
|
||||
assert [e["event_type"] for e in client.get(f"/api/pricing/events/order/{o.id}", headers=seer).json()] == ["manual_price"]
|
||||
assert client.get(f"/api/pricing/events/order/{o.id}", headers=blind).json() == []
|
||||
got = client.get(f"/api/orders/{o.id}/price-changes", headers=seer).json()
|
||||
assert len(got) == 1 and got[0]["before"] == 4.0 and got[0]["after"] == 3.0 and got[0]["reason"] == "x" and got[0]["product_name"]
|
||||
assert client.get(f"/api/orders/{o.id}/price-changes", headers=blind).status_code == 403
|
||||
rep = client.get(f"/api/reports/price-changes?business_day_id={o.business_day_id}" if o.business_day_id else
|
||||
"/api/reports/price-changes", headers=seer).json()
|
||||
assert rep["count"] >= 1 and rep["total_value"] <= -1.0 and rep["by_person"][0]["count"] >= 1
|
||||
assert client.get("/api/reports/price-changes", headers=blind).status_code == 403
|
||||
|
||||
|
||||
def test_combining_lines_keeps_their_changes(client, db, shop, login):
|
||||
o, items = shop["order"], shop["items"]
|
||||
h = login(shop["new_waiter"](add=("ordering.prices.modify_sent",)), client="waiter")
|
||||
for it in items[:2]:
|
||||
assert client.patch(f"/api/orders/{o.id}/items/{it.id}/price-adjust", headers=h, json={"price_adjustment": -1}).status_code == 200
|
||||
r = client.post(f"/api/orders/{o.id}/items/combine", headers=h, json={"item_ids": [items[0].id, items[1].id]})
|
||||
assert r.status_code == 200, r.text
|
||||
assert {e.order_item_id for e in manual_events(db, o.id)} == {items[0].id}
|
||||
assert len(manual_events(db, o.id)) == 2
|
||||
@@ -84,6 +84,16 @@ def test_blank_slides_and_widgets_placed_by_hand(client, owner_h):
|
||||
assert clock["size"] == "custom" and clock["box"] == {"x": 90, "y": 5, "w": 20, "h": 10} and clock["align"] == "right"
|
||||
assert big["box"] == {"x": 95, "y": -15, "w": 30, "h": 20}
|
||||
assert date["size"] == "medium" and date["box"] is None # a corner: no box, a real size
|
||||
# owner 2026-11-23: a picture made larger than the slide (cut off at its edges); a gallery's title below
|
||||
r = client.put(f"/api/signage/slides/{s['id']}", headers=owner_h, json={"content": {"widgets": [
|
||||
{"kind": "logo", "position": "custom", "box": {"x": -60, "y": -40, "w": 220, "h": 180}},
|
||||
{"kind": "gallery", "text": "Our dishes", "title_position": "below", "position": "top-left"}]}})
|
||||
logo, gallery = r.json()["content"]["widgets"]
|
||||
assert logo["box"] == {"x": -60, "y": -40, "w": 220, "h": 180}
|
||||
assert gallery["text"] == "Our dishes" and gallery["title_position"] == "below"
|
||||
r = client.put(f"/api/signage/slides/{s['id']}", headers=owner_h, json={"content": {"widgets": [
|
||||
{"kind": "logo", "position": "custom", "box": {"x": 0, "y": 0, "w": 401, "h": 10}}]}})
|
||||
assert err(r) == "signage.content_invalid" # at most four times the slide
|
||||
r = client.put(f"/api/signage/slides/{s['id']}", headers=owner_h, json={"content": {"widgets": [{"kind": "clock", "position": "custom"}]}})
|
||||
assert err(r) == "signage.content_invalid" # placed by hand needs its box
|
||||
r = client.put(f"/api/signage/slides/{s['id']}", headers=owner_h, json={"content": {"title": "x"}})
|
||||
|
||||
@@ -55,6 +55,10 @@ def test_a_screens_picture_area_and_calibration(client, owner_h, screens, sent):
|
||||
assert ("signage.calibrate", [tv["id"]]) not in sent
|
||||
# limits; not a screen
|
||||
assert client.put(f"/api/signage/screens/{tv['id']}", headers=owner_h, json={"area_left": 5000}).status_code == 422
|
||||
# owner 2026-11-23: an edge may reach past the window the TV reported (its real picture is larger)
|
||||
r = client.put(f"/api/signage/screens/{tv['id']}", headers=owner_h, json={"area_left": -60, "area_top": 0})
|
||||
assert r.status_code == 200 and r.json()["area"]["left"] == -60
|
||||
assert client.put(f"/api/signage/screens/{tv['id']}", headers=owner_h, json={"area_left": -2001}).status_code == 422
|
||||
assert err(client.post("/api/signage/screens/99999/calibrate", headers=owner_h, json={"on": True})) == "signage.not_a_screen"
|
||||
# a screen can't calibrate itself or report for another
|
||||
assert client.post(f"/api/signage/screens/{other['id']}/calibrate", headers=tv["h"], json={"on": True}).status_code in (401, 403)
|
||||
|
||||
@@ -98,10 +98,13 @@ def test_revert_payment_is_a_key_a_manager_can_approve(client, db, shop):
|
||||
|
||||
|
||||
def test_price_change_needs_only_the_key_no_venue_switch(client, shop, login):
|
||||
"""A sent line's price: ordering.prices.modify_sent since 6F.3 (modify alone is for the cart)."""
|
||||
o, item = shop["order"], shop["items"][0]
|
||||
url = f"/api/orders/{o.id}/items/{item.id}/price-adjust"
|
||||
assert err(client.patch(url, headers=shop["h"], json={"price_adjustment": -1})) == "access.override_possible"
|
||||
h = login(shop["new_waiter"](add=("ordering.prices.modify",)), client="waiter")
|
||||
assert err(client.patch(url, headers=h, json={"price_adjustment": -1})) == "access.override_possible"
|
||||
h = login(shop["new_waiter"](add=("ordering.prices.modify_sent",)), client="waiter")
|
||||
r = client.patch(url, headers=h, json={"price_adjustment": -1})
|
||||
assert r.status_code == 200, r.text
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ import PrepZonesPage from './pages/reports/prepzones/PrepZonesReport'
|
||||
import ExpensesReportPage from './pages/reports/expenses/ExpensesReport'
|
||||
import TechnicalPage from './pages/reports/technical/TechnicalReport'
|
||||
import MiscPage from './pages/reports/misc/MiscReport'
|
||||
import MovesPage from './pages/reports/moves/MovesReport'
|
||||
|
||||
// Other
|
||||
import { AppsPage, IntegrationsPage } from './pages/platform/ModulesPage'
|
||||
@@ -172,6 +173,7 @@ export default function App() {
|
||||
<Route path="reports/expenses" element={<ExpensesReportPage />} />
|
||||
<Route path="reports/technical" element={<TechnicalPage />} />
|
||||
<Route path="reports/misc" element={<MiscPage />} />
|
||||
<Route path="reports/moves" element={<MovesPage />} />
|
||||
|
||||
{/* ── Apps & Settings ── */}
|
||||
<Route path="apps" element={<AppsPage />} />
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { useSearchParams } from 'react-router-dom'
|
||||
import { useCan, useModule } from '@xenia/access'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Page, Tabs } from '@xenia/ui'
|
||||
import { Columns, Page, Tabs } from '@xenia/ui'
|
||||
import PrintingSettings from '../printing/PrintingSettings'
|
||||
import CustomerDisplaySettings from './sections/CustomerDisplaySettings'
|
||||
import DevelopmentSettings from './sections/DevelopmentSettings'
|
||||
@@ -20,10 +20,10 @@ import IdentitySettings from './sections/IdentitySettings'
|
||||
|
||||
const TABS = {
|
||||
'app-info': () => <SystemSettings />,
|
||||
venue: () => <VenueSettings />,
|
||||
venue: () => <Columns><VenueSettings /></Columns>,
|
||||
identity: () => <IdentitySettings />,
|
||||
'customer-display': () => <CustomerDisplaySettings />,
|
||||
'menu-tablets': () => <MenuTabletSettings />,
|
||||
'menu-tablets': () => <Columns><MenuTabletSettings /></Columns>,
|
||||
security: () => <SecuritySettings />,
|
||||
operation: () => <OperationSettings />,
|
||||
colours: () => <TableColours />,
|
||||
@@ -49,8 +49,8 @@ export default function SettingsPage() {
|
||||
const active = tabs.includes(params.get('tab')) ? params.get('tab') : tabs[0]
|
||||
const Tab = TABS[active]
|
||||
return (
|
||||
// settings are forms: the page's form width, centred (the page rule, 2026-11-20)
|
||||
<Page testId="settings-page" width="form" aria-label={t('settings.title')}
|
||||
// full width like every page (6F.0, owner 2026-11-23); each tab's cards sit in <Columns>
|
||||
<Page testId="settings-page" aria-label={t('settings.title')}
|
||||
top={<Tabs size="lg" value={active} onChange={id => setParams({ tab: id }, { replace: true })}
|
||||
tabs={tabs.map(id => ({ id, label: t(`settings.tabs.${id}`), testId: `settings-tab-${id}` }))} />}>
|
||||
<Tab />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Settings → Development (plan step 6.14a; was the v1 DevelopmentTab): for testing only. Printing
|
||||
// "spoof": every print job is dropped silently and the apps behave as if it printed.
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Spinner, Switch } from '@xenia/ui'
|
||||
import { Columns, Spinner, Switch } from '@xenia/ui'
|
||||
import { SettingRow, SettingsCard } from './SettingsCard'
|
||||
import { useSettings } from './useSettings'
|
||||
|
||||
@@ -11,13 +11,13 @@ export default function DevelopmentSettings() {
|
||||
if (s.loading) return <div className="py-8 flex justify-center"><Spinner /></div>
|
||||
const spoof = s.get('dev.spoof_printing', 'false') === 'true'
|
||||
return (
|
||||
<div className="grid gap-5" data-testid="settings-development">
|
||||
<p className="rounded-card bg-danger-soft text-danger-ink p-3 text-label" role="note">{t('settings.dev.warning')}</p>
|
||||
<Columns testId="settings-development">
|
||||
<p className="x-columns__wide rounded-card bg-danger-soft text-danger-ink p-3 text-label" role="note">{t('settings.dev.warning')}</p>
|
||||
<SettingsCard title={t('settings.dev.title')}>
|
||||
<SettingRow label={t('settings.dev.spoof')} hint={t('settings.dev.spoofHint')} warning={spoof ? t('settings.dev.spoofOn') : undefined}>
|
||||
<Switch checked={spoof} disabled={s.saving} onChange={v => s.save('dev.spoof_printing', v)} aria-label={t('settings.dev.spoof')} data-testid="setting-dev.spoof_printing" />
|
||||
</SettingRow>
|
||||
</SettingsCard>
|
||||
</div>
|
||||
</Columns>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import toast from 'react-hot-toast'
|
||||
import { CheckCircle2, Plus, Trash2, XCircle } from 'lucide-react'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Button, Field, IconButton, Input, Select, Spinner, Switch } from '@xenia/ui'
|
||||
import { Button, Columns, Field, IconButton, Input, Select, Spinner, Switch } from '@xenia/ui'
|
||||
import client from '../../../api/client'
|
||||
import { SettingRow, SettingsCard } from './SettingsCard'
|
||||
import { cleanVatGroups, endLines, readJson } from './settingsLogic'
|
||||
@@ -21,9 +21,9 @@ export default function FiscalSettings() {
|
||||
if (s.loading) return <div className="py-8 flex justify-center"><Spinner /></div>
|
||||
const on = s.get('fiscal.enabled', 'false') === 'true'
|
||||
return (
|
||||
<div className="grid gap-5" data-testid="settings-fiscal">
|
||||
<Columns testId="settings-fiscal">
|
||||
<SettingsCard title={t('settings.fiscal.title')} description={t('settings.fiscal.intro')}>
|
||||
<SettingRow label={t('settings.fiscal.enabled')} hint={t('settings.fiscal.enabledHint')}
|
||||
<SettingRow label={t('settings.fiscal.enabled')} hint={t('settings.fiscal.enabledHint')} tip={t('settings.fiscal.enabledTip')}
|
||||
warning={on ? t('settings.fiscal.onWarning') : undefined}>
|
||||
<Switch checked={on} disabled={s.saving} onChange={v => s.save('fiscal.enabled', v)} aria-label={t('settings.fiscal.enabled')} data-testid="setting-fiscal.enabled" />
|
||||
</SettingRow>
|
||||
@@ -37,7 +37,7 @@ export default function FiscalSettings() {
|
||||
<Folders s={s} />
|
||||
<EndMessage s={s} />
|
||||
<VatGroups s={s} />
|
||||
</div>
|
||||
</Columns>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { Plus, Trash2 } from 'lucide-react'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useCan } from '@xenia/access'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Button, ColourField, Dropdown, Field, IconButton, Input, Spinner, Switch } from '@xenia/ui'
|
||||
import { Button, ColourField, Columns, Dropdown, Field, IconButton, Input, Spinner, Switch } from '@xenia/ui'
|
||||
import { wifiQr } from '@xenia/signage/logic'
|
||||
import client from '../../../api/client'
|
||||
import MediaField from '../../media/MediaField'
|
||||
@@ -50,8 +50,8 @@ function IdentityForm({ saved }) {
|
||||
const qr = wifiQr(wifi)
|
||||
|
||||
return (
|
||||
<div className="grid gap-5" data-testid="settings-identity">
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<Columns testId="settings-identity">
|
||||
<div className="x-columns__wide flex flex-wrap items-center gap-3">
|
||||
<p className="text-label text-ink-2 flex-1 min-w-[16rem]">{t('identity.intro')}</p>
|
||||
{dirty && <span className="text-label text-ink-3">{t('identity.unsaved')}</span>}
|
||||
<Button variant="secondary" disabled={!dirty || busy} onClick={() => setD(structuredClone(saved))}>{t('identity.undo')}</Button>
|
||||
@@ -141,6 +141,6 @@ function IdentityForm({ saved }) {
|
||||
))}
|
||||
</div>
|
||||
</SettingsCard>
|
||||
</div>
|
||||
</Columns>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
// table flags, quick messages to the staff, and sending the digital menu to the cloud now.
|
||||
// Each part shows only with its app on. Dropped from v1: "automatic store schedule" (its switches
|
||||
// were kept in the browser only and nothing ever read them).
|
||||
import { useState } from 'react'
|
||||
import { useId, useState } from 'react'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import toast from 'react-hot-toast'
|
||||
import { ArrowDown, ArrowUp, Plus, RefreshCw, Trash2 } from 'lucide-react'
|
||||
import { useModule } from '@xenia/access'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Button, IconButton, Input, Spinner, Switch } from '@xenia/ui'
|
||||
import { Button, Columns, IconButton, InfoTip, Input, Select, Spinner, Switch } from '@xenia/ui'
|
||||
import client from '../../../api/client'
|
||||
import QuickMessages from './QuickMessages'
|
||||
import RolePermissions from './RolePermissions'
|
||||
@@ -26,19 +26,19 @@ export default function OperationSettings() {
|
||||
const chat = useModule('chat')
|
||||
const qrMenu = useModule('connect_menu')
|
||||
return (
|
||||
<div className="grid gap-5" data-testid="settings-operation">
|
||||
<Columns testId="settings-operation">
|
||||
<RolePermissions />
|
||||
{ordering && <OrderingSettings />}
|
||||
{ordering && <TableFlags />}
|
||||
{chat && <QuickMessages />}
|
||||
{qrMenu && <MenuSync />}
|
||||
</div>
|
||||
</Columns>
|
||||
)
|
||||
}
|
||||
|
||||
function Toggle({ s, k, fallback = 'false', label, hint }) {
|
||||
function Toggle({ s, k, fallback = 'false', label, hint, tip }) {
|
||||
return (
|
||||
<SettingRow label={label} hint={hint}>
|
||||
<SettingRow label={label} hint={hint} tip={tip}>
|
||||
<Switch checked={s.get(k, fallback) === 'true'} disabled={s.saving} onChange={v => s.save(k, v)} aria-label={label} data-testid={`setting-${k}`} />
|
||||
</SettingRow>
|
||||
)
|
||||
@@ -51,24 +51,67 @@ function OrderingSettings() {
|
||||
const o = k => t(`settings.ops.${k}`)
|
||||
return (<>
|
||||
<SettingsCard title={o('staffTitle')} description={o('staffIntro')} testId="settings-staff">
|
||||
<Toggle s={s} k="shifts.waiter_self_start" fallback="true" label={o('selfStart')} hint={o('selfStartHint')} />
|
||||
<Toggle s={s} k="shifts.waiter_self_end" fallback="true" label={o('selfEnd')} hint={o('selfEndHint')} />
|
||||
<Toggle s={s} k="shifts.hide_revenue_from_waiters" label={o('hideTakings')} hint={o('hideTakingsHint')} />
|
||||
<Toggle s={s} k="shifts.waiter_self_start" fallback="true" label={o('selfStart')} hint={o('selfStartHint')} tip={o('selfStartTip')} />
|
||||
<Toggle s={s} k="shifts.waiter_self_end" fallback="true" label={o('selfEnd')} hint={o('selfEndHint')} tip={o('selfEndTip')} />
|
||||
<Toggle s={s} k="shifts.hide_revenue_from_waiters" label={o('hideTakings')} hint={o('hideTakingsHint')} tip={o('hideTakingsTip')} />
|
||||
</SettingsCard>
|
||||
<SettingsCard title={o('paymentsTitle')} testId="settings-payments">
|
||||
<Toggle s={s} k="payments.card_enabled" label={o('card')} hint={o('cardHint')} />
|
||||
<Toggle s={s} k="payments.card_enabled" label={o('card')} hint={o('cardHint')} tip={o('cardTip')} />
|
||||
</SettingsCard>
|
||||
<SettingsCard title={o('ordersTitle')} description={o('ordersIntro')} testId="settings-orders">
|
||||
<Toggle s={s} k="orders.auto_close_on_full_payment" label={o('autoClose')} hint={o('autoCloseHint')} />
|
||||
<Toggle s={s} k="orders.close_with_unpaid" label={t('settings.operation.closeUnpaid')} hint={t('settings.operation.closeUnpaidHint')} />
|
||||
<Toggle s={s} k="orders.bypass_kds_serve" label={o('bypassKds')} hint={o('bypassKdsHint')} />
|
||||
<Toggle s={s} k="orders.courses_enabled" label={o('courses')} hint={o('coursesHint')} />
|
||||
<Toggle s={s} k="orders.auto_close_on_full_payment" label={o('autoClose')} hint={o('autoCloseHint')} tip={o('autoCloseTip')} />
|
||||
<Toggle s={s} k="orders.close_with_unpaid" label={t('settings.operation.closeUnpaid')} hint={t('settings.operation.closeUnpaidHint')} tip={t('settings.operation.closeUnpaidTip')} />
|
||||
<Toggle s={s} k="orders.bypass_kds_serve" label={o('bypassKds')} hint={o('bypassKdsHint')} tip={o('bypassKdsTip')} />
|
||||
<Toggle s={s} k="orders.courses_enabled" label={o('courses')} hint={o('coursesHint')} tip={o('coursesTip')} />
|
||||
{s.get('orders.courses_enabled') === 'true' && <Courses s={s} />}
|
||||
<QuickNotes s={s} />
|
||||
<TextList s={s} k="orders.quick_notes" title={o('quickNotes')} hint={o('quickNotesHint')} tip={o('quickNotesTip')}
|
||||
itemLabel={o('quickNote')} placeholder={o('newQuickNote')} testId="settings-quick-notes" newTestId="quick-note" />
|
||||
</SettingsCard>
|
||||
<PriceChangeSettings s={s} />
|
||||
<QuantitySettings s={s} />
|
||||
</>)
|
||||
}
|
||||
|
||||
/** A sent line's quantity changed without a new ticket (6F.5). Who may: ordering.items.change_quantity;
|
||||
* lowering also needs ordering.orders.cancel ("What each role may do", a person's permissions). */
|
||||
function QuantitySettings({ s }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const q = k => t(`settings.quantity.${k}`)
|
||||
const id = useId()
|
||||
return (
|
||||
<SettingsCard title={q('title')} description={q('intro')} testId="settings-quantity">
|
||||
<SettingRow label={q('when')} hint={q('whenHint')} tip={q('whenTip')} htmlFor={id}>
|
||||
<Select id={id} value={s.get('orders.quantity_change', 'off')} disabled={s.saving} data-testid="setting-orders.quantity_change"
|
||||
onChange={e => s.save('orders.quantity_change', e.target.value)}
|
||||
options={['off', 'add_only', 'add_and_remove'].map(v => ({ value: v, label: q(`modes.${v}`) }))} />
|
||||
</SettingRow>
|
||||
</SettingsCard>
|
||||
)
|
||||
}
|
||||
|
||||
/** Prices changed by hand (6F.3): the venue's switch, the reason, the quick reasons. Who may: the
|
||||
* keys ordering.prices.modify / modify_sent ("What each role may do", a person's permissions). */
|
||||
function PriceChangeSettings({ s }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const p = k => t(`settings.prices.${k}`)
|
||||
const id = useId()
|
||||
const reasonOn = s.get('orders.price_change_reason', 'false') === 'true'
|
||||
return (
|
||||
<SettingsCard title={p('title')} description={p('intro')} testId="settings-price-changes">
|
||||
<SettingRow label={p('when')} hint={p('whenHint')} tip={p('whenTip')} htmlFor={id}>
|
||||
<Select id={id} value={s.get('orders.price_change', 'anytime')} disabled={s.saving} data-testid="setting-orders.price_change"
|
||||
onChange={e => s.save('orders.price_change', e.target.value)}
|
||||
options={['off', 'before_sending', 'anytime'].map(v => ({ value: v, label: p(`modes.${v}`) }))} />
|
||||
</SettingRow>
|
||||
{s.get('orders.price_change', 'anytime') !== 'off' && (<>
|
||||
<Toggle s={s} k="orders.price_change_reason" label={p('reason')} hint={p('reasonHint')} tip={p('reasonTip')} />
|
||||
{reasonOn && <TextList s={s} k="orders.price_change_reasons" title={p('reasons')} hint={p('reasonsHint')}
|
||||
itemLabel={p('reasonItem')} placeholder={p('newReason')} testId="settings-price-reasons" newTestId="price-reason" />}
|
||||
</>)}
|
||||
</SettingsCard>
|
||||
)
|
||||
}
|
||||
|
||||
/** orders.courses: [{ id, name, color }] in the order they are served. */
|
||||
function Courses({ s }) {
|
||||
const { t } = useTranslation('manager')
|
||||
@@ -94,29 +137,30 @@ function Courses({ s }) {
|
||||
)
|
||||
}
|
||||
|
||||
/** orders.quick_notes: the notes a waiter can add to a line with one tap. */
|
||||
function QuickNotes({ s }) {
|
||||
/** A JSON list of short texts in a setting (orders.quick_notes: notes a waiter adds to a line with
|
||||
* one tap; orders.price_change_reasons: quick reasons for a price changed by hand, 6F.3). */
|
||||
function TextList({ s, k, title, hint, tip, itemLabel, placeholder, testId, newTestId }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const notes = readJson(s.get('orders.quick_notes', '[]'), [])
|
||||
const notes = readJson(s.get(k, '[]'), [])
|
||||
const [typed, setTyped] = useState('')
|
||||
const [edits, setEdits] = useState({})
|
||||
const save = next => s.save('orders.quick_notes', JSON.stringify(cleanNotes(next)))
|
||||
const save = next => s.save(k, JSON.stringify(cleanNotes(next)))
|
||||
const add = () => { if (typed.trim()) { save([...notes, typed]); setTyped('') } }
|
||||
return (
|
||||
<div className="px-5 py-3 grid gap-2" data-testid="settings-quick-notes">
|
||||
<span className="text-body font-medium text-ink">{t('settings.ops.quickNotes')}</span>
|
||||
<span className="text-label text-ink-2 -mt-1">{t('settings.ops.quickNotesHint')}</span>
|
||||
<div className="px-5 py-3 grid gap-2" data-testid={testId}>
|
||||
<span className="flex items-center gap-1 text-body font-medium text-ink">{title}{tip && <InfoTip>{tip}</InfoTip>}</span>
|
||||
<span className="text-label text-ink-2 -mt-1">{hint}</span>
|
||||
{notes.map((n, i) => (
|
||||
<div key={`${i}-${n}`} className="flex items-center gap-2">
|
||||
<Input value={edits[i] ?? n} aria-label={t('settings.ops.quickNote')} onChange={e => setEdits(x => ({ ...x, [i]: e.target.value }))}
|
||||
<Input value={edits[i] ?? n} aria-label={itemLabel} onChange={e => setEdits(x => ({ ...x, [i]: e.target.value }))}
|
||||
onBlur={() => { if (edits[i] != null && edits[i] !== n) save(notes.map((x, j) => (j === i ? edits[i] : x))); setEdits({}) }} />
|
||||
<IconButton size="sm" variant="ghost" label={t('settings.ops.remove', { name: n })} onClick={() => save(notes.filter((_, j) => j !== i))}><Trash2 size={14} /></IconButton>
|
||||
</div>
|
||||
))}
|
||||
<div className="flex items-center gap-2">
|
||||
<Input value={typed} placeholder={t('settings.ops.newQuickNote')} aria-label={t('settings.ops.newQuickNote')} onChange={e => setTyped(e.target.value)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') add() }} data-testid="quick-note-new" />
|
||||
<Button size="sm" variant="secondary" icon={<Plus size={14} />} disabled={!typed.trim()} onClick={add} data-testid="quick-note-add">{t('settings.ops.add')}</Button>
|
||||
<Input value={typed} placeholder={placeholder} aria-label={placeholder} onChange={e => setTyped(e.target.value)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') add() }} data-testid={`${newTestId}-new`} />
|
||||
<Button size="sm" variant="secondary" icon={<Plus size={14} />} disabled={!typed.trim()} onClick={add} data-testid={`${newTestId}-add`}>{t('settings.ops.add')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ import toast from 'react-hot-toast'
|
||||
import { Copy, RefreshCw } from 'lucide-react'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Button, IconButton, Select, Spinner, Switch } from '@xenia/ui'
|
||||
import { Button, Columns, IconButton, Select, Spinner, Switch } from '@xenia/ui'
|
||||
import client from '../../../api/client'
|
||||
import { useLiveQuery } from '../../../live/useLiveQuery'
|
||||
import { Pill } from '../../overview/parts'
|
||||
@@ -19,11 +19,11 @@ import { useSettings } from './useSettings'
|
||||
|
||||
export default function SecuritySettings() {
|
||||
return (
|
||||
<div className="grid gap-5" data-testid="settings-security">
|
||||
<Columns testId="settings-security">
|
||||
<SignInSettings />
|
||||
<IdleSettings />
|
||||
<RecoveryCodes />
|
||||
</div>
|
||||
</Columns>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ function IdleSettings() {
|
||||
const options = current => [...new Set([...IDLE_STEPS, current])].sort((a, b) => a - b).map(v => ({ value: String(v), label: span(v) }))
|
||||
return (
|
||||
<SettingsCard title={t('settings.security.idleTitle')} description={t('settings.security.idleIntro')} testId="settings-idle">
|
||||
<SettingRow label={t('settings.security.lock')} hint={t('settings.security.lockHint')}>
|
||||
<SettingRow label={t('settings.security.lock')} hint={t('settings.security.lockHint')} tip={t('settings.security.lockTip')}>
|
||||
<Switch checked={lock} disabled={s.saving} onChange={v => s.save('security.auto_lock', v)} aria-label={t('settings.security.lock')} data-testid="setting-security.auto_lock" />
|
||||
</SettingRow>
|
||||
{lock && (
|
||||
|
||||
@@ -25,7 +25,7 @@ export function SettingRow({ label, hint, tip, children, warning, htmlFor }) {
|
||||
</div>
|
||||
{hint && <p className="text-label text-ink-2 mt-0.5">{hint}</p>}
|
||||
</div>
|
||||
<div className="sm:w-64 shrink-0">{children}</div>
|
||||
<div className="sm:w-64 shrink-0 flex sm:justify-end [&>*]:max-w-full [&>.x-select]:w-full [&>.x-dropdown]:w-full [&>.x-input]:w-full">{children}</div>
|
||||
</div>
|
||||
{warning && <p className="mt-2 rounded-control bg-warning-soft text-warning-ink text-label px-3 py-2" role="note">{warning}</p>}
|
||||
</div>
|
||||
|
||||
@@ -46,23 +46,23 @@ export default function SignInSettings() {
|
||||
<SettingRow label={t('settings.signIn.autofill')} hint={t('settings.signIn.autofillHint')}>
|
||||
{toggle('security.autofill_username', 'true', t('settings.signIn.autofill'))}
|
||||
</SettingRow>
|
||||
<SettingRow label={t('settings.signIn.waiter')} htmlFor={idWaiter}
|
||||
<SettingRow label={t('settings.signIn.waiter')} htmlFor={idWaiter} tip={t('settings.signIn.waiterTip')}
|
||||
warning={waiterMode === 'tap' ? t('settings.signIn.waiterTapWarning') : undefined}>
|
||||
{select('auth.waiter_login_mode', 'pin', opts(['pin', 'password', 'tap'], 'settings.mode'), idWaiter)}
|
||||
</SettingRow>
|
||||
<SettingRow label={t('settings.signIn.requireUsername')} hint={t('settings.signIn.requireUsernameHint')}>
|
||||
<SettingRow label={t('settings.signIn.requireUsername')} hint={t('settings.signIn.requireUsernameHint')} tip={t('settings.signIn.requireUsernameTip')}>
|
||||
{toggle('auth.waiter_require_username', 'false', t('settings.signIn.requireUsername'))}
|
||||
</SettingRow>
|
||||
<SettingRow label={t('settings.signIn.device')} htmlFor={idDevice} hint={t('settings.signIn.deviceHint')}>
|
||||
<SettingRow label={t('settings.signIn.device')} htmlFor={idDevice} hint={t('settings.signIn.deviceHint')} tip={t('settings.signIn.deviceTip')}>
|
||||
{select('auth.default_login_mode', 'pin', opts(['pin', 'password', 'tap', 'none'], 'settings.mode'), idDevice)}
|
||||
</SettingRow>
|
||||
<SettingRow label={t('settings.signIn.singleManager')} htmlFor={idSingleManager} tip={t('settings.signIn.singleTip')}>
|
||||
{select('auth.single_session_manager', 'off', opts(SESSION_RULES, 'settings.session'), idSingleManager)}
|
||||
</SettingRow>
|
||||
<SettingRow label={t('settings.signIn.singleWaiter')} htmlFor={idSingleWaiter}>
|
||||
<SettingRow label={t('settings.signIn.singleWaiter')} htmlFor={idSingleWaiter} tip={t('settings.signIn.singleTip')}>
|
||||
{select('auth.single_session_waiter', 'off', opts(SESSION_RULES, 'settings.session'), idSingleWaiter)}
|
||||
</SettingRow>
|
||||
<SettingRow label={t('settings.signIn.idle')} htmlFor={idIdle} hint={t('settings.signIn.idleHint')}>
|
||||
<SettingRow label={t('settings.signIn.idle')} htmlFor={idIdle} hint={t('settings.signIn.idleHint')} tip={t('settings.signIn.idleTip')}>
|
||||
{select('auth.idle_days', '14', idleOptions, idIdle)}
|
||||
</SettingRow>
|
||||
</SettingsCard>
|
||||
|
||||
@@ -10,7 +10,7 @@ import { Lock, LockOpen, QrCode as QrIcon, RefreshCw } from 'lucide-react'
|
||||
import { useAccess } from '@xenia/access'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, Input, Spinner } from '@xenia/ui'
|
||||
import { Button, Columns, Dialog, Input, Spinner } from '@xenia/ui'
|
||||
import { QrCode } from '@xenia/ui/qr'
|
||||
import client from '../../../api/client'
|
||||
import { useLiveQuery } from '../../../live/useLiveQuery'
|
||||
@@ -43,7 +43,7 @@ export default function SystemSettings() {
|
||||
const counts = ['categories', 'products', 'tables', 'table_groups', 'managers', 'waiters']
|
||||
|
||||
return (
|
||||
<div className="grid gap-5" data-testid="settings-system">
|
||||
<Columns testId="settings-system">
|
||||
<SettingsCard title={t('settings.system.title')}>
|
||||
<SettingRow label={t('settings.system.version')}>
|
||||
<span className="flex flex-wrap items-center gap-2 text-body font-semibold text-ink" data-testid="system-version">
|
||||
@@ -106,7 +106,7 @@ export default function SystemSettings() {
|
||||
</div>
|
||||
</Dialog>
|
||||
)}
|
||||
</div>
|
||||
</Columns>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ function LanAccess({ status, onQr }) {
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
<SettingRow label={t('settings.lan.address')} hint={!ip ? t('settings.lan.unknown') : info && info.detection !== 'ok' && editing == null ? t(`settings.lan.detection.${info.detection}`, { defaultValue: '' }) : undefined}>
|
||||
<SettingRow label={t('settings.lan.address')} tip={t('settings.lan.addressTip')} hint={!ip ? t('settings.lan.unknown') : info && info.detection !== 'ok' && editing == null ? t(`settings.lan.detection.${info.detection}`, { defaultValue: '' }) : undefined}>
|
||||
{editing != null ? (
|
||||
<span className="grid gap-2">
|
||||
<Input value={editing} autoFocus className="font-mono" placeholder={info?.detected || '192.168.1.50'} onChange={e => setEditing(e.target.value)}
|
||||
|
||||
@@ -29,12 +29,12 @@ export default function VenueSettings() {
|
||||
|
||||
return (
|
||||
<SettingsCard title={t('settings.venue.title')} testId="settings-venue">
|
||||
<SettingRow label={t('settings.venue.language')} htmlFor={langId} hint={t('settings.venue.languageHint')}>
|
||||
<SettingRow label={t('settings.venue.language')} htmlFor={langId} hint={t('settings.venue.languageHint')} tip={t('settings.venue.languageTip')}>
|
||||
<Select id={langId} value={s.get('venue.language', 'en')} disabled={s.saving} data-testid="setting-venue.language"
|
||||
onChange={e => s.save('venue.language', e.target.value)}
|
||||
options={(languages || ['en', 'el']).map(l => ({ value: l, label: LANGUAGE_NAMES[l] || l }))} />
|
||||
</SettingRow>
|
||||
<SettingRow label={t('settings.venue.timezone')} htmlFor={tzId}
|
||||
<SettingRow label={t('settings.venue.timezone')} htmlFor={tzId} tip={t('settings.venue.timezoneTip')}
|
||||
hint={t('settings.venue.timezoneHint', { time: f.formatTime(new Date()) })}>
|
||||
<Select id={tzId} value={tz} disabled={s.saving} data-testid="setting-venue.timezone"
|
||||
onChange={e => s.save('venue.timezone', e.target.value)}
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
// evaluated by the backend's engine (local_backend/services/fees.py, the same file the cloud
|
||||
// runs); this file only turns forms into request bodies and rules into readable lines.
|
||||
// Pure: unit-tested in Node (tests/fees.test.mjs).
|
||||
import { parseNumber } from '@xenia/i18n/number'
|
||||
|
||||
export const ACTIONS = ['set', 'add', 'percent', 'free', 'minimum']
|
||||
export const DAYS = [0, 1, 2, 3, 4, 5, 6] // Monday = 0
|
||||
|
||||
const num = v => (v === '' || v == null ? null : Number(String(v).replace(',', '.')))
|
||||
const num = v => (v === '' || v == null ? null : (parseNumber(String(v)) ?? NaN))
|
||||
|
||||
/** Postcodes typed with commas, semicolons or new lines → a tidy list without duplicates. */
|
||||
export function parsePostcodes(text) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { EmptyState, cx } from '@xenia/ui'
|
||||
import { Pill } from '../overview/parts'
|
||||
import { nameOf } from './orderLogic'
|
||||
import { nameOf, pathText } from './orderLogic'
|
||||
|
||||
const EVENT_TONE = { PAYMENT: 'success', PAYMENT_OFFLINE: 'success', ORDER_CLOSED: 'neutral', ORDER_CANCELLED: 'danger', ITEM_CANCELLED: 'danger' }
|
||||
const ids = raw => { try { return raw ? JSON.parse(raw) : [] } catch { return [] } }
|
||||
@@ -59,6 +59,8 @@ export function PriceEventList({ events }) {
|
||||
<span className="flex flex-wrap gap-x-3">
|
||||
{(ev.modifier_name || ev.deal_name) && <span className="font-semibold">{ev.modifier_name || ev.deal_name}</span>}
|
||||
{ev.applied_by_username && <span className="text-ink-3">{t('orders.history.by', { name: ev.applied_by_username })}</span>}
|
||||
{ev.approved_by_username && <span className="text-ink-3">{t('orders.history.approvedBy', { name: ev.approved_by_username })}</span>}
|
||||
{ev.stage && <span className="text-ink-3">{t(`orders.history.stage.${ev.stage}`)}</span>}
|
||||
{ev.delta_amount != null && (
|
||||
<span className={cx('font-semibold tabular-nums', ev.delta_amount < 0 ? 'text-success-ink' : 'text-danger-ink')}>
|
||||
{formatMoney(ev.delta_amount, { signDisplay: 'exceptZero' })}
|
||||
@@ -74,3 +76,44 @@ export function PriceEventList({ events }) {
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
/** The order's moves (6F.4): the whole order's path (table transfers, tables joined into it), then
|
||||
* each moved line's own path, however many moves. */
|
||||
export function MoveList({ moves, order }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const { formatDateTime, formatNumber } = useFormat()
|
||||
const byId = new Map(order.items.map(i => [i.id, i]))
|
||||
const lines = Object.entries(moves.items ?? {}).map(([id, ms]) => [byId.get(Number(id)), ms]).filter(([i]) => i)
|
||||
if (!moves.order?.length && !lines.length) return <EmptyState compact title={t('orders.moves.none')} />
|
||||
const row = (m, itemId) => {
|
||||
const mine = itemId != null ? m.items.find(i => i.item_id === itemId) : null
|
||||
return (
|
||||
<li key={`${itemId ?? 'o'}-${m.id}`} className="px-4 py-2 flex items-start gap-3" data-testid="order-move">
|
||||
<Pill tone="info">{t(`orders.moves.kind.${m.kind}`)}</Pill>
|
||||
<span className="flex-1 min-w-0 text-label text-ink">
|
||||
<span className="font-semibold">{m.from_table || '—'} → {m.to_table || '—'}</span>
|
||||
{m.by && <span className="ml-2 text-ink-3">{t('orders.history.by', { name: m.by })}</span>}
|
||||
{mine?.quantity != null && <span className="ml-2 text-ink-3">×{formatNumber(mine.quantity, { maxDecimals: 3 })}</span>}
|
||||
{itemId == null && <span className="ml-2 text-ink-3">{t('orders.moves.lines', { count: m.items.length })}</span>}
|
||||
</span>
|
||||
<span className="text-caption text-ink-3 shrink-0">{formatDateTime(m.at, 'datetimeShort')}</span>
|
||||
</li>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<div className="divide-y divide-line" data-testid="order-moves">
|
||||
{moves.order?.length > 0 && (
|
||||
<section>
|
||||
<h3 className="px-4 pt-3 pb-1 text-label font-semibold text-ink-2">{t('orders.moves.wholeOrder', { path: pathText(moves.order) })}</h3>
|
||||
<ul className="divide-y divide-line">{moves.order.map(m => row(m))}</ul>
|
||||
</section>
|
||||
)}
|
||||
{lines.map(([item, ms]) => (
|
||||
<section key={item.id}>
|
||||
<h3 className="px-4 pt-3 pb-1 text-label font-semibold text-ink-2">{nameOf(item)} · {pathText(ms)}</h3>
|
||||
<ul className="divide-y divide-line">{ms.map(m => row(m, item.id))}</ul>
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -8,16 +8,16 @@ import toast from 'react-hot-toast'
|
||||
import { Ban, CreditCard, Percent, Printer, Receipt } from 'lucide-react'
|
||||
import { useCan, useModule } from '@xenia/access'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { parseNumber, useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, EmptyState, Field, Input, cx } from '@xenia/ui'
|
||||
import client from '../../api/client'
|
||||
import { Pill } from '../overview/parts'
|
||||
import { lineAmount, lineDetails, nameOf, selectable, selectedAmount, shownLines, toggleSelected, unitOf } from './orderLogic'
|
||||
import { lineAmount, lineDetails, nameOf, pathText, selectable, selectedAmount, shownLines, toggleSelected, unitOf } from './orderLogic'
|
||||
|
||||
const STATUS_TONE = { paid: 'success', cancelled: 'danger', tabbed: 'info', closed: 'warning' }
|
||||
const EVENT_TONE = { waiter_discount: 'text-accent-ink', free_item_added: 'text-success-ink', modifier_applied: 'text-info-ink' }
|
||||
const EVENT_TONE = { waiter_discount: 'text-accent-ink', free_item_added: 'text-success-ink', modifier_applied: 'text-info-ink', manual_price: 'text-warning-ink' }
|
||||
|
||||
export default function OrderLines({ order, open, priceEvents, onPay, onChanged }) {
|
||||
export default function OrderLines({ order, open, priceEvents, moves = {}, onPay, onChanged }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const { formatMoney, formatTime } = useFormat()
|
||||
const canDiscount = useCan('pricing.discounts.apply')
|
||||
@@ -70,6 +70,11 @@ export default function OrderLines({ order, open, priceEvents, onPay, onChanged
|
||||
{d.choices.length > 0 && <div className="text-caption text-ink-2">{d.choices.join(', ')}</div>}
|
||||
{d.removed.length > 0 && <div className="text-caption text-ink-2">{t('orders.lines.without', { list: d.removed.join(', ') })}</div>}
|
||||
{d.note && <div className="text-caption text-warning-ink">{d.note}</div>}
|
||||
{moves[item.id]?.length > 0 && (
|
||||
<div className="text-caption text-info-ink" data-testid="line-moved">
|
||||
↪ {t('orders.moves.linePath', { path: pathText(moves[item.id]) })}
|
||||
</div>
|
||||
)}
|
||||
<div className="text-caption text-ink-3">
|
||||
{t('orders.lines.added', { time: formatTime(item.added_at), name: item.added_by_name ?? '' })}
|
||||
{item.paid_by_name && ` · ${t('orders.lines.paidBy', { name: item.paid_by_name })}`}
|
||||
@@ -79,6 +84,12 @@ export default function OrderLines({ order, open, priceEvents, onPay, onChanged
|
||||
<span aria-hidden="true">↳</span>
|
||||
<span>{ev.modifier_name || ev.deal_name || t(`overview.order.event.${ev.event_type}`)}</span>
|
||||
{ev.delta_amount != null && <span className="font-semibold">{formatMoney(ev.delta_amount, { signDisplay: 'exceptZero' })}</span>}
|
||||
{ev.event_type === 'manual_price' && (
|
||||
<span className="text-ink-3" data-testid="line-price-change">
|
||||
{formatMoney(ev.price_before)} → {formatMoney(ev.price_after)}
|
||||
{ev.applied_by_username && ` · ${ev.applied_by_username}`}{ev.waiter_note && ` · ${ev.waiter_note}`}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
@@ -123,7 +134,7 @@ function DiscountDialog({ orderId, itemIds, amount, onClose, onDone }) {
|
||||
const { formatMoney } = useFormat()
|
||||
const [pct, setPct] = useState('10')
|
||||
const [note, setNote] = useState('')
|
||||
const value = Number(String(pct).replace(',', '.'))
|
||||
const value = parseNumber(String(pct)) ?? NaN
|
||||
const ok = value > 0 && value <= 100
|
||||
const apply = useMutation({
|
||||
mutationFn: () => client.post(`/api/orders/${orderId}/items/discount`, { item_ids: itemIds, discount_percent: value, note: note.trim() || null }),
|
||||
|
||||
@@ -21,12 +21,12 @@ import OrderLines from './OrderLines'
|
||||
import OrderPeople from './OrderPeople'
|
||||
import PayDialog from './PayDialog'
|
||||
import PrintProblemsCard from './PrintProblemsCard'
|
||||
import { AuditList, PriceEventList } from './OrderHistory'
|
||||
import { AuditList, MoveList, PriceEventList } from './OrderHistory'
|
||||
import { closeStep, totals, unpaidIds, venueRules } from './orderLogic'
|
||||
|
||||
const ORDER_EVENTS = ['order_updated', 'order_paid', 'order_closed', 'order_refunded', 'kds_order_updated', 'kds_item_updated']
|
||||
const STATUS_TONE = { open: 'success', partially_paid: 'info', paid: 'accent', closed: 'neutral', cancelled: 'danger' }
|
||||
const TABS = ['order', 'prices', 'history']
|
||||
const TABS = ['order', 'prices', 'moves', 'history']
|
||||
|
||||
export default function OrderPage() {
|
||||
const { orderId } = useParams()
|
||||
@@ -90,9 +90,14 @@ function OrderView({ orderId }) {
|
||||
queryKey: ['price-events', orderId], queryFn: () => client.get(`/api/pricing/events/order/${orderId}`).then(r => r.data), events: ['order_updated'],
|
||||
})
|
||||
|
||||
const { data: moves = { order: [], items: {} } } = useLiveQuery({ // 6F.4
|
||||
queryKey: ['order-moves', orderId], queryFn: () => client.get(`/api/orders/${orderId}/moves`).then(r => r.data), events: ['order_updated'],
|
||||
})
|
||||
|
||||
const refresh = () => {
|
||||
qc.invalidateQueries({ queryKey: ['order', orderId] })
|
||||
qc.invalidateQueries({ queryKey: ['price-events', orderId] })
|
||||
qc.invalidateQueries({ queryKey: ['order-moves', orderId] })
|
||||
qc.invalidateQueries({ queryKey: ['orders-active'] })
|
||||
}
|
||||
const onError = err => toast.error(errorMessage(err, t))
|
||||
@@ -155,7 +160,7 @@ function OrderView({ orderId }) {
|
||||
{tab === 'order' && (
|
||||
<div className={cx('grid gap-4 items-start', editable && 'lg:grid-cols-[minmax(0,1fr)_minmax(0,1.1fr)]')}>
|
||||
<div className="grid gap-4 min-w-0">
|
||||
<OrderLines order={order} open={editable} priceEvents={priceEvents} onChanged={refresh}
|
||||
<OrderLines order={order} open={editable} priceEvents={priceEvents} moves={moves.items} onChanged={refresh}
|
||||
onPay={(ids, amount, after) => setPaying({ ids, amount, after })} />
|
||||
<OrderPeople order={order} open={editable} staff={staff} onChanged={refresh} />
|
||||
</div>
|
||||
@@ -163,6 +168,7 @@ function OrderView({ orderId }) {
|
||||
</div>
|
||||
)}
|
||||
{tab === 'prices' && <section className="rounded-card border border-line bg-surface shadow-raised overflow-hidden"><PriceEventList events={priceEvents} /></section>}
|
||||
{tab === 'moves' && <section className="rounded-card border border-line bg-surface shadow-raised overflow-hidden"><MoveList moves={moves} order={order} /></section>}
|
||||
{tab === 'history' && <section className="rounded-card border border-line bg-surface shadow-raised overflow-hidden"><AuditList order={order} /></section>}
|
||||
|
||||
{paying && <PayDialog orderId={order.id} itemIds={paying.ids} amount={paying.amount} card={venue.card} thenClose={!!paying.thenClose}
|
||||
|
||||
@@ -104,3 +104,11 @@ export function flagsByTable(defs = [], assignments = []) {
|
||||
|
||||
/** Where a table's card goes: its order, or a new order at that table. */
|
||||
export const cardTarget = card => (card.order ? `/orders/${card.order.id}` : `/orders/new?table=${card.table.id}`)
|
||||
|
||||
/** "T2 → T5 → T7": the tables a moved order or line went through (6F.4; '—' for no table). */
|
||||
export function pathText(moves) {
|
||||
if (!moves?.length) return ''
|
||||
const stops = [moves[0].from_table || '—']
|
||||
for (const m of moves) stops.push(m.to_table || '—')
|
||||
return stops.join(' → ')
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ export default function OrderDialog({ orderId, tableName, onClose, onOpenFull })
|
||||
{evs.map((ev, i) => (
|
||||
<div key={i} className={cx('flex items-center gap-2 pl-4 text-caption', EVENT_TONE[ev.event_type])}>
|
||||
<span aria-hidden="true">↳</span>
|
||||
<span className="flex-1">{ev.modifier_name || ev.deal_name || t(`overview.order.event.${ev.event_type}`)}</span>
|
||||
<span className="flex-1">{ev.modifier_name || ev.deal_name || t(`overview.order.event.${ev.event_type}`)}{ev.event_type === 'manual_price' && ev.waiter_note ? ` · ${ev.waiter_note}` : ''}</span>
|
||||
{ev.delta_amount != null && <span className="font-semibold">{formatMoney(ev.delta_amount, { signDisplay: 'exceptZero' })}</span>}
|
||||
{ev.price_after != null && <span className="text-ink-3">→ {formatMoney(ev.price_after)}</span>}
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// expected (short / over / even), then "End the shift".
|
||||
import { useState } from 'react'
|
||||
import { useTranslation, useFormat, parseNumber } from '@xenia/i18n'
|
||||
import { Button, Dialog, Field, Input, Spinner, Textarea, cx } from '@xenia/ui'
|
||||
import { Button, Dialog, Field, InfoTip, Input, Spinner, Textarea, cx } from '@xenia/ui'
|
||||
import client from '../../api/client'
|
||||
import { useLiveQuery } from '../../live/useLiveQuery'
|
||||
import { ITEM_KINDS, cashCheck, hourBuckets, itemKind, itemShown, quickAmounts, shiftCounts, shiftMoney, shiftPairs } from './overviewLogic'
|
||||
@@ -127,7 +127,7 @@ export default function ShiftDialog({ shift, mode, onClose, onConfirm, busy }) {
|
||||
{closing && step === 2 && (
|
||||
<div className="grid gap-3">
|
||||
<h3 className="text-title font-semibold text-ink">{t('overview.shift.handover')}</h3>
|
||||
<Field label={t('overview.shift.counted')} hint={t('overview.shift.countedHint')}>
|
||||
<Field label={t('overview.shift.counted')} info={<InfoTip>{t('overview.shift.countedTip')}</InfoTip>} hint={t('overview.shift.countedHint')}>
|
||||
<Input inputMode="decimal" autoFocus value={counted} onChange={e => setCounted(e.target.value)}
|
||||
placeholder={String(money.expected.toFixed(2))} data-testid="shift-counted" />
|
||||
</Field>
|
||||
|
||||
@@ -15,7 +15,7 @@ import { MonitorSmartphone, Plus } from 'lucide-react'
|
||||
import { DeviceSupport } from './DeviceSupport'
|
||||
import { errorMessage, parseError } from '@xenia/api'
|
||||
import { useTranslation, useFormat } from '@xenia/i18n'
|
||||
import { Button, Dialog, EmptyState, Field, Input, Page, Select, Spinner } from '@xenia/ui'
|
||||
import { Button, Dialog, EmptyState, Field, InfoTip, Input, Page, Select, Spinner } from '@xenia/ui'
|
||||
import client from '../../api/client'
|
||||
import DeviceConfigFields from './DeviceConfigFields'
|
||||
import { configInitial, deviceStatus, deviceUsage, hasRoom, linkTargets, normalizeCode } from './devicesLogic'
|
||||
@@ -258,7 +258,7 @@ function PairDialog({ apps, usage, devices, appName, limitLabel, initialApp, onC
|
||||
<Input value={name} onChange={e => setName(e.target.value)} placeholder={t('devices.form.namePlaceholder')} maxLength={60} />
|
||||
</Field>
|
||||
{modes && (
|
||||
<Field label={t('devices.form.signIn')}>
|
||||
<Field label={t('devices.form.signIn')} info={<InfoTip>{t('devices.form.signInTip')}</InfoTip>}>
|
||||
<Select value={mode} onChange={e => setMode(e.target.value)} options={modes} />
|
||||
</Field>
|
||||
)}
|
||||
@@ -304,7 +304,7 @@ function EditDialog({ device, apps, devices, onClose, onSave }) {
|
||||
<Input value={name} onChange={e => setName(e.target.value)} maxLength={60} />
|
||||
</Field>
|
||||
{modes && (
|
||||
<Field label={t('devices.form.signIn')}>
|
||||
<Field label={t('devices.form.signIn')} info={<InfoTip>{t('devices.form.signInTip')}</InfoTip>}>
|
||||
<Select value={mode} onChange={e => setMode(e.target.value)} options={modes} />
|
||||
</Field>
|
||||
)}
|
||||
|
||||
@@ -9,7 +9,7 @@ import toast from 'react-hot-toast'
|
||||
import { Plus } from 'lucide-react'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, EmptyState, Field, Input, Select, Spinner, Switch } from '@xenia/ui'
|
||||
import { Button, DecimalInput, Dialog, EmptyState, Field, Input, Select, Spinner, Switch } from '@xenia/ui'
|
||||
import { useLiveQuery } from '../../live/useLiveQuery'
|
||||
import * as api from './pricingApi'
|
||||
import { ColourPicker, ConditionList, Missing, PickSeveral, RuleCard, Segmented, TabHead, TagPicker, TargetList } from './PricingParts'
|
||||
@@ -145,8 +145,8 @@ function DealDialog({ deal, catalog, rules, busy, onClose, onSave }) {
|
||||
)}
|
||||
{['set_price', 'add_amount', 'add_percent'].includes(a) && (
|
||||
<Field label={t(`pricing.actions.valueLabel.${a === 'set_price' ? 'set' : a}`)} hint={a !== 'set_price' ? t('pricing.actions.minusHint') : undefined}>
|
||||
<Input type="number" step={a === 'add_percent' ? 1 : 0.1} className="w-36" value={Number.isFinite(f.action_value) ? f.action_value : ''}
|
||||
onChange={e => set('action_value', e.target.value === '' ? NaN : Number(e.target.value))} />
|
||||
<DecimalInput allowNegative decimals={2} suffix={a === 'add_percent' ? '%' : '€'} className="w-36" value={f.action_value}
|
||||
onChange={v => set('action_value', v ?? NaN)} />
|
||||
</Field>
|
||||
)}
|
||||
<ColourPicker value={f.color} onChange={v => set('color', v)} label={t('pricing.colour')} />
|
||||
|
||||
@@ -12,7 +12,7 @@ import toast from 'react-hot-toast'
|
||||
import { Layers, Plus } from 'lucide-react'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, EmptyState, Field, InfoTip, Input, Select, Spinner, Switch } from '@xenia/ui'
|
||||
import { Button, DecimalInput, Dialog, EmptyState, Field, InfoTip, Input, Select, Spinner, Switch } from '@xenia/ui'
|
||||
import { useLiveQuery } from '../../live/useLiveQuery'
|
||||
import * as api from './pricingApi'
|
||||
import { ColourPicker, ConditionList, Missing, RuleCard, Segmented, TabHead, TargetList } from './PricingParts'
|
||||
@@ -147,8 +147,8 @@ function RuleDialog({ rule, catalog, busy, onClose, onSave }) {
|
||||
options={MODIFIER_ACTIONS.map(v => ({ value: v, label: t(`pricing.actions.${v}`) }))} />
|
||||
<div className="grid sm:grid-cols-2 gap-3">
|
||||
<Field label={t(`pricing.actions.valueLabel.${f.action_type}`)} hint={f.action_type !== 'set' ? t('pricing.actions.minusHint') : undefined}>
|
||||
<Input type="number" step={f.action_type === 'add_percent' ? 1 : 0.1} value={Number.isFinite(f.action_value) ? f.action_value : ''}
|
||||
onChange={e => set('action_value', e.target.value === '' ? NaN : Number(e.target.value))} data-testid="pricing-rule-value" />
|
||||
<DecimalInput allowNegative decimals={2} suffix={f.action_type === 'add_percent' ? '%' : '€'} value={f.action_value}
|
||||
onChange={v => set('action_value', v ?? NaN)} data-testid="pricing-rule-value" />
|
||||
</Field>
|
||||
{f.action_type === 'add_percent' && (
|
||||
<Field label={t('pricing.rules.rounding')}>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useState } from 'react'
|
||||
import { ArrowDown, ArrowUp, Check, Pencil, Plus, Power, Trash2, X } from 'lucide-react'
|
||||
import { SALES_POINTS, normalizeSalesPoints } from '@xenia/access'
|
||||
import { latin, useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dropdown, IconButton, Input, Select, cx } from '@xenia/ui'
|
||||
import { Button, Dropdown, IconButton, Input, MoneyInput, Select, cx } from '@xenia/ui'
|
||||
import { COLOURS } from './useCatalog'
|
||||
import { OLD_PLACEHOLDERS, WEEKDAYS, blankCondition, conditionComplete, toggleIn } from './pricingLogic'
|
||||
|
||||
@@ -202,7 +202,13 @@ function ConditionFields({ cond, onChange, catalog }) {
|
||||
case 'specific_date': return <DateList value={p.dates ?? []} onChange={v => set('dates', v)} />
|
||||
case 'day_of_week': return <DayPicker value={p.days ?? []} onChange={v => set('days', v)} />
|
||||
case 'min_item_quantity': return <label className="flex items-center gap-2 text-label text-ink-2">{num('min', 1, 1)}{t('pricing.condition.ofTheDish')}</label>
|
||||
case 'min_order_value': return <label className="flex items-center gap-2 text-label text-ink-2">{num('min', 0, 0.5)}{t('pricing.condition.orderTotal')}</label>
|
||||
case 'min_order_value': return (
|
||||
<label className="flex items-center gap-2 text-label text-ink-2">
|
||||
<MoneyInput size="sm" className="w-32" value={p.min ?? null} aria-label={t('pricing.condition.fields.min_order_value')}
|
||||
onChange={v => set('min', Number.isFinite(v) ? v : null)} />
|
||||
{t('pricing.condition.orderTotal')}
|
||||
</label>
|
||||
)
|
||||
case 'min_category_qty': return (
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{num('min', 1, 1)}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// (modifier) and a deal, what they send to the server, what's missing before they can be saved,
|
||||
// and their one-line summaries. Tested in tests/pricing-logic.test.mjs.
|
||||
// The server's engine: local_backend/services/pricing.py (conditions AND-ed, targets OR-ed).
|
||||
import { parseNumber } from '@xenia/i18n/number'
|
||||
|
||||
export const WEEKDAYS = [0, 1, 2, 3, 4, 5, 6] // Monday = 0, as the server counts
|
||||
|
||||
@@ -226,9 +227,9 @@ export const COUNT_LIMITS = new Set(['max_items_per_shift', 'max_items_per_workd
|
||||
|
||||
/** A limit typed in a box: '' = no limit; a comma works as the decimal point. null when it isn't a number ≥ 0. */
|
||||
export function parseLimit(text, count = false) {
|
||||
const s = String(text ?? '').trim().replace(',', '.')
|
||||
const s = String(text ?? '').trim()
|
||||
if (s === '') return { ok: true, value: null }
|
||||
const v = Number(s)
|
||||
const v = parseNumber(s) ?? NaN
|
||||
if (!Number.isFinite(v) || v < 0 || (count && !Number.isInteger(v))) return { ok: false, value: null }
|
||||
return { ok: true, value: v }
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
// Settings → Printing (plan step 6.10; replaces the v1 "Print fonts" tab): when managers are
|
||||
// told about tickets that keep failing, the printers, and the tickets' look and beep.
|
||||
import { Columns } from '@xenia/ui'
|
||||
import PrintAlertSetting from '../Settings/sections/PrintAlertSetting'
|
||||
import PrintersCard from './PrintersCard'
|
||||
import TicketSettings from './TicketSettings'
|
||||
|
||||
export default function PrintingSettings() {
|
||||
return (
|
||||
<div className="grid gap-5" data-testid="printing-settings">
|
||||
<Columns testId="printing-settings">
|
||||
<PrintersCard />
|
||||
<PrintAlertSetting />
|
||||
<TicketSettings />
|
||||
</div>
|
||||
</Columns>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useState } from 'react'
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import toast from 'react-hot-toast'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { parseNumber, useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, EmptyState, Page, Pane, Spinner } from '@xenia/ui'
|
||||
import { Package } from 'lucide-react'
|
||||
import client from '../../api/client'
|
||||
@@ -23,7 +23,7 @@ import { emptyProduct } from './editor/formLogic'
|
||||
import { NO_FILTERS, SCOPES, applyFilters, bulkCategories, groupProducts, isArchived, isCategoryScope, listedIn, scopeProducts, subsOf } from './productsLogic'
|
||||
|
||||
const EVENTS = ['products_changed']
|
||||
const number = v => (v === '' ? null : Number(String(v).replace(',', '.')))
|
||||
const number = v => (v === '' ? null : (parseNumber(String(v)) ?? NaN))
|
||||
|
||||
export default function ProductsPage() {
|
||||
const { t } = useTranslation('manager')
|
||||
|
||||
@@ -31,7 +31,7 @@ export function InfoTab({ form, set, setForm, categories, prepZones }) {
|
||||
</Field>
|
||||
<Tags tags={form.tags} onChange={v => set('tags', v)} />
|
||||
<div className="grid gap-3 grid-cols-2">
|
||||
<Field label={t('products.editor.unit')} hint={WEIGHED.has(form.unit_type) ? t('products.editor.unitWeighed') : undefined}>
|
||||
<Field label={t('products.editor.unit')} info={<InfoTip>{t('products.editor.unitTip')}</InfoTip>} hint={WEIGHED.has(form.unit_type) ? t('products.editor.unitWeighed') : undefined}>
|
||||
<Dropdown value={form.unit_type} onChange={v => set('unit_type', v)} data-testid="product-unit" options={UNITS.map(u => ({ value: u, label: t(`products.unit.${u}`) }))} />
|
||||
</Field>
|
||||
<Field label={t('products.editor.price')} required>
|
||||
@@ -41,8 +41,9 @@ export function InfoTab({ form, set, setForm, categories, prepZones }) {
|
||||
<CategoriesField form={form} setForm={setForm} categories={categories} />
|
||||
<PrepZonesField form={form} set={set} prepZones={prepZones} />
|
||||
<AllergensField value={form.allergens} onChange={v => set('allergens', v)} />
|
||||
<Switch checked={form.is_available} onChange={v => set('is_available', v)} label={t('products.editor.available')} description={t('products.editor.availableHint')} />
|
||||
<Switch checked={form.quick_add_enabled} onChange={v => set('quick_add_enabled', v)} label={t('products.editor.quickAdd')} description={t('products.editor.quickAddHint')} />
|
||||
<Switch checked={form.is_available} onChange={v => set('is_available', v)} label={t('products.editor.available')} info={<InfoTip>{t('products.editor.availableTip')}</InfoTip>} description={t('products.editor.availableHint')} />
|
||||
<Switch checked={form.quick_add_enabled} onChange={v => set('quick_add_enabled', v)} label={t('products.editor.quickAdd')} info={<InfoTip>{t('products.editor.quickAddTip')}</InfoTip>} description={t('products.editor.quickAddHint')} />
|
||||
<Switch checked={form.one_more_enabled} onChange={v => set('one_more_enabled', v)} label={t('products.editor.oneMore')} info={<InfoTip>{t('products.editor.oneMoreTip')}</InfoTip>} description={t('products.editor.oneMoreHint')} data-testid="product-one-more" />
|
||||
<MediaField value={form.image} onChange={image => set('image', image)} nameAfter={shownText(form.names, venue, form.name)} label={t('media.photo')} testid="product-photo" />
|
||||
</div>
|
||||
)
|
||||
@@ -158,7 +159,7 @@ export function CostTab({ form, set, setForm }) {
|
||||
))}
|
||||
</div>
|
||||
{form.cost_mode === 'simple' ? (
|
||||
<Field label={t('products.editor.costPerUnit')}><PriceInput className="w-full" value={form.cost_simple} onChange={v => set('cost_simple', v)} label={t('products.editor.costPerUnit')} /></Field>
|
||||
<Field label={t('products.editor.costPerUnit')} info={<InfoTip>{t('products.editor.costTip')}</InfoTip>}><PriceInput className="w-full" value={form.cost_simple} onChange={v => set('cost_simple', v)} label={t('products.editor.costPerUnit')} /></Field>
|
||||
) : (
|
||||
<div className="grid gap-2">
|
||||
{form.cost_breakdown.map((e, i) => (
|
||||
@@ -190,7 +191,7 @@ export function FiscalTab({ form, set, vatGroups }) {
|
||||
<Field label={t('products.editor.fiscalName')} hint={t('products.editor.fiscalNameHint')}>
|
||||
<Input className="font-mono uppercase" maxLength={30} value={form.fiscal_name} onChange={e => set('fiscal_name', e.target.value.toUpperCase())} placeholder={form.name.toUpperCase()} />
|
||||
</Field>
|
||||
<Field label={t('products.editor.vatGroup')} error={!form.fiscal_vat_group_id ? t('products.editor.vatGroupNeeded') : undefined}>
|
||||
<Field label={t('products.editor.vatGroup')} info={<InfoTip>{t('products.editor.vatGroupTip')}</InfoTip>} error={!form.fiscal_vat_group_id ? t('products.editor.vatGroupNeeded') : undefined}>
|
||||
{vatGroups.length === 0
|
||||
? <p className="text-label text-warning-ink">{t('products.editor.noVatGroups')}</p>
|
||||
: <Select value={form.fiscal_vat_group_id ?? ''} onChange={e => set('fiscal_vat_group_id', e.target.value ? Number(e.target.value) : null)}>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// with a price: printed in its own SERVICE section and counted in the takings.
|
||||
import { useState } from 'react'
|
||||
import { DEFAULT_LANGUAGE } from '@xenia/access'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { parseNumber, useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, Field } from '@xenia/ui'
|
||||
import { PrepZonesField } from './InfoTabs'
|
||||
import { LanguagePicker, TrInput } from './LanguageFields'
|
||||
@@ -19,7 +19,7 @@ export default function ServiceItemDialog({ product, prepZones, saving, onSave,
|
||||
const [lang, setLang] = useState(DEFAULT_LANGUAGE)
|
||||
const set = (k, v) => setForm(f => ({ ...f, [k]: v }))
|
||||
const isNew = !product.id
|
||||
const paid = Number(String(form.base_price ?? '').replace(',', '.')) > 0
|
||||
const paid = (parseNumber(String(form.base_price ?? '')) ?? 0) > 0
|
||||
return (
|
||||
<EditLang.Provider value={editLangOf(lang, venue)}>
|
||||
<Dialog open size="md" onClose={onClose}
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
// language picker picks which language the fields edit; "Default" is the venue's language.
|
||||
import { SALES_POINTS } from '@xenia/access/salesPoints'
|
||||
import { MENU_LANGUAGES, shownText } from '@xenia/access/menuLanguages'
|
||||
import { parseNumber } from '@xenia/i18n/number'
|
||||
|
||||
export const UNITS = ['piece', 'portion', 'kg', 'liter', 'gram', 'ml']
|
||||
export const WEIGHED = new Set(['kg', 'liter', 'gram', 'ml'])
|
||||
export const LISTS = { quick: 'quick_options', ingredient: 'ingredients', option: 'options', pref: 'preference_sets' }
|
||||
|
||||
const num = v => (v === '' || v == null ? 0 : Number(String(v).replace(',', '.')) || 0)
|
||||
const num = v => (v === '' || v == null ? 0 : parseNumber(String(v)) || 0)
|
||||
const sub = s => ({ name: s.name ?? '', tr: { ...(s.translations ?? {}) }, extra_cost: s.extra_cost ?? 0, is_default: !!s.is_default, allow_multiple: !!s.allow_multiple, is_compact: !!s.is_compact })
|
||||
const field = (tr, k) => Object.fromEntries(Object.entries(tr ?? {}).filter(([, v]) => v?.[k]).map(([l, v]) => [l, v[k]]))
|
||||
|
||||
@@ -80,6 +81,7 @@ export function buildForm(p) {
|
||||
cost_simple: p.cost_simple ?? '',
|
||||
cost_breakdown: (p.cost_breakdown ?? []).map(e => ({ label: e.label, amount: e.amount })),
|
||||
quick_add_enabled: p.quick_add_enabled ?? true,
|
||||
one_more_enabled: !!p.one_more_enabled, // 6F.5
|
||||
tags: [...(p.tags ?? [])],
|
||||
is_service_item: !!p.is_service_item,
|
||||
fiscal_name: p.fiscal_name ?? '',
|
||||
@@ -142,6 +144,7 @@ export function buildBody(f, venue = 'el') {
|
||||
cost_breakdown: f.cost_mode === 'detailed' && f.cost_breakdown.length
|
||||
? f.cost_breakdown.map(e => ({ label: e.label, amount: num(e.amount) })) : null,
|
||||
quick_add_enabled: f.quick_add_enabled,
|
||||
one_more_enabled: !!f.one_more_enabled,
|
||||
tags: f.tags,
|
||||
is_service_item: f.is_service_item,
|
||||
fiscal_name: f.fiscal_name.trim() || null,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// language picked at the top of the editor.
|
||||
import { useState } from 'react'
|
||||
import { ChevronDown, ChevronUp, Heart, Minus, Pencil, Plus, Trash2 } from 'lucide-react'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { parseNumber, useTranslation } from '@xenia/i18n'
|
||||
import { Button, FilterChip, IconButton, cx } from '@xenia/ui'
|
||||
import { TrInput } from './LanguageFields'
|
||||
import { useEditLang } from './editLang'
|
||||
@@ -12,7 +12,7 @@ import { labelIn } from './formLogic'
|
||||
/** A price with − / + of 0.10 (negative allowed for choices that lower the price). */
|
||||
export function PriceInput({ value, onChange, allowNegative = false, size = 'md', className, label, ...rest }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const n = Number(String(value ?? '').replace(',', '.')) || 0
|
||||
const n = parseNumber(String(value ?? '')) || 0
|
||||
const step = d => {
|
||||
const next = Math.round((n + d) * 100) / 100
|
||||
onChange(allowNegative ? next : Math.max(0, next))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// cancelled line (what, how much, who sent it, who cancelled it, why) and every discount given
|
||||
// (on what, how much, by whom, why), with totals per person; exports for Excel.
|
||||
import { useState } from 'react'
|
||||
import { useCan } from '@xenia/access'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import client from '../../../api/client'
|
||||
import { useLiveQuery } from '../../../live/useLiveQuery'
|
||||
@@ -12,9 +13,11 @@ import { defaultPeriod, periodParams, periodSlug } from '../kit/reportLogic'
|
||||
|
||||
export default function MiscReport() {
|
||||
const { t } = useTranslation('manager')
|
||||
const seesChanges = useCan('ordering.prices.view_changes')
|
||||
const tabs = [
|
||||
{ id: 'cancellations', label: t('reports.misc.cancellations'), Component: CancellationsTab },
|
||||
{ id: 'discounts', label: t('reports.misc.discounts'), Component: DiscountsTab },
|
||||
...(seesChanges ? [{ id: 'price-changes', label: t('reports.misc.priceChanges'), Component: PriceChangesTab }] : []),
|
||||
]
|
||||
return <ReportPage title={t('reports.misc.title')} tabs={tabs} testId="report-misc" />
|
||||
}
|
||||
@@ -102,3 +105,46 @@ function DiscountsTab() {
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
/** Prices changed by hand (6F.3): each change, before → after, its value for the line's quantity,
|
||||
* where (cart / sent / served), who, the approving manager, why; totals per person. */
|
||||
function PriceChangesTab() {
|
||||
const { t } = useTranslation('manager')
|
||||
const fmt = useFormat()
|
||||
const [period, setPeriod] = useState(() => defaultPeriod(fmt.venueToday()))
|
||||
const params = periodParams(period)
|
||||
const { data, isPending, error, refetch } = useLiveQuery({ queryKey: ['report-price-changes', params], queryFn: () => client.get('/api/reports/price-changes', { params }).then(r => r.data) })
|
||||
const rows = data?.changes ?? []
|
||||
const columns = [
|
||||
{ key: 'at', label: t('reports.misc.when'), render: c => fmt.formatDateTime(c.at, 'datetimeShort') },
|
||||
{ key: 'product_name', label: t('reports.prod.product'), render: c => <span className="font-semibold text-ink">{c.product_name}</span> },
|
||||
{ key: 'table_name', label: t('reports.place'), render: c => c.table_name || t('reports.noTable') },
|
||||
{ key: 'before', label: t('reports.misc.priceWas'), align: 'right', render: c => fmt.formatMoney(c.before) },
|
||||
{ key: 'after', label: t('reports.misc.priceNow'), align: 'right', render: c => fmt.formatMoney(c.after) },
|
||||
{ key: 'value', label: t('reports.misc.value'), align: 'right', render: c => <span className={c.value < 0 ? 'font-semibold text-danger-ink' : 'font-semibold text-success-ink'}>{fmt.formatMoney(c.value, { signDisplay: 'exceptZero' })}</span> },
|
||||
{ key: 'stage', label: t('reports.misc.stage'), render: c => (c.stage ? t(`orders.history.stage.${c.stage}`) : '') },
|
||||
{ key: 'by', label: t('reports.misc.changedBy'), render: c => c.by || '' },
|
||||
{ key: 'approved_by', label: t('reports.misc.approvedBy'), render: c => c.approved_by || '' },
|
||||
{ key: 'reason', label: t('reports.misc.reason'), render: c => c.reason || '' },
|
||||
]
|
||||
return (
|
||||
<div className="grid gap-4">
|
||||
<PeriodPicker value={period} onChange={setPeriod} right={<ExportButton endpoint="/api/reports/price-changes/export" params={params} filename={`price-changes-${periodSlug(period)}.csv`} />} />
|
||||
{isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (<>
|
||||
<div className="grid gap-3 grid-cols-[repeat(auto-fill,minmax(12rem,1fr))]">
|
||||
<Stat label={t('reports.misc.changes')} value={data.count} testId="price-changes-count" />
|
||||
<Stat label={t('reports.misc.changesValue')} tone={data.total_value < 0 ? 'danger' : 'success'} value={fmt.formatMoney(data.total_value, { signDisplay: 'exceptZero' })} tip={t('reports.misc.changesValueTip')} />
|
||||
</div>
|
||||
{data.by_person.length > 1 && (
|
||||
<Panel title={t('reports.misc.byWhom')}>
|
||||
<BarList format={v => fmt.formatMoney(v, { signDisplay: 'exceptZero' })} rows={data.by_person.map(p => ({ key: p.user_id ?? '—', label: p.name ?? '—', value: p.total_value, sub: t('reports.misc.changesCount', { count: p.count }) }))} />
|
||||
</Panel>
|
||||
)}
|
||||
<Panel padded={false} title={t('reports.misc.priceChanges')}>
|
||||
<Table columns={columns} rows={rows} rowTestId="report-price-change" initialSort={{ key: 'at', dir: 'desc' }} limit={500} />
|
||||
</Panel>
|
||||
</>)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
// Reports → Moves (plan 6F.4, owner 2026-11-23): every move between tables and orders in a period:
|
||||
// a whole table moved, lines moved to another table, tables joined; from / to, who, the lines
|
||||
// with their quantities and value; counts per kind and per person; export for Excel.
|
||||
// GET /api/reports/moves (+ /export).
|
||||
import { useState } from 'react'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { Dropdown, Toolbar } from '@xenia/ui'
|
||||
import client from '../../../api/client'
|
||||
import { useLiveQuery } from '../../../live/useLiveQuery'
|
||||
import { BarList } from '../kit/charts'
|
||||
import { ExportButton, Failed, Loading, Panel, ReportPage, Stat, Table } from '../kit/parts'
|
||||
import { PeriodPicker } from '../kit/Period'
|
||||
import { defaultPeriod, periodParams, periodSlug } from '../kit/reportLogic'
|
||||
|
||||
const KINDS = ['table_transfer', 'items_moved', 'orders_merged']
|
||||
|
||||
export default function MovesReport() {
|
||||
const { t } = useTranslation('manager')
|
||||
return <ReportPage title={t('reports.moves.title')} testId="report-moves"><MovesBody /></ReportPage>
|
||||
}
|
||||
|
||||
function MovesBody() {
|
||||
const { t } = useTranslation('manager')
|
||||
const fmt = useFormat()
|
||||
const [period, setPeriod] = useState(() => defaultPeriod(fmt.venueToday()))
|
||||
const [kinds, setKinds] = useState([])
|
||||
const params = { ...periodParams(period), ...(kinds.length === 1 ? { kind: kinds[0] } : {}) }
|
||||
const { data, isPending, error, refetch } = useLiveQuery({ queryKey: ['report-moves', params], queryFn: () => client.get('/api/reports/moves', { params }).then(r => r.data) })
|
||||
const rows = (data?.moves ?? []).filter(m => !kinds.length || kinds.includes(m.kind))
|
||||
const columns = [
|
||||
{ key: 'at', label: t('reports.misc.when'), render: m => fmt.formatDateTime(m.at, 'datetimeShort') },
|
||||
{ key: 'kind', label: t('reports.moves.kind'), render: m => t(`reports.moves.kinds.${m.kind}`) },
|
||||
{ key: 'from_table', label: t('reports.moves.from'), render: m => <span className="font-semibold text-ink">{m.from_table || t('reports.noTable')}</span> },
|
||||
{ key: 'to_table', label: t('reports.moves.to'), render: m => <span className="font-semibold text-ink">{m.to_table || t('reports.noTable')}</span> },
|
||||
{ key: 'items', label: t('reports.moves.lines'), sortable: false,
|
||||
render: m => <span className="text-label text-ink-2">{m.items.map(i => `${i.name ?? `#${i.item_id}`}${i.quantity != null ? ` ×${fmt.formatNumber(i.quantity, { maxDecimals: 3 })}` : ''}`).join(', ')}</span> },
|
||||
{ key: 'value', label: t('reports.misc.value'), align: 'right', render: m => fmt.formatMoney(m.value) },
|
||||
{ key: 'by', label: t('reports.moves.by'), render: m => m.by || '' },
|
||||
{ key: 'orders', label: '#', sortable: false, render: m => <span className="tabular-nums text-ink-3">#{m.from_order_id}{m.to_order_id !== m.from_order_id ? ` → #${m.to_order_id}` : ''}</span> },
|
||||
]
|
||||
return (
|
||||
<div className="grid gap-4">
|
||||
<PeriodPicker value={period} onChange={setPeriod} right={<ExportButton endpoint="/api/reports/moves/export" params={params} filename={`moves-${periodSlug(period)}.csv`} />} />
|
||||
<Toolbar>
|
||||
<Dropdown multiple value={kinds} onChange={setKinds} allLabel={t('reports.moves.allKinds')} aria-label={t('reports.moves.kind')}
|
||||
options={KINDS.map(k => ({ value: k, label: t(`reports.moves.kinds.${k}`) }))} data-testid="moves-kind" />
|
||||
</Toolbar>
|
||||
{isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (<>
|
||||
<div className="grid gap-3 grid-cols-[repeat(auto-fill,minmax(12rem,1fr))]">
|
||||
<Stat label={t('reports.moves.count')} value={rows.length} testId="moves-count" />
|
||||
{KINDS.map(k => <Stat key={k} label={t(`reports.moves.kinds.${k}`)} value={data.by_kind[k] ?? 0} />)}
|
||||
</div>
|
||||
{data.by_person.length > 1 && (
|
||||
<Panel title={t('reports.misc.byWhom')}>
|
||||
<BarList format={v => fmt.formatNumber(v)} rows={data.by_person.map(p => ({ key: p.user_id ?? '—', label: p.name ?? '—', value: p.count }))} />
|
||||
</Panel>
|
||||
)}
|
||||
<Panel padded={false} title={t('reports.moves.list')} tip={t('reports.moves.listTip')}>
|
||||
<Table columns={columns} rows={rows} rowTestId="report-move" initialSort={{ key: 'at', dir: 'desc' }} limit={500} />
|
||||
</Panel>
|
||||
</>)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -3,6 +3,10 @@
|
||||
// pixel by pixel (or in steps of 10 / 50 px), or a preset sets the largest box of a common shape in
|
||||
// the middle of the TV's window (it reports its size). Every change reaches the TV at once; closing
|
||||
// ends the calibration (the TV also stops by itself after 15 min).
|
||||
// Owner 2026-11-23: every row centred; "Each click moves" above its choice; the window size is
|
||||
// marked as the one the TV reported (recognised), and an edge may go past it (below 0 px) when the
|
||||
// TV's real picture is larger; "on" is sent again a moment after opening (the TV shows the outline
|
||||
// the first time).
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import toast from 'react-hot-toast'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
@@ -15,6 +19,7 @@ import { ShapeMark } from './ShapeField'
|
||||
const EDGES = ['top', 'right', 'bottom', 'left']
|
||||
const PRESETS = ['full', '16:9', '16:10', '21:9', '32:9', '4:3', '9:16']
|
||||
const SAVE_MS = 200
|
||||
const OUT = 2000 // px an edge may reach past the recognised window
|
||||
|
||||
export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
||||
const { t } = useTranslation('manager')
|
||||
@@ -30,7 +35,8 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
||||
useEffect(() => {
|
||||
const mine = ++alive.current
|
||||
api.calibrateScreen(screen.id, true).catch(err => toast.error(errorMessage(err, t)))
|
||||
return () => { setTimeout(() => { if (alive.current === mine) api.calibrateScreen(screen.id, false).catch(() => {}) }, 300) }
|
||||
const again = setTimeout(() => { if (alive.current === mine) api.calibrateScreen(screen.id, true).catch(() => {}) }, 1500)
|
||||
return () => { clearTimeout(again); setTimeout(() => { if (alive.current === mine) api.calibrateScreen(screen.id, false).catch(() => {}) }, 300) }
|
||||
}, [screen.id]) // eslint-disable-line react-hooks/exhaustive-deps
|
||||
// the TV's window size (it reports it when it starts and when it changes)
|
||||
useEffect(() => {
|
||||
@@ -54,15 +60,20 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
||||
useEffect(() => () => clearTimeout(timer.current), [])
|
||||
const win = viewport ? { w: viewport.width, h: viewport.height } : null
|
||||
const pic = win ? pictureArea(win, area) : null
|
||||
const setEdge = (edge, v) => change({ ...area, [edge]: Math.max(0, Math.min(4000, v ?? 0)) })
|
||||
const setEdge = (edge, v) => change({ ...area, [edge]: Math.max(-OUT, Math.min(4000, v ?? 0)) })
|
||||
|
||||
// the diagram: the TV's window and the picture inside it, to scale
|
||||
// the diagram: the recognised window (dashed) and the picture, to scale; a picture reaching past
|
||||
// the window makes the drawing as large as both
|
||||
const bounds = win && pic ? {
|
||||
x: Math.min(0, pic.left), y: Math.min(0, pic.top),
|
||||
r: Math.max(win.w, pic.left + pic.width), b: Math.max(win.h, pic.top + pic.height),
|
||||
} : null
|
||||
const W = 320
|
||||
const H = win ? Math.round(W * win.h / win.w) : 180
|
||||
const k = win ? W / win.w : 0
|
||||
const H = bounds ? Math.round(W * (bounds.b - bounds.y) / (bounds.r - bounds.x)) : 180
|
||||
const k = bounds ? W / (bounds.r - bounds.x) : 0
|
||||
const edge = e => (
|
||||
<Field label={t(`signage.calibrate.edges.${e}`)} className="w-36">
|
||||
<NumberInput size="sm" value={area[e]} min={0} max={4000} step={step} suffix="px" onChange={v => setEdge(e, v)} data-testid={`signage-calibrate-${e}`} />
|
||||
<NumberInput size="sm" value={area[e]} min={-OUT} max={4000} step={step} suffix="px" onChange={v => setEdge(e, v)} data-testid={`signage-calibrate-${e}`} />
|
||||
</Field>
|
||||
)
|
||||
return (
|
||||
@@ -71,13 +82,17 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
||||
<Button variant="secondary" onClick={() => change({ left: 0, top: 0, right: 0, bottom: 0 })} data-testid="signage-calibrate-reset">{t('signage.calibrate.reset')}</Button>
|
||||
<Button onClick={onClose} data-testid="signage-calibrate-done">{t('signage.calibrate.done')}</Button>
|
||||
</>}>
|
||||
<div className="grid gap-5" data-testid="signage-calibrate-dialog">
|
||||
<p className="text-label text-ink-2" data-testid="signage-calibrate-window">
|
||||
{win ? t('signage.calibrate.window', { w: win.w, h: win.h, shape: shapeName(win.w, win.h) }) : t('signage.calibrate.waiting')}
|
||||
</p>
|
||||
<div className="grid gap-2">
|
||||
<div className="grid gap-5 justify-items-center text-center" data-testid="signage-calibrate-dialog">
|
||||
<div className="grid gap-1 justify-items-center">
|
||||
<span className="text-caption font-medium text-ink-3 uppercase tracking-wide">{t('signage.calibrate.recognised')}</span>
|
||||
<p className="text-body-lg font-semibold text-ink tabular-nums" data-testid="signage-calibrate-window">
|
||||
{win ? t('signage.calibrate.window', { w: win.w, h: win.h, shape: shapeName(win.w, win.h) }) : t('signage.calibrate.waiting')}
|
||||
</p>
|
||||
{win && <p className="text-caption text-ink-3 max-w-md">{t('signage.calibrate.recognisedHint')}</p>}
|
||||
</div>
|
||||
<div className="grid gap-2 justify-items-center">
|
||||
<span className="text-label font-medium text-ink">{t('signage.calibrate.presets')}</span>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
<div className="flex flex-wrap justify-center gap-1.5">
|
||||
{PRESETS.map(p => (
|
||||
<Button key={p} size="sm" variant="secondary" disabled={!win} onClick={() => change(presetInsets(win, p))} data-preset={p}
|
||||
icon={p === 'full' ? undefined : <ShapeMark shape={p} size={16} />}>
|
||||
@@ -86,7 +101,7 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<div className="grid gap-2 justify-items-center">
|
||||
<span className="text-label font-medium text-ink">{t('signage.calibrate.step')}</span>
|
||||
<Segmented value={step} onChange={setStep} options={[1, 10, 50].map(n => ({ value: n, label: `${n} px` }))} data-testid="signage-calibrate-step" />
|
||||
</div>
|
||||
@@ -94,13 +109,15 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
||||
{edge('top')}
|
||||
<div className="flex items-center gap-3 flex-wrap justify-center">
|
||||
{edge('left')}
|
||||
<div className="relative rounded-control border border-line-strong bg-surface-2" style={{ width: W, height: H }} aria-hidden="true">
|
||||
{pic && (
|
||||
<div className="relative rounded-control bg-surface-2" style={{ width: W, height: H }} aria-hidden="true" data-testid="signage-calibrate-diagram">
|
||||
{pic && bounds && <>
|
||||
<div className="absolute border-2 border-accent bg-accent-soft grid place-items-center text-caption text-accent-ink tabular-nums"
|
||||
style={{ left: pic.left * k, top: pic.top * k, width: pic.width * k, height: pic.height * k }}>
|
||||
style={{ left: (pic.left - bounds.x) * k, top: (pic.top - bounds.y) * k, width: pic.width * k, height: pic.height * k }}>
|
||||
{Math.round(pic.width)} × {Math.round(pic.height)}
|
||||
</div>
|
||||
)}
|
||||
<div className="absolute border border-dashed border-line-strong rounded-[2px] pointer-events-none"
|
||||
style={{ left: -bounds.x * k, top: -bounds.y * k, width: win.w * k, height: win.h * k }} />
|
||||
</>}
|
||||
</div>
|
||||
{edge('right')}
|
||||
</div>
|
||||
@@ -109,7 +126,9 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
||||
<p className="text-label text-ink-2 text-center" data-testid="signage-calibrate-picture">
|
||||
{pic ? t('signage.calibrate.picture', { w: Math.round(pic.width), h: Math.round(pic.height), shape: shapeName(pic.width, pic.height) }) : ''}
|
||||
</p>
|
||||
<p className="text-caption text-ink-3 max-w-md">{t('signage.calibrate.edgesHint')}</p>
|
||||
{EDGES.some(e => area[e] > 0) && <p className="text-caption text-ink-3">{t('signage.calibrate.outside')}</p>}
|
||||
{EDGES.some(e => area[e] < 0) && <p className="text-caption text-warning-ink" data-testid="signage-calibrate-past">{t('signage.calibrate.past')}</p>}
|
||||
</div>
|
||||
</Dialog>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
// A widget's "Text and colours" (owner review 5, 2026-11-21; owner 2026-11-23: everything about its
|
||||
// text and colours in one place): its text colour (text and pictures; empty = the slide's), a plate
|
||||
// behind it, its font, bold / italic / underline, text size and weight, a highlight behind the text,
|
||||
// its shadow (and the shadow's colour); a QR code's dots and background; a picture's (logo, gallery)
|
||||
// border. A menu, a stack and a shape have none (their own look / their main settings).
|
||||
import { useState } from 'react'
|
||||
import { Bold, ChevronDown, Italic, Palette, Underline } from 'lucide-react'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { ColourField, Dropdown, Field, FieldRow, Segmented, Slider } from '@xenia/ui'
|
||||
import { FONT_KEYS, FRAMED, lookKind, WIDGET_COLOURS } from './signageLogic'
|
||||
|
||||
// which widgets have text (their colour, font, style, size, weight, highlight)
|
||||
const TEXT_KINDS = ['name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'ticker', 'countdown', 'hours', 'wifi', 'contact', 'reviews', 'gallery']
|
||||
const WEIGHTS = [100, 200, 300, 400, 500, 600, 700, 800, 900]
|
||||
|
||||
export default function LookFields({ w, set }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const [open, setOpen] = useState(false)
|
||||
if (!lookKind(w.kind)) return null
|
||||
const text = TEXT_KINDS.includes(w.kind)
|
||||
const framed = FRAMED.includes(w.kind)
|
||||
const m = 'signage.more'
|
||||
const changed = !!(w.colour || w.background_colour || w.font || w.bold != null || w.italic || w.underline || (w.text_size && w.text_size !== 100) || w.qr_colour || w.qr_background
|
||||
|| w.weight || w.highlight || (w.shadow && w.shadow !== 'none') || (framed && (w.border_width || w.border_radius)))
|
||||
const styles = [w.bold !== false && 'bold', w.italic && 'italic', w.underline && 'underline'].filter(Boolean)
|
||||
return (
|
||||
<div className="grid gap-2" data-testid="signage-widget-look">
|
||||
<button type="button" onClick={() => setOpen(o => !o)} aria-expanded={open} data-testid="signage-widget-look-toggle"
|
||||
className="justify-self-start flex items-center gap-1.5 text-label font-medium text-ink-2 hover:text-ink">
|
||||
<Palette size={15} aria-hidden="true" />{t('signage.widgets.look')}
|
||||
{changed && <span className="w-1.5 h-1.5 rounded-full bg-accent" aria-hidden="true" />}
|
||||
<ChevronDown size={15} className={`transition-transform duration-fast ${open ? 'rotate-180' : ''}`} aria-hidden="true" />
|
||||
</button>
|
||||
{open && (
|
||||
<FieldRow className="-mx-3" min="10rem">
|
||||
{text && <ColourField label={t('signage.widgets.colour')} value={w.colour || WIDGET_COLOURS.text} onChange={colour => set({ colour })} testId="signage-widget-colour"
|
||||
auto={{ label: t('signage.widgets.asSlide'), on: !w.colour, pick: () => set({ colour: null }) }} />}
|
||||
<ColourField label={t('signage.widgets.plate')} value={w.background_colour || WIDGET_COLOURS.plate} onChange={background_colour => set({ background_colour })} testId="signage-widget-plate"
|
||||
auto={{ label: t('signage.widgets.noPlate'), on: !w.background_colour, pick: () => set({ background_colour: null }) }} />
|
||||
{text && <>
|
||||
<Field label={t('signage.font')}>
|
||||
<Dropdown value={w.font || ''} onChange={v => set({ font: v || null })} data-testid="signage-widget-font"
|
||||
options={[{ value: '', label: t('signage.widgets.asSlide') }, ...FONT_KEYS.map(x => ({ value: x, label: t(`signage.fonts.${x}`) }))]} />
|
||||
</Field>
|
||||
<Field label={t('signage.look.f.widget.style')}>
|
||||
<Segmented multiple fill value={styles} data-testid="signage-widget-style"
|
||||
onChange={list => set({ bold: list.includes('bold') ? null : false, italic: list.includes('italic'), underline: list.includes('underline') })}
|
||||
options={[['bold', Bold], ['italic', Italic], ['underline', Underline]].map(([v, Icon]) => (
|
||||
{ value: v, icon: <Icon size={16} aria-hidden="true" />, ariaLabel: t(`signage.look.${v}`), testId: `signage-widget-${v}` }))} />
|
||||
</Field>
|
||||
<Slider label={t('signage.widgets.textSize')} value={w.text_size || 100} min={50} max={200} step={10} suffix="%" onChange={text_size => set({ text_size })} testId="signage-widget-text-size" />
|
||||
<Field label={t(`${m}.weight`)}>
|
||||
<Dropdown value={w.weight || ''} onChange={v => set({ weight: v === '' ? null : Number(v) })} data-testid="signage-more-weight"
|
||||
options={[{ value: '', label: t(`${m}.usual`) }, ...WEIGHTS.map(n => ({ value: n, label: t(`${m}.weights.${n}`) }))]} />
|
||||
</Field>
|
||||
<ColourField label={t(`${m}.highlight`)} value={w.highlight || WIDGET_COLOURS.plate} onChange={highlight => set({ highlight })} testId="signage-more-highlight"
|
||||
auto={{ label: t(`${m}.noHighlight`), on: !w.highlight, pick: () => set({ highlight: null }) }} />
|
||||
</>}
|
||||
<ShadowFields w={w} set={set} />
|
||||
{(w.kind === 'qr' || w.kind === 'wifi') && <>
|
||||
<ColourField label={t('signage.widgets.qrColour')} value={w.qr_colour || WIDGET_COLOURS.qr} onChange={qr_colour => set({ qr_colour })} testId="signage-widget-qr-colour" opacity={false} />
|
||||
<ColourField label={t('signage.widgets.qrBackground')} value={w.qr_background || WIDGET_COLOURS.qrBackground} onChange={qr_background => set({ qr_background })} testId="signage-widget-qr-background" />
|
||||
</>}
|
||||
{framed && <BorderFields w={w} set={set} />}
|
||||
</FieldRow>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** A widget's shadow and its colour (here, or under More settings for a widget without Text and colours). */
|
||||
export function ShadowFields({ w, set }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const m = 'signage.more'
|
||||
return (<>
|
||||
<Field label={t(`${m}.shadow`)}>
|
||||
<Dropdown value={w.shadow || 'none'} onChange={shadow => set({ shadow })} data-testid="signage-more-shadow"
|
||||
options={['none', 'soft', 'strong', 'glow'].map(x => ({ value: x, label: t(`${m}.shadows.${x}`) }))} />
|
||||
</Field>
|
||||
{w.shadow && w.shadow !== 'none' && (
|
||||
<ColourField label={t(`${m}.shadowColour`)} value={w.shadow_colour || WIDGET_COLOURS.plate} onChange={shadow_colour => set({ shadow_colour })}
|
||||
auto={{ label: t(`${m}.usual`), on: !w.shadow_colour, pick: () => set({ shadow_colour: null }) }} />
|
||||
)}
|
||||
</>)
|
||||
}
|
||||
|
||||
/** A widget's border: its width, colour and rounded corners. */
|
||||
export function BorderFields({ w, set }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const m = 'signage.more'
|
||||
return (<>
|
||||
<Slider label={t(`${m}.border`)} value={w.border_width || 0} min={0} max={20} onChange={border_width => set({ border_width })} testId="signage-more-border" />
|
||||
{w.border_width > 0 && (
|
||||
<ColourField label={t(`${m}.borderColour`)} value={w.border_colour || WIDGET_COLOURS.text} onChange={border_colour => set({ border_colour })} />
|
||||
)}
|
||||
<Slider label={t(`${m}.radius`)} value={w.border_radius || 0} min={0} max={100} step={5} onChange={border_radius => set({ border_radius })} />
|
||||
</>)
|
||||
}
|
||||
@@ -2,27 +2,26 @@
|
||||
// for every widget its opacity, rotation (steps or any angle), shadow, border and an entrance
|
||||
// animation; a logo's fit; for texts the weight, a highlight behind them and typing themselves out;
|
||||
// date and clock formats; a logo in the middle of a QR code. The TV draws them (Slides.jsx `fx`,
|
||||
// `animate`, `dateText`).
|
||||
// `animate`, `dateText`). Owner 2026-11-23: the weight, highlight and shadow moved to "Text and
|
||||
// colours" (LookFields; the shadow stays here for a menu, a stack, a shape), a logo's / gallery's
|
||||
// border too, the date's and clock's formats to their main settings.
|
||||
import { useState } from 'react'
|
||||
import { ChevronDown, SlidersHorizontal } from 'lucide-react'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { ColourField, Dropdown, Field, FieldRow, Segmented, Slider, Switch } from '@xenia/ui'
|
||||
import { Dropdown, Field, FieldRow, Segmented, Slider, Switch } from '@xenia/ui'
|
||||
import { BorderFields, ShadowFields } from './LookFields'
|
||||
import { MediaPick } from './SignageFields'
|
||||
import { moreChanged, WIDGET_COLOURS } from './signageLogic'
|
||||
import { FRAMED, lookKind, moreChanged } from './signageLogic'
|
||||
|
||||
const TEXTS = ['name', 'date', 'clock', 'message', 'text', 'countdown', 'hours', 'wifi', 'contact', 'ticker', 'reviews', 'weather']
|
||||
const TYPED = ['name', 'message', 'text']
|
||||
const ANIMATIONS = ['none', 'fade', 'rise', 'drop', 'slide-left', 'slide-right', 'zoom', 'pop', 'pulse', 'float']
|
||||
const DELAYS = [0, 5, 10, 15, 20, 30, 50]
|
||||
const WEIGHTS = [100, 200, 300, 400, 500, 600, 700, 800, 900]
|
||||
const DATE_FORMATS = ['long', 'weekday_day_month', 'day_month', 'weekday', 'numeric', 'numeric_short', 'iso']
|
||||
|
||||
export default function MoreSettings({ w, set, media = {}, onMedia }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const [open, setOpen] = useState(false)
|
||||
const k = 'signage.more'
|
||||
const text = TEXTS.includes(w.kind)
|
||||
const numeric = ['numeric', 'numeric_short', 'iso'].includes(w.date_format)
|
||||
const look = lookKind(w.kind)
|
||||
return (
|
||||
<div className="grid gap-2" data-testid="signage-widget-more">
|
||||
<button type="button" onClick={() => setOpen(o => !o)} aria-expanded={open} data-testid="signage-widget-more-toggle"
|
||||
@@ -39,19 +38,8 @@ export default function MoreSettings({ w, set, media = {}, onMedia }) {
|
||||
options={[0, 90, 180, -90].map(r => ({ value: r, label: `${r}°` }))} data-testid="signage-more-rotation-steps" />
|
||||
</Field>
|
||||
<Slider label={t(`${k}.angle`)} value={w.rotation || 0} min={-180} max={180} step={1} suffix="°" onChange={rotation => set({ rotation })} testId="signage-more-rotation" />
|
||||
<Field label={t(`${k}.shadow`)}>
|
||||
<Dropdown value={w.shadow || 'none'} onChange={shadow => set({ shadow })} data-testid="signage-more-shadow"
|
||||
options={['none', 'soft', 'strong', 'glow'].map(x => ({ value: x, label: t(`${k}.shadows.${x}`) }))} />
|
||||
</Field>
|
||||
{w.shadow && w.shadow !== 'none' && (
|
||||
<ColourField label={t(`${k}.shadowColour`)} value={w.shadow_colour || WIDGET_COLOURS.plate} onChange={shadow_colour => set({ shadow_colour })}
|
||||
auto={{ label: t(`${k}.usual`), on: !w.shadow_colour, pick: () => set({ shadow_colour: null }) }} />
|
||||
)}
|
||||
<Slider label={t(`${k}.border`)} value={w.border_width || 0} min={0} max={20} onChange={border_width => set({ border_width })} testId="signage-more-border" />
|
||||
{w.border_width > 0 && (
|
||||
<ColourField label={t(`${k}.borderColour`)} value={w.border_colour || WIDGET_COLOURS.text} onChange={border_colour => set({ border_colour })} />
|
||||
)}
|
||||
<Slider label={t(`${k}.radius`)} value={w.border_radius || 0} min={0} max={100} step={5} onChange={border_radius => set({ border_radius })} />
|
||||
{!look && <ShadowFields w={w} set={set} />}
|
||||
{!FRAMED.includes(w.kind) && <BorderFields w={w} set={set} />}
|
||||
<Field label={t(`${k}.animation`)}>
|
||||
<Dropdown value={w.animation || 'none'} onChange={animation => set({ animation })} data-testid="signage-more-animation"
|
||||
options={ANIMATIONS.map(x => ({ value: x, label: t(`${k}.animations.${x}`) }))} />
|
||||
@@ -68,46 +56,17 @@ export default function MoreSettings({ w, set, media = {}, onMedia }) {
|
||||
options={['contain', 'cover', 'fill'].map(x => ({ value: x, label: t(`${k}.fits.${x}`) }))} />
|
||||
</Field>
|
||||
)}
|
||||
{text && (
|
||||
<Field label={t(`${k}.weight`)}>
|
||||
<Dropdown value={w.weight || ''} onChange={v => set({ weight: v === '' ? null : Number(v) })} data-testid="signage-more-weight"
|
||||
options={[{ value: '', label: t(`${k}.usual`) }, ...WEIGHTS.map(n => ({ value: n, label: t(`${k}.weights.${n}`) }))]} />
|
||||
</Field>
|
||||
)}
|
||||
{text && (
|
||||
<ColourField label={t(`${k}.highlight`)} value={w.highlight || WIDGET_COLOURS.plate} onChange={highlight => set({ highlight })} testId="signage-more-highlight"
|
||||
auto={{ label: t(`${k}.noHighlight`), on: !w.highlight, pick: () => set({ highlight: null }) }} />
|
||||
)}
|
||||
{TYPED.includes(w.kind) && (
|
||||
<Field label={t(`${k}.typing`)}>
|
||||
<Switch boxed className="h-control" checked={w.text_effect === 'typewriter'} onChange={on => set({ text_effect: on ? 'typewriter' : 'none' })}
|
||||
label={t(`${k}.typewriter`)} data-testid="signage-more-typewriter" />
|
||||
</Field>
|
||||
)}
|
||||
{w.kind === 'date' && (
|
||||
<Field label={t(`${k}.dateFormat`)}>
|
||||
<Dropdown value={w.date_format || (w.date_style === 'short' ? 'numeric' : 'long')} onChange={date_format => set({ date_format })} data-testid="signage-more-date-format"
|
||||
options={DATE_FORMATS.map(x => ({ value: x, label: t(`${k}.dateFormats.${x}`) }))} />
|
||||
</Field>
|
||||
)}
|
||||
{w.kind === 'date' && numeric && (
|
||||
<Field label={t(`${k}.separator`)}>
|
||||
<Segmented fill value={w.date_separator || (w.date_format === 'iso' ? '-' : '/')} onChange={date_separator => set({ date_separator })}
|
||||
options={['/', '.', '-', ' '].map(x => ({ value: x, label: x === ' ' ? t(`${k}.space`) : x }))} />
|
||||
</Field>
|
||||
)}
|
||||
{w.kind === 'clock' && <>
|
||||
<Field label={t(`${k}.clockFormat`)}>
|
||||
<Segmented fill value={w.clock_format || '24'} onChange={clock_format => set({ clock_format })} data-testid="signage-more-clock-format"
|
||||
options={['24', '12'].map(x => ({ value: x, label: t(`${k}.clockFormats.${x}`) }))} />
|
||||
</Field>
|
||||
<Field label={t(`${k}.separator`)}>
|
||||
<Segmented fill value={w.clock_separator || ':'} onChange={clock_separator => set({ clock_separator })} options={[':', '.'].map(x => ({ value: x, label: x }))} />
|
||||
</Field>
|
||||
{w.kind === 'clock' && (
|
||||
<Field label={t(`${k}.blink`)}>
|
||||
<Switch boxed className="h-control" checked={!!w.clock_blink} onChange={clock_blink => set({ clock_blink })} label={t(`${k}.blinkLabel`)} />
|
||||
</Field>
|
||||
</>}
|
||||
)}
|
||||
{w.kind === 'qr' && (
|
||||
<div className="col-span-full">
|
||||
<MediaPick kind="image" label={t(`${k}.qrLogo`)} value={w.media_id} entry={media[String(w.media_id)]} testid="signage-more-qr-logo"
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useEffect, useState } from 'react'
|
||||
import { ArrowLeft, ArrowRight, Film, Plus, X } from 'lucide-react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Button, ColourField, Dropdown, Field, IconButton, Input, Notice, NumberInput, Segmented, Slider, Switch } from '@xenia/ui'
|
||||
import { Button, ColourField, Dropdown, Field, IconButton, InfoTip, Input, Notice, NumberInput, Segmented, Slider, Switch } from '@xenia/ui'
|
||||
import { listFolders } from '../media/mediaApi'
|
||||
import MediaPicker from '../media/MediaPicker'
|
||||
import { useHours, useIdentity } from '../../shell/useIdentity'
|
||||
@@ -84,7 +84,7 @@ export function MoreInlineFields({ w, set }) {
|
||||
}
|
||||
if (w.kind === 'gallery') {
|
||||
return (<>
|
||||
<Field label={t(`${k}.gallery.source`)}>
|
||||
<Field label={t(`${k}.gallery.source`)} className="col-span-2">
|
||||
<Segmented fill value={w.gallery_source || 'pictures'} onChange={gallery_source => set({ gallery_source })} data-testid="signage-widget-gallery-source"
|
||||
options={['pictures', 'folder'].map(v => ({ value: v, label: t(`${k}.gallery.sources.${v}`) }))} />
|
||||
</Field>
|
||||
@@ -99,11 +99,19 @@ export function MoreInlineFields({ w, set }) {
|
||||
<Dropdown value={w.gallery_fit || 'cover'} onChange={gallery_fit => set({ gallery_fit })}
|
||||
options={[{ value: 'cover', label: t('signage.fits.cover') }, { value: 'contain', label: t('signage.fits.contain') }]} />
|
||||
</Field>
|
||||
{/* its title, above or below the pictures (owner 2026-11-23) */}
|
||||
<Field label={t(`${k}.gallery.title`)}>
|
||||
<Input value={w.text || ''} maxLength={120} placeholder={t(`${k}.gallery.titlePlaceholder`)} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-gallery-title" />
|
||||
</Field>
|
||||
<Field label={t(`${k}.gallery.titleAt`)}>
|
||||
<Segmented fill value={w.title_position || 'above'} onChange={title_position => set({ title_position })} data-testid="signage-widget-gallery-title-at"
|
||||
options={['above', 'below'].map(v => ({ value: v, label: t(`${k}.gallery.titleAts.${v}`) }))} />
|
||||
</Field>
|
||||
</>)
|
||||
}
|
||||
if (w.kind === 'reviews') {
|
||||
return (<>
|
||||
<Field label={t(`${k}.reviews.min`)}>
|
||||
<Field label={t(`${k}.reviews.min`)} className="col-span-2">
|
||||
<Segmented fill value={w.reviews_min || 4} onChange={reviews_min => set({ reviews_min })} data-testid="signage-widget-reviews-min"
|
||||
options={[1, 2, 3, 4, 5].map(n => ({ value: n, label: `${n}+` }))} />
|
||||
</Field>
|
||||
@@ -176,7 +184,7 @@ export function MoreBelowFields({ w, set, media = {}, onMedia }) {
|
||||
options={['full', 'hide'].map(v => ({ value: v, label: t(`${k}.countdown.waitingModes.${v}`) }))} />
|
||||
</Field>
|
||||
)}
|
||||
<Field label={t(`${k}.countdown.done`)} hint={t(`${k}.countdown.doneHint`)}>
|
||||
<Field label={t(`${k}.countdown.done`)} info={<InfoTip>{t(`${k}.countdown.doneHint`)}</InfoTip>}>
|
||||
<Input value={w.countdown_done || ''} maxLength={80} placeholder={t(`${k}.countdown.donePlaceholder`)} onChange={e => set({ countdown_done: e.target.value || null, countdown_done_hide: !e.target.value })} />
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
@@ -24,24 +24,32 @@
|
||||
// in layers: the card at the top is the widget drawn over the others, so a new widget goes on top
|
||||
// (last in the slide's list, first here); the arrows bring a widget forward / send it backward.
|
||||
// Up to the venue's limit (10 recommended; Signage → Message & settings → Performance).
|
||||
// Owner 2026-11-23: a card is its main settings (the row and what needs more room under it: a
|
||||
// picture, a gallery's pictures, the weather's details, a countdown's start and end…), then "Text
|
||||
// and colours" (LookFields: every text, colour, shadow and highlight setting), then More settings.
|
||||
// Alignment only where it lines something up: texts of several lines (Enter makes a new line in a
|
||||
// text or the message), the hours, contact details, Wi-Fi (its code left / right / above), the
|
||||
// weather laid out in rows, reviews, a countdown's title, a QR's caption, a gallery's title; inside
|
||||
// a stack's part it also places the widget in its part.
|
||||
import { Fragment, useEffect, useRef, useState } from 'react'
|
||||
import {
|
||||
AlignCenter, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowUp, Bold, Italic, Palette, RotateCcw, Underline, BookImage, CalendarDays, ChevronDown, Clock, CloudSun, Columns3, GripVertical,
|
||||
AlignCenter, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowUp, RotateCcw, BookImage, CalendarDays, ChevronDown, Clock, CloudSun, Columns3, GripVertical,
|
||||
ImageIcon, LayoutList, MessageSquare, Plus, QrCode, Rows3, Store, Trash2, Type, UtensilsCrossed,
|
||||
CalendarClock, Contact, GalleryHorizontal, MessageSquareQuote, MoveHorizontal, Shapes, Timer, Wifi,
|
||||
} from 'lucide-react'
|
||||
import { cellWidgets, evenShares, setShare } from '@xenia/signage'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Button, ColourField, Dialog, Dropdown, Field, FieldRow, IconButton, Input, Popover, Segmented, Slider, Switch } from '@xenia/ui'
|
||||
import { Button, Dialog, Dropdown, Field, IconButton, Input, Popover, Segmented, Switch, Textarea } from '@xenia/ui'
|
||||
import MessageOfTheDay from './MessageOfTheDay'
|
||||
import { usePerformance } from './usePerformance'
|
||||
import * as api from './signageApi'
|
||||
import LookFields from './LookFields'
|
||||
import MenuEditor from './MenuEditor'
|
||||
import MoreSettings from './MoreSettings'
|
||||
import { MoreBelowFields as MoreBelow, MoreInlineFields as MoreInline } from './MoreWidgetFields'
|
||||
import { MediaPick, Section } from './SignageFields'
|
||||
import {
|
||||
CELL_KINDS, cellWidget, WEATHER_DETAILS, WEATHER_LAYOUTS, fillPlace, FONT_KEYS, WIDGET_COLOURS, moved, newWidget, pickedAfterMove, presetWidget, WEATHER_CHOICES, weatherChoice, WIDGET_KINDS, WIDGET_POSITIONS,
|
||||
CELL_KINDS, cellWidget, WEATHER_DETAILS, WEATHER_LAYOUTS, fillPlace, moved, newWidget, pickedAfterMove, presetWidget, WEATHER_CHOICES, weatherChoice, WIDGET_KINDS, WIDGET_POSITIONS,
|
||||
} from './signageLogic'
|
||||
|
||||
const ICON = { logo: ImageIcon, name: Store, date: CalendarDays, clock: Clock, message: MessageSquare, text: Type, qr: QrCode, weather: CloudSun, menu: UtensilsCrossed, hstack: Columns3, vstack: Rows3,
|
||||
@@ -50,6 +58,23 @@ const MORE_KINDS = ['shape', 'ticker', 'countdown', 'hours', 'wifi', 'contact',
|
||||
const iconOf = w => (w.kind === 'stack' ? (w.direction === 'column' ? Rows3 : Columns3) : ICON[w.kind] || LayoutList)
|
||||
const kindLabel = (t, w) => t(`signage.widgets.kinds.${w.kind === 'stack' ? (w.direction === 'column' ? 'vstack' : 'hstack') : w.kind}`)
|
||||
const ROW = 'grid gap-4 items-end grid-cols-[repeat(auto-fill,minmax(11rem,1fr))]'
|
||||
const DATE_FORMATS = ['long', 'weekday_day_month', 'day_month', 'weekday', 'numeric', 'numeric_short', 'iso']
|
||||
|
||||
/**
|
||||
* Whether the alignment lines something up (owner 2026-11-23): a widget of several lines or parts;
|
||||
* one line (a name, date, clock), a picture, a scrolling text, a shape, a menu or a stack: no (each
|
||||
* is exactly as big as what it shows, or fills its place). In a stack's part it also places the
|
||||
* widget in its part, so there every widget but a stack, a menu, a scrolling text and a shape has it.
|
||||
*/
|
||||
function alignable(w, inPart = false) {
|
||||
if (['stack', 'menu', 'ticker', 'shape'].includes(w.kind)) return false
|
||||
if (inPart) return true
|
||||
if (['logo', 'name', 'date', 'clock'].includes(w.kind)) return false
|
||||
if (w.kind === 'weather') return (w.weather_layout || 'row') !== 'row'
|
||||
if (w.kind === 'gallery' || w.kind === 'countdown') return !!w.text
|
||||
if (w.kind === 'qr') return !!w.qr_caption
|
||||
return true
|
||||
}
|
||||
|
||||
let library = null // the Slides library (for stacks' parts), read once
|
||||
|
||||
@@ -135,13 +160,13 @@ export default function WidgetsEditor({ widgets = [], onChange, media, onMedia,
|
||||
options={[...['small', 'medium', 'large'].map(s => ({ value: s, label: t(`signage.widgets.sizes.${s}`) })),
|
||||
...(custom ? [{ value: 'custom', label: t('signage.widgets.custom') }] : [])]} />
|
||||
</Field>
|
||||
{w.kind !== 'stack' && <AlignField w={w} set={patch => set(i, patch)} />}
|
||||
{alignable(w) && <AlignField w={w} set={patch => set(i, patch)} />}
|
||||
<InlineFields w={w} set={patch => set(i, patch)} />
|
||||
</div>
|
||||
<LookFields w={w} set={patch => set(i, patch)} />
|
||||
<MoreSettings w={w} set={patch => set(i, patch)} media={media} onMedia={onMedia} />
|
||||
<BelowFields w={w} set={patch => set(i, patch)} media={media} onMedia={onMedia} extras={extras} path={String(i)} depth={0}
|
||||
selected={selected} onSelect={onSelect} />
|
||||
<LookFields w={w} set={patch => set(i, patch)} />
|
||||
<MoreSettings w={w} set={patch => set(i, patch)} media={media} onMedia={onMedia} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
@@ -179,64 +204,12 @@ function VerticalField({ w, set }) {
|
||||
)
|
||||
}
|
||||
|
||||
// which widgets have text (their colour, font, style and size), a QR code's own colours, a plate
|
||||
const TEXT_KINDS = ['name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'ticker', 'countdown', 'hours', 'wifi', 'contact', 'reviews']
|
||||
|
||||
/**
|
||||
* A widget's own look (owner review 5), folded under "Text and colours": its colour (text and
|
||||
* pictures; empty = the slide's), a plate behind it, its font, bold / italic / underline and text
|
||||
* size; a QR code's dots and background. A logo has only the plate; a menu has its own look.
|
||||
*/
|
||||
function LookFields({ w, set }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const [open, setOpen] = useState(false)
|
||||
if (w.kind === 'menu' || w.kind === 'stack' || w.kind === 'shape') return null
|
||||
const text = TEXT_KINDS.includes(w.kind)
|
||||
const changed = !!(w.colour || w.background_colour || w.font || w.bold != null || w.italic || w.underline || (w.text_size && w.text_size !== 100) || w.qr_colour || w.qr_background)
|
||||
const styles = [w.bold !== false && 'bold', w.italic && 'italic', w.underline && 'underline'].filter(Boolean)
|
||||
return (
|
||||
<div className="grid gap-2" data-testid="signage-widget-look">
|
||||
<button type="button" onClick={() => setOpen(o => !o)} aria-expanded={open} data-testid="signage-widget-look-toggle"
|
||||
className="justify-self-start flex items-center gap-1.5 text-label font-medium text-ink-2 hover:text-ink">
|
||||
<Palette size={15} aria-hidden="true" />{t(text ? 'signage.widgets.look' : 'signage.widgets.plateOnly')}
|
||||
{changed && <span className="w-1.5 h-1.5 rounded-full bg-accent" aria-hidden="true" />}
|
||||
<ChevronDown size={15} className={`transition-transform duration-fast ${open ? 'rotate-180' : ''}`} aria-hidden="true" />
|
||||
</button>
|
||||
{open && (
|
||||
<FieldRow className="-mx-3" min="10rem">
|
||||
{text && <ColourField label={t('signage.widgets.colour')} value={w.colour || WIDGET_COLOURS.text} onChange={colour => set({ colour })} testId="signage-widget-colour"
|
||||
auto={{ label: t('signage.widgets.asSlide'), on: !w.colour, pick: () => set({ colour: null }) }} />}
|
||||
<ColourField label={t('signage.widgets.plate')} value={w.background_colour || WIDGET_COLOURS.plate} onChange={background_colour => set({ background_colour })} testId="signage-widget-plate"
|
||||
auto={{ label: t('signage.widgets.noPlate'), on: !w.background_colour, pick: () => set({ background_colour: null }) }} />
|
||||
{text && <>
|
||||
<Field label={t('signage.font')}>
|
||||
<Dropdown value={w.font || ''} onChange={v => set({ font: v || null })} data-testid="signage-widget-font"
|
||||
options={[{ value: '', label: t('signage.widgets.asSlide') }, ...FONT_KEYS.map(x => ({ value: x, label: t(`signage.fonts.${x}`) }))]} />
|
||||
</Field>
|
||||
<Field label={t('signage.look.f.widget.style')}>
|
||||
<Segmented multiple fill value={styles} data-testid="signage-widget-style"
|
||||
onChange={list => set({ bold: list.includes('bold') ? null : false, italic: list.includes('italic'), underline: list.includes('underline') })}
|
||||
options={[['bold', Bold], ['italic', Italic], ['underline', Underline]].map(([v, Icon]) => (
|
||||
{ value: v, icon: <Icon size={16} aria-hidden="true" />, ariaLabel: t(`signage.look.${v}`), testId: `signage-widget-${v}` }))} />
|
||||
</Field>
|
||||
<Slider label={t('signage.widgets.textSize')} value={w.text_size || 100} min={50} max={200} step={10} suffix="%" onChange={text_size => set({ text_size })} testId="signage-widget-text-size" />
|
||||
</>}
|
||||
{(w.kind === 'qr' || w.kind === 'wifi') && <>
|
||||
<ColourField label={t('signage.widgets.qrColour')} value={w.qr_colour || WIDGET_COLOURS.qr} onChange={qr_colour => set({ qr_colour })} testId="signage-widget-qr-colour" opacity={false} />
|
||||
<ColourField label={t('signage.widgets.qrBackground')} value={w.qr_background || WIDGET_COLOURS.qrBackground} onChange={qr_background => set({ qr_background })} testId="signage-widget-qr-background" />
|
||||
</>}
|
||||
</FieldRow>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** The message of the day's hint, and the message itself changed right here (owner review 5). */
|
||||
function MessageHint() {
|
||||
const { t } = useTranslation('manager')
|
||||
const [open, setOpen] = useState(false)
|
||||
return (
|
||||
<div className="flex flex-wrap items-center gap-2 -mt-2">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<p className="text-caption text-ink-3 flex-1 min-w-[12rem]">{t('signage.widgets.ownTextHint')}</p>
|
||||
<Button size="sm" variant="secondary" onClick={() => setOpen(true)} data-testid="signage-widget-message-open">{t('signage.widgets.changeMessage')}</Button>
|
||||
{open && (
|
||||
@@ -252,35 +225,36 @@ function MessageHint() {
|
||||
/** The options only some widgets have, on the same row as where / size / alignment. */
|
||||
function InlineFields({ w, set }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const m = 'signage.more'
|
||||
if (MORE_KINDS.includes(w.kind)) return <MoreInline w={w} set={set} />
|
||||
if (w.kind === 'message') {
|
||||
return (
|
||||
<Field label={t('signage.widgets.ownText')} className="col-span-2">
|
||||
<Input value={w.text || ''} maxLength={200} placeholder={t('signage.widgets.ownTextPlaceholder')} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-text" />
|
||||
</Field>
|
||||
)
|
||||
}
|
||||
if (w.kind === 'text') {
|
||||
return (
|
||||
<Field label={t('signage.widgets.theText')} className="col-span-2">
|
||||
<Input value={w.text || ''} maxLength={200} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-own-text" />
|
||||
</Field>
|
||||
)
|
||||
}
|
||||
if (w.kind === 'date') {
|
||||
return (
|
||||
<Field label={t('signage.widgets.dateStyle')}>
|
||||
<Dropdown value={w.date_style || 'long'} onChange={date_style => set({ date_style })}
|
||||
options={[{ value: 'long', label: t('signage.widgets.dateLong') }, { value: 'short', label: t('signage.widgets.dateShort') }]} />
|
||||
const format = w.date_format || (w.date_style === 'short' ? 'numeric' : 'long')
|
||||
return (<>
|
||||
<Field label={t(`${m}.dateFormat`)} className="col-span-2">
|
||||
<Dropdown value={format} onChange={date_format => set({ date_format })} data-testid="signage-more-date-format"
|
||||
options={DATE_FORMATS.map(x => ({ value: x, label: t(`${m}.dateFormats.${x}`) }))} />
|
||||
</Field>
|
||||
)
|
||||
{['numeric', 'numeric_short', 'iso'].includes(format) && (
|
||||
<Field label={t(`${m}.separator`)}>
|
||||
<Segmented fill value={w.date_separator || (format === 'iso' ? '-' : '/')} onChange={date_separator => set({ date_separator })}
|
||||
options={['/', '.', '-', ' '].map(x => ({ value: x, label: x === ' ' ? t(`${m}.space`) : x }))} />
|
||||
</Field>
|
||||
)}
|
||||
</>)
|
||||
}
|
||||
if (w.kind === 'clock') {
|
||||
return (
|
||||
return (<>
|
||||
<Field label={t(`${m}.clockFormat`)}>
|
||||
<Segmented fill value={w.clock_format || '24'} onChange={clock_format => set({ clock_format })} data-testid="signage-more-clock-format"
|
||||
options={['24', '12'].map(x => ({ value: x, label: t(`${m}.clockFormats.${x}`) }))} />
|
||||
</Field>
|
||||
<Field label={t(`${m}.separator`)}>
|
||||
<Segmented fill value={w.clock_separator || ':'} onChange={clock_separator => set({ clock_separator })} options={[':', '.'].map(x => ({ value: x, label: x }))} />
|
||||
</Field>
|
||||
<Field label={t('signage.widgets.clockShows')}>
|
||||
<Switch boxed className="h-control" checked={!!w.clock_seconds} onChange={on => set({ clock_seconds: on })} label={t('signage.widgets.seconds')} data-testid="signage-widget-seconds" />
|
||||
</Field>
|
||||
)
|
||||
</>)
|
||||
}
|
||||
if (w.kind === 'qr') {
|
||||
return (
|
||||
@@ -323,7 +297,23 @@ function BelowFields({ w, set, media, onMedia, extras, path, depth, selected, on
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (w.kind === 'message') return <MessageHint />
|
||||
if (w.kind === 'message') {
|
||||
return (
|
||||
<div className="grid gap-3">
|
||||
<Field label={t('signage.widgets.ownText')} hint={t('signage.widgets.enterHint')}>
|
||||
<Textarea rows={2} value={w.text || ''} maxLength={500} placeholder={t('signage.widgets.ownTextPlaceholder')} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-text" />
|
||||
</Field>
|
||||
<MessageHint />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (w.kind === 'text') {
|
||||
return (
|
||||
<Field label={t('signage.widgets.theText')} hint={t('signage.widgets.enterHint')}>
|
||||
<Textarea rows={2} value={w.text || ''} maxLength={500} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-own-text" />
|
||||
</Field>
|
||||
)
|
||||
}
|
||||
if (w.kind === 'weather') {
|
||||
return (
|
||||
<div className="grid gap-3">
|
||||
@@ -488,14 +478,14 @@ function StackFields({ w, set, media, onMedia, extras, path, depth, selected, on
|
||||
? <Button variant="secondary" icon={<RotateCcw size={14} />} onClick={() => setW(fillPlace(x))} data-testid="signage-cell-fill">{t('signage.widgets.backInPlace')}</Button>
|
||||
: <span className="h-control flex items-center text-label text-ink-2" data-testid="signage-cell-place">{t('signage.widgets.fillsPlace')}</span>}
|
||||
</Field>
|
||||
<AlignField w={x} set={setW} testid="signage-cell-align" />
|
||||
{alignable(x, true) && <AlignField w={x} set={setW} testid="signage-cell-align" />}
|
||||
<VerticalField w={x} set={setW} />
|
||||
<InlineFields w={x} set={setW} />
|
||||
</div>
|
||||
)}
|
||||
<BelowFields w={x} set={setW} media={media} onMedia={onMedia} extras={extras} path={wp} depth={depth + 1} selected={selected} onSelect={onSelect} />
|
||||
<LookFields w={x} set={setW} />
|
||||
<MoreSettings w={x} set={setW} media={media} onMedia={onMedia} />
|
||||
<BelowFields w={x} set={setW} media={media} onMedia={onMedia} extras={extras} path={wp} depth={depth + 1} selected={selected} onSelect={onSelect} />
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
|
||||
@@ -417,8 +417,16 @@ export const LETTER_SPACINGS = [-0.05, -0.02, 0.02, 0.05, 0.1, 0.15, 0.2, 0.3]
|
||||
// a widget's "More settings" (6R.17)
|
||||
/** Has any of these been changed from the usual? (the dot on the toggle) */
|
||||
export function moreChanged(w) {
|
||||
return !!((w.opacity ?? 100) < 100 || w.rotation || (w.shadow && w.shadow !== 'none') || w.border_width || w.border_radius
|
||||
|| (w.animation && w.animation !== 'none') || w.weight || w.highlight || (w.text_effect && w.text_effect !== 'none')
|
||||
|| w.date_format || w.date_separator || w.clock_format === '12' || (w.clock_separator && w.clock_separator !== ':') || w.clock_blink
|
||||
// owner 2026-11-23: text, colours, shadow and highlight are under "Text and colours" (a picture's
|
||||
// border too), the date's and clock's formats among their main settings
|
||||
const look = lookKind(w.kind)
|
||||
return !!((w.opacity ?? 100) < 100 || w.rotation || (!look && w.shadow && w.shadow !== 'none')
|
||||
|| (!FRAMED.includes(w.kind) && (w.border_width || w.border_radius))
|
||||
|| (w.animation && w.animation !== 'none') || (w.text_effect && w.text_effect !== 'none') || w.clock_blink
|
||||
|| (w.kind === 'qr' && w.media_id) || (w.fit && w.fit !== 'contain'))
|
||||
}
|
||||
|
||||
/** The widgets with "Text and colours" (all but a menu, a stack and a shape: those have their own look). */
|
||||
export const lookKind = kind => !['menu', 'stack', 'shape'].includes(kind)
|
||||
/** The pictures whose border is under "Text and colours" (owner 2026-11-23). */
|
||||
export const FRAMED = ['logo', 'gallery']
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Camera, Trash2 } from 'lucide-react'
|
||||
import { useAccess } from '@xenia/access'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { LANGUAGE_NAMES, useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, Field, Input, Select, Textarea } from '@xenia/ui'
|
||||
import { Button, Dialog, Field, InfoTip, Input, Select, Textarea } from '@xenia/ui'
|
||||
import client from '../../api/client'
|
||||
import { Avatar } from '../overview/parts'
|
||||
import { ROLES, displayName, staffBody, staffForm, staffProblems } from './staffLogic'
|
||||
@@ -67,7 +67,7 @@ export default function StaffDialog({ member, onClose, onSaved }) {
|
||||
<Field label={t('staff.username')} required hint={t('staff.usernameHint')} error={err('username')}>
|
||||
<Input value={form.username} autoCapitalize="none" onChange={e => set('username', e.target.value)} data-testid="staff-username" />
|
||||
</Field>
|
||||
<Field label={t('staff.role')} hint={isNew ? t('staff.roleHintNew') : t('staff.roleHintEdit')}>
|
||||
<Field label={t('staff.role')} info={<InfoTip>{t('staff.roleTip')}</InfoTip>} hint={isNew ? t('staff.roleHintNew') : t('staff.roleHintEdit')}>
|
||||
<Select value={form.role} onChange={e => set('role', e.target.value)} data-testid="staff-role"
|
||||
options={roles.map(r => ({ value: r, label: t(`roles.${r}`) }))} />
|
||||
</Field>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// The staff page as plain data (plan step 6.11), tested in tests/staff.test.mjs.
|
||||
import { parseNumber } from '@xenia/i18n/number'
|
||||
|
||||
/** The roles in the order the page lists them (backend roles.py); names are i18n `roles.*`. */
|
||||
export const ROLES = ['owner', 'store_manager', 'staff_manager', 'chef', 'assistant_chef', 'barista', 'barman', 'waiter', 'assistant_waiter', 'custom']
|
||||
@@ -58,8 +59,9 @@ export function staffProblems(form, isNew) {
|
||||
if (!form.full_name.trim()) out.push('full_name')
|
||||
if (!form.nickname.trim()) out.push('nickname')
|
||||
if (!/^[^\s]{2,}$/.test(form.username.trim())) out.push('username')
|
||||
const rate = String(form.hourly_rate).trim().replace(',', '.')
|
||||
if (rate && !(Number(rate) >= 0)) out.push('hourly_rate')
|
||||
const rate = String(form.hourly_rate ?? '').trim()
|
||||
const rateValue = rate ? parseNumber(rate) : null
|
||||
if (rate && !(rateValue != null && rateValue >= 0)) out.push('hourly_rate')
|
||||
if (isNew && !validPin(form.pin)) out.push('pin')
|
||||
if (isNew && form.password && !validPassword(form.password)) out.push('password')
|
||||
return out
|
||||
@@ -68,11 +70,11 @@ export function staffProblems(form, isNew) {
|
||||
/** POST /api/waiters/ (new) or PUT /api/waiters/{id} (edit). */
|
||||
export function staffBody(form, isNew) {
|
||||
const text = v => (v ?? '').trim() || null
|
||||
const rate = String(form.hourly_rate).trim().replace(',', '.')
|
||||
const rate = String(form.hourly_rate ?? '').trim()
|
||||
const body = {
|
||||
full_name: form.full_name.trim(), nickname: form.nickname.trim(), username: form.username.trim(), role: form.role,
|
||||
mobile_phone: text(form.mobile_phone), email: text(form.email), note: text(form.note),
|
||||
hourly_rate: rate ? Number(rate) : null, language: form.language || '',
|
||||
hourly_rate: rate ? parseNumber(rate, { decimals: 2 }) : null, language: form.language || '',
|
||||
}
|
||||
if (isNew) {
|
||||
body.pin = form.pin
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// converts those routers.
|
||||
// anyPerm instead of perm: any one of these keys is enough (the media library)
|
||||
// label a key in the i18n `manager` namespace
|
||||
import { Activity, AppWindow, BadgeCheck, BarChart2, BookUser, Boxes, CalendarDays, ConciergeBell, CookingPot, CreditCard, FileText, Images, LayoutDashboard, LayoutGrid, LogIn, MonitorSmartphone, Package, PartyPopper, Percent, Plug, Printer, Receipt, Settings, ShieldCheck, ShoppingBag, ShoppingCart, StickyNote, TableProperties, Tag, Trash2, TrendingUp, Tv, UserCog, Users, Users2 } from 'lucide-react'
|
||||
import { Activity, AppWindow, ArrowRightLeft, BadgeCheck, BarChart2, BookUser, Boxes, CalendarDays, ConciergeBell, CookingPot, CreditCard, FileText, Images, LayoutDashboard, LayoutGrid, LogIn, MonitorSmartphone, Package, PartyPopper, Percent, Plug, Printer, Receipt, Settings, ShieldCheck, ShoppingBag, ShoppingCart, StickyNote, TableProperties, Tag, Trash2, TrendingUp, Tv, UserCog, Users, Users2 } from 'lucide-react'
|
||||
|
||||
const DASH = 'core.dashboard.access'
|
||||
// The media library: whoever manages something that shows pictures (routers/media.py MANAGE)
|
||||
@@ -90,6 +90,7 @@ export const NAV = [
|
||||
{ to: '/reports/expenses', icon: FileText, label: 'nav.reportsExpenses', module: 'reports', perm: 'reports.view' },
|
||||
{ to: '/reports/technical', icon: Printer, label: 'nav.reportsTechnical', module: 'reports', perm: 'reports.view' },
|
||||
{ to: '/reports/misc', icon: Tag, label: 'nav.reportsMisc', module: 'reports', perm: 'reports.view' },
|
||||
{ to: '/reports/moves', icon: ArrowRightLeft, label: 'nav.reportsMoves', module: 'reports', perm: 'reports.view' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -140,3 +140,11 @@ test('a category dropped above or below a row lands where the line showed (2026-
|
||||
assert.equal(moveIdTo([1, 2, 3], 1, 2, false), null) // already there
|
||||
assert.equal(moveIdTo([1, 2, 3], 2, 2, true), null)
|
||||
})
|
||||
|
||||
test('"One more" travels with the product, off unless set (6F.5)', () => {
|
||||
assert.equal(buildForm({ name: 'Beer', base_price: 4 }).one_more_enabled, false)
|
||||
const f = buildForm({ name: 'Beer', base_price: 4, one_more_enabled: true })
|
||||
assert.equal(f.one_more_enabled, true)
|
||||
assert.equal(buildBody(f).one_more_enabled, true)
|
||||
assert.equal(buildBody({ ...f, one_more_enabled: false }).one_more_enabled, false)
|
||||
})
|
||||
|
||||
@@ -123,7 +123,11 @@ test('owner review 6: a box off the slide (a strip stays), a tight box scaled ke
|
||||
test("a widget's More settings: changed or as usual (6R.17)", () => {
|
||||
assert.equal(moreChanged({ kind: 'clock' }), false)
|
||||
assert.equal(moreChanged({ kind: 'clock', opacity: 100, shadow: 'none', animation: 'none', clock_separator: ':' }), false)
|
||||
assert.equal(moreChanged({ kind: 'clock', clock_format: '12' }), true)
|
||||
assert.equal(moreChanged({ kind: 'clock', clock_format: '12' }), false) // a main setting since 2026-11-23
|
||||
assert.equal(moreChanged({ kind: 'clock', shadow: 'soft', weight: 300, highlight: '#ff0000' }), false) // under Text and colours
|
||||
assert.equal(moreChanged({ kind: 'shape', shadow: 'soft' }), true) // a shape has no Text and colours
|
||||
assert.equal(moreChanged({ kind: 'gallery', border_width: 4 }), false) // a picture's border: Text and colours
|
||||
assert.equal(moreChanged({ kind: 'clock', border_width: 4 }), true)
|
||||
assert.equal(moreChanged({ kind: 'date', rotation: -15 }), true)
|
||||
assert.equal(moreChanged({ kind: 'qr', media_id: 4 }), true)
|
||||
assert.equal(moreChanged({ kind: 'logo', media_id: 4 }), false)
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
"_comment": "Plan step 6.1 → 6.14b: what is on the v2 rules. `paths` is all of `src` (6.14b): tests/v2-guards.test.mjs refuses Greek and colour literals anywhere in it (colour data files: the guard's DATA list). `strict`: also no setState in effects (data loads with useLiveQuery / react-query); a few older files still load in an effect and are left out.",
|
||||
"paths": ["src"],
|
||||
"strict": [
|
||||
"src/App.jsx", "src/hooks", "src/live", "src/pages/Settings/SettingsPage.jsx", "src/pages/Settings/sections/DataTransfer.jsx", "src/pages/Settings/sections/DevelopmentSettings.jsx", "src/pages/Settings/sections/FiscalSettings.jsx", "src/pages/Settings/sections/OperationSettings.jsx", "src/pages/Settings/sections/QuickMessages.jsx", "src/pages/Settings/sections/SecuritySettings.jsx", "src/pages/Settings/sections/SystemSettings.jsx", "src/pages/Settings/sections/TableColours.jsx", "src/pages/Settings/sections/TableFlags.jsx", "src/pages/customers", "src/pages/finance", "src/pages/floor", "src/pages/inventory", "src/pages/notes", "src/pages/online/OnlineOrdersPage.jsx", "src/pages/orders", "src/pages/overview", "src/pages/pricing", "src/pages/printing", "src/pages/products", "src/pages/reports/expenses", "src/pages/reports/kit", "src/pages/reports/misc", "src/pages/reports/prepzones", "src/pages/reports/products", "src/pages/reports/staff", "src/pages/reports/store", "src/pages/reports/technical", "src/pages/reports/today", "src/pages/schedule", "src/pages/setup", "src/pages/staff", "src/pages/staff/SessionsPage.jsx", "src/pages/tables", "src/shell"
|
||||
"src/App.jsx", "src/hooks", "src/live", "src/pages/Settings/SettingsPage.jsx", "src/pages/Settings/sections/DataTransfer.jsx", "src/pages/Settings/sections/DevelopmentSettings.jsx", "src/pages/Settings/sections/FiscalSettings.jsx", "src/pages/Settings/sections/OperationSettings.jsx", "src/pages/Settings/sections/QuickMessages.jsx", "src/pages/Settings/sections/SecuritySettings.jsx", "src/pages/Settings/sections/SystemSettings.jsx", "src/pages/Settings/sections/TableColours.jsx", "src/pages/Settings/sections/TableFlags.jsx", "src/pages/customers", "src/pages/finance", "src/pages/floor", "src/pages/inventory", "src/pages/notes", "src/pages/online/OnlineOrdersPage.jsx", "src/pages/orders", "src/pages/overview", "src/pages/pricing", "src/pages/printing", "src/pages/products", "src/pages/reports/expenses", "src/pages/reports/kit", "src/pages/reports/misc", "src/pages/reports/moves", "src/pages/reports/prepzones", "src/pages/reports/products", "src/pages/reports/staff", "src/pages/reports/store", "src/pages/reports/technical", "src/pages/reports/today", "src/pages/schedule", "src/pages/setup", "src/pages/staff", "src/pages/staff/SessionsPage.jsx", "src/pages/tables", "src/shell"
|
||||
]
|
||||
}
|
||||
|
||||
Generated
+1
@@ -9729,6 +9729,7 @@
|
||||
"name": "@xenia/ui",
|
||||
"version": "0.0.0",
|
||||
"peerDependencies": {
|
||||
"@xenia/i18n": "*",
|
||||
"qrcode.react": "^4.2.0",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Order lines: what POST /api/orders/{id}/items and POST /api/orders/quote take (plan step 4.4).
|
||||
//
|
||||
// An app never sends a price. A line says what was chosen, by id (sub-choices by name):
|
||||
// { product_id, quantity, notes?, course_id?, price_adjustment?, is_service_item?,
|
||||
// { product_id, quantity, notes?, course_id?, price_adjustment?, price_reason?, is_service_item?,
|
||||
// quick: [{id, qty?}], options: [{id, qty?, subs: [name]}],
|
||||
// prefs: [{set_id, choices: [{id, qty?, sub?}], shared?}], removed: [ingredient_id] }
|
||||
// and the server prices it (local_backend/services/pos_cart.py; the counter POS builds the
|
||||
@@ -108,6 +108,7 @@ export function wireLine(item, product) {
|
||||
if (item.notes?.trim()) line.notes = item.notes.trim()
|
||||
if (item.course_id != null) line.course_id = item.course_id
|
||||
if (item.price_adjustment) line.price_adjustment = cents(item.price_adjustment)
|
||||
if (item.price_adjustment && item.price_reason) line.price_reason = String(item.price_reason).slice(0, 200) // 6F.3
|
||||
if (item.is_service_item) line.is_service_item = true
|
||||
return line
|
||||
}
|
||||
|
||||
@@ -64,6 +64,12 @@ test('a price changed by hand and a service item travel with the line; nothing e
|
||||
assert.deepEqual(line, { product_id: 1, quantity: 1, price_adjustment: -1, is_service_item: true })
|
||||
})
|
||||
|
||||
test('the reason for a price changed by hand travels with it, never alone (6F.3)', () => {
|
||||
assert.deepEqual(wireLine({ product_id: 1, quantity: 1, price_adjustment: -0.5, price_reason: 'Regular customer' }, burger),
|
||||
{ product_id: 1, quantity: 1, price_adjustment: -0.5, price_reason: 'Regular customer' })
|
||||
assert.deepEqual(wireLine({ product_id: 1, quantity: 1, price_reason: 'nothing changed' }, burger), { product_id: 1, quantity: 1 })
|
||||
})
|
||||
|
||||
test('what is not on the menu any more is refused, not dropped', () => {
|
||||
assert.throws(() => lineFromOptions(burger, { selected_options: [e('extra', 99, 'Truffle')] }), LineError)
|
||||
assert.throws(() => lineFromOptions(burger, { selected_options: [e('quick', null, 'Bacon')] }), LineError)
|
||||
|
||||
@@ -102,7 +102,16 @@
|
||||
"discounts_off": "Οι εκπτώσεις είναι απενεργοποιημένες σε αυτό το κατάστημα.",
|
||||
"no_customer": "Ορίστε πρώτα πελάτη στην παραγγελία.",
|
||||
"item_not_tabbable": "Αυτό το είδος είναι ήδη {{status}}: δεν μπαίνει σε καρτέλα.",
|
||||
"product_unavailable": "Το προϊόν {{product_id}} δεν είναι διαθέσιμο."
|
||||
"product_unavailable": "Το προϊόν {{product_id}} δεν είναι διαθέσιμο.",
|
||||
"price_change_off": "Η αλλαγή τιμής με το χέρι είναι κλειστή σε αυτό το κατάστημα.",
|
||||
"price_change_sent_off": "Οι τιμές αλλάζουν μόνο πριν σταλούν τα είδη.",
|
||||
"price_reason_required": "Γράψτε γιατί αλλάζει η τιμή.",
|
||||
"one_more_off": "Το «Άλλο ένα» δεν είναι ενεργό για αυτό το προϊόν.",
|
||||
"one_more_line": "Αυτή η γραμμή δεν ξαναπαραγγέλνεται με ένα πάτημα.",
|
||||
"quantity_change_off": "Η αλλαγή ποσότητας είναι κλειστή σε αυτό το κατάστημα.",
|
||||
"quantity_remove_off": "Εδώ οι ποσότητες μόνο αυξάνονται.",
|
||||
"quantity_invalid": "Διαλέξτε ακέραιο από 1 έως {{max}}.",
|
||||
"quantity_line": "Η ποσότητα αυτής της γραμμής δεν αλλάζει εδώ."
|
||||
},
|
||||
"notification": {
|
||||
"not_found": "Η ειδοποίηση {{notification_id}} δεν βρέθηκε."
|
||||
|
||||
@@ -50,7 +50,8 @@
|
||||
"media": "Πολυμέσα",
|
||||
"signage": "Προβολή",
|
||||
"main": "Κύριο μενού",
|
||||
"scenes": "Σκηνές"
|
||||
"scenes": "Σκηνές",
|
||||
"reportsMoves": "Μεταφορές"
|
||||
},
|
||||
"profile": {
|
||||
"edit": "Επεξεργασία προφίλ",
|
||||
@@ -220,7 +221,8 @@
|
||||
"none": "Κανένα",
|
||||
"linkHint": "Για παράδειγμα μια οθόνη πελάτη που δείχνει την παραγγελία ενός ταμείου πάγκου.",
|
||||
"full": "{{label}}: η άδεια επιτρέπει {{max}} και χρησιμοποιούνται όλα. Αφαιρέστε μία ή ζητήστε μεγαλύτερη άδεια.",
|
||||
"noApps": "Καμία εφαρμογή συσκευών δεν είναι ενεργή. Ενεργοποιήστε μία πρώτα από τις Εφαρμογές."
|
||||
"noApps": "Καμία εφαρμογή συσκευών δεν είναι ενεργή. Ενεργοποιήστε μία πρώτα από τις Εφαρμογές.",
|
||||
"signInTip": "PIN ή κωδικός: ο καθένας συνδέεται. Πάτημα στο όνομα: ο καθένας αλλάζει χρήστη χωρίς μυστικό (κοινό ταμείο). Κανένας: η οθόνη δουλεύει χωρίς χρήστη (οθόνη κουζίνας)."
|
||||
},
|
||||
"actions": {
|
||||
"rename": "Μετονομασία",
|
||||
@@ -409,7 +411,11 @@
|
||||
"idleHint": "Ημέρες χωρίς χρήση της εφαρμογής (διαχείριση, εφαρμογή σερβιτόρων και συζευγμένες συσκευές). Την επόμενη φορά συνδέονται ξανά.",
|
||||
"idleDays_one": "{{count}} ημέρα χωρίς χρήση",
|
||||
"idleDays_other": "{{count}} ημέρες χωρίς χρήση",
|
||||
"idleNever": "Ποτέ"
|
||||
"idleNever": "Ποτέ",
|
||||
"waiterTip": "PIN: γρήγορο, λίγα ψηφία. Κωδικός: πιο ασφαλής, πιο αργός. Πάτημα στο όνομα: καθόλου μυστικό, γι' αυτό λειτουργεί μόνο σε συσκευές που συνδέσατε, ποτέ σε προσωπικά κινητά.",
|
||||
"requireUsernameTip": "Το κινητό δεν δείχνει πια τη λίστα του προσωπικού: όποιος πιάσει ένα κινητό δεν βλέπει ποιοι δουλεύουν εδώ ούτε δοκιμάζει το PIN συναδέλφου.",
|
||||
"deviceTip": "Πάτημα στο όνομα: ο καθένας αλλάζει χρήστη σε κοινή οθόνη χωρίς μυστικό (ένα πολυσύχναστο ταμείο). Κανένας: η οθόνη δουλεύει χωρίς χρήστη (μια οθόνη κουζίνας που βλέπουν όλοι).",
|
||||
"idleTip": "Μετράει σε μέρες, όχι λεπτά: ένα κινητό που έμεινε συνδεδεμένο εβδομάδες αποσυνδέεται. Για κλείδωμα του πίνακα μετά από λίγα λεπτά, δείτε «Όταν ο πίνακας δεν χρησιμοποιείται»."
|
||||
},
|
||||
"venue": {
|
||||
"title": "Κατάστημα",
|
||||
@@ -427,7 +433,9 @@
|
||||
"rose": "Ροζ",
|
||||
"identity": "Η ταυτότητα του καταστήματος (το πρώτο χρώμα της)"
|
||||
},
|
||||
"identityNoColour": "Η ταυτότητα του καταστήματος δεν έχει χρώματα ακόμη (Ρυθμίσεις → Ταυτότητα): τα κινητά μένουν πορτοκαλί και οι οθόνες κρατούν το δικό τους χρώμα μέχρι να αποκτήσει."
|
||||
"identityNoColour": "Η ταυτότητα του καταστήματος δεν έχει χρώματα ακόμη (Ρυθμίσεις → Ταυτότητα): τα κινητά μένουν πορτοκαλί και οι οθόνες κρατούν το δικό τους χρώμα μέχρι να αποκτήσει.",
|
||||
"languageTip": "Ο καθένας μπορεί να διαλέξει τη δική του γλώσσα στο προφίλ του. Τα δελτία κουζίνας τυπώνονται στη γλώσσα κάθε χώρου προετοιμασίας (Εκτύπωση → χώροι), αλλιώς σε αυτήν.",
|
||||
"timezoneTip": "Ορίζει σε ποια μέρα ανήκει μια πώληση και τις ώρες σε δελτία και αναφορές. Αλλάξτε τη μόνο αν το κατάστημα βρίσκεται πράγματι σε άλλη ζώνη ώρας."
|
||||
},
|
||||
"print": {
|
||||
"title": "Ειδοποιήσεις εκτύπωσης",
|
||||
@@ -439,7 +447,8 @@
|
||||
},
|
||||
"operation": {
|
||||
"closeUnpaid": "Κλείσιμο τραπεζιού με απλήρωτα",
|
||||
"closeUnpaidHint": "Ανενεργό: το κλείσιμο τραπεζιού με απλήρωτα ζητά πρώτα την πληρωμή και μετά το κλείνει. Ενεργό: κλείνει και τα απλήρωτα καταγράφονται ως απλήρωτα."
|
||||
"closeUnpaidHint": "Ανενεργό: το κλείσιμο τραπεζιού με απλήρωτα ζητά πρώτα την πληρωμή και μετά το κλείνει. Ενεργό: κλείνει και τα απλήρωτα καταγράφονται ως απλήρωτα.",
|
||||
"closeUnpaidTip": "Ό,τι κλείνει έτσι μένει στο ιστορικό της παραγγελίας ως απλήρωτο, δεν χάνεται τίποτα· απλώς δεν μετράει στις πωλήσεις."
|
||||
},
|
||||
"title": "Ρυθμίσεις",
|
||||
"save": "Αποθήκευση",
|
||||
@@ -507,7 +516,8 @@
|
||||
"waiters": "Σερβιτόροι (Wi-Fi)",
|
||||
"waitersHint": "Τα κινητά στο ίδιο Wi-Fi ανοίγουν αυτή, ή σαρώνουν το QR.",
|
||||
"qrCaption": "Σαρώστε με την κάμερα του κινητού: ανοίγει την εφαρμογή σερβιτόρου. Το κινητό πρέπει να είναι στο ίδιο Wi-Fi.",
|
||||
"manager": "Υπεύθυνοι (Wi-Fi)"
|
||||
"manager": "Υπεύθυνοι (Wi-Fi)",
|
||||
"addressTip": "Η διεύθυνση που χρησιμοποιούν κινητά και οθόνες για να βρουν αυτόν τον διακομιστή στο Wi-Fi του καταστήματος. Βρίσκεται μόνη της· γράψτε την μόνο αν η εμφανιζόμενη είναι λάθος (π.χ. υπολογιστής με δύο κάρτες δικτύου)."
|
||||
},
|
||||
"transfer": {
|
||||
"title": "Εξαγωγή και εισαγωγή",
|
||||
@@ -568,7 +578,8 @@
|
||||
"replaceYes": "Νέοι κωδικοί",
|
||||
"remake": "Νέοι κωδικοί",
|
||||
"make": "Δημιουργία κωδικών ανάκτησης",
|
||||
"recoveryHow": "Φυλάξτε τους σε ασφαλές μέρος. Στη σελίδα σύνδεσης: το όνομα χρήστη και ένας κωδικός αντί για τον κωδικό πρόσβασης."
|
||||
"recoveryHow": "Φυλάξτε τους σε ασφαλές μέρος. Στη σελίδα σύνδεσης: το όνομα χρήστη και ένας κωδικός αντί για τον κωδικό πρόσβασης.",
|
||||
"lockTip": "Το κλείδωμα κρατά τον υπεύθυνο συνδεδεμένο: η οθόνη ζητά PIN για να συνεχίσει. Καλό για πίνακα σε κοινόχρηστο υπολογιστή."
|
||||
},
|
||||
"ops": {
|
||||
"staffTitle": "Σερβιτόροι",
|
||||
@@ -607,7 +618,15 @@
|
||||
"syncNow": "Αποστολή τώρα",
|
||||
"syncNowHint": "Αντί να περιμένετε την επόμενη φορά.",
|
||||
"sync": "Αποστολή",
|
||||
"synced": "Το μενού στάλθηκε"
|
||||
"synced": "Το μενού στάλθηκε",
|
||||
"selfStartTip": "Ναι: οι σερβιτόροι ξεκινούν τη βάρδια από το κινητό τους και γράφουν τα μετρητά με τα οποία ξεκινούν. Όχι: δεν παίρνουν παραγγελίες μέχρι να ξεκινήσει τη βάρδια ένας υπεύθυνος από την Επισκόπηση.",
|
||||
"selfEndTip": "Ναι: οι σερβιτόροι κλείνουν τη βάρδια από το κινητό τους. Όχι: μόνο ένας υπεύθυνος την κλείνει, από την Επισκόπηση, όπου μετράει τα μετρητά που παραδίδουν: κάθε βάρδια κλείνει με καταμέτρηση.",
|
||||
"hideTakingsTip": "Οι σερβιτόροι βλέπουν κανονικά τραπέζια και παραγγελίες· κρύβονται μόνο τα χρήματα της βάρδιας (τι εισέπραξαν, τι πρέπει να παραδώσουν). Οι υπεύθυνοι τα βλέπουν πάντα.",
|
||||
"cardTip": "Μια πληρωμή με κάρτα καταγράφεται ως κάρτα, άρα δεν μετράει στα μετρητά που παραδίδει ο σερβιτόρος. Η χρέωση γίνεται κανονικά στο τερματικό της τράπεζας: το Xenia δεν επικοινωνεί μαζί του.",
|
||||
"autoCloseTip": "Ναι: το τραπέζι ελευθερώνεται για νέους πελάτες αμέσως μετά την τελευταία πληρωμή. Όχι: το κλείνει ο σερβιτόρος, χρήσιμο όταν οι πελάτες μένουν και ίσως παραγγείλουν ξανά.",
|
||||
"bypassKdsTip": "Για καταστήματα χωρίς οθόνες κουζίνας ή όπου κανείς δεν σημειώνει τα πιάτα ως σερβιρισμένα. Η εφαρμογή σερβιτόρων τότε δεν περιμένει «έτοιμο» ή «σερβιρίστηκε».",
|
||||
"coursesTip": "Κάθε γραμμή παίρνει ένα πιάτο σειράς και το χρώμα του φαίνεται στα δελτία και στις οθόνες κουζίνας, ώστε η κουζίνα να τα ετοιμάζει με τη σειρά. Ορίστε τα παρακάτω, με τη σειρά που σερβίρονται.",
|
||||
"quickNotesTip": "Η σημείωση τυπώνεται στο δελτίο κουζίνας κάτω από το είδος και φαίνεται στην οθόνη κουζίνας."
|
||||
},
|
||||
"flags": {
|
||||
"title": "Σημάνσεις τραπεζιών",
|
||||
@@ -712,7 +731,8 @@
|
||||
"vatName": "Όνομα",
|
||||
"vatNameHint": "π.χ. Φαγητό, Ποτά, Αλκοόλ",
|
||||
"removeVat": "Αφαίρεση ομάδας",
|
||||
"addVat": "Προσθήκη ομάδας"
|
||||
"addVat": "Προσθήκη ομάδας",
|
||||
"enabledTip": "Κάθε πληρωμή στέλνει τότε απόδειξη στον φορολογικό μηχανισμό. Κάθε προϊόν χρειάζεται ομάδα ΦΠΑ για να πληρωθεί (η επεξεργασία προϊόντος προειδοποιεί)."
|
||||
},
|
||||
"dev": {
|
||||
"warning": "Μόνο για δοκιμές. Μην τα αφήνετε ενεργά ενώ λειτουργεί το κατάστημα.",
|
||||
@@ -720,6 +740,37 @@
|
||||
"spoof": "Προσποιητή εκτύπωση",
|
||||
"spoofHint": "Κάθε εκτύπωση απορρίπτεται· οι εφαρμογές συμπεριφέρονται σαν να τυπώθηκε.",
|
||||
"spoofOn": "Ενεργό: οι εκτυπωτές δεν τυπώνουν τίποτα."
|
||||
},
|
||||
"prices": {
|
||||
"title": "Τιμές που αλλάζουν με το χέρι",
|
||||
"intro": "Πότε το προσωπικό γράφει δική του τιμή σε μια γραμμή και αν πρέπει να πει γιατί. Κάθε αλλαγή κρατιέται: ποιος, πότε, από πόσο σε πόσο, γιατί.",
|
||||
"when": "Το προσωπικό αλλάζει τιμή",
|
||||
"whenHint": "Ποιος: «Τι επιτρέπεται σε κάθε ρόλο» και τα δικαιώματα κάθε ατόμου.",
|
||||
"whenTip": "Ποτέ: κανείς δεν γράφει τιμή, ούτε οι ιδιοκτήτες. Πριν την αποστολή: μόνο στο καλάθι, πριν πάει η παραγγελία στην κουζίνα. Οποτεδήποτε: και σε γραμμή που έχει σταλεί ή σερβιριστεί (θέλει δικό του δικαίωμα, «ήδη σταλμένο ή σερβιρισμένο»).",
|
||||
"modes": {
|
||||
"off": "Ποτέ",
|
||||
"before_sending": "Μόνο πριν την αποστολή",
|
||||
"anytime": "Οποτεδήποτε"
|
||||
},
|
||||
"reason": "Να ζητείται αιτία",
|
||||
"reasonHint": "Μια τιμή που αλλάζει με το χέρι δεν αποθηκεύεται χωρίς αιτία.",
|
||||
"reasonTip": "Η αιτία κρατιέται με την αλλαγή και φαίνεται στο ιστορικό της παραγγελίας και στις Αναφορές → Ακυρώσεις, εκπτώσεις και αλλαγές τιμών. Οι εκπτώσεις % του ταμείου δεν ζητούν: η έκπτωση λέει τι είναι.",
|
||||
"reasons": "Γρήγορες αιτίες",
|
||||
"reasonsHint": "Με ένα πάτημα· το προσωπικό μπορεί και να γράψει δική του. Καμία: οι έτοιμες.",
|
||||
"reasonItem": "Γρήγορη αιτία",
|
||||
"newReason": "Νέα γρήγορη αιτία…"
|
||||
},
|
||||
"quantity": {
|
||||
"title": "Αλλαγή ποσότητας σταλμένης γραμμής",
|
||||
"intro": "Το προσωπικό διορθώνει πόσα είναι σε μια γραμμή χωρίς να ξαναστείλει στην κουζίνα. Κάθε αλλαγή κρατιέται στο ιστορικό της παραγγελίας.",
|
||||
"when": "Το προσωπικό μπορεί",
|
||||
"whenHint": "Ποιος: «Τι επιτρέπεται σε κάθε ρόλο» και τα δικαιώματα κάθε ατόμου.",
|
||||
"whenTip": "Μόνο προσθήκη: η ποσότητα μόνο ανεβαίνει (μια μπίρα από το ψυγείο), δεν τυπώνεται τίποτα. Προσθήκη και αφαίρεση: όταν κατεβαίνει, η διαφορά ακυρώνεται ως ξεχωριστή γραμμή και ρωτά αν θα σταλεί ακύρωση στην κουζίνα. Η αφαίρεση θέλει και το δικαίωμα ακύρωσης.",
|
||||
"modes": {
|
||||
"off": "Καθόλου",
|
||||
"add_only": "Μόνο προσθήκη",
|
||||
"add_and_remove": "Προσθήκη και αφαίρεση"
|
||||
}
|
||||
}
|
||||
},
|
||||
"logs": {
|
||||
@@ -1541,7 +1592,7 @@
|
||||
"dragHint": "Η λίστα είναι σε επίπεδα: το widget στην κορυφή σχεδιάζεται πάνω από τα από κάτω, και ένα νέο widget μπαίνει στην κορυφή. Διαλέξτε ένα widget στην προεπισκόπηση ή εδώ, σύρετέ το (ή με τα βέλη) για να το μετακινήσετε και από τις λαβές για να αλλάξετε το μέγεθος· η θέση και το μέγεθος γράφουν τότε «Προσαρμοσμένο».",
|
||||
"custom": "Προσαρμοσμένο",
|
||||
"align": "Στοίχιση",
|
||||
"alignAuto": "Αυτόματη",
|
||||
"alignAuto": "Auto",
|
||||
"dateStyle": "Μορφή",
|
||||
"canvas": "Τα widgets της διαφάνειας: σύρετε ένα για μετακίνηση, τις λαβές για μέγεθος, τα βέλη για μικρές κινήσεις",
|
||||
"earlier": "Πάνω (σχεδιάζεται κάτω από τα επόμενα)",
|
||||
@@ -1594,8 +1645,7 @@
|
||||
"backInPlace": "Πίσω σε στοίχιση",
|
||||
"vertical": "Κάθετη στοίχιση",
|
||||
"look": "Κείμενο και χρώματα",
|
||||
"plateOnly": "Φόντο πίσω του",
|
||||
"colour": "Χρώμα",
|
||||
"colour": "Χρώμα κειμένου",
|
||||
"asSlide": "Όπως η διαφάνεια",
|
||||
"plate": "Φόντο πίσω του",
|
||||
"noPlate": "Κανένα",
|
||||
@@ -1633,8 +1683,8 @@
|
||||
"text": "Το κείμενο",
|
||||
"direction": "Κινείται",
|
||||
"directions": {
|
||||
"left": "Προς τα αριστερά",
|
||||
"right": "Προς τα δεξιά"
|
||||
"left": "Αριστερά",
|
||||
"right": "Δεξιά"
|
||||
},
|
||||
"speed": "Ταχύτητα"
|
||||
},
|
||||
@@ -1717,7 +1767,14 @@
|
||||
"noFolders": "Δεν υπάρχουν φάκελοι πολυμέσων ακόμη.",
|
||||
"toMedia": "Φτιάξτε έναν στη σελίδα Πολυμέσα",
|
||||
"add": "Προσθήκη εικόνων ή βίντεο",
|
||||
"empty": "Η συλλογή είναι άδεια ακόμη: μένει κρυφή."
|
||||
"empty": "Η συλλογή είναι άδεια ακόμη: μένει κρυφή.",
|
||||
"title": "Τίτλος",
|
||||
"titlePlaceholder": "Κανένας",
|
||||
"titleAt": "Ο τίτλος μπαίνει",
|
||||
"titleAts": {
|
||||
"above": "Από πάνω",
|
||||
"below": "Από κάτω"
|
||||
}
|
||||
},
|
||||
"weatherLayout": "Διάταξη",
|
||||
"weatherLayouts": {
|
||||
@@ -1741,7 +1798,8 @@
|
||||
"weatherHours": "Ώρες",
|
||||
"weatherPlace": "Η τοποθεσία",
|
||||
"weatherPlaceLabel": "Δείχνει το όνομά της",
|
||||
"logoFromIdentity": "Χωρίς εικόνα: εμφανίζεται το λογότυπο του καταστήματος (Ρυθμίσεις → Ταυτότητα)."
|
||||
"logoFromIdentity": "Χωρίς εικόνα: εμφανίζεται το λογότυπο του καταστήματος (Ρυθμίσεις → Ταυτότητα).",
|
||||
"enterHint": "Με Enter αλλάζει γραμμή."
|
||||
},
|
||||
"tabs": {
|
||||
"playlists": "Λίστες",
|
||||
@@ -1986,21 +2044,25 @@
|
||||
"open": "Βαθμονόμηση εικόνας",
|
||||
"title": "Βαθμονόμηση εικόνας: {{name}}",
|
||||
"intro": "Η τηλεόραση δείχνει τώρα τις άκρες της εικόνας με τέσσερα βέλη προς τα έξω. Μετακινήστε κάθε άκρη μέχρι το βέλος της να ακουμπά την άκρη της οθόνης ή διαλέξτε σχήμα. Οι αλλαγές φαίνονται αμέσως στην τηλεόραση.",
|
||||
"window": "Το παράθυρο της τηλεόρασης: {{w}} × {{h}} px ({{shape}}).",
|
||||
"window": "{{w}} × {{h}} px ({{shape}})",
|
||||
"waiting": "Αναμονή για το μέγεθος της τηλεόρασης… Είναι ανοιχτή και δείχνει ψηφιακή σήμανση;",
|
||||
"presets": "Σχήματα",
|
||||
"full": "Όλη η οθόνη",
|
||||
"step": "Κάθε κλικ μετακινεί",
|
||||
"edges": {
|
||||
"top": "Πάνω άκρη μέσα",
|
||||
"right": "Δεξιά άκρη μέσα",
|
||||
"bottom": "Κάτω άκρη μέσα",
|
||||
"left": "Αριστερή άκρη μέσα"
|
||||
"top": "Πάνω άκρη",
|
||||
"right": "Δεξιά άκρη",
|
||||
"bottom": "Κάτω άκρη",
|
||||
"left": "Αριστερή άκρη"
|
||||
},
|
||||
"picture": "Η εικόνα: {{w}} × {{h}} px ({{shape}})",
|
||||
"outside": "Έξω από την εικόνα η τηλεόραση μένει μαύρη.",
|
||||
"reset": "Ξανά όλη η οθόνη",
|
||||
"done": "Τέλος"
|
||||
"done": "Τέλος",
|
||||
"recognised": "Ανάλυση που αναγνωρίστηκε",
|
||||
"recognisedHint": "Το μέγεθος που ανέφερε η ίδια η τηλεόραση. Αν η πραγματική της εικόνα είναι μεγαλύτερη ή μικρότερη, αλλάξτε την εδώ με τις άκρες από κάτω.",
|
||||
"edgesHint": "Θετικός αριθμός φέρνει την άκρη μέσα· αρνητικός τη σπρώχνει έξω, πέρα από την ανάλυση που αναγνωρίστηκε.",
|
||||
"past": "Μέρος της εικόνας περνά πλέον πέρα από την ανάλυση που αναγνωρίστηκε: αν η τηλεόραση δεν έχει πραγματικά εικόνα εκεί, αυτό το κομμάτι κόβεται."
|
||||
},
|
||||
"reviews": {
|
||||
"title": "Κριτικές",
|
||||
@@ -2200,7 +2262,8 @@
|
||||
"made_one": "Έφτιαξε · {{count}} παραγγελία",
|
||||
"made_other": "Έφτιαξε · {{count}} παραγγελίες",
|
||||
"paidItems": "Πληρώθηκαν",
|
||||
"onTab": "Σε καρτέλα"
|
||||
"onTab": "Σε καρτέλα",
|
||||
"countedTip": "Γράψτε τι παραδίδει ο σερβιτόρος, με κόμμα ή τελεία για τα λεπτά. Συγκρίνεται με τα μετρητά που αναμένονται από τη βάρδια, όπως φαίνονται παραπάνω."
|
||||
},
|
||||
"cash": {
|
||||
"even": "Ισοσκελισμένο",
|
||||
@@ -2259,7 +2322,8 @@
|
||||
"event": {
|
||||
"waiter_discount": "Έκπτωση",
|
||||
"free_item_added": "Δωρεάν",
|
||||
"modifier_applied": "Τροποποιητής"
|
||||
"modifier_applied": "Τροποποιητής",
|
||||
"manual_price": "Τιμή με το χέρι"
|
||||
}
|
||||
},
|
||||
"orderStatus": {
|
||||
@@ -2756,7 +2820,15 @@
|
||||
"altPrices": "Εναλλακτικές τιμές",
|
||||
"altPricesHint": "Αποθηκεύστε πρώτα το προϊόν.",
|
||||
"langOf": "Γλώσσα",
|
||||
"mainLang": "{{language}} (κύρια)"
|
||||
"mainLang": "{{language}} (κύρια)",
|
||||
"unitTip": "Τα τεμάχια μετριούνται (2 μπίρες). Οι μονάδες βάρους ή όγκου ζητούν ποσότητα στην παραγγελία (0,5 κιλά) και η τιμή είναι ανά μονάδα.",
|
||||
"availableTip": "Όχι: εξαφανίζεται από τα μενού των σερβιτόρων και του ταμείου μέχρι να το ενεργοποιήσετε ξανά (τελείωσε για σήμερα). Τίποτε άλλο δεν αλλάζει.",
|
||||
"quickAddTip": "Ναι: ένα πάτημα στη λίστα του σερβιτόρου το προσθέτει κατευθείαν, χωρίς να ανοίξουν οι επιλογές του. Αφήστε το κλειστό για προϊόντα που χρειάζονται επιλογή (ψήσιμο, συνοδευτικά).",
|
||||
"vatGroupTip": "Ο συντελεστής ΦΠΑ που χρησιμοποιεί η φορολογική απόδειξη για το προϊόν. Χρειάζεται για να πληρωθεί όσο ο φορολογικός μηχανισμός είναι ενεργός.",
|
||||
"costTip": "Τι σας κοστίζει μία μονάδα (υλικά, συσκευασία). Οι αναφορές το χρησιμοποιούν για το κέρδος· προϊόντα χωρίς κόστος κάνουν το κέρδος κατώτερη εκτίμηση.",
|
||||
"oneMore": "Άλλο ένα (+1)",
|
||||
"oneMoreHint": "Μια σταλμένη γραμμή αυτού του προϊόντος έχει κουμπί +1 στα κινητά και στο ταμείο.",
|
||||
"oneMoreTip": "Για ό,τι τα τραπέζια ξαναπαραγγέλνουν (μπίρες, καφέδες). Το +1 παραγγέλνει το ίδιο ξανά, με τις ίδιες επιλογές και σημείωση, στη σημερινή τιμή, και το στέλνει στην κουζίνα ή στο μπαρ όπως κάθε νέα παραγγελία. Κλειστό αρχικά."
|
||||
}
|
||||
},
|
||||
"menuTabletSettings": {
|
||||
@@ -3230,7 +3302,8 @@
|
||||
"tabs": {
|
||||
"order": "Παραγγελία",
|
||||
"prices": "Αλλαγές τιμών",
|
||||
"history": "Ιστορικό"
|
||||
"history": "Ιστορικό",
|
||||
"moves": "Μεταφορές"
|
||||
},
|
||||
"payAll": "Πληρωμή όλων",
|
||||
"close": "Κλείσιμο",
|
||||
@@ -3332,7 +3405,11 @@
|
||||
"PAYMENT_OFFLINE": "Πληρωμή (offline)",
|
||||
"ORDER_CLOSED": "Κλείσιμο",
|
||||
"ORDER_CANCELLED": "Ακύρωση",
|
||||
"ITEM_CANCELLED": "Ακύρωση γραμμής"
|
||||
"ITEM_CANCELLED": "Ακύρωση γραμμής",
|
||||
"PRICE_CHANGED": "Αλλαγή τιμής",
|
||||
"PRICE_SET_BY_HAND": "Τιμή με το χέρι (εγκρίθηκε)",
|
||||
"QUANTITY_CHANGED": "Αλλαγή ποσότητας",
|
||||
"ITEM_REORDERED": "Άλλο ένα"
|
||||
},
|
||||
"price": {
|
||||
"modifier_applied": "Κανόνας τιμής",
|
||||
@@ -3341,7 +3418,14 @@
|
||||
"deal_offer_accepted": "Προσφορά (αποδεκτή)",
|
||||
"deal_offer_dismissed": "Προσφορά (απορρίφθηκε)",
|
||||
"waiter_discount": "Έκπτωση",
|
||||
"free_item_added": "Δωρεάν προϊόν"
|
||||
"free_item_added": "Δωρεάν προϊόν",
|
||||
"manual_price": "Τιμή με το χέρι"
|
||||
},
|
||||
"approvedBy": "με έγκριση {{name}}",
|
||||
"stage": {
|
||||
"cart": "πριν την αποστολή",
|
||||
"sent": "μετά την αποστολή",
|
||||
"served": "μετά το σερβίρισμα"
|
||||
}
|
||||
},
|
||||
"add": {
|
||||
@@ -3389,7 +3473,19 @@
|
||||
"saved": "Οι σημαίες αποθηκεύτηκαν",
|
||||
"sent": "Σημαίες αποθηκεύτηκαν και το μήνυμα στάλθηκε"
|
||||
},
|
||||
"printHelp": "Τα δελτία ξαναδοκιμάζονται κάθε 8 δευτερόλεπτα μέχρι να τυπωθούν. Αν ένας εκτυπωτής είναι κλειστός ή χωρίς χαρτί, στείλτε τα σε άλλον, ή σημειώστε ότι τα χειριστήκατε όταν μάθει η κουζίνα."
|
||||
"printHelp": "Τα δελτία ξαναδοκιμάζονται κάθε 8 δευτερόλεπτα μέχρι να τυπωθούν. Αν ένας εκτυπωτής είναι κλειστός ή χωρίς χαρτί, στείλτε τα σε άλλον, ή σημειώστε ότι τα χειριστήκατε όταν μάθει η κουζίνα.",
|
||||
"moves": {
|
||||
"none": "Τίποτα δεν μεταφέρθηκε σε αυτή την παραγγελία.",
|
||||
"wholeOrder": "Όλη η παραγγελία: {{path}}",
|
||||
"linePath": "μεταφέρθηκε: {{path}}",
|
||||
"lines_one": "{{count}} γραμμή",
|
||||
"lines_other": "{{count}} γραμμές",
|
||||
"kind": {
|
||||
"table_transfer": "Όλο το τραπέζι",
|
||||
"items_moved": "Μεταφορά γραμμών",
|
||||
"orders_merged": "Ένωση τραπεζιών"
|
||||
}
|
||||
}
|
||||
},
|
||||
"printing": {
|
||||
"back": "Πίσω",
|
||||
@@ -3711,7 +3807,8 @@
|
||||
"zonesBody": "Το κινητό του και ο χάρτης τραπεζιών δείχνουν μόνο τα τραπέζια αυτών των ζωνών.",
|
||||
"noGroups": "Δεν υπάρχουν ζώνες ακόμα (Διαχείριση → Τραπέζια).",
|
||||
"noZonesWarn": "Χωρίς ζώνη δεν βλέπει κανένα τραπέζι.",
|
||||
"zonesSaved": "Οι ζώνες αποθηκεύτηκαν: {{name}}"
|
||||
"zonesSaved": "Οι ζώνες αποθηκεύτηκαν: {{name}}",
|
||||
"roleTip": "Ο ρόλος δίνει στο άτομο τα δικαιώματα του ρόλου (Ρυθμίσεις → Λειτουργία → Τι επιτρέπεται σε κάθε ρόλο). Τα δικαιώματα ενός ατόμου αλλάζουν και ξεχωριστά."
|
||||
},
|
||||
"schedule": {
|
||||
"title": "Πρόγραμμα",
|
||||
@@ -4032,7 +4129,7 @@
|
||||
}
|
||||
},
|
||||
"misc": {
|
||||
"title": "Ακυρώσεις και εκπτώσεις",
|
||||
"title": "Ακυρώσεις, εκπτώσεις και αλλαγές τιμών",
|
||||
"cancellations": "Ακυρώσεις",
|
||||
"discounts": "Εκπτώσεις",
|
||||
"when": "Πότε",
|
||||
@@ -4056,7 +4153,18 @@
|
||||
"discountTotal": "Σύνολο εκπτώσεων",
|
||||
"alreadyOff": "έχουν ήδη αφαιρεθεί από τα έσοδα",
|
||||
"times_one": "{{count}} φορά",
|
||||
"times_other": "{{count}} φορές"
|
||||
"times_other": "{{count}} φορές",
|
||||
"priceChanges": "Αλλαγές τιμών",
|
||||
"priceWas": "Ήταν",
|
||||
"priceNow": "Έγινε",
|
||||
"stage": "Πότε",
|
||||
"changedBy": "Άλλαξε από",
|
||||
"approvedBy": "Ενέκρινε",
|
||||
"changes": "Αλλαγές τιμών",
|
||||
"changesValue": "Διαφορά",
|
||||
"changesValueTip": "Τι πρόσθεσαν (+) ή αφαίρεσαν (−) οι αλλαγές, για την ποσότητα κάθε γραμμής τη στιγμή της αλλαγής.",
|
||||
"changesCount_one": "{{count}} αλλαγή",
|
||||
"changesCount_other": "{{count}} αλλαγές"
|
||||
},
|
||||
"tech": {
|
||||
"title": "Τεχνικά",
|
||||
@@ -4118,6 +4226,23 @@
|
||||
"dueDate": "Λήξη {{date}}",
|
||||
"payments": "Πληρωμές",
|
||||
"noPayments": "Δεν έχει πληρωθεί τίποτα ακόμα."
|
||||
},
|
||||
"moves": {
|
||||
"title": "Μεταφορές μεταξύ τραπεζιών",
|
||||
"kind": "Τι",
|
||||
"from": "Από",
|
||||
"to": "Προς",
|
||||
"lines": "Γραμμές",
|
||||
"by": "Από ποιον",
|
||||
"allKinds": "Όλα τα είδη",
|
||||
"count": "Μεταφορές",
|
||||
"list": "Όλες οι μεταφορές",
|
||||
"listTip": "Ολόκληρο τραπέζι σε ελεύθερο, γραμμές σε άλλο τραπέζι, ή ένωση δύο τραπεζιών. Κάθε γραμμή κρατά τις μεταφορές της όπου κι αν καταλήξει, ακόμη κι αν χωριστεί ή μεταφερθεί ξανά.",
|
||||
"kinds": {
|
||||
"table_transfer": "Όλο το τραπέζι",
|
||||
"items_moved": "Μεταφορά γραμμών",
|
||||
"orders_merged": "Ένωση τραπεζιών"
|
||||
}
|
||||
}
|
||||
},
|
||||
"finance": {
|
||||
|
||||
@@ -454,7 +454,9 @@
|
||||
"cancel": "Ακύρωση ειδών που έχουν σταλεί"
|
||||
},
|
||||
"prices": {
|
||||
"modify": "Αλλαγή τιμής είδους"
|
||||
"modify": "Αλλαγή τιμής είδους πριν σταλεί",
|
||||
"modify_sent": "Αλλαγή τιμής είδους που έχει ήδη σταλεί ή σερβιριστεί",
|
||||
"view_changes": "Προβολή τιμών που άλλαξαν με το χέρι (ποιος, πότε, γιατί)"
|
||||
},
|
||||
"business_day": {
|
||||
"manage": "Άνοιγμα και κλείσιμο της εργάσιμης ημέρας"
|
||||
@@ -462,6 +464,9 @@
|
||||
"refunds": "Επιστροφή χρημάτων για πληρωμές άλλων βαρδιών",
|
||||
"payments": {
|
||||
"revert": "Αναίρεση πληρωμής (πληρωμένα → απλήρωτα)"
|
||||
},
|
||||
"items": {
|
||||
"change_quantity": "Αλλαγή ποσότητας σταλμένης γραμμής (χωρίς νέο δελτίο)"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -466,6 +466,11 @@
|
||||
},
|
||||
"dialog": {
|
||||
"close": "Κλείσιμο"
|
||||
},
|
||||
"oneMore": {
|
||||
"send": "Αποστολή +{{count}}",
|
||||
"label": "Άλλο ένα",
|
||||
"sent": "Στάλθηκαν {{count}} ακόμη {{name}}"
|
||||
}
|
||||
},
|
||||
"display": {
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
"startQuestion": "Θέλεις να ξεκινήσεις τη βάρδια σου;",
|
||||
"startingCash": "Αρχικά μετρητά (προαιρετικό)",
|
||||
"starting": "Εκκίνηση…",
|
||||
"startShift": "Έναρξη Βάρδιας"
|
||||
"startShift": "Έναρξη Βάρδιας",
|
||||
"badAmount": "Γράψτε ένα ποσό, π.χ. 50 ή 50,00."
|
||||
},
|
||||
"nav": {
|
||||
"tables": "Τραπέζια",
|
||||
@@ -527,7 +528,10 @@
|
||||
"merge": "Σφάλμα συγχώνευσης",
|
||||
"moveItems": "Σφάλμα μεταφοράς αντικειμένων",
|
||||
"flags": "Σφάλμα αποθήκευσης σημαιών",
|
||||
"combine": "Σφάλμα συνδυασμού"
|
||||
"combine": "Σφάλμα συνδυασμού",
|
||||
"price": "Η τιμή δεν άλλαξε.",
|
||||
"again": "Το «άλλο ένα» δεν στάλθηκε.",
|
||||
"quantity": "Η ποσότητα δεν άλλαξε."
|
||||
},
|
||||
"openOrder": "Άνοιγμα Παραγγελίας",
|
||||
"noPaid": "Δεν υπάρχουν πληρωμένα αντικείμενα",
|
||||
@@ -856,5 +860,63 @@
|
||||
"accepted": "Στάλθηκε στην κουζίνα",
|
||||
"declined": "Απορρίφθηκε",
|
||||
"note": "Σημείωση: {{note}}"
|
||||
},
|
||||
"price": {
|
||||
"reason": "Γιατί αλλάζει η τιμή;",
|
||||
"reasonMissing": "Γράψτε γιατί αλλάζει η τιμή",
|
||||
"reasons": {
|
||||
"regular": "Τακτικός πελάτης",
|
||||
"mistake": "Λάθος τιμή στο μενού",
|
||||
"compensation": "Αποζημίωση για πρόβλημα",
|
||||
"manager": "Απόφαση υπευθύνου",
|
||||
"happyHour": "Προσφορά ημέρας",
|
||||
"other": "Άλλο"
|
||||
},
|
||||
"history": "Ιστορικό τιμής",
|
||||
"historySub": "Ποιος την άλλαξε, πότε και γιατί",
|
||||
"historyNone": "Καμία αλλαγή τιμής σε αυτή τη γραμμή.",
|
||||
"historyFailed": "Το ιστορικό τιμής δεν φόρτωσε.",
|
||||
"stage": {
|
||||
"cart": "πριν την αποστολή",
|
||||
"sent": "μετά την αποστολή",
|
||||
"served": "μετά το σερβίρισμα"
|
||||
},
|
||||
"approvedBy": "με έγκριση {{name}}"
|
||||
},
|
||||
"moves": {
|
||||
"orderCame": "Μεταφέρθηκε: {{path}}",
|
||||
"details": "Λεπτομέρειες",
|
||||
"orderTitle": "Μεταφορές της παραγγελίας",
|
||||
"lineTitle": "Ιστορικό μεταφορών",
|
||||
"lineSub": "Τα τραπέζια από όπου πέρασε αυτή η γραμμή",
|
||||
"lineMoved": "Ήρθε εδώ από άλλο τραπέζι",
|
||||
"movedShort": "μεταφ.",
|
||||
"lines_one": "{{count}} γραμμή",
|
||||
"lines_other": "{{count}} γραμμές",
|
||||
"kind": {
|
||||
"table_transfer": "Όλο το τραπέζι",
|
||||
"items_moved": "Μεταφορά γραμμών",
|
||||
"orders_merged": "Ένωση τραπεζιών"
|
||||
}
|
||||
},
|
||||
"oneMore": {
|
||||
"label": "Άλλο ένα",
|
||||
"send": "Αποστολή +{{count}}"
|
||||
},
|
||||
"quantity": {
|
||||
"title": "Αλλαγή ποσότητας",
|
||||
"actionSub": "Διόρθωση ποσότητας· δεν ξαναστέλνεται στην κουζίνα",
|
||||
"now": "Τώρα",
|
||||
"new": "Νέα",
|
||||
"less": "Ένα λιγότερο",
|
||||
"more": "Ένα ακόμη",
|
||||
"save": "Αποθήκευση",
|
||||
"upNote_one": "{{count}} ακόμη, χωρίς νέο δελτίο",
|
||||
"upNote_other": "{{count}} ακόμη, χωρίς νέο δελτίο",
|
||||
"downNote_one": "{{count}} θα ακυρωθεί",
|
||||
"downNote_other": "{{count}} θα ακυρωθούν",
|
||||
"noChange": "Αλλάξτε τη με − και +",
|
||||
"onlyUp": "Σε αυτό το κατάστημα οι ποσότητες μόνο αυξάνονται.",
|
||||
"sendCancel": "Αποστολή ακύρωσης στην κουζίνα"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,16 @@
|
||||
"discounts_off": "Discounts are turned off for this venue.",
|
||||
"no_customer": "Give the order a customer first.",
|
||||
"item_not_tabbable": "This item is already {{status}}: it can't go on a tab.",
|
||||
"product_unavailable": "Product {{product_id}} isn't available."
|
||||
"product_unavailable": "Product {{product_id}} isn't available.",
|
||||
"price_change_off": "Changing prices by hand is turned off for this venue.",
|
||||
"price_change_sent_off": "Prices can only be changed before the items are sent.",
|
||||
"price_reason_required": "Say why the price changes.",
|
||||
"one_more_off": "\"One more\" isn't turned on for this product.",
|
||||
"one_more_line": "This line can't be ordered again with one tap.",
|
||||
"quantity_change_off": "Changing quantities is turned off for this venue.",
|
||||
"quantity_remove_off": "Quantities can only go up at this venue.",
|
||||
"quantity_invalid": "Choose a whole number from 1 to {{max}}.",
|
||||
"quantity_line": "This line's quantity can't be changed here."
|
||||
},
|
||||
"notification": {
|
||||
"not_found": "Notification {{notification_id}} not found."
|
||||
|
||||
@@ -50,7 +50,8 @@
|
||||
"media": "Media",
|
||||
"signage": "Signage",
|
||||
"main": "Main menu",
|
||||
"scenes": "Scenes"
|
||||
"scenes": "Scenes",
|
||||
"reportsMoves": "Moves"
|
||||
},
|
||||
"profile": {
|
||||
"edit": "Edit profile",
|
||||
@@ -220,7 +221,8 @@
|
||||
"none": "None",
|
||||
"linkHint": "For example a customer display that shows a counter POS's order.",
|
||||
"full": "{{label}}: the license allows {{max}}, all in use. Remove one or ask for a bigger license.",
|
||||
"noApps": "No device app is turned on. Turn one on in Apps first."
|
||||
"noApps": "No device app is turned on. Turn one on in Apps first.",
|
||||
"signInTip": "PIN or password: each person signs in. Tap your name: anyone switches user without a secret (a shared counter). None: the screen works without a user (a kitchen display)."
|
||||
},
|
||||
"actions": {
|
||||
"rename": "Rename",
|
||||
@@ -409,7 +411,11 @@
|
||||
"idleHint": "Days without using the app (manager, waiter app and paired devices). They sign in again next time.",
|
||||
"idleDays_one": "{{count}} day without use",
|
||||
"idleDays_other": "{{count}} days without use",
|
||||
"idleNever": "Never"
|
||||
"idleNever": "Never",
|
||||
"waiterTip": "PIN: fast, a few digits. Password: safer, slower to type. Tap your name: no secret at all, so it works only on devices you paired, never on personal phones.",
|
||||
"requireUsernameTip": "The phone no longer lists the staff: someone who picks up a phone can't see who works here or try a colleague's PIN.",
|
||||
"deviceTip": "Tap your name: anyone switches user on a shared screen without a secret (a busy counter). None: the screen works without a user (a kitchen display everyone watches).",
|
||||
"idleTip": "Counted in days, not minutes: a phone left signed in for weeks gets signed out. To lock the dashboard after minutes, see \"When the dashboard isn't used\"."
|
||||
},
|
||||
"venue": {
|
||||
"title": "Venue",
|
||||
@@ -427,7 +433,9 @@
|
||||
"rose": "Rose",
|
||||
"identity": "The venue's identity (its first colour)"
|
||||
},
|
||||
"identityNoColour": "The venue's identity has no colours yet (Settings → Identity): the phones stay amber and the screens keep their own colour until it has one."
|
||||
"identityNoColour": "The venue's identity has no colours yet (Settings → Identity): the phones stay amber and the screens keep their own colour until it has one.",
|
||||
"languageTip": "Each person can choose their own language on their profile. Kitchen tickets print in each prep zone's language (Printing → prep zones), else in this one.",
|
||||
"timezoneTip": "Decides which day a sale belongs to, and the times on tickets and reports. Change it only if the venue really is in another time zone."
|
||||
},
|
||||
"print": {
|
||||
"title": "Print alerts",
|
||||
@@ -439,7 +447,8 @@
|
||||
},
|
||||
"operation": {
|
||||
"closeUnpaid": "Close a table with unpaid items",
|
||||
"closeUnpaidHint": "Off: closing a table with unpaid items asks for the payment first, then closes it. On: it closes and the unpaid items are recorded as unpaid."
|
||||
"closeUnpaidHint": "Off: closing a table with unpaid items asks for the payment first, then closes it. On: it closes and the unpaid items are recorded as unpaid.",
|
||||
"closeUnpaidTip": "Items written off this way stay in the order's history as unpaid, so nothing disappears; they just don't count as sales."
|
||||
},
|
||||
"title": "Settings",
|
||||
"save": "Save",
|
||||
@@ -507,7 +516,8 @@
|
||||
"waiters": "Waiters (Wi-Fi)",
|
||||
"waitersHint": "Phones on the same Wi-Fi open this, or scan the QR.",
|
||||
"qrCaption": "Scan with the phone's camera: it opens the waiter app. The phone must be on the same Wi-Fi.",
|
||||
"manager": "Managers (Wi-Fi)"
|
||||
"manager": "Managers (Wi-Fi)",
|
||||
"addressTip": "The address the phones and screens use to reach this server on the venue's Wi-Fi. It's found by itself; type it only if the one shown is wrong (e.g. a PC with two network cards)."
|
||||
},
|
||||
"transfer": {
|
||||
"title": "Export and import",
|
||||
@@ -568,7 +578,8 @@
|
||||
"replaceYes": "Make new codes",
|
||||
"remake": "Make new codes",
|
||||
"make": "Make recovery codes",
|
||||
"recoveryHow": "Keep them somewhere safe. On the sign-in page: your username and a code instead of the password."
|
||||
"recoveryHow": "Keep them somewhere safe. On the sign-in page: your username and a code instead of the password.",
|
||||
"lockTip": "Locking keeps the manager signed in: the screen asks for a PIN to go on. Good for a dashboard on a shared PC."
|
||||
},
|
||||
"ops": {
|
||||
"staffTitle": "Waiters",
|
||||
@@ -607,7 +618,15 @@
|
||||
"syncNow": "Send it now",
|
||||
"syncNowHint": "Instead of waiting for the next time.",
|
||||
"sync": "Send",
|
||||
"synced": "The menu was sent"
|
||||
"synced": "The menu was sent",
|
||||
"selfStartTip": "On: waiters start their shift from their phone and type the cash they start with. Off: they can't take orders until a manager starts their shift on the Overview.",
|
||||
"selfEndTip": "On: waiters end their shift from their phone. Off: only a manager ends it, on the Overview, where the cash they hand over is counted, so every shift ends with a count.",
|
||||
"hideTakingsTip": "Waiters still see their tables and orders; only their shift's money (what they took, what they should hand over) is hidden. Managers always see it.",
|
||||
"cardTip": "A card payment is recorded as card, so it isn't part of the cash the waiter hands over. Charge the card on the bank's terminal as usual: Xenia doesn't talk to it.",
|
||||
"autoCloseTip": "On: the table is free for new customers right after the last payment. Off: the waiter closes it, useful when customers stay and may order again.",
|
||||
"bypassKdsTip": "For venues without kitchen screens, or where nobody marks dishes as served. The waiter app then doesn't wait for \"ready\" or \"served\".",
|
||||
"coursesTip": "Each line gets a course and its colour shows on tickets and kitchen screens, so the kitchen prepares them in order. Set the courses below, in the order they are served.",
|
||||
"quickNotesTip": "The note prints on the kitchen ticket under the item and shows on the kitchen screen."
|
||||
},
|
||||
"flags": {
|
||||
"title": "Table flags",
|
||||
@@ -712,7 +731,8 @@
|
||||
"vatName": "Name",
|
||||
"vatNameHint": "e.g. Food, Drinks, Alcohol",
|
||||
"removeVat": "Remove this group",
|
||||
"addVat": "Add a group"
|
||||
"addVat": "Add a group",
|
||||
"enabledTip": "Every payment then sends a receipt to the fiscal device. Each product needs a VAT group before it can be paid (the product editor warns)."
|
||||
},
|
||||
"dev": {
|
||||
"warning": "For testing only. Don't leave these on while the venue is working.",
|
||||
@@ -720,6 +740,37 @@
|
||||
"spoof": "Pretend to print",
|
||||
"spoofHint": "Every print job is dropped; the apps behave as if it printed.",
|
||||
"spoofOn": "On: the printers print nothing."
|
||||
},
|
||||
"prices": {
|
||||
"title": "Prices changed by hand",
|
||||
"intro": "When staff may type a line's own price, and whether they must say why. Every change is kept: who, when, from what to what, why.",
|
||||
"when": "Staff may change a price",
|
||||
"whenHint": "Who may: \"What each role may do\" and each person's permissions.",
|
||||
"whenTip": "Never: nobody types a price, owners included. Before sending: only in the cart, before the order goes to the kitchen. Any time: also a line already sent or served (needs its own permission, \"already sent or served\").",
|
||||
"modes": {
|
||||
"off": "Never",
|
||||
"before_sending": "Before sending only",
|
||||
"anytime": "Any time"
|
||||
},
|
||||
"reason": "Ask for a reason",
|
||||
"reasonHint": "A price changed by hand can't be saved without one.",
|
||||
"reasonTip": "The reason is kept with the change and shown in the order's history and in Reports → Cancellations, discounts and price changes. The counter's % discounts don't ask: the discount says what it is.",
|
||||
"reasons": "Quick reasons",
|
||||
"reasonsHint": "Offered with one tap; staff can still type their own. None: the built-in ones.",
|
||||
"reasonItem": "Quick reason",
|
||||
"newReason": "A new quick reason…"
|
||||
},
|
||||
"quantity": {
|
||||
"title": "Changing a sent line's quantity",
|
||||
"intro": "Staff correct how many of a line there are without sending it to the kitchen again. Every change is kept in the order's history.",
|
||||
"when": "Staff may",
|
||||
"whenHint": "Who may: \"What each role may do\" and each person's permissions.",
|
||||
"whenTip": "Only add: the quantity can go up (a beer taken from the fridge), nothing is printed. Add and remove: lowering it also cancels the difference as its own cancelled line, and asks whether to send a cancellation to the kitchen. Removing needs the permission to cancel too.",
|
||||
"modes": {
|
||||
"off": "Not at all",
|
||||
"add_only": "Only add",
|
||||
"add_and_remove": "Add and remove"
|
||||
}
|
||||
}
|
||||
},
|
||||
"logs": {
|
||||
@@ -1594,8 +1645,7 @@
|
||||
"backInPlace": "Back to aligned",
|
||||
"vertical": "Vertical alignment",
|
||||
"look": "Text and colours",
|
||||
"plateOnly": "Background plate",
|
||||
"colour": "Colour",
|
||||
"colour": "Text colour",
|
||||
"asSlide": "As the slide",
|
||||
"plate": "Background plate",
|
||||
"noPlate": "None",
|
||||
@@ -1633,8 +1683,8 @@
|
||||
"text": "The text",
|
||||
"direction": "Moves",
|
||||
"directions": {
|
||||
"left": "To the left",
|
||||
"right": "To the right"
|
||||
"left": "Left",
|
||||
"right": "Right"
|
||||
},
|
||||
"speed": "Speed"
|
||||
},
|
||||
@@ -1717,7 +1767,14 @@
|
||||
"noFolders": "No media folders yet.",
|
||||
"toMedia": "Make one on the Media page",
|
||||
"add": "Add pictures or videos",
|
||||
"empty": "Nothing in the gallery yet: it stays hidden."
|
||||
"empty": "Nothing in the gallery yet: it stays hidden.",
|
||||
"title": "Title",
|
||||
"titlePlaceholder": "None",
|
||||
"titleAt": "Title goes",
|
||||
"titleAts": {
|
||||
"above": "Above",
|
||||
"below": "Below"
|
||||
}
|
||||
},
|
||||
"weatherLayout": "Layout",
|
||||
"weatherLayouts": {
|
||||
@@ -1741,7 +1798,8 @@
|
||||
"weatherHours": "Hours",
|
||||
"weatherPlace": "The place",
|
||||
"weatherPlaceLabel": "Show its name",
|
||||
"logoFromIdentity": "No picture chosen: the venue's logo (Settings → Identity) shows."
|
||||
"logoFromIdentity": "No picture chosen: the venue's logo (Settings → Identity) shows.",
|
||||
"enterHint": "Enter starts a new line."
|
||||
},
|
||||
"tabs": {
|
||||
"playlists": "Playlists",
|
||||
@@ -1986,21 +2044,25 @@
|
||||
"open": "Calibrate the picture",
|
||||
"title": "Calibrate the picture: {{name}}",
|
||||
"intro": "The TV now shows its picture's edges with four arrows pointing out. Move each edge until its arrow just touches the edge of the screen, or pick a shape. Changes show on the TV at once.",
|
||||
"window": "The TV's window: {{w}} × {{h}} px ({{shape}}).",
|
||||
"window": "{{w}} × {{h}} px ({{shape}})",
|
||||
"waiting": "Waiting for the TV to tell its size… Is it on and showing signage?",
|
||||
"presets": "Shapes",
|
||||
"full": "Whole screen",
|
||||
"step": "Each click moves",
|
||||
"edges": {
|
||||
"top": "Top edge in",
|
||||
"right": "Right edge in",
|
||||
"bottom": "Bottom edge in",
|
||||
"left": "Left edge in"
|
||||
"top": "Top edge",
|
||||
"right": "Right edge",
|
||||
"bottom": "Bottom edge",
|
||||
"left": "Left edge"
|
||||
},
|
||||
"picture": "The picture: {{w}} × {{h}} px ({{shape}})",
|
||||
"outside": "Outside the picture the TV stays black.",
|
||||
"reset": "Whole screen again",
|
||||
"done": "Done"
|
||||
"done": "Done",
|
||||
"recognised": "Recognised resolution",
|
||||
"recognisedHint": "The size the TV reported for itself. If its real picture is larger or smaller, change it right here with the edges below.",
|
||||
"edgesHint": "A positive number moves that edge in; a negative one pushes it out, past the recognised resolution.",
|
||||
"past": "Part of the picture now reaches past the recognised resolution: if the TV really has no picture there, that part is cut off."
|
||||
},
|
||||
"reviews": {
|
||||
"title": "Reviews",
|
||||
@@ -2200,7 +2262,8 @@
|
||||
"made_one": "Made · {{count}} order",
|
||||
"made_other": "Made · {{count}} orders",
|
||||
"paidItems": "Paid",
|
||||
"onTab": "Put on a tab"
|
||||
"onTab": "Put on a tab",
|
||||
"countedTip": "Type what the waiter hands over, with a comma or a dot for the cents. It is compared with the cash expected from their shift, shown above."
|
||||
},
|
||||
"cash": {
|
||||
"even": "Balanced",
|
||||
@@ -2259,7 +2322,8 @@
|
||||
"event": {
|
||||
"waiter_discount": "Discount",
|
||||
"free_item_added": "Free",
|
||||
"modifier_applied": "Price change"
|
||||
"modifier_applied": "Price change",
|
||||
"manual_price": "Price changed by hand"
|
||||
}
|
||||
},
|
||||
"orderStatus": {
|
||||
@@ -2756,7 +2820,15 @@
|
||||
"altPrices": "Edit alternate prices",
|
||||
"altPricesHint": "Save the product first.",
|
||||
"langOf": "Language",
|
||||
"mainLang": "{{language}} (main)"
|
||||
"mainLang": "{{language}} (main)",
|
||||
"unitTip": "Pieces are counted (2 beers). Weighed or measured units ask for an amount when ordered (0.5 kg) and the price is per unit.",
|
||||
"availableTip": "Off: it disappears from the waiters' and the counter's menus until you switch it back on (sold out today). Nothing else about it changes.",
|
||||
"quickAddTip": "On: one tap in the waiter's product list adds it straight to the order without opening its choices. Leave it off for products whose choices must be picked (cooking, sides).",
|
||||
"vatGroupTip": "The VAT rate the fiscal receipt uses for this product. Needed before it can be paid while the fiscal device is on.",
|
||||
"costTip": "What one unit costs you (ingredients, packaging). Reports use it for the profit; products without a cost make the profit a lower estimate.",
|
||||
"oneMore": "One more (+1)",
|
||||
"oneMoreHint": "A sent line of this product gets a +1 button on the phones and the counter.",
|
||||
"oneMoreTip": "For what tables keep ordering again (beers, coffees). +1 orders the same again, with the same choices and note, at today's price, and sends it to the kitchen or bar like any new order. Off by default."
|
||||
}
|
||||
},
|
||||
"menuTabletSettings": {
|
||||
@@ -3230,7 +3302,8 @@
|
||||
"tabs": {
|
||||
"order": "Order",
|
||||
"prices": "Price changes",
|
||||
"history": "History"
|
||||
"history": "History",
|
||||
"moves": "Moves"
|
||||
},
|
||||
"payAll": "Pay everything",
|
||||
"close": "Close",
|
||||
@@ -3332,7 +3405,11 @@
|
||||
"PAYMENT_OFFLINE": "Payment (offline)",
|
||||
"ORDER_CLOSED": "Closed",
|
||||
"ORDER_CANCELLED": "Cancelled",
|
||||
"ITEM_CANCELLED": "Line cancelled"
|
||||
"ITEM_CANCELLED": "Line cancelled",
|
||||
"PRICE_CHANGED": "Price changed",
|
||||
"PRICE_SET_BY_HAND": "Price set by hand (approved)",
|
||||
"QUANTITY_CHANGED": "Quantity changed",
|
||||
"ITEM_REORDERED": "One more"
|
||||
},
|
||||
"price": {
|
||||
"modifier_applied": "Price rule",
|
||||
@@ -3341,7 +3418,14 @@
|
||||
"deal_offer_accepted": "Deal accepted",
|
||||
"deal_offer_dismissed": "Deal declined",
|
||||
"waiter_discount": "Discount",
|
||||
"free_item_added": "Free item"
|
||||
"free_item_added": "Free item",
|
||||
"manual_price": "Price changed by hand"
|
||||
},
|
||||
"approvedBy": "approved by {{name}}",
|
||||
"stage": {
|
||||
"cart": "before sending",
|
||||
"sent": "after sending",
|
||||
"served": "after serving"
|
||||
}
|
||||
},
|
||||
"add": {
|
||||
@@ -3389,7 +3473,19 @@
|
||||
"saved": "Flags saved",
|
||||
"sent": "Flags saved and message sent"
|
||||
},
|
||||
"printHelp": "Tickets are tried again every 8 seconds until they print. If a printer is off or out of paper, send them to another one, or mark them handled once the kitchen knows."
|
||||
"printHelp": "Tickets are tried again every 8 seconds until they print. If a printer is off or out of paper, send them to another one, or mark them handled once the kitchen knows.",
|
||||
"moves": {
|
||||
"none": "Nothing moved on this order.",
|
||||
"wholeOrder": "The whole order: {{path}}",
|
||||
"linePath": "moved: {{path}}",
|
||||
"lines_one": "{{count}} line",
|
||||
"lines_other": "{{count}} lines",
|
||||
"kind": {
|
||||
"table_transfer": "Whole table",
|
||||
"items_moved": "Lines moved",
|
||||
"orders_merged": "Tables joined"
|
||||
}
|
||||
}
|
||||
},
|
||||
"printing": {
|
||||
"back": "Back",
|
||||
@@ -3711,7 +3807,8 @@
|
||||
"zonesBody": "Their phone and the table map only show these zones' tables.",
|
||||
"noGroups": "There are no zones yet (Management → Tables).",
|
||||
"noZonesWarn": "With no zone they see no tables.",
|
||||
"zonesSaved": "Zones of {{name}} saved"
|
||||
"zonesSaved": "Zones of {{name}} saved",
|
||||
"roleTip": "The role gives the person that role's permissions (Settings → Operation → What each role may do). One person's permissions can still be changed on their own."
|
||||
},
|
||||
"schedule": {
|
||||
"title": "Schedule",
|
||||
@@ -4032,7 +4129,7 @@
|
||||
}
|
||||
},
|
||||
"misc": {
|
||||
"title": "Cancellations and discounts",
|
||||
"title": "Cancellations, discounts and price changes",
|
||||
"cancellations": "Cancellations",
|
||||
"discounts": "Discounts",
|
||||
"when": "When",
|
||||
@@ -4056,7 +4153,18 @@
|
||||
"discountTotal": "Total off",
|
||||
"alreadyOff": "already taken off the revenue",
|
||||
"times_one": "{{count}} time",
|
||||
"times_other": "{{count}} times"
|
||||
"times_other": "{{count}} times",
|
||||
"priceChanges": "Price changes",
|
||||
"priceWas": "Was",
|
||||
"priceNow": "Became",
|
||||
"stage": "When",
|
||||
"changedBy": "Changed by",
|
||||
"approvedBy": "Approved by",
|
||||
"changes": "Prices changed",
|
||||
"changesValue": "Difference",
|
||||
"changesValueTip": "What the changes added (+) or took off (−), for each line's quantity at the time of the change.",
|
||||
"changesCount_one": "{{count}} change",
|
||||
"changesCount_other": "{{count}} changes"
|
||||
},
|
||||
"tech": {
|
||||
"title": "Technical",
|
||||
@@ -4118,6 +4226,23 @@
|
||||
"dueDate": "Due by {{date}}",
|
||||
"payments": "Payments",
|
||||
"noPayments": "Nothing paid yet."
|
||||
},
|
||||
"moves": {
|
||||
"title": "Moves between tables",
|
||||
"kind": "What",
|
||||
"from": "From",
|
||||
"to": "To",
|
||||
"lines": "Lines",
|
||||
"by": "By",
|
||||
"allKinds": "Every kind",
|
||||
"count": "Moves",
|
||||
"list": "Every move",
|
||||
"listTip": "A whole table moved to a free one, lines moved to another table, or two tables joined. Each line keeps its moves wherever it ends up, even split or moved again.",
|
||||
"kinds": {
|
||||
"table_transfer": "Whole table",
|
||||
"items_moved": "Lines moved",
|
||||
"orders_merged": "Tables joined"
|
||||
}
|
||||
}
|
||||
},
|
||||
"finance": {
|
||||
|
||||
@@ -454,7 +454,9 @@
|
||||
"cancel": "Cancel items already sent"
|
||||
},
|
||||
"prices": {
|
||||
"modify": "Change an item's price"
|
||||
"modify": "Change an item's price before it is sent",
|
||||
"modify_sent": "Change the price of an item already sent or served",
|
||||
"view_changes": "See prices changed by hand (who, when, why)"
|
||||
},
|
||||
"business_day": {
|
||||
"manage": "Open and close the business day"
|
||||
@@ -462,6 +464,9 @@
|
||||
"refunds": "Refund payments from other shifts",
|
||||
"payments": {
|
||||
"revert": "Turn paid items back to unpaid"
|
||||
},
|
||||
"items": {
|
||||
"change_quantity": "Change a sent line's quantity (no new ticket)"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -466,6 +466,11 @@
|
||||
},
|
||||
"dialog": {
|
||||
"close": "Close"
|
||||
},
|
||||
"oneMore": {
|
||||
"send": "Send +{{count}}",
|
||||
"label": "One more",
|
||||
"sent": "{{count}} more {{name}} sent"
|
||||
}
|
||||
},
|
||||
"display": {
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
"startQuestion": "Start your shift?",
|
||||
"startingCash": "Starting cash (optional)",
|
||||
"starting": "Starting…",
|
||||
"startShift": "Start shift"
|
||||
"startShift": "Start shift",
|
||||
"badAmount": "Type an amount, e.g. 50 or 50,00."
|
||||
},
|
||||
"nav": {
|
||||
"tables": "Tables",
|
||||
@@ -527,7 +528,10 @@
|
||||
"merge": "Couldn't merge",
|
||||
"moveItems": "Couldn't move the items",
|
||||
"flags": "Couldn't save the flags",
|
||||
"combine": "Couldn't combine the lines"
|
||||
"combine": "Couldn't combine the lines",
|
||||
"price": "The price didn't change.",
|
||||
"again": "One more wasn't sent.",
|
||||
"quantity": "The quantity didn't change."
|
||||
},
|
||||
"openOrder": "Open an order",
|
||||
"noPaid": "No paid items",
|
||||
@@ -856,5 +860,63 @@
|
||||
"accepted": "Sent to the kitchen",
|
||||
"declined": "Declined",
|
||||
"note": "Note: {{note}}"
|
||||
},
|
||||
"price": {
|
||||
"reason": "Why does the price change?",
|
||||
"reasonMissing": "Say why the price changes",
|
||||
"reasons": {
|
||||
"regular": "Regular customer",
|
||||
"mistake": "Wrong price on the menu",
|
||||
"compensation": "Making up for a problem",
|
||||
"manager": "Manager's decision",
|
||||
"happyHour": "Offer of the day",
|
||||
"other": "Other"
|
||||
},
|
||||
"history": "Price history",
|
||||
"historySub": "Who changed it, when and why",
|
||||
"historyNone": "No price changes on this line.",
|
||||
"historyFailed": "The price history didn't load.",
|
||||
"stage": {
|
||||
"cart": "before sending",
|
||||
"sent": "after sending",
|
||||
"served": "after serving"
|
||||
},
|
||||
"approvedBy": "approved by {{name}}"
|
||||
},
|
||||
"moves": {
|
||||
"orderCame": "Moved here: {{path}}",
|
||||
"details": "Details",
|
||||
"orderTitle": "This order's moves",
|
||||
"lineTitle": "Move history",
|
||||
"lineSub": "The tables this line went through",
|
||||
"lineMoved": "Moved here from another table",
|
||||
"movedShort": "moved",
|
||||
"lines_one": "{{count}} line",
|
||||
"lines_other": "{{count}} lines",
|
||||
"kind": {
|
||||
"table_transfer": "Whole table",
|
||||
"items_moved": "Lines moved",
|
||||
"orders_merged": "Tables joined"
|
||||
}
|
||||
},
|
||||
"oneMore": {
|
||||
"label": "One more",
|
||||
"send": "Send +{{count}}"
|
||||
},
|
||||
"quantity": {
|
||||
"title": "Change quantity",
|
||||
"actionSub": "Correct how many; nothing is sent to the kitchen again",
|
||||
"now": "Now",
|
||||
"new": "New",
|
||||
"less": "One less",
|
||||
"more": "One more",
|
||||
"save": "Save",
|
||||
"upNote_one": "{{count}} more, without a new ticket",
|
||||
"upNote_other": "{{count}} more, without a new ticket",
|
||||
"downNote_one": "{{count}} will be cancelled",
|
||||
"downNote_other": "{{count}} will be cancelled",
|
||||
"noChange": "Use − and + to change it",
|
||||
"onlyUp": "At this venue quantities only go up.",
|
||||
"sendCancel": "Send a cancellation to the kitchen"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
// Guard (plan 6F.2, owner 2026-11-23): numbers people type are read with parseNumber (a comma or
|
||||
// a dot for the decimals, "1.234,50" too), never with parseFloat / Number(x.replace(',', '.')),
|
||||
// and a field for money or a weight is never <input type="number"> with a decimal step: a phone's
|
||||
// Greek keypad types a comma, which such a field silently drops ("12,50" became 12 or nothing).
|
||||
// Use DecimalInput / MoneyInput (@xenia/ui) or a text field with inputMode="decimal" + parseNumber.
|
||||
import assert from 'node:assert/strict'
|
||||
import { readdirSync, readFileSync, statSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { test } from 'node:test'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const CS = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', '..')
|
||||
const ROOTS = ['manager_dashboard/src', 'waiter_pwa/src', 'terminal/src', 'packages/ui/src']
|
||||
// reading CSS lengths, not typed numbers (the older TVs' layer)
|
||||
const SKIP = new Set(['terminal/src/compat.js'])
|
||||
|
||||
function* files(dir) {
|
||||
for (const name of readdirSync(dir)) {
|
||||
const p = path.join(dir, name)
|
||||
if (statSync(p).isDirectory()) yield* files(p)
|
||||
else if (/\.(jsx?|mjs)$/.test(name)) yield p
|
||||
}
|
||||
}
|
||||
|
||||
const RULES = [
|
||||
[/\bparseFloat\(/, 'parseFloat'],
|
||||
[/\.replace\(\s*['"],['"]\s*,\s*['"]\.['"]\s*\)/, ".replace(',', '.')"],
|
||||
[/type=["']number["'][^>]*\bstep=(?:["']0?\.\d|\{[^}]*\b0?\.\d)/, 'type="number" with a decimal step'],
|
||||
]
|
||||
|
||||
test('typed numbers are read with parseNumber, never parseFloat or a type="number" decimal field', () => {
|
||||
const bad = []
|
||||
for (const root of ROOTS) {
|
||||
for (const file of files(path.join(CS, root))) {
|
||||
const rel = path.relative(CS, file).replace(/\\/g, '/')
|
||||
if (SKIP.has(rel)) continue
|
||||
const text = readFileSync(file, 'utf8')
|
||||
// a JSX element can span lines: look at each tag as one piece
|
||||
const flat = text.replace(/<input\b[^>]*>/gs, m => m.replace(/\s+/g, ' '))
|
||||
flat.split('\n').forEach((line, i) => {
|
||||
for (const [re, what] of RULES) if (re.test(line)) bad.push(`${rel}:${i + 1} ${what}`)
|
||||
})
|
||||
}
|
||||
}
|
||||
assert.deepEqual(bad, [])
|
||||
})
|
||||
@@ -167,6 +167,7 @@ const CORNER = {
|
||||
'bottom-right': { bottom: cq(3), right: cq(3), alignItems: 'flex-end' },
|
||||
}
|
||||
const SELF = { left: 'flex-start', center: 'center', right: 'flex-end' }
|
||||
const GRID = { left: 'start', center: 'center', right: 'end' } // a grid's items, by the widget's alignment
|
||||
const placedBy = w => (w.position === 'custom' && w.box ? (TIGHT.includes(w.kind) ? 'tight' : true) : false)
|
||||
const VSELF = { top: 'flex-start', middle: 'center', bottom: 'flex-end', auto: 'center' }
|
||||
/** A widget's own colour and the plate behind it (owner review 5); `pad`: a plate that hugs it. */
|
||||
@@ -265,7 +266,7 @@ export function Widgets({ widgets, media, venue, now, colour, extras, embed }) {
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const own = w.align && w.align !== 'auto' ? { alignItems: SELF[w.align], textAlign: w.align } : {}
|
||||
const own = w.align && w.align !== 'auto' ? { alignItems: SELF[w.align], textAlign: w.align } : { textAlign: widgetAlign(w) }
|
||||
return (
|
||||
<div key={i} data-widget={i} ref={animate(w)} className="absolute" style={{ ...CORNER[w.position], ...own, display: 'flex', flexDirection: 'column', color: colour || '#fff', ...plate(w, true), ...fx(w, CORNER[w.position].transform) }}>
|
||||
{body}
|
||||
@@ -283,9 +284,10 @@ const OBJECT_POSITION = { left: 'left center', center: 'center', right: 'right c
|
||||
* the slide at size medium); `fit`: the widget fills its place instead (fitUnit: a stack's part);
|
||||
* fit 'tight' (owner review 6): placed by hand, its box is exactly its content: the box's height
|
||||
* (× its text size) sets the size and its width follows. `path`: the widget's place in the slide
|
||||
* ("2", "2.1.0" inside a stack), for its extras.
|
||||
* ("2", "2.1.0" inside a stack), for its extras. `align`: how its lines line up with each other (owner
|
||||
* 2026-11-23: the lines of a text, the rows of the hours or contact details, the weather's parts…).
|
||||
*/
|
||||
function widgetBody(w, ctx, fit, path) {
|
||||
function widgetBody(w, ctx, fit, path, align = widgetAlign(w)) {
|
||||
const { media, venue, now, fmt, extras } = ctx
|
||||
const { formatDate, formatTime } = fmt
|
||||
const x = extras[path] || {}
|
||||
@@ -300,10 +302,12 @@ function widgetBody(w, ctx, fit, path) {
|
||||
}
|
||||
const text = (u, size, weight = 700) => ({ fontSize: u(size), fontWeight: w.weight || (w.bold === false ? 400 : w.bold ? Math.max(weight, 800) : weight), lineHeight: 1.15,
|
||||
...(w.highlight ? { background: w.highlight, padding: '0.05em 0.25em', borderRadius: '0.15em', boxDecorationBreak: 'clone', WebkitBoxDecorationBreak: 'clone' } : {}),
|
||||
textShadow: w.background_colour ? undefined : `0 ${cq(0.2)} ${cq(0.8)} rgba(0,0,0,0.35)`, whiteSpace: fit ? 'nowrap' : undefined,
|
||||
textShadow: w.background_colour ? undefined : `0 ${cq(0.2)} ${cq(0.8)} rgba(0,0,0,0.35)`, whiteSpace: fit ? 'pre' : 'pre-line',
|
||||
...(w.font ? { fontFamily: FONTS[w.font] } : {}), ...(w.italic ? { fontStyle: 'italic' } : {}), ...(w.underline ? { textDecoration: 'underline' } : {}) })
|
||||
// a text of several lines (Enter, owner 2026-11-23): sized by its longest line and how many there are
|
||||
const line = (str, testid, weight) => {
|
||||
const u = unit(3.4 * 1.15, textWidth(str.length, 3.4))
|
||||
const rows = str.split('\n')
|
||||
const u = unit(3.4 * 1.15 * rows.length, textWidth(Math.max(...rows.map(r => r.length)), 3.4))
|
||||
return <span style={text(u, 3.4, weight)} data-testid={testid}>{w.text_effect === 'typewriter' ? <TypeText text={str} /> : str}</span>
|
||||
}
|
||||
// a menu or a stack fills a box: its own, or (in a corner / bar) one of a usual size
|
||||
@@ -353,7 +357,7 @@ function widgetBody(w, ctx, fit, path) {
|
||||
const caption = w.qr_caption ? 2.4 * 1.15 + 0.8 : 0
|
||||
const u = unit(16 + caption, Math.max(16, w.qr_caption ? textWidth(w.qr_caption.length, 2.4) : 0))
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: u(0.8) }} data-testid="signage-w-qr" data-link={link}>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: SELF[align], textAlign: align, gap: u(0.8) }} data-testid="signage-w-qr" data-link={link}>
|
||||
<div style={{ background: w.qr_background || '#fff', padding: u(1), borderRadius: u(1), lineHeight: 0 }}>
|
||||
<QRCodeSVG value={link} size={256} fgColor={w.qr_colour || '#000000'} bgColor={w.qr_background || '#ffffff'} style={{ width: u(14), height: u(14) }}
|
||||
level={logo ? 'H' : 'M'} imageSettings={logo ? { src: logo.src, width: 64, height: 64, excavate: true } : undefined} />
|
||||
@@ -362,7 +366,7 @@ function widgetBody(w, ctx, fit, path) {
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (w.kind === 'weather') return weatherBody(w, venue?.weather, unit, text, formatDate, ctx.t)
|
||||
if (w.kind === 'weather') return weatherBody(w, venue?.weather, unit, text, formatDate, ctx.t, align)
|
||||
if (w.kind === 'menu') return boxed(<MenuWidget board={w.board || {}} menu={x.menu} now={now} badges={venue?.badges} />, 'menu')
|
||||
if (w.kind === 'stack') return boxed(<Stack w={w} path={path} ctx={ctx} />, 'stack')
|
||||
// 6R.15
|
||||
@@ -382,26 +386,26 @@ function widgetBody(w, ctx, fit, path) {
|
||||
const label = w.text || ''
|
||||
const u = unit((label ? 2.4 * 1.15 + 0.4 : 0) + 6 * 1.1, Math.max(textWidth(digits.length, 6) * 0.9, label ? textWidth(label.length, 2.4) : 0))
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'inherit', gap: u(0.4) }} data-testid="signage-w-countdown" data-state={st.state} data-left={st.left}>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: SELF[align], textAlign: align, gap: u(0.4) }} data-testid="signage-w-countdown" data-state={st.state} data-left={st.left}>
|
||||
{label && <span style={text(u, 2.4, 600)}>{label}</span>}
|
||||
<span style={{ ...text(u, 6, 800), lineHeight: 1.1, fontVariantNumeric: 'tabular-nums' }}>{digits}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (w.kind === 'hours') return hoursBody(w, ctx, unit, text)
|
||||
if (w.kind === 'wifi') return wifiBody(w, venue?.identity?.wifi, unit, text)
|
||||
if (w.kind === 'contact') return contactBody(w, venue?.identity?.contact, unit, text)
|
||||
if (w.kind === 'hours') return hoursBody(w, ctx, unit, text, align)
|
||||
if (w.kind === 'wifi') return wifiBody(w, venue?.identity?.wifi, unit, text, align)
|
||||
if (w.kind === 'contact') return contactBody(w, venue?.identity?.contact, unit, text, align)
|
||||
if (w.kind === 'gallery') {
|
||||
const ids = w.gallery_source === 'folder' ? (x.gallery || []) : (w.media_ids || [])
|
||||
const items = ids.map(id => media(id)).filter(Boolean)
|
||||
if (!items.length) return null
|
||||
return boxed(<Gallery w={w} items={items} now={now} />, 'gallery')
|
||||
return boxed(<Gallery w={w} items={items} now={now} title={w.text ? text(n => cq(+(n * ts).toFixed(3), 'h'), 9, 700) : null} align={align} />, 'gallery')
|
||||
}
|
||||
if (w.kind === 'reviews') {
|
||||
const list = (venue?.reviews || []).filter(r => r.stars >= (w.reviews_min || 4))
|
||||
if (!list.length) return null
|
||||
const r = list[pageAt(list.length, w.reviews_seconds || 8, now.getTime())]
|
||||
return boxed(<ReviewBody w={w} r={r} fmt={fmt} n={list.length} />, 'reviews')
|
||||
return boxed(<ReviewBody w={w} r={r} fmt={fmt} n={list.length} align={align} />, 'reviews')
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -440,8 +444,11 @@ const GALLERY_IN = {
|
||||
zoom: [{ opacity: 0, transform: 'scale(1.12)' }, { opacity: 1, transform: 'scale(1)' }],
|
||||
}
|
||||
|
||||
/** A gallery (6R.16): its pictures and videos one after another, each for its seconds, coming in with its transition. */
|
||||
function Gallery({ w, items, now }) {
|
||||
/**
|
||||
* A gallery (6R.16): its pictures and videos one after another, each for its seconds, coming in with
|
||||
* its transition; its title above or below them (owner 2026-11-23), `title` = the title's text style.
|
||||
*/
|
||||
function Gallery({ w, items, now, title, align }) {
|
||||
const i = pageAt(items.length, w.gallery_seconds || 5, now.getTime())
|
||||
const m = items[i]
|
||||
const el = useRef(null)
|
||||
@@ -453,11 +460,15 @@ function Gallery({ w, items, now }) {
|
||||
}, [i, frames])
|
||||
const fit = { width: '100%', height: '100%', objectFit: w.gallery_fit || 'cover', display: 'block' }
|
||||
return (
|
||||
<div style={{ width: '100%', height: '100%', overflow: 'hidden', position: 'relative' }} data-testid="signage-w-gallery" data-index={i} data-count={items.length}>
|
||||
<div key={`${i}-${m.src}`} ref={el} style={{ position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 }}>
|
||||
{m.kind === 'video'
|
||||
? <video src={m.src} poster={m.poster} muted autoPlay loop playsInline style={fit} />
|
||||
: <img src={m.src} alt="" style={fit} />}
|
||||
<div style={{ width: '100%', height: '100%', display: 'flex', flexDirection: w.title_position === 'below' ? 'column-reverse' : 'column', gap: title ? '2%' : 0 }}
|
||||
data-testid="signage-w-gallery" data-index={i} data-count={items.length}>
|
||||
{title && <div style={{ ...title, flexShrink: 0, textAlign: align, overflow: 'hidden', textOverflow: 'ellipsis' }} data-testid="signage-w-gallery-title">{w.text}</div>}
|
||||
<div style={{ flex: '1 1 0%', minHeight: 0, overflow: 'hidden', position: 'relative' }}>
|
||||
<div key={`${i}-${m.src}`} ref={el} style={{ position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 }}>
|
||||
{m.kind === 'video'
|
||||
? <video src={m.src} poster={m.poster} muted autoPlay loop playsInline style={fit} />
|
||||
: <img src={m.src} alt="" style={fit} />}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
@@ -467,7 +478,7 @@ function Gallery({ w, items, now }) {
|
||||
* One of the venue's reviews (6R.19), the next one every few seconds: its stars, what they wrote,
|
||||
* who and where. It fills its place: the text is sized from the place's size and the review's length.
|
||||
*/
|
||||
function ReviewBody({ w, r, fmt, n }) {
|
||||
function ReviewBody({ w, r, fmt, n, align }) {
|
||||
const box = useRef(null)
|
||||
const [size, setSize] = useState(null)
|
||||
useEffect(() => {
|
||||
@@ -483,15 +494,17 @@ function ReviewBody({ w, r, fmt, n }) {
|
||||
const who = [w.reviews_name !== false && r.name, r.source, r.date && fmt.formatDate(`${r.date}T12:00:00Z`, 'date')].filter(Boolean).join(' · ')
|
||||
const font = { ...(w.font ? { fontFamily: FONTS[w.font] } : {}), ...(w.italic ? { fontStyle: 'italic' } : {}) }
|
||||
return (
|
||||
<div ref={box} style={{ width: '100%', height: '100%', overflow: 'hidden', display: 'flex', flexDirection: 'column', justifyContent: 'center', gap: f * 0.35, ...font }}
|
||||
<div ref={box} style={{ width: '100%', height: '100%', overflow: 'hidden', display: 'flex', flexDirection: 'column', justifyContent: 'center', textAlign: align, gap: f * 0.35, ...font }}
|
||||
data-testid="signage-w-reviews" data-count={n} data-name={r.name}>
|
||||
{size && <>
|
||||
{w.reviews_stars !== false && (
|
||||
<div style={{ display: 'flex', gap: f * 0.15, justifyContent: 'inherit' }} aria-label={`${r.stars}/5`}>
|
||||
<div style={{ display: 'flex', gap: f * 0.15, justifyContent: SELF[align] }} aria-label={`${r.stars}/5`}>
|
||||
{[1, 2, 3, 4, 5].map(i => <Star key={i} style={{ width: f * 1.1, height: f * 1.1, color: STAR, fill: i <= r.stars ? STAR : 'none', opacity: i <= r.stars ? 1 : 0.4 }} aria-hidden="true" />)}
|
||||
</div>
|
||||
)}
|
||||
<div style={{ fontSize: f, lineHeight: 1.35, fontWeight: w.bold ? 700 : 500, ...(w.underline ? { textDecoration: 'underline' } : {}) }}>“{r.text}”</div>
|
||||
<div style={{ fontSize: f, lineHeight: 1.35, fontWeight: w.weight || (w.bold ? 700 : 500), ...(w.underline ? { textDecoration: 'underline' } : {}) }}>
|
||||
<span style={w.highlight ? { background: w.highlight, padding: '0.05em 0.25em', borderRadius: '0.15em', boxDecorationBreak: 'clone', WebkitBoxDecorationBreak: 'clone' } : undefined}>“{r.text}”</span>
|
||||
</div>
|
||||
{who && <div style={{ fontSize: f * 0.72, fontWeight: 700, opacity: 0.85 }}>— {who}</div>}
|
||||
</>}
|
||||
</div>
|
||||
@@ -563,7 +576,7 @@ const MONDAY = '2026-11-16' // a Monday: day names from the venue'
|
||||
const dayShort = (fmt, i) => fmt.formatDate(`2026-11-${16 + i}T12:00:00Z`, 'weekday').slice(0, 3)
|
||||
|
||||
/** The opening hours (6R.15): the week (days with the same hours on one line) or today; today stands out. */
|
||||
function hoursBody(w, ctx, unit, text) {
|
||||
function hoursBody(w, ctx, unit, text, align = 'left') {
|
||||
const { venue, now, fmt, t } = ctx
|
||||
const hours = venue?.hours
|
||||
if (!hours?.set) return null
|
||||
@@ -573,14 +586,15 @@ function hoursBody(w, ctx, unit, text) {
|
||||
const spansText = r => (r.spans.length ? r.spans.map(x => `${x.from}–${x.to}`).join(', ') : t('signage.closed'))
|
||||
const widest = Math.max(...rows.map(r => daysText(r).length + 2 + spansText(r).length), w.text ? w.text.length : 0)
|
||||
const u = unit((rows.length + (w.text ? 1.3 : 0)) * 3 * 1.35, textWidth(widest, 3))
|
||||
// lined up (owner 2026-11-23): left / right: both columns to that side; centre: they meet in the middle
|
||||
return (
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'auto auto', columnGap: u(2), rowGap: u(0.4), alignItems: 'baseline', textAlign: 'left' }}
|
||||
data-testid="signage-w-hours" data-rows={rows.length} data-start={MONDAY}>
|
||||
{w.text && <span style={{ ...text(u, 3.4, 800), gridColumn: '1 / -1' }}>{w.text}</span>}
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'auto auto', columnGap: u(2), rowGap: u(0.4), alignItems: 'baseline' }}
|
||||
data-testid="signage-w-hours" data-rows={rows.length} data-start={MONDAY} data-align={align}>
|
||||
{w.text && <span style={{ ...text(u, 3.4, 800), gridColumn: '1 / -1', textAlign: align }}>{w.text}</span>}
|
||||
{rows.map(r => (
|
||||
<span key={r.days.join()} style={{ display: 'contents' }} data-today={r.today ? 'true' : undefined}>
|
||||
<span style={{ ...text(u, 3, r.today ? 800 : 600), opacity: r.today || w.hours_style === 'today' ? 1 : 0.85 }}>{daysText(r)}</span>
|
||||
<span style={{ ...text(u, 3, r.today ? 800 : 500), fontVariantNumeric: 'tabular-nums' }}>{spansText(r)}</span>
|
||||
<span style={{ ...text(u, 3, r.today ? 800 : 600), opacity: r.today || w.hours_style === 'today' ? 1 : 0.85, textAlign: align === 'left' ? 'left' : 'right' }}>{daysText(r)}</span>
|
||||
<span style={{ ...text(u, 3, r.today ? 800 : 500), fontVariantNumeric: 'tabular-nums', textAlign: align === 'right' ? 'right' : 'left' }}>{spansText(r)}</span>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
@@ -588,24 +602,29 @@ function hoursBody(w, ctx, unit, text) {
|
||||
}
|
||||
|
||||
/** The guests' Wi-Fi (6R.15, from the identity): its code to join, the network and the password. */
|
||||
function wifiBody(w, wifi, unit, text) {
|
||||
function wifiBody(w, wifi, unit, text, align = 'left') {
|
||||
if (!wifi?.ssid) return null
|
||||
const qr = w.wifi_qr !== false ? wifiQr(wifi) : ''
|
||||
const pw = w.wifi_password !== false && wifi.security !== 'nopass' && wifi.password ? wifi.password : ''
|
||||
const lines = [wifi.ssid, pw, wifi.note].filter(Boolean)
|
||||
const chars = Math.max(...lines.map(l => l.length)) + 2
|
||||
const u = unit(Math.max(qr ? 13 : 0, lines.length * 3.4 * 1.35), (qr ? 14.5 : 0) + textWidth(chars, 3.4))
|
||||
// the code on the left (left), on the right (right), above the text (centre: owner 2026-11-23)
|
||||
const stacked = align === 'center' && qr
|
||||
const u = stacked ? unit(13 + 1.5 + lines.length * 3.4 * 1.35, Math.max(13, textWidth(chars, 3.4)))
|
||||
: unit(Math.max(qr ? 13 : 0, lines.length * 3.4 * 1.35), (qr ? 14.5 : 0) + textWidth(chars, 3.4))
|
||||
const icon = { width: u(3), height: u(3), flexShrink: 0 }
|
||||
const row = { display: 'flex', alignItems: 'center', gap: u(0.8), justifyContent: SELF[align] }
|
||||
return (
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: u(1.5), textAlign: 'left' }} data-testid="signage-w-wifi">
|
||||
<div style={{ display: 'flex', flexDirection: stacked ? 'column' : align === 'right' ? 'row-reverse' : 'row', alignItems: 'center', gap: u(1.5), textAlign: align }}
|
||||
data-testid="signage-w-wifi" data-align={align}>
|
||||
{qr && (
|
||||
<div style={{ background: w.qr_background || '#fff', padding: u(0.7), borderRadius: u(0.8), lineHeight: 0 }}>
|
||||
<QRCodeSVG value={qr} size={256} fgColor={w.qr_colour || '#000000'} bgColor={w.qr_background || '#ffffff'} style={{ width: u(11.5), height: u(11.5) }} />
|
||||
</div>
|
||||
)}
|
||||
<div style={{ display: 'grid', gap: u(0.5) }}>
|
||||
<span style={{ display: 'flex', alignItems: 'center', gap: u(0.8), ...text(u, 3.4, 800) }}><Wifi style={icon} aria-hidden="true" />{wifi.ssid}</span>
|
||||
{pw && <span style={{ display: 'flex', alignItems: 'center', gap: u(0.8), ...text(u, 3.4, 600) }}><Lock style={icon} aria-hidden="true" />{pw}</span>}
|
||||
<div style={{ display: 'grid', gap: u(0.5), justifyItems: GRID[align] }}>
|
||||
<span style={{ ...row, ...text(u, 3.4, 800) }}><Wifi style={icon} aria-hidden="true" />{wifi.ssid}</span>
|
||||
{pw && <span style={{ ...row, ...text(u, 3.4, 600) }}><Lock style={icon} aria-hidden="true" />{pw}</span>}
|
||||
{wifi.note && <span style={{ ...text(u, 2.6, 500), opacity: 0.85 }}>{wifi.note}</span>}
|
||||
</div>
|
||||
</div>
|
||||
@@ -616,12 +635,12 @@ const CONTACT_ICONS = { phone: Phone, phone2: Phone, email: Mail, address: MapPi
|
||||
instagram: Camera, tiktok: Music, tripadvisor: Star, whatsapp: MessageCircle, viber: MessageCircle }
|
||||
|
||||
/** The venue's contact details (6R.15, from the identity): the chosen ones that are set, one a line with an icon. */
|
||||
function contactBody(w, contact, unit, text) {
|
||||
function contactBody(w, contact, unit, text, align = 'left') {
|
||||
const rows = (w.contact_fields || ['phone', 'website', 'instagram']).filter(k => contact?.[k]).map(k => [k, contact[k]])
|
||||
if (!rows.length) return null
|
||||
const u = unit(rows.length * 3.2 * 1.4, textWidth(Math.max(...rows.map(([, v]) => v.length)) + 2, 3.2))
|
||||
return (
|
||||
<div style={{ display: 'grid', gap: u(0.6), textAlign: 'left' }} data-testid="signage-w-contact" data-rows={rows.length}>
|
||||
<div style={{ display: 'grid', gap: u(0.6), justifyItems: GRID[align], textAlign: align }} data-testid="signage-w-contact" data-rows={rows.length} data-align={align}>
|
||||
{rows.map(([k, v]) => {
|
||||
const Icon = CONTACT_ICONS[k] || Globe
|
||||
return (
|
||||
@@ -640,7 +659,7 @@ function contactBody(w, contact, unit, text) {
|
||||
* next hours; with the details chosen (feels like, humidity, wind, rain chance, sunrise / sunset,
|
||||
* UV, in words) and the place's name. Older forecasts without the details just leave them out.
|
||||
*/
|
||||
function weatherBody(w, wx, unit, text, formatDate, t) {
|
||||
function weatherBody(w, wx, unit, text, formatDate, t, align = 'left') {
|
||||
if (!wx || wx.temperature == null) return null // no internet / no place: hidden (5.4c)
|
||||
const from = w.weather_from || 0
|
||||
const style = w.weather_style || 'both'
|
||||
@@ -678,7 +697,7 @@ function weatherBody(w, wx, unit, text, formatDate, t) {
|
||||
if (!hours.length) return null
|
||||
const u = unit((place ? 3.2 : 0) + 3 + 5 + 3.6, hours.length * 9)
|
||||
return (
|
||||
<div style={{ display: 'grid', gap: u(0.6) }} data-testid="signage-w-weather" data-layout="hourly">
|
||||
<div style={{ display: 'grid', gap: u(0.6), justifyItems: GRID[align] }} data-testid="signage-w-weather" data-layout="hourly">
|
||||
{place && <span style={text(u, 2.6, 700)}>{place}</span>}
|
||||
<div style={{ display: 'flex', gap: u(1.5) }}>
|
||||
{hours.map(h => {
|
||||
@@ -699,7 +718,7 @@ function weatherBody(w, wx, unit, text, formatDate, t) {
|
||||
const list = days.slice(from, from + (w.weather_days || 3))
|
||||
const u = unit((place ? 3.4 : 0) + list.length * 4.4, tw(4, 3) + 5 + tw(11, 3) + (want.has('rain') ? tw(5, 3) : 0) + 4)
|
||||
return (
|
||||
<div style={{ display: 'grid', gap: u(0.5) }} data-testid="signage-w-weather" data-layout="list">
|
||||
<div style={{ display: 'grid', gap: u(0.5), justifyItems: GRID[align] }} data-testid="signage-w-weather" data-layout="list">
|
||||
{place && <span style={text(u, 2.8, 700)}>{place}</span>}
|
||||
<div style={{ display: 'grid', gridTemplateColumns: `auto auto auto${want.has('rain') ? ' auto' : ''}`, columnGap: u(1.6), rowGap: u(0.6), alignItems: 'center' }}>
|
||||
{list.map((d, n) => {
|
||||
@@ -737,7 +756,7 @@ function weatherBody(w, wx, unit, text, formatDate, t) {
|
||||
const width = Math.max((pic ? 9 : 0) + (deg ? tw(main.label.length, 6) : 0), card ? detailW * 2 * 2.4 * 0.6 + 3 : tw(detailW, 2.6), tw(16, 2.4), place ? tw(place.length, 2.8) : 0)
|
||||
const u = unit(lines * 4.2 + 3, width + 2)
|
||||
return (
|
||||
<div style={{ display: 'grid', gap: u(0.8), justifyItems: 'inherit', ...(card ? { padding: u(1.5), borderRadius: u(1.5), background: w.background_colour ? undefined : 'rgba(0,0,0,0.28)' } : {}) }}
|
||||
<div style={{ display: 'grid', gap: u(0.8), justifyItems: GRID[align], textAlign: align, ...(card ? { padding: u(1.5), borderRadius: u(1.5), background: w.background_colour ? undefined : 'rgba(0,0,0,0.28)' } : {}) }}
|
||||
data-testid="signage-w-weather" data-layout={layout} data-style={style} data-from={from}>
|
||||
{place && <span style={{ ...text(u, 2.8, 700), opacity: 0.9 }}>{place}</span>}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: u(1.5) }}>
|
||||
@@ -746,11 +765,11 @@ function weatherBody(w, wx, unit, text, formatDate, t) {
|
||||
</div>
|
||||
{words && <span style={{ ...text(u, 2.8, 600), opacity: 0.9 }} data-testid="signage-weather-words">{words}</span>}
|
||||
{details.length > 0 && (
|
||||
<div style={{ display: 'grid', gridTemplateColumns: card ? 'auto auto' : 'auto', columnGap: u(2), rowGap: u(0.5) }}>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: card ? 'auto auto' : 'auto', columnGap: u(2), rowGap: u(0.5), justifyItems: GRID[align] }}>
|
||||
{detailEls({ u, s: 2.6 }, u(0.6))}
|
||||
</div>
|
||||
)}
|
||||
{rest.length > 0 && <div style={{ display: card ? 'flex' : 'grid', gap: u(card ? 1.6 : 0.4), flexWrap: 'wrap' }}>{restEls(u, 2.4)}</div>}
|
||||
{rest.length > 0 && <div style={{ display: card ? 'flex' : 'grid', gap: u(card ? 1.6 : 0.4), flexWrap: 'wrap', justifyContent: SELF[align], justifyItems: GRID[align] }}>{restEls(u, 2.4)}</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -820,7 +839,7 @@ function Stack({ w, path, ctx }) {
|
||||
const wp = `${cp}.${k}`
|
||||
const own = cw.position === 'custom' && cw.box
|
||||
const align = cw.align && cw.align !== 'auto' ? cw.align : 'center'
|
||||
const body = widgetBody(cw, ctx, own && TIGHT.includes(cw.kind) ? 'tight' : true, wp)
|
||||
const body = widgetBody(cw, ctx, own && TIGHT.includes(cw.kind) ? 'tight' : true, wp, align)
|
||||
return (
|
||||
<div key={k} style={{ flex: '1 1 0%', minWidth: 0, minHeight: 0, overflow: 'hidden', containerType: 'size', position: 'relative',
|
||||
...(own ? {} : { display: 'flex', alignItems: VSELF[cw.vertical] || 'center', justifyContent: SELF[align], textAlign: align }) }}
|
||||
|
||||
@@ -481,10 +481,11 @@ export function fitBox(W, H, ratio) {
|
||||
|
||||
/** A screen's picture area in its window: the window minus the calibrated insets (never smaller than 50 px). */
|
||||
export function pictureArea(win, area = {}) {
|
||||
const l = Math.max(0, area.left || 0)
|
||||
const t = Math.max(0, area.top || 0)
|
||||
const width = Math.max(50, win.w - l - Math.max(0, area.right || 0))
|
||||
const height = Math.max(50, win.h - t - Math.max(0, area.bottom || 0))
|
||||
// below 0 an edge reaches past the window the TV reported (owner 2026-11-23): that part is cut off
|
||||
const l = area.left || 0
|
||||
const t = area.top || 0
|
||||
const width = Math.max(50, win.w - l - (area.right || 0))
|
||||
const height = Math.max(50, win.h - t - (area.bottom || 0))
|
||||
return { left: l, top: t, width, height }
|
||||
}
|
||||
|
||||
|
||||
@@ -264,6 +264,8 @@ test('slide shapes: custom ratios, the canvas, the box a slide keeps on any scre
|
||||
assert.deepEqual([c.left, c.top, c.width, c.height], [0, 60, 1920, 1080])
|
||||
// calibration: the window minus the insets; the presets centre a shape
|
||||
assert.deepEqual(pictureArea({ w: 1920, h: 1080 }, { left: 10, top: 0, right: 30, bottom: 20 }), { left: 10, top: 0, width: 1880, height: 1060 })
|
||||
// below 0 an edge reaches past the window the TV reported (owner 2026-11-23)
|
||||
assert.deepEqual(pictureArea({ w: 1920, h: 1080 }, { left: -40, top: -10, right: -40, bottom: 0 }), { left: -40, top: -10, width: 2000, height: 1090 })
|
||||
assert.deepEqual(presetInsets({ w: 2560, h: 1080 }, '16:9'), { left: 320, top: 0, right: 320, bottom: 0 })
|
||||
assert.deepEqual(presetInsets({ w: 1920, h: 1080 }, 'full'), { left: 0, top: 0, right: 0, bottom: 0 })
|
||||
assert.equal(shapeName(2560, 1080), '21:9')
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
"test": "node --test \"tests/*.test.mjs\""
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@xenia/i18n": "*",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0",
|
||||
"qrcode.react": "^4.2.0"
|
||||
|
||||
@@ -409,6 +409,11 @@
|
||||
.x-page--fit .x-page__body > * { flex-shrink: 0; }
|
||||
.x-page--fit .x-page__body > .x-page__fill { flex: 1 1 0; min-height: 0; grid-template-rows: minmax(0, 1fr); align-items: stretch; }
|
||||
}
|
||||
/* cards in columns (6F.0): settings and forms on a full-width page */
|
||||
.x-columns { columns: var(--x-columns-min, 34rem); column-gap: var(--x-page-gap); }
|
||||
.x-columns > * { break-inside: avoid; margin-bottom: var(--x-page-gap); }
|
||||
.x-columns > *:last-child { margin-bottom: 0; }
|
||||
.x-columns > .x-columns__wide { column-span: all; }
|
||||
.x-page-header { display: flex; flex-wrap: wrap; align-items: center; gap: var(--x-space-3); }
|
||||
.x-page-header__titles { flex: 1; min-width: 0; }
|
||||
.x-page-header__title { margin: 0; display: flex; align-items: center; gap: var(--x-space-1); font-size: var(--x-text-title); line-height: var(--x-leading-title); font-weight: var(--x-weight-semibold); color: var(--x-ink); }
|
||||
@@ -496,6 +501,9 @@
|
||||
font: inherit; font-size: var(--x-text-body); text-align: center; font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.x-number__suffix { align-self: center; padding-right: var(--x-space-1); color: var(--x-ink-3); font-size: var(--x-text-label); }
|
||||
/* DecimalInput / MoneyInput (6F.2): the number frame without − / +, text from the left */
|
||||
.x-decimal__input { text-align: left; padding: 0 var(--x-space-3); }
|
||||
.x-decimal__suffix { padding-right: var(--x-space-3); }
|
||||
|
||||
/* ── Slider (2026-11-21): framed like a field, its value beside it ──────────────── */
|
||||
.x-slider {
|
||||
@@ -641,8 +649,8 @@
|
||||
/* ── Tabs ────────────────────────────────────────────────────────────────── */
|
||||
.x-tabs { display: flex; align-items: center; gap: var(--x-space-2); box-shadow: inset 0 calc(-1 * var(--x-border-width)) 0 var(--x-line); }
|
||||
.x-page__top .x-tabs { box-shadow: none; }
|
||||
.x-tabs__list { flex: 1; min-width: 0; display: flex; gap: var(--x-space-1); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
|
||||
.x-tabs__list::-webkit-scrollbar { display: none; }
|
||||
/* tabs that don't fit wrap onto another row: never hidden in a sideways scroll (6F.0, 2026-11-23) */
|
||||
.x-tabs__list { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: var(--x-space-1); }
|
||||
.x-tabs__tab {
|
||||
display: inline-flex; align-items: center; gap: var(--x-space-1-5); flex-shrink: 0;
|
||||
padding: var(--x-space-2-5) var(--x-space-3); border: 0; background: transparent;
|
||||
|
||||
@@ -67,7 +67,7 @@ export function Segmented({ options = [], value, onChange, size = 'md', fill = f
|
||||
}
|
||||
|
||||
/**
|
||||
* Tabs with an underline: a page's or a dialog's sections. Scrolls sideways when they don't fit,
|
||||
* Tabs with an underline: a page's or a dialog's sections. Tabs that don't fit wrap onto another row (6F.0),
|
||||
* never up and down. tabs: [{ id, label, badge?, warn?, testId? }].
|
||||
* <Tabs tabs={tabs} value={tab} onChange={setTab} />
|
||||
* end: an element at the right end of the strip (a refresh button…).
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { cx } from '../internal/cx.js'
|
||||
import { readDecimal } from './decimal.js'
|
||||
|
||||
const shown = v => (v == null || Number.isNaN(v) ? '' : String(v))
|
||||
|
||||
/**
|
||||
* A number with decimals typed with a comma or a dot (owner 2026-11-23, plan 6F.2): "12,50",
|
||||
* "12.50" and "1.234,50" all work, on every keyboard (a phone's Greek keypad has only a comma).
|
||||
* The field keeps what is being typed ("12," on the way to "12,50") and reports a number:
|
||||
* onChange(number) a number onChange(null) empty onChange(NaN) not a number (show an error)
|
||||
* Never `type="number"` + parseFloat for money or quantities: those read "12,50" as 12 or nothing.
|
||||
*
|
||||
* <DecimalInput value={kg} onChange={setKg} decimals={3} suffix="kg" />
|
||||
* decimals: rounds what is reported; allowNegative (default false); suffix: shown at the end.
|
||||
*/
|
||||
export function DecimalInput({ value, onChange, decimals, allowNegative = false, suffix, size = 'md', invalid = false, disabled = false, className, inputClassName, ...rest }) {
|
||||
const [text, setText] = useState(() => shown(value))
|
||||
const [focus, setFocus] = useState(false)
|
||||
const reported = useRef(value)
|
||||
// a value set from outside (a reset, − / + elsewhere) replaces the text; our own report doesn't
|
||||
useEffect(() => {
|
||||
if (Object.is(value, reported.current)) return
|
||||
reported.current = value
|
||||
setText(shown(value))
|
||||
}, [value])
|
||||
const bad = invalid || Number.isNaN(value)
|
||||
return (
|
||||
<span className={cx('x-number', 'x-decimal', `x-number--${size}`, bad && 'x-number--invalid', focus && 'x-number--focus', disabled && 'x-number--disabled', className)}>
|
||||
<input type="text" inputMode="decimal" autoComplete="off" className={cx('x-number__input', 'x-decimal__input', inputClassName)} value={text} disabled={disabled}
|
||||
aria-invalid={bad || undefined}
|
||||
onChange={e => {
|
||||
const s = e.target.value
|
||||
setText(s)
|
||||
const out = readDecimal(s, { decimals, allowNegative })
|
||||
reported.current = out
|
||||
onChange?.(out, s)
|
||||
}}
|
||||
onFocus={e => { setFocus(true); e.target.select() }}
|
||||
onBlur={() => setFocus(false)}
|
||||
{...rest} />
|
||||
{suffix && <span className="x-number__suffix x-decimal__suffix" aria-hidden="true">{suffix}</span>}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
/** An amount of money: DecimalInput with cents and "€" (6F.2). */
|
||||
export function MoneyInput({ suffix = '€', ...rest }) {
|
||||
return <DecimalInput decimals={2} suffix={suffix} {...rest} />
|
||||
}
|
||||
@@ -5,11 +5,17 @@ import { useLabels } from './labels.js'
|
||||
|
||||
const GAP = 8
|
||||
const MARGIN = 8
|
||||
/** How long the pointer rests on the "i" before its tip opens (owner 2026-11-23, plan 6F.1a).
|
||||
* A click or a tap opens it at once. */
|
||||
export const INFOTIP_HOVER_MS = 1500
|
||||
|
||||
/**
|
||||
* The "(i)" help tip next to a setting or label (D-12: every manager page gets them).
|
||||
* Opens while the pointer rests on it (2026-11-20) and on click/tap (touch screens: a tap keeps
|
||||
* it open), closes on Escape, a click outside, a second click or the pointer leaving. Placed above the button, or below when there's no room.
|
||||
* Opens when the pointer has rested on it for 1.5 s (INFOTIP_HOVER_MS; leaving earlier cancels it), and
|
||||
* at once on click / tap (it then stays open: touch screens). Closes on Escape, a click outside, a
|
||||
* second click, or the pointer leaving the "i" and the tip (a hover-opened tip). Placed above the
|
||||
* button, or below when there's no room. The same component in the manager, the waiter app and the
|
||||
* terminal (6F.1a).
|
||||
*
|
||||
* <label>Alert after failures <InfoTip>How many failed print attempts before managers are notified. 0 turns it off.</InfoTip></label>
|
||||
*
|
||||
@@ -20,11 +26,22 @@ export function InfoTip({ children, label, side = 'top', className }) {
|
||||
const [pinned, setPinned] = useState(false)
|
||||
const [hover, setHover] = useState(false)
|
||||
const leaveTimer = useRef(null)
|
||||
const enterTimer = useRef(null)
|
||||
const open = pinned || hover
|
||||
const setOpen = v => { setPinned(v); if (!v) setHover(false) }
|
||||
const enter = () => { clearTimeout(leaveTimer.current); setHover(true) }
|
||||
const leave = () => { clearTimeout(leaveTimer.current); leaveTimer.current = setTimeout(() => setHover(false), 120) }
|
||||
useEffect(() => () => clearTimeout(leaveTimer.current), [])
|
||||
const setOpen = v => { clearTimeout(enterTimer.current); setPinned(v); if (!v) setHover(false) }
|
||||
// the pointer on the "i": open after the delay; on the open tip: keep it open
|
||||
const enter = () => {
|
||||
clearTimeout(leaveTimer.current)
|
||||
if (hover) return
|
||||
clearTimeout(enterTimer.current)
|
||||
enterTimer.current = setTimeout(() => setHover(true), INFOTIP_HOVER_MS)
|
||||
}
|
||||
const stay = () => clearTimeout(leaveTimer.current)
|
||||
const leave = () => {
|
||||
clearTimeout(enterTimer.current); clearTimeout(leaveTimer.current)
|
||||
leaveTimer.current = setTimeout(() => setHover(false), 120)
|
||||
}
|
||||
useEffect(() => () => { clearTimeout(leaveTimer.current); clearTimeout(enterTimer.current) }, [])
|
||||
const [pos, setPos] = useState(null)
|
||||
const button = useRef(null)
|
||||
const tip = useRef(null)
|
||||
@@ -89,7 +106,7 @@ export function InfoTip({ children, label, side = 'top', className }) {
|
||||
ref={tip}
|
||||
id={id}
|
||||
role="tooltip"
|
||||
onPointerEnter={enter}
|
||||
onPointerEnter={stay}
|
||||
onPointerLeave={leave}
|
||||
className={cx('x-infotip__popover', pos && (pos.above ? 'x-infotip__popover--above' : 'x-infotip__popover--below'))}
|
||||
style={pos ? { top: pos.top, left: pos.left, '--x-arrow-x': `${pos.arrow}px` } : { top: 0, left: 0, visibility: 'hidden' }}
|
||||
|
||||
@@ -11,11 +11,14 @@ const Icon = ({ d }) => (
|
||||
* <NumberInput value={seconds} min={1} max={3600} onChange={setSeconds} suffix="s" />
|
||||
* The field may be emptied while typing: onChange(null). The form shows its own error for an empty
|
||||
* value and keeps it from being saved. A value over `max` is brought down; under `min`, brought up
|
||||
* when the field is left. Inside a <Field> it takes the field's id.
|
||||
* when the field is left. Inside a <Field> it takes the field's id. With a `min` below 0 a minus
|
||||
* may be typed in front (2026-11-23).
|
||||
*/
|
||||
export function NumberInput({ value, onChange, min = 0, max = Infinity, step = 1, suffix, size = 'md', invalid = false, disabled = false, className, id, ...rest }) {
|
||||
const labels = useLabels()
|
||||
const [focus, setFocus] = useState(false)
|
||||
const [draft, setDraft] = useState(null) // "-" typed, no digits yet
|
||||
const signed = min < 0
|
||||
const n = value === '' || value == null ? null : Number(value)
|
||||
const clamp = v => Math.min(max, Math.max(min, v))
|
||||
const stepBy = d => onChange?.(clamp((n ?? min) + d))
|
||||
@@ -24,14 +27,16 @@ export function NumberInput({ value, onChange, min = 0, max = Infinity, step = 1
|
||||
<button type="button" className="x-number__btn" onClick={() => stepBy(-step)} disabled={disabled || (n != null && n <= min)} aria-label={labels.decrease} tabIndex={-1}>
|
||||
<Icon d="M5 12h14" />
|
||||
</button>
|
||||
<input id={id} type="text" inputMode="numeric" className="x-number__input" value={n == null ? '' : String(n)} disabled={disabled}
|
||||
<input id={id} type="text" inputMode={signed ? 'text' : 'numeric'} className="x-number__input" value={draft ?? (n == null ? '' : String(n))} disabled={disabled}
|
||||
aria-invalid={invalid || undefined}
|
||||
onChange={e => {
|
||||
const minus = signed && /^\s*-/.test(e.target.value)
|
||||
const digits = e.target.value.replace(/\D/g, '')
|
||||
onChange?.(digits === '' ? null : Math.min(max, Number(digits)))
|
||||
setDraft(minus && digits === '' ? '-' : null)
|
||||
onChange?.(digits === '' ? null : Math.min(max, (minus ? -1 : 1) * Number(digits)))
|
||||
}}
|
||||
onFocus={() => setFocus(true)}
|
||||
onBlur={() => { setFocus(false); if (n != null && n < min) onChange?.(min) }}
|
||||
onBlur={() => { setFocus(false); setDraft(null); if (n != null && n < min) onChange?.(min) }}
|
||||
onKeyDown={e => {
|
||||
if (e.key === 'ArrowUp') { e.preventDefault(); stepBy(step) }
|
||||
if (e.key === 'ArrowDown') { e.preventDefault(); stepBy(-step) }
|
||||
|
||||
@@ -75,3 +75,21 @@ export function Pane({ header, footer, sunken = false, as: Tag = 'section', clas
|
||||
</Tag>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Cards in columns (2026-11-23, plan 6F.0): a full-width page of settings or forms keeps each card
|
||||
* at a readable width. Cards flow top to bottom, then into the next column; a column is at least
|
||||
* `min` wide (default 34rem), so a 1080p screen shows two, an ultrawide three, a phone one.
|
||||
* A child with `x-columns__wide` (or wrapped in <ColumnsWide>) spans every column (a header row,
|
||||
* a wide table).
|
||||
* <Columns testId="settings-operation"><SettingsCard …/><SettingsCard …/></Columns>
|
||||
*/
|
||||
export function Columns({ min, className, testId, style, children, ...rest }) {
|
||||
return (
|
||||
<div className={cx('x-columns', className)} data-testid={testId}
|
||||
style={min ? { ...style, '--x-columns-min': min } : style} {...rest}>{children}</div>
|
||||
)
|
||||
}
|
||||
export function ColumnsWide({ className, children, ...rest }) {
|
||||
return <div className={cx('x-columns__wide', className)} {...rest}>{children}</div>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { parseNumber } from '@xenia/i18n/number'
|
||||
|
||||
/** What a DecimalInput reports for the typed text (6F.2): a number, null (empty) or NaN (not a number). */
|
||||
export function readDecimal(text, { decimals, allowNegative = false } = {}) {
|
||||
const s = String(text ?? '')
|
||||
if (s.trim() === '') return null
|
||||
const n = parseNumber(s, { decimals, allowNegative })
|
||||
return n == null ? NaN : n
|
||||
}
|
||||
@@ -17,7 +17,9 @@ export { PrintArea, PrintSheet } from './components/PrintArea.jsx'
|
||||
export { ToastProvider } from './components/Toast.jsx'
|
||||
export { useToast } from './components/toastContext.js'
|
||||
export { PinPad } from './components/PinPad.jsx'
|
||||
export { InfoTip } from './components/InfoTip.jsx'
|
||||
export { INFOTIP_HOVER_MS, InfoTip } from './components/InfoTip.jsx'
|
||||
export { DecimalInput, MoneyInput } from './components/DecimalInput.jsx'
|
||||
export { readDecimal } from './components/decimal.js'
|
||||
export { EmptyState } from './components/EmptyState.jsx'
|
||||
export { Spinner } from './components/Spinner.jsx'
|
||||
export { Field, Input, Textarea, Select } from './components/Field.jsx'
|
||||
@@ -31,7 +33,7 @@ export { Slider } from './components/Slider.jsx'
|
||||
export { NumberInput } from './components/NumberInput.jsx'
|
||||
export { Notice } from './components/Notice.jsx'
|
||||
export { IconPicker } from './components/IconPicker.jsx'
|
||||
export { Page, PageHeader, Pane, Toolbar, ToolbarSpacer } from './components/Page.jsx'
|
||||
export { Columns, ColumnsWide, Page, PageHeader, Pane, Toolbar, ToolbarSpacer } from './components/Page.jsx'
|
||||
export { SearchInput, FilterChip, Segmented, Tabs } from './components/Controls.jsx'
|
||||
export { Switch } from './components/Switch.jsx'
|
||||
export { Stepper } from './components/Stepper.jsx'
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { test } from 'node:test'
|
||||
import { readDecimal } from '../src/components/decimal.js'
|
||||
|
||||
test('money typed with a comma or a dot (6F.2)', () => {
|
||||
assert.equal(readDecimal('12,50', { decimals: 2 }), 12.5)
|
||||
assert.equal(readDecimal('12.50', { decimals: 2 }), 12.5)
|
||||
assert.equal(readDecimal('1.234,50', { decimals: 2 }), 1234.5)
|
||||
assert.equal(readDecimal('0,05', { decimals: 2 }), 0.05)
|
||||
assert.equal(readDecimal('€ 7,3', { decimals: 2 }), 7.3)
|
||||
assert.equal(readDecimal('0,125', { decimals: 3 }), 0.125)
|
||||
})
|
||||
|
||||
test('empty is null, nonsense is NaN, negatives only when allowed', () => {
|
||||
assert.equal(readDecimal(''), null)
|
||||
assert.equal(readDecimal(' '), null)
|
||||
assert.ok(Number.isNaN(readDecimal('abc')))
|
||||
assert.ok(Number.isNaN(readDecimal('12,5,0')))
|
||||
assert.ok(Number.isNaN(readDecimal('-2,5')))
|
||||
assert.equal(readDecimal('-2,5', { allowNegative: true }), -2.5)
|
||||
})
|
||||
@@ -30,9 +30,9 @@ export default function CartLine({ line, priced, product, canDiscount, onQty, on
|
||||
<IconButton size="sm" variant="secondary" label={t('pos.more')} onClick={() => onQty(line.quantity + step)}><Plus size={16} /></IconButton>
|
||||
{priced && line.quantity !== 1 && <span className="text-caption text-ink-3">{t('pos.each', { price: formatMoney(priced.unit_price) })}</span>}
|
||||
<span className="flex-1" />
|
||||
<Select size="sm" value={String(line.discount_pct ?? 0)} onChange={e => onDiscount(Number(e.target.value))} aria-label={t('pos.discount')}
|
||||
{canDiscount !== null && <Select size="sm" value={String(line.discount_pct ?? 0)} onChange={e => onDiscount(Number(e.target.value))} aria-label={t('pos.discount')}
|
||||
title={canDiscount ? undefined : t('pos.discountNeedsApproval')} data-testid="line-discount" className="w-36"
|
||||
options={DISCOUNTS.map(d => ({ value: String(d), label: d ? `−${d}%` : t('pos.noDiscount') }))} />
|
||||
options={DISCOUNTS.map(d => ({ value: String(d), label: d ? `−${d}%` : t('pos.noDiscount') }))} />}
|
||||
</div>
|
||||
{priced?.discount ? <span className="text-label text-success-ink">{t('pos.discountLine', { pct: priced.discount_pct, amount: formatMoney(priced.discount) })}</span> : null}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// "+1" on a sent line at the counter (plan 6F.5; the waiter app has the same): the first tap arms
|
||||
// it, more taps count up, "Send +N" sends one more of the same line (printed as new); 4 s without
|
||||
// a tap puts it back. Nothing is sent by one stray tap.
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Button } from '@xenia/ui'
|
||||
|
||||
const WAIT_MS = 4000
|
||||
|
||||
export default function OneMore({ onSend }) {
|
||||
const { t } = useTranslation('terminal')
|
||||
const [count, setCount] = useState(0)
|
||||
const [busy, setBusy] = useState(false)
|
||||
const timer = useRef(null)
|
||||
useEffect(() => () => clearTimeout(timer.current), [])
|
||||
const tap = () => {
|
||||
if (busy) return
|
||||
setCount(c => Math.min(c + 1, 20))
|
||||
clearTimeout(timer.current)
|
||||
timer.current = setTimeout(() => setCount(0), WAIT_MS)
|
||||
}
|
||||
const send = async () => {
|
||||
if (busy || !count) return
|
||||
clearTimeout(timer.current)
|
||||
setBusy(true)
|
||||
try { await onSend(count) } finally { setBusy(false); setCount(0) }
|
||||
}
|
||||
return (
|
||||
<span className="flex items-center gap-1.5 shrink-0 px-2" data-testid="one-more" data-armed={count ? 'true' : 'false'}>
|
||||
{count > 0 && <Button size="sm" variant="primary" loading={busy} onClick={send} data-testid="one-more-send">{t('pos.oneMore.send', { count })}</Button>}
|
||||
<Button size="sm" variant={count ? 'primary' : 'secondary'} onClick={tap} aria-label={t('pos.oneMore.label')} data-testid="one-more-tap">+{count || 1}</Button>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -62,7 +62,9 @@ function Counter({ menu, t }) {
|
||||
const [tableCart, setTableCart] = useState([])
|
||||
const [dialog, setDialog] = useState(null) // product
|
||||
const tables = useTables()
|
||||
const canDiscount = useCan('ordering.prices.modify')
|
||||
// a discount is a price changed in the cart (6F.3): none when the venue turned that off
|
||||
const mayDiscount = useCan('ordering.prices.modify')
|
||||
const canDiscount = menu.settings.price_change === 'off' ? null : mayDiscount // null: no discount at all
|
||||
const toast = useToast()
|
||||
const onlineModule = useModule('connect_orders')
|
||||
const handlesOnline = useCan('connect_orders.manage')
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user