618 lines · 15.3 KB · JSONRaw
{ "format_version": 1, "id": "statement", "name": "Statement", "plural": "Statements", "builtin": true, "visibility": "owner", "date": "period_end", "columns": [ { "key": "document_id", "name": "Document", "type": "link", "link_to": "document", "required": true, "readonly": true }, { "key": "account_id", "name": "Account", "type": "link", "link_to": "money_account", "readonly": true }, { "key": "kind", "type": "choice", "choices": [ "bank", "credit_card" ], "labels": { "bank": "Bank statement", "credit_card": "Card statement" }, "readonly": true }, { "key": "period_start", "name": "Period", "type": "date", "readonly": true }, { "key": "period_end", "name": "To", "type": "date", "readonly": true }, { "key": "opening_balance_minor", "name": "Opening balance", "type": "amount", "readonly": true, "currency": "currency" }, { "key": "closing_balance_minor", "name": "Closing balance", "type": "amount", "readonly": true, "currency": "currency" }, { "key": "currency", "type": "text", "readonly": true }, { "key": "read_status", "name": "Reading", "type": "choice", "choices": [ "pending", "read", "mismatch", "failed" ], "labels": { "pending": "Not read yet", "read": "Read", "mismatch": "Read, totals differ", "failed": "Could not be read" }, "readonly": true }, { "key": "read_error", "name": "Read problem", "type": "text", "readonly": true }, { "key": "read_by", "type": "text", "readonly": true }, { "key": "read_at", "name": "Read", "type": "date", "readonly": true }, { "key": "line_count", "name": "Lines", "type": "number", "readonly": true }, { "key": "sum_in_minor", "name": "Money in", "type": "amount", "readonly": true, "currency": "currency" }, { "key": "sum_out_minor", "name": "Money out", "type": "amount", "readonly": true, "currency": "currency" }, { "key": "balance_check", "name": "Balance check", "type": "choice", "choices": [ "ok", "mismatch", "unknown" ], "labels": { "ok": "Adds up", "mismatch": "Does not add up", "unknown": "Not checked" }, "readonly": true }, { "key": "recorded_count", "name": "Recorded entries", "type": "number", "readonly": true }, { "key": "visual_problem", "name": "Reading problem", "type": "text", "readonly": true, "labels": { "unavailable": "Could not read: page verification is unavailable on this Mac.", "renderer_failed": "Could not read: the page images could not be read.", "glyph_maps_unread": "Could not read: the PDF font maps could not be decoded.", "heading_mismatch": "Could not read: a figure in the statement heading differs from the page image." } }, { "key": "visual_problem_page", "name": "Reading problem", "type": "number", "readonly": true, "units": { "one": "Could not read page {n}: a figure differs from the page image.", "other": "Could not read page {n}: a figure differs from the page image." } }, { "key": "visual_problem_field", "name": "Figure", "type": "text", "readonly": true, "labels": { "date": "Date", "amount": "Amount", "direction": "Money in or out", "balance": "Running balance", "balance_after": "Running balance", "balance_after_minor": "Running balance", "period_start": "Period start", "period_end": "Period end", "opening_balance": "Opening balance", "closing_balance": "Closing balance", "opening_balance_minor": "Opening balance", "closing_balance_minor": "Closing balance", "entry_count": "Repeated entries", "entry_type": "Money entry or total" } } ], "instructions": "A statement is a bank or card statement read from a filed document, covering one period of one account. Read status is pending until read, read when the totals agreed, mismatch when they did not, and failed when it could not be read. Nothing is recorded from a statement whose totals did not agree; amounts are integer minor units.", "tables": [ { "name": "cotton_money_statements", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "document_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n document_id TEXT NOT NULL", "position": 2 }, { "name": "account_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n account_id TEXT", "position": 3 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL", "position": 4 }, { "name": "period_start", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n period_start TEXT", "position": 5 }, { "name": "period_end", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n period_end TEXT", "position": 6 }, { "name": "opening_balance_minor", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n opening_balance_minor INTEGER", "position": 7 }, { "name": "closing_balance_minor", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n closing_balance_minor INTEGER", "position": 8 }, { "name": "currency", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n currency TEXT NOT NULL", "position": 9 }, { "name": "read_status", "type": "TEXT", "default": "'pending'", "nullable": false, "primary_key": false, "declaration": "\n read_status TEXT NOT NULL DEFAULT 'pending'", "position": 10 }, { "name": "read_error", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n read_error TEXT", "position": 11 }, { "name": "read_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n read_by TEXT", "position": 12 }, { "name": "read_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n read_at TEXT", "position": 13 }, { "name": "line_count", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n line_count INTEGER NOT NULL DEFAULT 0", "position": 14 }, { "name": "sum_in_minor", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n sum_in_minor INTEGER NOT NULL DEFAULT 0", "position": 15 }, { "name": "sum_out_minor", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n sum_out_minor INTEGER NOT NULL DEFAULT 0", "position": 16 }, { "name": "balance_check", "type": "TEXT", "default": "'unknown'", "nullable": false, "primary_key": false, "declaration": "\n balance_check TEXT NOT NULL DEFAULT 'unknown'", "position": 17 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 18 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 19 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 20 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 21 } ], "constraints": [ { "declaration": "\n UNIQUE (document_id)", "position": 22 }, { "declaration": "\n CHECK (balance_check IN ('ok', 'mismatch', 'unknown'))", "position": 23 }, { "declaration": "\n CHECK (kind IN ('bank', 'credit_card'))", "position": 24 }, { "declaration": "\n CHECK (line_count >= 0)", "position": 25 }, { "declaration": "\n CHECK ((period_start IS NULL) OR (period_end IS NULL) OR (period_end >= period_start))", "position": 26 }, { "declaration": "\n CHECK (read_status IN ('pending', 'read', 'mismatch', 'failed'))", "position": 27 }, { "declaration": "\n FOREIGN KEY (document_id) REFERENCES cotton_documents(id)", "position": 28 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 29 } ], "prefix": "CREATE TABLE cotton_money_statements (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_money_statements_account ON cotton_money_statements (account_id, period_start) WHERE account_id IS NOT NULL", "CREATE INDEX idx_cotton_money_statements_pending ON cotton_money_statements (created_at) WHERE read_status = 'pending'", "CREATE INDEX idx_cotton_money_statements_workspace ON cotton_money_statements (workspace_id, period_start DESC)", "CREATE INDEX IF NOT EXISTS idx_cotton_money_statements_author ON cotton_money_statements (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ], "picture": null, "engine": "money", "title": "period_start", "project": null, "order": null, "slip": { "title": "period_start", "subtitle": "account_id", "trailing": "period_end", "photo": null, "toggle": null, "caption": { "columns": [ "closing_balance_minor", "balance_check", "recorded_count" ] } }, "tile": { "face": "slip-list" }, "page": [ { "heading": null, "columns": [ "period_start", "period_end", "account_id", "document_id" ], "figure": "closing_balance_minor" }, { "heading": null, "columns": [ "visual_problem", "visual_problem_page", "visual_problem_field" ], "when": { "column": "visual_problem", "present": true } }, { "heading": null, "columns": [ "opening_balance_minor", "closing_balance_minor", "balance_check", "read_error" ], "role": "facts" }, { "heading": "Lines", "columns": [], "list": { "table": "statement_line", "link": "statement_id", "empty": { "title": "Kept as a summary", "message": "This statement was kept as its totals only. Its lines were not kept." } }, "when": { "column": "read_status", "values": [ "read", "mismatch" ] }, "role": "main" }, { "heading": null, "columns": [ "kind", "currency", "read_status" ], "role": "side" }, { "heading": "Totals", "columns": [ "line_count", "recorded_count", "sum_in_minor", "sum_out_minor", "read_at" ], "role": "side" } ], "sort": { "column": "period_start", "descending": true }, "delete": false, "derived": true, "parts": { "shape": "sheet", "head": { "facts": [] }, "links": [], "lists": [ { "table": "statement_line", "relation": "statement_id", "heading": "Lines" } ], "acts": { "more": [] }, "cards": [ { "column": "balance_check" }, { "column": "read_status" }, { "column": "visual_problem", "when": { "column": "visual_problem", "values": [ "unavailable", "renderer_failed", "glyph_maps_unread", "heading_mismatch" ] } }, { "column": "visual_problem_page", "when": { "column": "visual_problem", "values": [ "page_mismatch" ] } }, { "column": "visual_problem_field", "when": { "column": "visual_problem", "values": [ "heading_mismatch", "page_mismatch" ] } }, { "column": "read_error" }, { "column": "opening_balance_minor" }, { "column": "closing_balance_minor" }, { "column": "sum_in_minor" }, { "column": "sum_out_minor" }, { "column": "recorded_count" } ], "strip": [] }}