askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
dbbasic-package.json · 12.8 KB · 163 lines
| 1 | { |
| 2 | "id": "app-banking", |
| 3 | "name": "Banking", |
| 4 | "version": "0.9.1", |
| 5 | "description": "Bank statement import and reconciliation -- the #1 practical anti-fraud control, and the one place a third party's independent record enters the system (plan/bank-import-reconciliation-spec.md). The posture is evidence handling, not ETL: bank_lines are append-only, keep their original row verbatim in `raw`, and are never hand-edited, so nobody can quietly reshape the evidence to agree with the books. Imports check THEMSELVES -- a statement carries its own checksum, so tie-out (opening + lines == closing) and continuity (this opening == the last statement's closing) run at import time and set the import's status; flagged imports still store their lines because hiding a truncated statement is exactly the failure this control catches, and the flags record which checks RAN so a balance-less CSV never reads as trustworthy as a tied-out one. Dedup is by the bank's own transaction id when the format has one (OFX FITID), else an ordinal-disambiguated content hash so genuine same-day twins both land while a re-imported file adds nothing; file-level idempotency is by sha256 of the statement itself. Reading a bank's export is DATA (bank_import_profiles.column_map), authored once with AI help and executed deterministically thereafter -- an AI that re-reads statements every month is nondeterministic and unauditable, the opposite of a control. Pure parsing/hashing/gate logic lives in object_banking.py at the repository root, a plain importable library like object_stock.py and object_finance.py, not a registered object. 0.1.0 shipped the evidence layer (collections, the CSV importer, the duplicate gate). 0.2.0 adds the reconciliation work itself: system_bank_matcher proposes book-side records for unmatched lines in tiers (reference+amount, exact amount in a date window, batched-deposit combinations) but only ever SUGGESTS above the configured auto-match tier, because confirming a match must be an ordinary attributed update -- reconciliation performed invisibly by whoever moves the money is the classic fraud hole. hook_bank_lines additionally makes the evidence immutable on update: what the bank said (posted_on, amount, description, raw, identity fields) can never be edited, only the operator's own reconciliation work can. action_resolve_bank_line books the unmatched tail -- bank fees and interest (entries small books routinely never record, which is why their cash drifts until they stop reconciling), own-account transfers, and NSF bounces -- each through object_finance.compose_posted_journal stamped generated_from bank_lines/{id} so resolving twice composes once. The reconciliation statement view is the remaining slice. 0.3.0 adds two things. `value_accounts` generalizes bank_accounts to every place value actually sits -- a checking account, a hardware wallet, a till, a gift card -- carrying denomination, custody (institution/self/third_party), how the balance can be VERIFIED, who manages it day to day, and whether a count needs a witness; the assurance a reconciliation carries follows from the verification method rather than being assumed equal (object_money.assurance_for). value_accounts REPLACED bank_accounts outright in 0.4.0 (rename plus a richer shape, migrated in one commit rather than left as two collections for one concept -- the drift this project criticises in the predecessor). And system_bank_escalation turns a quietly growing unreconciled tail into work someone is accountable for, in BOTH directions: bank lines the books cannot explain, and -- the direction people forget, and the more serious one -- recorded payments the bank never confirmed. OFX/QFX import lands too (action_import_ofx over object_ofx.py): the format worth supporting after CSV because it carries a stable per-transaction id (FITID), which makes dedup exact rather than heuristic and survives a bank re-wording a memo, and a stated closing balance, which lets the statement check its own arithmetic. OFX has no opening-balance tag at all, so a chained opening is taken from the previous statement's closing -- and the import records that the figure was DERIVED, because it makes the continuity check true by construction and only tie-out then carries weight. 0.4.0 also reconciles the accounts nobody sends a statement for: action_record_count counts a till or a safe, stamps what the books said at that moment, books the variance as cash over/short (a real expense -- pretending the drawer always balances is how a slow leak stays invisible for years), and records who counted AND who witnessed. An account may refuse a self-certified count outright, because the person counting the till is usually the person who could take from it. Structurally the same verb as app-catalog's action_apply_count: inventory shrinkage and a cash shortage are the same event in different denominations. Declares an attention count (collection + where, counted per viewer) for `unmatched` bank lines: money moved in the real world and this server has no book record explaining it, after system_bank_matcher already had its go. `suggested` is deliberately not counted -- a suggestion is the machine having done its job. 0.6.1: action_record_count writes the count row before the variance journal, so a failed count write books nothing; a journal that cannot be booked is reported as NOT booked (never a 200), and the journal's generated_from names its count even if the link write fails. value_account_counts v2 adds book_basis (read_only, unique per account), a fingerprint of the ledger a variance was computed against, so two counts against the same books -- a double click -- book the shortage once. The statement importers now RESUME an import that stopped part-way (re-importing the file lands its missing lines under the original import instead of answering 'already imported' forever), derive the import id from the account and file hash so overlapping uploads converge on one import, and read their gates strictly: an unreadable history is a 409, never 'nothing on file'. 0.8.2: action_import_bank_csv asks the permission engine (object_access) for the account and the import profile, where an account with no owner took a statement from any signed-in user and any profile could be read by id. 0.8.3: action_import_ofx asks the permission engine (object_access) for the account, where an account with no owner took a statement from any signed-in user. 0.8.4: action_record_count asks the permission engine (object_access) for the account, where an account with no owner could be counted, and its variance booked, by any signed-in user. 0.8.5: action_resolve_bank_line asks the permission engine (object_access) for the line, the payment an NSF bounces and a transfer's counterpart account, where a line with no owner could be resolved by any signed-in user and any payment could be bounced by naming its id. 0.8.6: a row a registered user writes could point at anybody's record, because the rules asked only that the new row be the writer's own. Every pointer a non-admin can write now declares relation.requires (bank_import_profiles.bank_account_id update, bank_lines.import_id read, bank_lines.bank_account_id update, bank_lines.entity_id update, bank_statement_imports.bank_account_id update, bank_statement_imports.profile_id read, bank_statement_imports.entity_id update, value_account_counts.value_account_id update, value_account_counts.journal_id update, value_account_counts.entity_id update, value_accounts.denomination_id read, value_accounts.fin_account_id update, value_accounts.entity_id update), so over the API a row points only at a record its writer may see, or, where it moves money, stock or state of what it points at, may update; a record they may not see is answered like a missing one (docs/permissions-model.md, 'Pointing at a record you may not act on'). 0.9.0: a cash count's witness is a person who confirms, not a name typed in. action_record_count took any text as witnessed_by, so a closer could pocket cash, type a colleague's name, and the books showed a witnessed shortage implicating the colleague. witnessed_by must now be the user id of another active user (unknown, inactive, the counter by id, display name or email, or another identity account's user all get one refusal that does not say which); the count is still recorded and its variance booked at once, but it stays witness_status named -- rated weak, and an account's second-attestor requirement reported unmet -- until that user, signed in as themselves, states the same figure through the new action_confirm_count (GET lists the counts waiting for them, without the figure). A different figure is recorded as disputed, never as confirmed; the witness answers once; neither the counter, a third user nor an admin can answer for them. value_account_counts v4 makes witnessed_by read_only and adds witness_status, witness_stated_minor and witness_answered_at, all read_only, so the record API cannot set them. Two attention counts show the account owner counts awaiting their witness and counts the witness disputed (docs/cash-counts.md). 0.9.1: value_account_counts v5 makes counted_by read_only, so a registered user creating a count over the record API can no longer put another user's id there; action_record_count still sets it.", |
| 6 | "compatibility": { |
| 7 | "dbbasic_object_server": ">=0.1.0" |
| 8 | }, |
| 9 | "dependencies": [ |
| 10 | "app-finance" |
| 11 | ], |
| 12 | "objects": [ |
| 13 | { |
| 14 | "id": "hook_bank_lines", |
| 15 | "path": "objects/hook/bank_lines.py" |
| 16 | }, |
| 17 | { |
| 18 | "id": "action_import_bank_csv", |
| 19 | "path": "objects/action/import_bank_csv.py" |
| 20 | }, |
| 21 | { |
| 22 | "id": "action_import_ofx", |
| 23 | "path": "objects/action/import_ofx.py" |
| 24 | }, |
| 25 | { |
| 26 | "id": "system_bank_matcher", |
| 27 | "path": "objects/system/bank_matcher.py" |
| 28 | }, |
| 29 | { |
| 30 | "id": "action_resolve_bank_line", |
| 31 | "path": "objects/action/resolve_bank_line.py" |
| 32 | }, |
| 33 | { |
| 34 | "id": "site_reconcile", |
| 35 | "path": "objects/site/reconcile.py" |
| 36 | }, |
| 37 | { |
| 38 | "id": "system_bank_escalation", |
| 39 | "path": "objects/system/bank_escalation.py" |
| 40 | }, |
| 41 | { |
| 42 | "id": "action_record_count", |
| 43 | "path": "objects/action/record_count.py" |
| 44 | }, |
| 45 | { |
| 46 | "id": "action_confirm_count", |
| 47 | "path": "objects/action/confirm_count.py" |
| 48 | } |
| 49 | ], |
| 50 | "schemas": [ |
| 51 | { |
| 52 | "collection": "value_accounts", |
| 53 | "path": "schemas/value_accounts.json" |
| 54 | }, |
| 55 | { |
| 56 | "collection": "value_account_counts", |
| 57 | "path": "schemas/value_account_counts.json" |
| 58 | }, |
| 59 | { |
| 60 | "collection": "bank_import_profiles", |
| 61 | "path": "schemas/bank_import_profiles.json" |
| 62 | }, |
| 63 | { |
| 64 | "collection": "bank_statement_imports", |
| 65 | "path": "schemas/bank_statement_imports.json" |
| 66 | }, |
| 67 | { |
| 68 | "collection": "bank_lines", |
| 69 | "path": "schemas/bank_lines.json" |
| 70 | } |
| 71 | ], |
| 72 | "permissions": [ |
| 73 | { |
| 74 | "path": "permissions/rules.json" |
| 75 | } |
| 76 | ], |
| 77 | "seed": [ |
| 78 | { |
| 79 | "collection": "site_routes", |
| 80 | "path": "seed/site_routes.tsv" |
| 81 | } |
| 82 | ], |
| 83 | "migrations": [], |
| 84 | "schedules": [ |
| 85 | { |
| 86 | "id": "bank_matcher_daily", |
| 87 | "object_id": "system_bank_matcher", |
| 88 | "schedule": "40 6 * * *", |
| 89 | "description": "Suggest and auto-match bank lines against existing records." |
| 90 | }, |
| 91 | { |
| 92 | "id": "bank_escalation_daily", |
| 93 | "object_id": "system_bank_escalation", |
| 94 | "schedule": "55 6 * * *", |
| 95 | "description": "Escalate bank lines left unmatched too long, so a stalled reconciliation is visible rather than silent." |
| 96 | } |
| 97 | ], |
| 98 | "nav": [ |
| 99 | { |
| 100 | "id": "reconcile", |
| 101 | "label": "Reconcile", |
| 102 | "path": "/reconcile", |
| 103 | "blurb": "Match imported bank lines against the books and resolve what differs", |
| 104 | "surface": "member", |
| 105 | "group": "Money", |
| 106 | "order": 360 |
| 107 | } |
| 108 | ], |
| 109 | "attention": [ |
| 110 | { |
| 111 | "id": "bank_lines_unmatched", |
| 112 | "collection": "bank_lines", |
| 113 | "where": { |
| 114 | "match_status": { |
| 115 | "op": "in", |
| 116 | "value": [ |
| 117 | "unmatched", |
| 118 | "" |
| 119 | ] |
| 120 | } |
| 121 | }, |
| 122 | "detail": { |
| 123 | "op": "count", |
| 124 | "where": { |
| 125 | "posted_on": { |
| 126 | "op": "older_than_days", |
| 127 | "value": 7 |
| 128 | } |
| 129 | }, |
| 130 | "text": "{value} older than 7 days" |
| 131 | }, |
| 132 | "label": "Bank lines to match", |
| 133 | "path": "/reconcile", |
| 134 | "nav_id": "reconcile", |
| 135 | "group": "Money", |
| 136 | "severity": "normal" |
| 137 | }, |
| 138 | { |
| 139 | "id": "counts_awaiting_witness", |
| 140 | "collection": "value_account_counts", |
| 141 | "where": { |
| 142 | "witness_status": "named" |
| 143 | }, |
| 144 | "label": "Cash counts awaiting their witness", |
| 145 | "path": "/reconcile", |
| 146 | "nav_id": "reconcile", |
| 147 | "group": "Money", |
| 148 | "severity": "normal" |
| 149 | }, |
| 150 | { |
| 151 | "id": "counts_witness_disputed", |
| 152 | "collection": "value_account_counts", |
| 153 | "where": { |
| 154 | "witness_status": "disputed" |
| 155 | }, |
| 156 | "label": "Cash counts the named witness disputed", |
| 157 | "path": "/reconcile", |
| 158 | "nav_id": "reconcile", |
| 159 | "group": "Money", |
| 160 | "severity": "warning" |
| 161 | } |
| 162 | ] |
| 163 | } |