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
fin_journals.json · 9.1 KB · 219 lines
1{
2 "name": "fin_journals",
3 "title": "Journals",
4 "version": 12,
5 "unique": [
6 {
7 "fields": [
8 "generated_from"
9 ],
10 "message": "This has already been posted as a journal, so it was not posted again."
11 }
12 ],
13 "description": "Double-entry transaction headers; the actual debit/credit rows live in fin_journal_lines. Reconciled against a private predecessor-system audit, not part of this repo (its Journal model: '+lines; draft/posted; contact/project/document links; period_locked'). Whether a journal balances (total_debits_cents == total_credits_cents) is a COMPUTED property (see object_finance.journal_totals), never enforced here -- see the status field's help below for why, matching the source's own weak spot exactly (reconciled against a private predecessor-system audit, not part of this repo: 'posting is a bare status flip -- balance NOT enforced at post'). v2 adds generated_from (plan/vocabulary/61-materialize-spec.md, additive): a small optional JSON provenance stamp on a journal materialize generated (definition id, source row id, period), left blank on a hand-created journal. v8 makes generated_from unique (blank exempt), checked inside the write lock; object_finance.compose_posted_journal answers a refusal as already composed. Its scan-then-write had let two overlapping callers post two journals for one fact (four reversal mirrors of one journal). v9 makes posted FINAL: locked_when freezes every field of a posted journal and refuses its delete, inside the write lock and for every writer (docs/validation-and-logic.md). Until then nothing froze a posted journal -- its owner could re-date it into another month's figures or delete it and orphan its lines. status is deliberately not in the rule's `except`, so posted is terminal, which is what the transitions map already said. The correction for a posted journal is a reversing journal. v10 only rewords the unique message for the person refused (it had been a developer note). v11 moves the closed-period rule into the write lock: locked_checks.closed_period (hook_fin_journals.LOCKED_CHECK) refuses creating, editing or deleting a journal dated inside a closed period, or moving one in or out, for EVERY writer. The rule had lived only in the HTTP hook, and every composer writes below it, so an expense approved and a payment recorded after November was closed each posted into November. Composers now book such a fact on the first open day after the period instead (object_finance.compose_posted_journal), keeping the real date in occurred_on (read_only) and setting period_review=pending, which the attention board counts until somebody marks it reviewed -- the one field a posted journal still lets change. v12: entity_id declares relation.requires update: a journal is booked into an entity its writer may update.",
14 "fields": [
15 {
16 "name": "id"
17 },
18 {
19 "name": "date",
20 "type": "date",
21 "required": true,
22 "label": "Date"
23 },
24 {
25 "name": "description",
26 "type": "text",
27 "label": "Description",
28 "validation": {
29 "max_length": 300
30 }
31 },
32 {
33 "name": "status",
34 "type": "enum",
35 "label": "Status",
36 "default": "draft",
37 "enum": [
38 "draft",
39 "posted"
40 ],
41 "transitions": {
42 "draft": [
43 {
44 "to": "posted",
45 "when": {
46 "owner_id": "$user_id"
47 }
48 }
49 ]
50 },
51 "help": "posted is terminal (no move back to draft) -- matches the predecessor system exactly, which never offered one either. Posting is a bare status flip, owner-gated, and nothing more: it does NOT check total_debits_cents == total_credits_cents first. This is not an oversight -- the source's own posting flow never enforced or even computed a balance at post time (reconciled against a private predecessor-system audit, not part of this repo, whose own words are: 'posting is a bare status flip -- balance NOT enforced at post'). journal_totals()/is_balanced (object_finance.py) is available for a caller (a report, a warning banner) to check before or after posting, but nothing in this schema or package blocks an unbalanced journal from being posted. See dbbasic-package.json's Deferred list -- adding that check would be a real improvement over the source, tracked there as future work, not built in this migration."
52 },
53 {
54 "name": "kind",
55 "type": "enum",
56 "label": "Kind",
57 "default": "standard",
58 "enum": [
59 "standard",
60 "adjusting",
61 "reversing",
62 "closing"
63 ]
64 },
65 {
66 "name": "contact_id",
67 "type": "text",
68 "label": "Contact",
69 "help": "Optional cross-reference to a contact/customer/vendor id. Plain text, not an enforced relation -- this package has no hard dependency on app-contacts, same posture as app-invoices' source_order_id and app-orders' product_id-optional pattern."
70 },
71 {
72 "name": "reference",
73 "type": "text",
74 "label": "Reference",
75 "validation": {
76 "max_length": 200
77 },
78 "help": "Free-text external reference (invoice number, check number, bank reference, etc.)."
79 },
80 {
81 "name": "currency",
82 "type": "text",
83 "default": "USD",
84 "label": "Currency (ISO 4217)",
85 "validation": {
86 "pattern": "^[A-Z]{3}$"
87 }
88 },
89 {
90 "name": "generated_from",
91 "type": "text",
92 "label": "Generated From",
93 "help": "Provenance stamp (JSON: definition_id/source_id/period_start) set when this journal was created by a materialize_definitions row (plan/vocabulary/61-materialize-spec.md) rather than hand-entered. Blank for a hand-created journal. An ordinary (not schema read_only) field, same reasoning as app-orders' order_totals-stamped fields: object_materialize's write is a plain field submission through create_collection_record, no special escape hatch -- keeping this field read_only would need one. Omitted from forms.default so the generated form never renders it as an editable input."
94 },
95 {
96 "name": "occurred_on",
97 "type": "date",
98 "label": "Occurred On",
99 "read_only": true,
100 "help": "Set only when a composer could not use the date the fact happened on because it fell inside a closed period: that date, kept here, while the journal itself is dated the first open day after the period (object_finance.compose_posted_journal). Blank means the journal is dated when it happened."
101 },
102 {
103 "name": "period_review",
104 "type": "enum",
105 "label": "Period Review",
106 "enum": [
107 "pending",
108 "reviewed"
109 ],
110 "help": "pending: a composer booked this after the period it belongs to had been closed, so it sits in the next open period and the closed one does not include it. Counted on the attention board until somebody looks and marks it reviewed. Blank for every other journal. Editable on a posted journal (locked_when's except) because marking it reviewed changes nothing about the money."
111 },
112 {
113 "name": "debit_total_cents",
114 "type": "computed",
115 "label": "Debits (cents)",
116 "rollup": {
117 "collection": "fin_journal_lines",
118 "fk_field": "journal_id",
119 "op": "sum",
120 "field": "debit_cents"
121 }
122 },
123 {
124 "name": "credit_total_cents",
125 "type": "computed",
126 "label": "Credits (cents)",
127 "rollup": {
128 "collection": "fin_journal_lines",
129 "fk_field": "journal_id",
130 "op": "sum",
131 "field": "credit_cents"
132 }
133 },
134 {
135 "name": "owner_id",
136 "type": "text",
137 "label": "Owner"
138 },
139 {
140 "name": "entity_id",
141 "type": "text",
142 "label": "Entity",
143 "relation": {
144 "collection": "entities",
145 "display_field": "name",
146 "requires": "update"
147 },
148 "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."
149 },
150 {
151 "name": "created_at",
152 "type": "datetime",
153 "label": "Created",
154 "read_only": true
155 }
156 ],
157 "forms": {
158 "default": {
159 "fields": [
160 "date",
161 "description",
162 "status",
163 "contact_id",
164 "reference",
165 "currency"
166 ]
167 }
168 },
169 "views": {
170 "list_mode": "table",
171 "list_fields": [
172 "date",
173 "description",
174 "status",
175 "currency"
176 ],
177 "filter_fields": [
178 "status",
179 "kind",
180 "period_review"
181 ]
182 },
183 "locked_when": [
184 {
185 "when": {
186 "status": [
187 "posted"
188 ]
189 },
190 "except": [
191 "period_review"
192 ],
193 "message": "A posted journal is final: it cannot be edited or deleted. Correct it with a reversing journal."
194 }
195 ],
196 "locked_checks": [
197 {
198 "name": "closed_period",
199 "object": "hook_fin_journals",
200 "function": "LOCKED_CHECK",
201 "reads": [
202 "fin_closed_periods"
203 ],
204 "lock": "fin_periods",
205 "on": {
206 "create": true,
207 "update": true,
208 "delete": true
209 }
210 }
211 ],
212 "hooks": {
213 "before_write": "hook_fin_journals"
214 },
215 "capabilities": {
216 "comments": true,
217 "attachments": true
218 }
219}