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.
fin_journal_lines.json · 3.8 KB · 117 lines
| 1 | { |
| 2 | "name": "fin_journal_lines", |
| 3 | "title": "Journal Lines", |
| 4 | "version": 5, |
| 5 | "storage": "append", |
| 6 | "description": "Debit/credit rows belonging to one journal. A line is a debit OR a credit -- nothing in this schema enforces that split (a row could carry both debit_cents and credit_cents nonzero), matching the source's own JournalLine model, which also never enforced it at the field level (reconciled against a private predecessor-system audit, not part of this repo: 'JournalLine (debit-or-credit, ...)' is a naming/usage convention, not a guarded constraint). Totals are never stamped back onto fin_journals -- see object_finance.journal_totals for the computed fold and packages/app-finance/schemas/fin_journals.json's status field help for why no balance check exists at post. v4: a line whose journal is dated inside a closed period cannot be added, edited, moved or removed by any writer -- locked_checks.closed_period (hook_fin_journal_lines.LOCKED_CHECK), inside the write lock, on the fin_periods lock every write to fin_journals and fin_closed_periods also takes. It had been the HTTP hook's rule only, which no composer reaches. v5: relation.requires update on the journal, the account and the entity. A registered user's own line could be added to anybody's journal, which is a change to their books.", |
| 7 | "fields": [ |
| 8 | { |
| 9 | "name": "id" |
| 10 | }, |
| 11 | { |
| 12 | "name": "journal_id", |
| 13 | "type": "relation", |
| 14 | "required": true, |
| 15 | "relation": { |
| 16 | "collection": "fin_journals", |
| 17 | "display_field": "description", |
| 18 | "requires": "update" |
| 19 | }, |
| 20 | "label": "Journal", |
| 21 | "help": "Set once at creation and not intended to change after. Not schema read_only -- same reason as app-invoices' invoice_lines.invoice_id: a required, client-submitted-at-creation field cannot also be read_only on this platform (the server rejects any client submission of a read_only field, even the first one)." |
| 22 | }, |
| 23 | { |
| 24 | "name": "account_id", |
| 25 | "type": "relation", |
| 26 | "required": true, |
| 27 | "relation": { |
| 28 | "collection": "fin_accounts", |
| 29 | "display_field": "name", |
| 30 | "requires": "update" |
| 31 | }, |
| 32 | "label": "Account" |
| 33 | }, |
| 34 | { |
| 35 | "name": "debit_cents", |
| 36 | "type": "integer", |
| 37 | "default": "0", |
| 38 | "label": "Debit (cents)" |
| 39 | }, |
| 40 | { |
| 41 | "name": "credit_cents", |
| 42 | "type": "integer", |
| 43 | "default": "0", |
| 44 | "label": "Credit (cents)" |
| 45 | }, |
| 46 | { |
| 47 | "name": "memo", |
| 48 | "type": "text", |
| 49 | "label": "Memo", |
| 50 | "validation": { |
| 51 | "max_length": 300 |
| 52 | } |
| 53 | }, |
| 54 | { |
| 55 | "name": "owner_id", |
| 56 | "type": "text", |
| 57 | "label": "Owner" |
| 58 | }, |
| 59 | { |
| 60 | "name": "entity_id", |
| 61 | "type": "text", |
| 62 | "label": "Entity", |
| 63 | "relation": { |
| 64 | "collection": "entities", |
| 65 | "display_field": "name", |
| 66 | "requires": "update" |
| 67 | }, |
| 68 | "help": "The set of books this belongs to (65 multi-entity). Optional during rollout; backfilled to the owner's default entity, set by the entity switcher on new writes." |
| 69 | }, |
| 70 | { |
| 71 | "name": "created_at", |
| 72 | "type": "datetime", |
| 73 | "label": "Created", |
| 74 | "read_only": true |
| 75 | } |
| 76 | ], |
| 77 | "forms": { |
| 78 | "default": { |
| 79 | "fields": [ |
| 80 | "journal_id", |
| 81 | "account_id", |
| 82 | "debit_cents", |
| 83 | "credit_cents", |
| 84 | "memo" |
| 85 | ] |
| 86 | } |
| 87 | }, |
| 88 | "views": { |
| 89 | "list_mode": "table", |
| 90 | "list_fields": [ |
| 91 | "account_id", |
| 92 | "debit_cents", |
| 93 | "credit_cents", |
| 94 | "memo" |
| 95 | ] |
| 96 | }, |
| 97 | "locked_checks": [ |
| 98 | { |
| 99 | "name": "closed_period", |
| 100 | "object": "hook_fin_journal_lines", |
| 101 | "function": "LOCKED_CHECK", |
| 102 | "reads": [ |
| 103 | "fin_journals", |
| 104 | "fin_closed_periods" |
| 105 | ], |
| 106 | "lock": "fin_periods", |
| 107 | "on": { |
| 108 | "create": true, |
| 109 | "update": true, |
| 110 | "delete": true |
| 111 | } |
| 112 | } |
| 113 | ], |
| 114 | "hooks": { |
| 115 | "before_write": "hook_fin_journal_lines" |
| 116 | } |
| 117 | } |