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
bank_lines.json · 5.9 KB · 64 lines
1{
2 "name": "bank_lines",
3 "title": "Bank Lines",
4 "version": 5,
5 "storage": "append",
6 "description": "Imported statement lines -- the independent third-party record the books are checked against, and the reason bank reconciliation is the #1 practical anti-fraud control. Append-only and never hand-edited: `raw` keeps the original row verbatim forever and the parsed fields are a VIEW of it, so nobody can quietly 'fix up' the evidence to agree with the books. amount_cents is signed (money into the account positive, out negative). Everything an operator DOES with a line -- matching it, resolving it as a fee or a transfer -- is a separate attributed update, so who reconciled what and when is structural, which matters because reconciliation performed invisibly by the same hands that move money is the classic fraud hole. hooks.before_write rejects duplicates within an account (external_id when the bank gives one, else line_hash). v2 declares both dedup keys unique per bank account -- external_id, and line_hash -- enforced inside the write lock (docs/validation-and-logic.md), which is the same rule the hook and both importers already apply by reading first. Reading first is not enough: two overlapping posts of one line each found nothing and both landed, and an importer whose read failed re-imported lines already on file. A line with no external_id (most CSV exports) is exempt from that key and held by its line_hash. v5: relation.requires on every pointer: update on the account and the entity whose books the line lands in, read on the import (imports are not updatable, even by their owner).",
7 "unique": [
8 {"fields": ["external_id"], "scope": ["bank_account_id"],
9 "message": "A statement line with this bank transaction id is already on file for this bank account. Bank lines are append-only evidence: re-importing a statement never duplicates it."},
10 {"fields": ["line_hash"], "scope": ["bank_account_id"],
11 "message": "This statement line is already on file for this bank account (same date, amount and description). Bank lines are append-only evidence: re-importing a statement never duplicates it."}
12 ],
13 "locked_when": [
14 {"when": {"match_status": ["unmatched", "suggested", "matched", "resolved", ""]},
15 "except": ["match_status", "matched_to", "resolved_as", "suggestions", "owner_id", "entity_id"],
16 "allow_delete": true,
17 "message": "A bank line records what the bank said and cannot be edited. Import a corrected statement instead -- reconciliation means explaining the difference between the bank and the books, never editing one to match the other."}
18 ],
19 "hooks": {"before_write": "hook_bank_lines"},
20 "fields": [
21 {"name": "id"},
22 {"name": "import_id", "label": "Import",
23 "relation": {"collection": "bank_statement_imports", "display_field": "period_end", "requires": "read"}},
24 {"name": "bank_account_id", "required": true, "label": "Bank Account",
25 "relation": {"collection": "value_accounts", "display_field": "name", "requires": "update"}},
26 {"name": "posted_on", "type": "date", "required": true, "label": "Posted"},
27 {"name": "amount_cents", "type": "integer", "required": true, "label": "Amount (cents)",
28 "help": "Signed: positive is money into the account, negative is money out. Integer cents, never a float."},
29 {"name": "description", "type": "text", "label": "Description"},
30 {"name": "external_id", "type": "text", "label": "Bank Transaction ID",
31 "help": "The bank's own id (OFX FITID) when the format carries one -- the strongest dedup key."},
32 {"name": "line_hash", "type": "text", "label": "Line Hash",
33 "help": "Content hash used for dedup when the bank gives no id; ordinal-disambiguated so genuine same-day twins both land."},
34 {"name": "raw", "type": "textarea", "label": "Raw Row",
35 "help": "The original statement row, verbatim. Never rewritten -- this is the evidence."},
36 {"name": "match_status", "type": "enum", "default": "unmatched", "label": "Match Status",
37 "enum": ["unmatched", "suggested", "matched", "resolved"],
38 "transitions": {
39 "unmatched": ["suggested", "matched", "resolved"],
40 "suggested": ["matched", "unmatched", "resolved"],
41 "matched": ["unmatched", "resolved"],
42 "resolved": ["unmatched"]
43 },
44 "help": "unmatched -> suggested (the matcher proposed something) -> matched (a human confirmed) or resolved (booked as a fee/interest/transfer/NSF/timing item). Every move is attributed."},
45 {"name": "matched_to", "type": "text", "label": "Matched To",
46 "validation": {"pattern": "[^/\\s]+/[^/\\s]+",
47 "required_when": {"match_status": ["matched"]}},
48 "help": "collection/record_id of the book-side record this line is, e.g. payments/p1 or fin_journals/j9."},
49 {"name": "resolved_as", "type": "enum", "label": "Resolved As",
50 "enum": ["fee", "interest", "transfer", "nsf", "timing", "other"],
51 "help": "For lines with no book counterpart yet: what the line actually was. Each has a resolution verb that composes the right journal."},
52 {"name": "suggestions", "type": "textarea", "label": "Suggestions (JSON)",
53 "help": "What the matcher proposed and why (tier + candidates). Derived and non-authoritative -- a human confirmation is what writes matched_to."},
54 {"name": "owner_id", "type": "text", "label": "Owner"},
55 {"name": "entity_id", "type": "text", "label": "Entity",
56 "relation": {"collection": "entities", "display_field": "name", "requires": "update"}},
57 {"name": "created_at", "type": "datetime", "read_only": true, "label": "Imported"}
58 ],
59 "search": {"fields": ["description", "external_id"]},
60 "forms": {"default": {"fields": ["bank_account_id", "posted_on", "amount_cents", "description"]}},
61 "views": {"list_mode": "table",
62 "list_fields": ["posted_on", "description", "amount_cents", "match_status", "resolved_as"],
63 "filter_fields": ["bank_account_id", "match_status", "resolved_as"]}
64}