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
dbbasic-package.json · 12.2 KB · 98 lines
1{
2 "id": "app-orders",
3 "name": "Orders",
4 "version": "0.9.0",
5 "description": "Sales and purchase orders (doc_type on one shared schema, the real SO/PO split): owner-scoped CRUD, guarded status lifecycle (draft/confirmed/processing/shipped/delivered/cancelled), and a HANDLES totals handler (system_order_totals) that stamps subtotal/tax/total from order_lines in integer cents on every line change. Order lines optionally relate to app-catalog's products collection but do not require it -- a line may be free-text. Reconciled against a private predecessor-system audit, not part of this repo. Deferred to a later slice: auto-numbered sequences per doc_type (an order_counters collection + a closed orders create route), the convert_to_invoice ACTION (invoice_id exists on orders so the provenance link has somewhere to land once that flow is built), stock decrement on ship, and purchase-order receiving. subtotal_cents/tax_cents/total_cents/line_total_cents/line_tax_cents are deliberately NOT schema read_only -- see objects/system/order_totals.py's module docstring for why (update_collection_record has no read_only write exception, so a truly read_only field could never be re-stamped). The order permalink /orders/{order_id:uuid} is now a seeded 59 detail view (site_view_render): a composed page of three generic block renderers -- an editable+deletable `detail` block (the order; money renders via /form's cents formatting, no custom JS, and status transitions become status-field edits in the owner edit form, guarded by the 10-flow transitions above -- no one-click status buttons, the same make-it-basic trade app-forum's pin/lock takes), a `related` block (order_lines flat by order_id), and a `form` block with fixed:{order_id:$record_id} (Add Line, FK locked to the page's order). order_lines stays a RELATIONAL collection, not embedded on orders -- a line is addressable on its own (it can have things attached to it later), matching every other line-item package here (app-invoices' invoice_lines, app-forum's forum_replies). No bespoke per-order page. 0.3.0 deletes the bespoke /orders list page object too: it was ~90 lines of chrome around two generator calls with no business logic of its own, and is now a seeded VIEW record over the same `list` block the order detail's own retrofit already established the precedent for. Ships an attention provider for committed orders with goods still owed -- the pick queue as a number. site_pick_list folds the same arithmetic live and is right to, because it is a working screen somebody opens on purpose; a home page cannot afford that fold a dozen times over, so the daemon runs this on an interval instead. The status set and the shipped-quantity rule are read from site_pick_list so the badge and the page it links to cannot disagree. 0.5.0 gives the CUSTOMER a voice back. Until now a guest paid and heard silence: there was no transactional email anywhere on this server and no way for a buyer without an account to ask where their order was. orders.portal_token (v5 of the schema, read_only like the invoice one) is that missing door -- an unguessable capability URL minted by system_order_portal_link the moment an order stops being a draft, and synchronously by app-shop's action_checkout so the checkout response can hand the shopper the link while they are still standing there. site_order_status renders it at /orders/track/{token}, PUBLIC: order number, date, the itemised receipt with prices (unlike the packing slip, which carries none because it goes in the box), the status translated out of warehouse vocabulary into words a person waiting for a parcel understands, the carrier and tracking number when a shipment has them, the pay link while the bill is open, and a return link carrying the same token once something has shipped. Looked up by token only with a constant-time compare; an unknown token gets a friendly 404 that never hints another one would have worked. system_order_email composes the three messages a shop owes a buyer -- confirmed, shipped, refunded -- each fired by a TRANSITION rather than a button, because a button is a thing somebody forgets on a busy Friday. It QUEUES into app-email's outbox and never sends inline, so a slow relay cannot slow the write that triggered it, and it is idempotent by provenance: the marker lives in the outbox row's source_object_id, so a replayed event composes nothing. No nav entry for the tracking page and none wanted -- it is a per-record customer document, not a door into the app, and this package already declares its front door at /orders. No new dependencies either: the email, shipment and invoice reads are all wrapped, because app-shipping already depends on app-orders and the arrow cannot point both ways. 0.6.0 is DROP-SHIPPING, the composition test plan/fulfillment-logistics-spec.md set for the whole fulfillment build -- and it lands here, in the orders package, with no new collection anywhere, because the v1 decision to give sales and purchase orders one shared schema turns out to have already modelled it: 'the vendor ships straight to my customer' is a sale order and a purchase order pointing at each other. orders v6 adds the five fields that link them (fulfillment_source, linked_order_id, vendor_id, ship_to_name, ship_to_address) and action_dropship_order writes both ends in one pass -- the PO confirmed rather than draft (a draft is not a commitment, and a customer waiting on a parcel nobody ordered is the whole failure), carrying the customer's ship-to onto the vendor's document, which is the one place in this repo where the counterparty on an order and the destination of its goods are different people. It refuses a sale order that already has stock moves against it (you cannot drop-ship what you already picked, and the refusal names the moves), refuses a second PO for the same sale order (one duplicate commitment to buy is one supplier who will happily send the goods twice), and reports every blocker together the way checkout does. The vendor's price is asked for -- per line, or flat, or from the product's recorded cost -- and when none of those exist the PO is raised at zero with a WARNING naming the lines, because a cost of zero reads as 100% margin and a cost copied from the sale price reads as none, and both are lies. site_dropship_margin at /orders/{order_id}/margin is the read the spec promised: two rows, one subtraction, object_billing.margin doing the arithmetic rather than a second implementation of it. THE HONEST HALF, named rather than hidden: a drop-ship order must never move our stock, and today the data says so while one handler does not read it. Receiving is safe by construction (nothing raises a receipt on its own, so a drop-ship PO nobody checks in never touches a shelf), but system_order_fulfillment in app-shipping composes a `sale` move for every shipment line at `shipped` without looking at fulfillment_source -- so a shipment recorded against a drop-ship sale order would decrement a shelf that never held the goods. The fix is one condition in a package this slice does not own; tests/test_dropship.py holds it as a strict xfail so it is an acceptance test the day somebody writes it, and app-shipping's schema still needs the `source: vendor` field the spec names for the vendor's own dispatch. 0.7.0 adds TIME, and it is five fields and three enum values rather than a new collection because everything about the MONEY was already built here and almost nothing about the time was (plan/pickup-and-counter-service-spec.md). A food business is a scheduling business that happens to sell food, and until orders v7 this collection could say `shipped` and `delivered` and had no way at all to say 'ready at 6:15' -- which is the whole of what a cafe needed that a parcel shop did not. fulfillment_method (shipping | pickup | delivery | counter, defaulting to shipping so no existing row changes meaning, the same argument fulfillment_source above already makes) is the fact every downstream behaviour keys off. requested_at and promised_at stay TWO fields because 'you wanted 6:00, we said 6:20' is worth keeping and collapsing them hides every capacity failure the shop ever had; ready_at and collected_at are stamped as they happen and never predicted. The status enum grows preparing/ready/collected -- new values, not a reuse of shipped/delivered, because a status a customer reads must use the customer's word -- and WHICH subset of the ladder an order may climb is decided by fulfillment_method in the objects, never by the enum, since an enum cannot condition on another field (the same note `shipments` carries about its own inbound and outbound ladders). site_order_status learns the three new words plus a promised-time line, and a shipping order's page is byte-for-byte what it was: the overlay is keyed on the method and falls back to the old wording when the field is blank. The slots those promised times come from, the generator that creates them and the checkout gate that books them all live in app-pickup, which depends on this package and not the other way round. v0.x adds LINE DISCOUNTS: discount_bps on a line is a negotiated reduction on that row -- ex-display stock, a trade rate, ten per cent off this item -- and it is deliberately NOT a promotion. app-promotions owns codes somebody types, applied to the whole basket and ROUNDED ONCE so four separately-rounded lines cannot accumulate an error nobody can reconcile against the percentage on the receipt; a line discount comes off one row and prints beside it. The two compose, and keeping them apart is what stops \"10% off\" meaning two different numbers depending on which layer applied it. Tax is charged on the DISCOUNTED amount, because a discount on goods reduces the taxable base -- the same thing object_promotions.applies_to already says, and the two must not disagree. The discount floors off the already-floored gross, which is what makes a zero discount arithmetically invisible: every historical line total is bit-identical to what it was. A rate over 100% is clamped rather than honoured, because 12000 basis points is a typo and a line that pays the customer is not something to infer from one. The arithmetic itself moved to object_lines, shared with app-invoices: the two copies of _line_amounts were near enough identical that one was the other plus modifier_cents, which was survivable until both had to subtract a discount. Orders declare capabilities.comments + attachments for the same reason invoices do -- the customer's PO and the internal thread about a specific order.",
6 "compatibility": {
7 "dbbasic_object_server": ">=0.1.0"
8 },
9 "dependencies": [
10 "app-views"
11 ],
12 "objects": [
13 {
14 "id": "system_order_totals",
15 "path": "objects/system/order_totals.py"
16 },
17 {
18 "id": "system_order_attention",
19 "path": "objects/system/order_attention.py"
20 },
21 {
22 "id": "system_order_portal_link",
23 "path": "objects/system/order_portal_link.py"
24 },
25 {
26 "id": "system_order_email",
27 "path": "objects/system/order_email.py"
28 },
29 {
30 "id": "site_order_status",
31 "path": "objects/site/order_status.py"
32 },
33 {
34 "id": "action_dropship_order",
35 "path": "objects/action/dropship_order.py"
36 },
37 {
38 "id": "site_dropship_margin",
39 "path": "objects/site/dropship_margin.py"
40 }
41 ],
42 "schemas": [
43 {
44 "collection": "orders",
45 "path": "schemas/orders.json"
46 },
47 {
48 "collection": "order_lines",
49 "path": "schemas/order_lines.json"
50 }
51 ],
52 "permissions": [
53 {
54 "path": "permissions/rules.json"
55 }
56 ],
57 "seed": [
58 {
59 "collection": "orders",
60 "path": "seed/orders.tsv"
61 },
62 {
63 "collection": "order_lines",
64 "path": "seed/order_lines.tsv"
65 },
66 {
67 "collection": "views",
68 "path": "seed/views.tsv"
69 },
70 {
71 "collection": "site_routes",
72 "path": "seed/site_routes.tsv"
73 }
74 ],
75 "migrations": [],
76 "nav": [
77 {
78 "id": "orders",
79 "label": "Orders",
80 "path": "/orders",
81 "blurb": "Sales and purchase orders with their lines and totals",
82 "surface": "member",
83 "group": "Commerce",
84 "order": 420
85 }
86 ],
87 "attention": [
88 {
89 "id": "orders_to_pick",
90 "object_id": "system_order_attention",
91 "label": "Orders to pick",
92 "path": "/orders",
93 "nav_id": "orders",
94 "group": "Commerce",
95 "severity": "normal"
96 }
97 ]
98}