feat(ordering): orders priced by the server (platform-v2 step 4.4)
The waiter app (and the manager's ordering tab) send what was chosen, by id; the
server prices it with the counter's code. No app sends a price any more.
- POST /api/orders/{id}/items takes `lines` (pos_cart's line + course_id,
price_adjustment, is_service_item): sales point checked first, refusals name the
product and line (order.line.*, order.not_sold_here); prices or selected_options in a
line -> order.line.client_price, the old `items` shape -> order.lines_required; a
by-hand price change needs ordering.prices.modify or a manager's approval (audited
PRICE_SET_BY_HAND). add_priced_items is the one writer of priced items (pos too).
- POST /api/orders/quote: the cart's total before sending; /api/pos/quote shares
pos_cart.quote().
- pos_cart: a preference set left out takes its default; a set at its free default
isn't stored; a default that costs is charged (the waiter never sent it: fixed);
an extra's sub-choice is charged per extra (the counter charged it once: fixed).
- @xenia/api lines.js: lineFromOptions / wireLine / estimate / LineError.
- Waiter: lines on send; cart total from the quote ("≈ estimate" offline); summary
shows the same prices; offline orders queued by id, priced on sync, refused lines
shown on a "Δεν στάλθηκαν" sheet (no empty order opened); dead ItemOptionsModal gone.
- Tests: test_order_lines.py (14), lines.test.mjs, waiter e2e +6.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -67,7 +67,7 @@ def test_tables_follow_the_cashiers_zones(client, db, till, floor, phone, menu):
|
||||
assert by_name["Corner"]["flags"] == [{"id": flag.id, "name": "VIP", "emoji": "⭐", "color": "#aa0000", "text_color": None}]
|
||||
# the waiter opens T1 on the phone; the counter sees it with totals and who is on it
|
||||
o = client.post("/api/orders/", headers=phone["h"], json={"table_id": floor["t1"].id}).json()
|
||||
client.post(f"/api/orders/{o['id']}/items", headers=phone["h"], json={"items": [{"product_id": menu["coffee"].id, "quantity": 2}]})
|
||||
client.post(f"/api/orders/{o['id']}/items", headers=phone["h"], json={"lines": [{"product_id": menu["coffee"].id, "quantity": 2}]})
|
||||
t1 = tables(client, till)[0]["T1"]["order"]
|
||||
assert t1["id"] == o["id"] and t1["total"] == 6.0 and t1["unpaid"] == 6.0 and t1["items"] == 1
|
||||
assert t1["people"] == ["Maria"] and t1["mine"] is False
|
||||
@@ -85,7 +85,7 @@ def test_counter_and_phone_share_a_table(client, db, till, floor, phone, menu, e
|
||||
seen = client.get(f"/api/orders/{oid}", headers=phone["h"]).json()
|
||||
assert [i["product_name"] for i in seen["items"]] == ["Freddo"]
|
||||
assert client.post(f"/api/orders/{oid}/items", headers=phone["h"],
|
||||
json={"items": [{"product_id": m["coffee"].id, "quantity": 1}]}).status_code == 200
|
||||
json={"lines": [{"product_id": m["coffee"].id, "quantity": 1}]}).status_code == 200
|
||||
# the counter adds a burger to the same order (not a second one)
|
||||
assert send(client, till, floor["t1"], [burger_line(m)]).json()["order_id"] == oid
|
||||
t1 = tables(client, till)[0]["T1"]["order"]
|
||||
@@ -125,7 +125,7 @@ def test_tables_outside_the_zones_are_refused(client, db, till, floor, menu, on_
|
||||
db.commit()
|
||||
h = login(nikos, "waiter")
|
||||
o = client.post("/api/orders/", headers=h, json={"table_id": floor["t3"].id}).json()
|
||||
client.post(f"/api/orders/{o['id']}/items", headers=h, json={"items": [{"product_id": menu["coffee"].id, "quantity": 1}]})
|
||||
client.post(f"/api/orders/{o['id']}/items", headers=h, json={"lines": [{"product_id": menu["coffee"].id, "quantity": 1}]})
|
||||
item = client.get(f"/api/orders/{o['id']}", headers=h).json()["items"][0]["id"]
|
||||
assert err(client.post("/api/pos/quote", headers=till["h"], json={"order_id": o["id"], "lines": []})) == "pos.table_not_yours"
|
||||
assert err(client.post(f"/api/pos/orders/{o['id']}/pay", headers=till["h"],
|
||||
|
||||
Reference in New Issue
Block a user