Cotton code
372 lines · 9.0 KB · JSONRaw
{  "format_version": 1,  "id": "statement_line",  "name": "Statement line",  "plural": "Statement lines",  "picture": null,  "builtin": true,  "delete": false,  "engine": "money",  "derived": true,  "columns": [    {      "key": "title",      "name": "With",      "type": "text",      "readonly": true    },    {      "key": "statement_id",      "type": "link",      "link_to": "statement",      "readonly": true,      "name": "Statement"    },    {  "key": "posted_on",  "type": "date",  "readonly": true,  "name": "Date",  "fact": true,  "reading": "{value}",  "format": "calendar-datetime"},    {      "key": "text",      "type": "text",      "readonly": true,      "name": "As the bank wrote it"    },    {      "key": "amount_minor",      "type": "amount",      "currency": "currency",      "signed": true,      "readonly": true,      "name": "Amount"    },    {      "key": "currency",      "type": "text",      "readonly": true    },    {      "key": "direction",      "type": "text",      "readonly": true    },    {      "key": "balance_after_minor",      "type": "amount",      "currency": "currency",      "readonly": true,      "name": "Balance after"    },    {      "key": "ignored_reason",      "type": "text",      "readonly": true,      "name": "Skipped because"    },    {      "key": "state",      "type": "choice",      "choices": [        "recorded",        "unread",        "skipped"      ],      "readonly": true,      "labels": {        "recorded": "Recorded",        "unread": "Not recorded yet",        "skipped": "Skipped"      }    },    {      "key": "transaction_id",      "type": "link",      "link_to": "transaction",      "readonly": true,      "name": "Recorded as"    }  ],  "title": "title",  "date": "posted_on",  "project": null,  "order": null,  "slip": {    "title": "title",    "subtitle": "state",    "trailing": "posted_on",    "photo": null,    "toggle": null,    "figure": "amount_minor",    "title_fallback": "text"  },  "tile": {    "face": "slip-list"  },  "page": [    {      "heading": null,      "columns": [        "title",        "text",        "amount_minor",        "posted_on",        "state",        "transaction_id",        "statement_id",        "balance_after_minor",        "ignored_reason"      ]    }  ],  "instructions": "Money engine view: one line as a statement printed it. title is the bank's words tidied for reading; text is exactly as the bank wrote them. Engine columns are read-only.",  "search": [    "text"  ],  "tables": [    {      "name": "cotton_money_statement_lines",      "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": "statement_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    statement_id TEXT NOT NULL",          "position": 2        },        {          "name": "page",          "type": "INTEGER",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    page INTEGER NOT NULL",          "position": 3        },        {          "name": "line_no",          "type": "INTEGER",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    line_no INTEGER NOT NULL",          "position": 4        },        {          "name": "posted_on",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    posted_on TEXT NOT NULL",          "position": 5        },        {          "name": "text",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    text TEXT NOT NULL",          "position": 6        },        {          "name": "amount_minor",          "type": "INTEGER",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    amount_minor INTEGER NOT NULL",          "position": 7        },        {          "name": "direction",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    direction TEXT NOT NULL",          "position": 8        },        {          "name": "balance_after_minor",          "type": "INTEGER",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    balance_after_minor INTEGER",          "position": 9        },        {          "name": "reference",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    reference TEXT",          "position": 10        },        {          "name": "fingerprint",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    fingerprint TEXT NOT NULL",          "position": 11        },        {          "name": "ignored_reason",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    ignored_reason TEXT",          "position": 12        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_at TEXT NOT NULL",          "position": 13        },        {          "name": "_hlc",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    _hlc TEXT NOT NULL DEFAULT ''",          "position": 14        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 15        }      ],      "constraints": [        {          "declaration": "\n    UNIQUE (statement_id, line_no)",          "position": 16        },        {          "declaration": "\n    CHECK (amount_minor > 0)",          "position": 17        },        {          "declaration": "\n    CHECK (direction IN ('in', 'out'))",          "position": 18        },        {          "declaration": "\n    CHECK (length(trim(text)) > 0)",          "position": 19        },        {          "declaration": "\n    CHECK (line_no >= 1)",          "position": 20        },        {          "declaration": "\n    CHECK (page >= 1)",          "position": 21        },        {          "declaration": "\n    FOREIGN KEY (statement_id) REFERENCES cotton_money_statements(id)",          "position": 22        },        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n  ",          "position": 23        }      ],      "prefix": "CREATE TABLE cotton_money_statement_lines (",      "suffix": ")",      "indexes": [        "CREATE INDEX idx_cotton_money_statement_lines_statement ON cotton_money_statement_lines (statement_id, line_no)",        "CREATE INDEX idx_cotton_money_statement_lines_workspace ON cotton_money_statement_lines (workspace_id)",        "CREATE UNIQUE INDEX uq_cotton_money_statement_lines_fingerprint ON cotton_money_statement_lines (statement_id, fingerprint)",        "CREATE INDEX idx_cotton_money_statement_lines_fingerprint ON cotton_money_statement_lines (fingerprint)",        "CREATE INDEX IF NOT EXISTS idx_cotton_money_statement_lines_author ON cotton_money_statement_lines (substr(_hlc, 20), _hlc)"      ],      "full_text": [],      "triggers": []    }  ],  "parts": {    "shape": "sheet",    "head": {      "facts": [        "posted_on"      ],      "state": "state"    },    "links": [],    "lists": [],    "acts": {      "more": [        "open-statement-id",        "open-transaction-id"      ]    },    "cards": [      {        "column": "amount_minor"      },      {        "column": "text"      },      {        "column": "balance_after_minor"      },      {        "column": "ignored_reason"      }    ],    "strip": []  },  "commands": [    {      "id": "open-statement-id",      "label": "Open statement",      "kind": "open",      "opens": "statement_id"    },    {      "id": "open-transaction-id",      "label": "Open recorded as",      "kind": "open",      "opens": "transaction_id"    }  ]}