askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
dbbasic-package.json · 7.8 KB · 99 lines
| 1 | { |
| 2 | "id": "app-pickup", |
| 3 | "name": "Pickup", |
| 4 | "version": "0.1.5", |
| 5 | "description": "The missing noun is TIME. Everything about the money was already built here -- browse, basket, guest checkout, order, invoice, pay link, payment, books, stock, tax, the receipt trail -- and a cafe still could not open on it, because a food business is a scheduling business that happens to sell food and this server had no way to say 'ready at 6:15'. plan/pickup-and-counter-service-spec.md is the argument; app-orders v7 is the half that lives on the order (fulfillment_method, requested_at/promised_at, ready_at/collected_at, and the preparing/ready/collected ladder), and this package is the half that decides whether a promised time is a promise or a guess. pickup_slots is a window and a number: starts_at, ends_at, and a CAPACITY COUNTED IN ORDERS RATHER THAN ITEMS, because a kitchen's real constraint is hands and handovers -- a fifteen-minute window that can look after four customers can look after them whether each ordered one coffee or three -- and because no owner alive knows how many 'items' their Friday holds while every owner knows how many people they can serve at once. system_slot_generator builds the next N days from five settings (open_time, close_time, slot_minutes, capacity_per_slot, days_ahead) on a nightly schedule, idempotent by the row's own natural key (starts_at, location_id) so re-running creates nothing twice and an operator's hand-typed 6pm slot is adopted rather than duplicated. It is a SCHEDULED PASS and not a page for one reason: a shop that has to create tomorrow's slots by hand will one day forget and take no orders at all, and that failure is silent -- an empty picker is indistinguishable from a fully-booked shop, and nothing logs an error. It only ever adds; a slot somebody edited is a decision, and a nightly pass that restated it would overwrite the operator every night. action_pickup_slots is what a storefront asks before it draws a time picker, and its answer is deliberately narrow -- open, in the future, past the lead time (pickup.lead_minutes), not at capacity -- because 'can I have a pizza at 3am' must be answered by not offering 3am, never by a refusal after the customer has typed their card in. hook_pickup_slots refuses a negative capacity and an orders_taken above capacity WITH BOTH NUMBERS, and is careful about what it does not claim: the real oversell race (two shoppers, one last place) lands through action_checkout's trusted server-side write, which bypasses hooks by design, and that is the point -- the oversell becomes a visible number on the row it happened to instead of being swallowed by a reservation ledger nobody has needed yet. What this hook refuses is a number somebody TYPED, because a typo is not a fact. The checkout gate itself lives in app-shop's action_checkout, alongside the price and stock checks and reported in the same response as them, never returned early on its own, with the next free slot named in the refusal so the shopper who lost the race is told before they pay rather than after. The attention count is orders past their promised time and not yet ready, severity warning because nobody chose to put them there and the clock is running in front of a customer; it keys on promised_at rather than on fulfillment_method, which is why a shipping order can never appear in it by construction rather than by a filter somebody has to remember. Two doors: the slot board an operator manages, and the pickup order list the count opens. Deliberately NOT here, named so each reads as a decision rather than an omission: per-line modifiers and the kitchen queue (the next slice -- the queue is the pick list with a different sort), the ready notification (an event on the transition into ready, not a button somebody forgets on a busy Friday), tax classes for prepared food, tips as a liability line, the counter sales page and its cash drawer, and any form of reservation or hold on a slot. 0.1.3: the slot board is READ-ONLY to signed-in users. It was create/read/update for every registered user on the theory that whoever is on shift edits it, and on a public shop every customer is a registered user -- one PUT raised a full window's capacity to 99. Writing the board is now role:manager (admins as always), the owner fallback is off for update as well as delete, and the old grant is in the rules file's retracted list so an upgrade removes it. 0.1.4: a booking that is never paid stops holding its window. orders_taken only ever went up, so a shopper who checked out and closed the tab held the place for good and a one-place 6pm refused everybody after them. The picker and action_checkout's gate now judge a window by object_pickup's live count: orders_taken less the bookings whose order is cancelled or is an unpaid draft older than pickup.hold_minutes (default 30; 0 keeps every hold). Derived on read from the orders, invoices and payments, so it needs no daemon; the counter itself is not written. The picker also ignores a public request's now. 0.1.5: the picker judges a pay-at-pickup booking (orders.pay_at_pickup) by its window, not its age: it holds its place until the window ends plus pickup.grace_minutes (object_pickup.hold_lapsed, the same rule that now decides whether an online order still holds its goods).", |
| 6 | "compatibility": { |
| 7 | "dbbasic_object_server": ">=0.1.0" |
| 8 | }, |
| 9 | "dependencies": [ |
| 10 | "app-orders", |
| 11 | "app-views" |
| 12 | ], |
| 13 | "objects": [ |
| 14 | { |
| 15 | "id": "system_slot_generator", |
| 16 | "path": "objects/system/slot_generator.py" |
| 17 | }, |
| 18 | { |
| 19 | "id": "action_pickup_slots", |
| 20 | "path": "objects/action/pickup_slots.py" |
| 21 | }, |
| 22 | { |
| 23 | "id": "hook_pickup_slots", |
| 24 | "path": "objects/hook/pickup_slots.py" |
| 25 | }, |
| 26 | { |
| 27 | "id": "system_pickup_attention", |
| 28 | "path": "objects/system/pickup_attention.py" |
| 29 | } |
| 30 | ], |
| 31 | "schemas": [ |
| 32 | { |
| 33 | "collection": "pickup_slots", |
| 34 | "path": "schemas/pickup_slots.json" |
| 35 | } |
| 36 | ], |
| 37 | "permissions": [ |
| 38 | { |
| 39 | "path": "permissions/rules.json" |
| 40 | } |
| 41 | ], |
| 42 | "seed": [ |
| 43 | { |
| 44 | "collection": "pickup_slots", |
| 45 | "path": "seed/pickup_slots.tsv" |
| 46 | }, |
| 47 | { |
| 48 | "collection": "views", |
| 49 | "path": "seed/views.tsv" |
| 50 | }, |
| 51 | { |
| 52 | "collection": "site_routes", |
| 53 | "path": "seed/site_routes.tsv" |
| 54 | } |
| 55 | ], |
| 56 | "migrations": [], |
| 57 | "schedules": [ |
| 58 | { |
| 59 | "id": "pickup_slot_generator_daily", |
| 60 | "object_id": "system_slot_generator", |
| 61 | "schedule": "50 3 * * *", |
| 62 | "description": "Build the next N days of collection windows from the shop's opening hours. Before dawn on purpose: the board must be complete before the first customer opens the storefront, and a pass that ran at nine would leave the morning's slots to whoever remembered. Costs almost nothing when it has nothing to do -- the (starts_at, location) key makes every window it has already built a skip. This is the pass that exists because a shop which has to type tomorrow's slots by hand will one day forget and take no orders at all, and nothing about that failure looks like a failure: the picker is simply empty." |
| 63 | } |
| 64 | ], |
| 65 | "nav": [ |
| 66 | { |
| 67 | "id": "pickup_orders", |
| 68 | "label": "Pickup Orders", |
| 69 | "path": "/pickup", |
| 70 | "blurb": "Orders being collected, and when each one was promised", |
| 71 | "surface": "member", |
| 72 | "group": "Commerce", |
| 73 | "order": 425 |
| 74 | }, |
| 75 | { |
| 76 | "id": "pickup_slots", |
| 77 | "label": "Pickup Slots", |
| 78 | "path": "/pickup-slots", |
| 79 | "blurb": "The collection windows the shop offers and how many orders each holds", |
| 80 | "surface": "member", |
| 81 | "group": "Commerce", |
| 82 | "order": 430 |
| 83 | } |
| 84 | ], |
| 85 | "attention": [ |
| 86 | { |
| 87 | "id": "pickup_orders_overdue", |
| 88 | "object_id": "system_pickup_attention", |
| 89 | "label": "Orders past their promised time", |
| 90 | "path": "/pickup", |
| 91 | "nav_id": "pickup_orders", |
| 92 | "group": "Commerce", |
| 93 | "severity": "warning", |
| 94 | "reads": [ |
| 95 | "orders" |
| 96 | ] |
| 97 | } |
| 98 | ] |
| 99 | } |