- manager: new pages/orders/ (Tables page cards + quick actions, order page with
lines, multi-select pay/discount/cancel/tab, staff + customer, price changes,
history, the menu + cart beside it); a free table opens a new order on first
Send; v1 TablesPage, OrderDetailPage, DesktopOrderingTab, ManagerOrderDrawer
and PaymentMethodModal removed
- ordering by line id like the phones: GET /api/orders/menu (the counter's
product shape, in-store prices); the product dialog, cart rules and quote hook
move to packages/ordering (@xenia/ordering), shared by counter, menu tablet,
manager
- close follows orders.close_with_unpaid (pay first, or write off after saying
so) on the order page and the overview's quick view; paying asks cash or card
- a confirmed booking can keep its table ahead (manager, phones, counter):
POST /api/connect/bookings/{id}/table, reservations create/PATCH; refused with
reservation.table_kept within 2 h of another booking
- tests: test_manager_ordering.py, online bookings +2, manager orders.test.mjs,
@xenia/ordering, e2e manager.mjs (take, change, pay-first close, RESERVED)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
3.0 KiB
Python
41 lines
3.0 KiB
Python
"""The manager's ordering (plan step 6.9): the menu it offers, and orders taken, changed, paid and
|
|
closed by the same rules as the phones (prices from line ids, close with unpaid items only when
|
|
the venue allows it)."""
|
|
from tests.test_live import err, owner_h # noqa: F401 (fixtures)
|
|
from tests.test_pos import menu # noqa: F401 (fixtures)
|
|
from tests.test_tablet_orders import day # noqa: F401 (fixtures)
|
|
|
|
|
|
def test_the_menu_for_the_manager(client, owner_h, menu, make_user, login):
|
|
data = client.get("/api/orders/menu", headers=owner_h).json()
|
|
by = {p["name"]: p for p in data["products"]}
|
|
assert by["Burger"]["price"] == 10.0 and by["Burger"]["prefs"][0]["name"] == "Cooking"
|
|
assert by["Cutlery"]["service"] is True and "Old dish" in by and by["Old dish"]["available"] is False
|
|
cook = login(make_user(role="cook"), client="manager")
|
|
assert err(client.get("/api/orders/menu", headers=cook)) == "access.denied"
|
|
|
|
|
|
def test_taken_changed_paid_and_closed_by_the_phones_rules(client, owner_h, menu, day, monkeypatch):
|
|
import routers.orders as orders_api
|
|
from models.settings import PosSettings # noqa: F401
|
|
monkeypatch.setattr(orders_api, "route_and_print_sync", lambda *a, **kw: [])
|
|
from models.table import Table
|
|
from database import SessionLocal # noqa: F401
|
|
o = client.post("/api/orders/", headers=owner_h, json={"table_id": None, "order_type": "here"}).json()
|
|
burger = {"product_id": menu["burger"].id, "quantity": 1, "prefs": [{"set_id": menu["cook"].id, "choices": [{"id": menu["well"].id}], "shared": "Fries"}]}
|
|
cheat = client.post("/api/orders/quote", headers=owner_h, json={"order_id": o["id"], "lines": [{**burger, "unit_price": 0.01}]})
|
|
assert err(cheat) == "order.line.client_price" # no app sends prices
|
|
q = client.post("/api/orders/quote", headers=owner_h, json={"order_id": o["id"], "lines": [burger]}).json()
|
|
assert q["total"] == 10.5
|
|
r = client.post(f"/api/orders/{o['id']}/items", headers=owner_h, json={"lines": [burger, {"product_id": menu["coffee"].id, "quantity": 2}]})
|
|
assert r.status_code == 200, r.text
|
|
items = client.get(f"/api/orders/{o['id']}", headers=owner_h).json()["items"]
|
|
assert sorted(round(i["unit_price"], 2) for i in items) == [3.0, 10.5]
|
|
coffee = next(i for i in items if i["product_id"] == menu["coffee"].id)
|
|
client.post(f"/api/orders/{o['id']}/cancel-items", headers=owner_h, json={"item_ids": [coffee["id"]], "reason": "wrong"})
|
|
# unpaid → closing is refused (the venue's default): pay first, then close
|
|
assert err(client.post(f"/api/orders/{o['id']}/close", headers=owner_h)) == "pos.order_unpaid"
|
|
live = [i["id"] for i in client.get(f"/api/orders/{o['id']}", headers=owner_h).json()["items"] if i["status"] == "active"]
|
|
assert client.post(f"/api/orders/{o['id']}/pay", headers=owner_h, json={"item_ids": live, "payment_method": "cash"}).status_code == 200
|
|
assert client.post(f"/api/orders/{o['id']}/close", headers=owner_h).json()["status"] == "closed"
|