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

0 downloads

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.

danq9 signup: the person chooses the password and name on the confirm page 83c7aa6 2 weeks, 5 days ago History
order_lines.json · 6.3 KB · 146 lines
1{
2 "name": "order_lines",
3 "title": "Order Lines",
4 "version": 3,
5 "description": "Line items belonging to one order. line_total_cents and line_tax_cents are stamped by the order_totals handler on every create/update/delete. See objects/system/order_totals.py. A line also carries what was ASKED FOR on it (line_note) and what that instruction cost (modifier_cents), which is how a kitchen order works: a large latte is genuinely its own product with its own SKU, price and stock, and variants-as-products already handles that, but '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. The note is never money and the delta always is: the note prints on the kitchen ticket and touches no total, while the delta is inside line_total_cents everywhere that number is folded. v3 records whether a line was BACKORDERED -- sold with the shop's open agreement that the goods are not here yet. The shipment builder reads it so a parcel never claims to carry what the shelf does not hold.",
6 "fields": [
7 {
8 "name": "id"
9 },
10 {
11 "name": "order_id",
12 "type": "relation",
13 "required": true,
14 "relation": {
15 "collection": "orders",
16 "display_field": "number"
17 },
18 "label": "Order",
19 "help": "Set once at creation and not intended to change after. Not schema read_only -- same reason as app-invoices' invoice_lines.invoice_id: a required, client-submitted-at-creation field cannot also be read_only on this platform (the server rejects any client submission of a read_only field, even the first one)."
20 },
21 {
22 "name": "product_id",
23 "label": "Product",
24 "relation": {
25 "collection": "products",
26 "display_field": "name"
27 },
28 "help": "Optional cross-reference to app-catalog's products collection. A line may reference a catalog product or stand alone as a free-text description -- optional, not required, so this package has no hard dependency on app-catalog."
29 },
30 {
31 "name": "description",
32 "type": "text",
33 "required": true,
34 "label": "Description",
35 "validation": {
36 "min_length": 1,
37 "max_length": 300
38 }
39 },
40 {
41 "name": "quantity",
42 "type": "number",
43 "default": "1",
44 "label": "Quantity",
45 "help": "A count/measure, not money -- may be fractional. This is the one deliberate use of a float-shaped field in this package; every *_cents field stays integer. Same exception app-invoices' invoice_lines.quantity documents."
46 },
47 {
48 "name": "unit_price_cents",
49 "type": "integer",
50 "required": true,
51 "label": "Unit Price (cents)"
52 },
53 {
54 "name": "line_note",
55 "type": "text",
56 "label": "Line Note",
57 "help": "What was asked for on THIS line -- 'no onions', 'extra hot', 'cut in half'. An instruction, not a product: it has no SKU and it is true of one line of one order. It prints on the kitchen ticket, where a cook actually reads it, and it is never money -- no total anywhere moves because somebody typed here.",
58 "validation": {
59 "max_length": 300
60 }
61 },
62 {
63 "name": "modifier_cents",
64 "type": "integer",
65 "default": "0",
66 "label": "Modifier (cents)",
67 "help": "The price delta the instruction carries -- 'oat milk +60c' -- in integer minor units, PER UNIT, so two oat lattes cost two deltas. Inside line_total_cents, never beside it: money that appears in one total and not another is the bug this codebase is organised against, so order_totals folds it in and the invoice line carries it in its unit price.",
68 "validation": {
69 "min": 0
70 }
71 },
72 {
73 "name": "backordered",
74 "type": "boolean",
75 "default": "false",
76 "label": "Backordered",
77 "help": "The shop sold this line knowing it did not have the goods, and said so at checkout. It lives HERE, on the order, because the picker and the packer read the order -- a fact kept only in another app's collection is a fact the warehouse never sees, and the consequence of not seeing it is a short parcel plus a stock ledger driven negative on goods nobody could pick. Written by checkout, read by the shipment builder, which packs what is on the shelf and leaves the rest owed."
78 },
79 {
80 "name": "discount_bps",
81 "type": "integer",
82 "label": "Discount %",
83 "help": "A negotiated reduction on THIS line, in basis points (1000 = 10%). Not a promotion -- a promo code applies to the whole basket and is rounded once (app-promotions); this comes off one row and prints beside it. Tax is charged on the discounted amount, because a discount on goods reduces the taxable base. A flat per-unit reduction is a negative modifier_cents; the percentage is what nothing else could express."
84 },
85 {
86 "name": "line_discount_cents",
87 "type": "integer",
88 "label": "Discount",
89 "help": "Computed from discount_bps."
90 },
91 {
92 "name": "line_total_cents",
93 "type": "integer",
94 "default": "0",
95 "label": "Line Total (cents)",
96 "help": "Stamped by order_totals: floor(quantity * (unit_price_cents + modifier_cents)). Never user-entered."
97 },
98 {
99 "name": "tax_rate_bps",
100 "type": "integer",
101 "label": "Tax Rate (bps)",
102 "help": "Basis points, e.g. 825 = 8.25%. Optional; blank or 0 means no tax on this line."
103 },
104 {
105 "name": "line_tax_cents",
106 "type": "integer",
107 "default": "0",
108 "label": "Line Tax (cents)",
109 "help": "Stamped by order_totals: line_total_cents * tax_rate_bps // 10000 (floor, not round)."
110 },
111 {
112 "name": "owner_id",
113 "type": "text",
114 "label": "Owner"
115 },
116 {
117 "name": "created_at",
118 "type": "datetime",
119 "label": "Created",
120 "read_only": true
121 }
122 ],
123 "forms": {
124 "default": {
125 "fields": [
126 "order_id",
127 "product_id",
128 "description",
129 "quantity",
130 "unit_price_cents",
131 "line_note",
132 "modifier_cents",
133 "tax_rate_bps"
134 ]
135 }
136 },
137 "views": {
138 "list_mode": "table",
139 "list_fields": [
140 "description",
141 "quantity",
142 "unit_price_cents",
143 "line_total_cents"
144 ]
145 }
146}