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
promotion_redemptions.json · 4.1 KB · 41 lines
1{
2 "name": "promotion_redemptions",
3 "title": "Promotion Redemptions",
4 "version": 1,
5 "storage": "append",
6 "description": "One row per use of a code, append-only: these rows ARE the redemption count (promotions.redemptions_used is a rollup over them), so a row is never edited or deleted -- a use given back is a compensating record on the order that gave it back, exactly as refunds correct payments and reversing journals correct postings (docs/logic-decisions.md #3). The load-bearing property is that THE TERMS ARE STAMPED HERE: kind, value, minimum_spend_cents and stacking are copied off the promotion at the moment somebody redeems it, so editing the promotion next month changes what the NEXT shopper gets and nothing else. Without that stamp, a shop that raises SPRING20 from 10% to 20% silently restates every receipt already issued under it, and the customer asking why their order shows one number and the promotion page shows another is right to be confused. discount_cents is the money that actually came off, computed once by object_promotions.discount_for and recorded rather than recomputed: a number rederived later from terms that have since moved is the very drift this row exists to prevent. code_used is stored upper-cased -- the comparison form -- because that is what a fold over these rows matches on.",
7 "fields": [
8 {"name": "id"},
9 {"name": "promotion_id", "required": true, "label": "Promotion",
10 "relation": {"collection": "promotions", "display_field": "code"}},
11 {"name": "code_used", "type": "text", "label": "Code",
12 "help": "The code as it was COMPARED -- trimmed and upper-cased. Kept beside the relation on purpose: a promotion row can be retired, and the receipt still has to be able to say which word the customer typed."},
13 {"name": "kind", "type": "text", "label": "Kind",
14 "help": "STAMPED: what the promotion was when this was redeemed. Plain text and not an enum, because this is a historical record of a term, and a later narrowing of the promotion's own enum must never make an old redemption unreadable."},
15 {"name": "value", "type": "integer", "default": "0", "label": "Value",
16 "help": "STAMPED: basis points or cents, whichever the stamped kind meant."},
17 {"name": "minimum_spend_cents", "type": "integer", "default": "0",
18 "label": "Minimum Spend",
19 "help": "STAMPED: the threshold this redemption was actually judged against, so a later change to the promotion cannot make a past use look like it should have been refused."},
20 {"name": "stacking", "type": "text", "label": "Stacking",
21 "help": "STAMPED: whether this code allowed company at the time it was used."},
22 {"name": "order_id", "label": "Order",
23 "relation": {"collection": "orders", "display_field": "number"},
24 "help": "The sale it came off. This is the join that makes a redemption auditable: what was bought, for how much, and what the code took off it."},
25 {"name": "customer_email", "type": "text", "label": "Customer",
26 "help": "Who used it, which is what a per-customer limit counts. Matched case-insensitively, because the same address with a capital letter is the same person."},
27 {"name": "discount_cents", "type": "integer", "default": "0",
28 "label": "Discount",
29 "help": "The money that actually came off, in cents, computed once at redemption. Recorded rather than recomputed later: a number rederived from terms that have moved is exactly the drift this row exists to prevent."},
30 {"name": "redeemed_at", "type": "datetime", "label": "Redeemed",
31 "help": "When it was used. Stamped by the writer rather than left to created_at so a backfilled or imported redemption can carry its real moment."},
32 {"name": "owner_id", "type": "text", "label": "Owner"},
33 {"name": "created_at", "type": "datetime", "read_only": true, "label": "Recorded"}
34 ],
35 "forms": {"default": {"fields": ["promotion_id", "code_used", "order_id",
36 "customer_email", "discount_cents"]}},
37 "views": {"list_mode": "table",
38 "list_fields": ["redeemed_at", "code_used", "customer_email",
39 "discount_cents", "order_id"],
40 "filter_fields": ["promotion_id"]}
41}