Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

9 downloads

Install on DigitalOcean Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Daniel Quellhorst Changelog for this batch. 65ef78d 3 hours, 42 minutes ago History
cart_items.json · 4.6 KB · 33 lines
1{
2 "name": "cart_items",
3 "title": "Cart Items",
4 "version": 3,
5 "description": "One product in one basket, with the price it carried when it went in. Stamping the price at add-time is what lets the shop notice later that it moved: a price that changes while somebody is shopping must not silently change what they thought they were agreeing to, and a basket that has sat for three weeks must not hold the seller to a stale price either. Both numbers are kept and the DISAGREEMENT is surfaced at checkout (object_cart.price_changes) rather than resolved in secret in either direction -- the same instinct as stamping a rate at approval and refusing to let a later change restate it (docs/logic-decisions.md #1). No stock is reserved by anything here: availability is decided at checkout, because reserving on add is how a shop shows 'sold out' for goods nobody bought. A line also carries an INSTRUCTION and a price delta (line_note, modifier_cents), which is why the same product can appear on two lines of one basket: 'no onions' on the first burger and not the second are two different things to make. A large latte is genuinely its own product with its own SKU, price and stock, and variants-as-products already handles that; 'no onions' is not a product -- it has no SKU, it is an instruction on one line of one order, and modelling it as a product would put thousands of dead rows in the catalogue. 'Oat milk +60c' is the same instruction with a price delta, which is why the delta lives on the line rather than in the price book.",
6 "fields": [
7 {"name": "id"},
8 {"name": "cart_id", "required": true, "label": "Cart",
9 "relation": {"collection": "carts", "display_field": "session_token"}},
10 {"name": "product_id", "required": true, "label": "Product",
11 "relation": {"collection": "products", "display_field": "name"}},
12 {"name": "description", "type": "text", "label": "Description",
13 "help": "Stamped from the product name so a basket still reads correctly if the product is later renamed."},
14 {"name": "quantity", "type": "number", "default": "1", "label": "Quantity",
15 "help": "May be fractional -- 1.5 kg, 2.5 hours of setup -- so line money is Decimal arithmetic rounded once per line."},
16 {"name": "unit_price_cents", "type": "integer", "default": "0", "label": "Unit Price",
17 "help": "What it cost when it went in the basket, in integer minor units. Compared against the live price at checkout, never quietly replaced by it."},
18 {"name": "line_note", "type": "text", "label": "Line Note",
19 "help": "What the shopper asked for on THIS line -- 'no onions', 'extra hot', 'cut in half'. An instruction, never a product: it has no SKU, it is true of one line of one order, and a catalogue row per instruction would be thousands of dead products. It is also never money: it reaches the kitchen ticket and the order line, and it changes no total anywhere.",
20 "validation": {"max_length": 300}},
21 {"name": "modifier_cents", "type": "integer", "default": "0", "label": "Modifier (cents)",
22 "help": "The price delta this instruction carries -- 'oat milk +60c' -- in integer minor units, PER UNIT, so two oat lattes cost two deltas. It lives on the line rather than in the price book for the same reason the note does: it is a fact about this order, not about the catalogue. Zero is the ordinary case. Never negative: a discount is a pricing decision that belongs in the price book or in a variant, and a shopper who can type their own negative delta can price their own lunch (action_cart refuses one). v3: COMPUTED, never taken from the request -- it is the sum of the prices products.modifiers declares for the extras named in `modifiers`, stamped when the line goes in and re-checked at checkout like the unit price. A client that sends its own modifier_cents is refused unless it is exactly that sum.",
23 "validation": {"min": 0}},
24 {"name": "modifiers", "type": "text", "label": "Extras",
25 "help": "Which of the product's declared extras this line carries, as a JSON list of their labels in the seller's spelling: [\"Oat milk\"]. The request names them; the price comes from products.modifiers. Kept so checkout can re-price the line against the live list, and so the cook is told what was paid for rather than only how much.",
26 "validation": {"max_length": 1000}},
27 {"name": "owner_id", "type": "text", "label": "Owner"},
28 {"name": "created_at", "type": "datetime", "read_only": true, "label": "Added"}
29 ],
30 "views": {"list_mode": "table",
31 "list_fields": ["description", "quantity", "unit_price_cents",
32 "modifier_cents", "line_note"]}
33}