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
wallet_entries.json · 5.3 KB · 127 lines
1{
2 "name": "wallet_entries",
3 "title": "Wallet Entries",
4 "version": 4,
5 "storage": "append",
6 "description": "Every movement of a wallet's balance, append-only: this ledger IS the balance (wallets.balance_minor is a rollup over it), so an entry is never edited or deleted -- a mistaken charge is corrected by a compensating entry that says so, exactly as refunds correct payments and reversing journals correct postings (docs/logic-decisions.md #3). amount_minor is signed: credits positive, debits negative, in the wallet denomination's smallest unit. generated_from carries provenance for machine-written entries (a Stripe top-up stamps its event, an auto-replenishment stamps its charge), which is what makes redelivery and re-runs safe by construction rather than by a dedup table. The reason a customer can always be shown WHY their balance is what it is: every entry names its kind, its amount, and what caused it. v3 makes two of those guarantees the ledger's rather than its callers': `unique` declares generated_from used once (blank exempt), checked inside the write lock, because every writer that looked for its own marker by reading first -- the auto top-up, the gift-card issuer, checkout, dispute resolution -- let a second overlapping writer through, and the hook's copy of the rule runs before the lock and never runs for a storage-level writer at all; and (wallet_id, spend_seq) is unique: the claim a debit writer puts on the balance it just summed, so two debits that read the same balance cannot both land (a 1000 gift card paid for two 1000 checkouts). Credits, and writers that do not claim, leave spend_seq blank and are exempt. v4 only rewords the posted-once unique message for the person refused.",
7 "hooks": {
8 "before_write": "hook_wallet_entries"
9 },
10 "unique": [
11 {
12 "fields": [
13 "generated_from"
14 ],
15 "message": "This event has already been posted to the wallet ledger, so it was not posted again."
16 },
17 {
18 "fields": [
19 "spend_seq"
20 ],
21 "scope": [
22 "wallet_id"
23 ],
24 "message": "Another debit claimed this wallet's balance first; read the balance again."
25 }
26 ],
27 "fields": [
28 {
29 "name": "id"
30 },
31 {
32 "name": "wallet_id",
33 "required": true,
34 "label": "Wallet",
35 "relation": {
36 "collection": "wallets",
37 "display_field": "owner_id"
38 }
39 },
40 {
41 "name": "amount_minor",
42 "type": "integer",
43 "required": true,
44 "label": "Amount",
45 "help": "Signed: a credit is positive, a debit negative. Integer minor units, never a float."
46 },
47 {
48 "name": "kind",
49 "type": "enum",
50 "required": true,
51 "default": "debit",
52 "label": "Kind",
53 "enum": [
54 "topup",
55 "auto_topup",
56 "debit",
57 "refund",
58 "promo",
59 "adjustment",
60 "hold",
61 "release"
62 ],
63 "help": "topup: the customer paid. auto_topup: the saved card was charged by the threshold rule. debit: usage drawn down. refund/promo/adjustment: money back, granted, or corrected. hold: money RESERVED against a commitment that has not executed yet (negative, so the balance gate fires at the moment of commitment rather than the moment of spending -- a template run queued against 5 cents of balance must be refused before the provider is paid real money, not billed after). release: a hold handed back at settlement, always in full, always paired to its hold by generated_from marker. The actual charge for a settled commitment is an ORDINARY debit, deliberately: a released hold must never read as a refund in the reports that already exist, because a hold is not a debit that got undone -- it is money that was never spent, and the ledger should say so."
64 },
65 {
66 "name": "description",
67 "type": "text",
68 "label": "Description",
69 "help": "What this was for, in words the customer would accept on a statement."
70 },
71 {
72 "name": "reference",
73 "type": "text",
74 "label": "Reference",
75 "help": "The thing that caused it: a task id, an invoice number, a provider charge."
76 },
77 {
78 "name": "generated_from",
79 "type": "text",
80 "label": "Generated From",
81 "help": "Provenance for machine-written entries (stripe_evt/..., auto_topup/...). Its presence is what makes a replay a no-op instead of a second charge."
82 },
83 {
84 "name": "spend_seq",
85 "type": "integer",
86 "label": "Spend Sequence",
87 "read_only": true,
88 "help": "Set by a debit writer that claims the balance it summed (checkout's gift-card spend): one more than the highest number on this wallet's entries. Unique per wallet, so of two debits that read the same balance only one lands and the other re-reads. Blank on credits and on writers that do not claim."
89 },
90 {
91 "name": "owner_id",
92 "type": "text",
93 "label": "Owner"
94 },
95 {
96 "name": "created_at",
97 "type": "datetime",
98 "read_only": true,
99 "label": "Recorded"
100 }
101 ],
102 "forms": {
103 "default": {
104 "fields": [
105 "wallet_id",
106 "amount_minor",
107 "kind",
108 "description",
109 "reference"
110 ]
111 }
112 },
113 "views": {
114 "list_mode": "table",
115 "list_fields": [
116 "created_at",
117 "kind",
118 "amount_minor",
119 "description",
120 "reference"
121 ],
122 "filter_fields": [
123 "wallet_id",
124 "kind"
125 ]
126 }
127}