Cotton code
406 lines · 9.6 KB · JSONRaw
{  "format_version": 1,  "id": "money_account",  "name": "Account",  "plural": "Accounts",  "builtin": true,  "visibility": "owner",  "title": "name",  "columns": [    {      "key": "kind",      "type": "choice",      "readonly": true,      "choices": [        "bank",        "credit_card",        "cash",        "wallet",        "loan"      ]    },    {      "key": "subtype",      "type": "text",      "readonly": true    },    {      "key": "name",      "type": "text"    },    {      "key": "counterparty_person_id",      "type": "link",      "link_to": "person",      "readonly": true    },    {      "key": "currency",      "type": "text",      "readonly": true    },    {      "key": "institution",      "name": "Bank",      "type": "text",      "readonly": true    },    {      "key": "number_mask",      "name": "Account ending",      "type": "account_number",      "readonly": true,      "fact": true,      "reading": "ending {value}"    },    {      "key": "is_default",      "name": "Usual account",      "type": "bool",      "readonly": true    },    {      "key": "is_pooled",      "type": "bool",      "name": "Pooled"    },    {      "key": "archived_at",      "type": "date",      "format": "calendar-datetime",      "readonly": true    },    {      "key": "trashed_at",      "type": "date",      "format": "calendar-datetime",      "readonly": true    },    {      "key": "balance_minor",      "name": "Balance",      "type": "amount",      "readonly": true,      "currency": "currency"    },    {      "key": "balance_as_of",      "name": "Balance as of",      "type": "date",      "readonly": true    },    {      "key": "known_balance_minor",      "name": "Known balance",      "type": "amount",      "currency": "currency"    },    {      "key": "known_balance_on",      "name": "Known balance on",      "type": "date"    }  ],  "seal": {    "clear": [      "kind",      "subtype",      "counterparty_person_id",      "currency",      "is_default",      "is_pooled",      "archived_at",      "trashed_at",      "balance_as_of",      "known_balance_on"    ],    "blind": [      "name"    ]  },  "instructions": "An account is a bank, card, cash, wallet or loan account. Loan statements are booked like bank statements and the balance is what is still owed.",  "tables": [    {      "name": "cotton_money_accounts",      "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": "kind",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    kind TEXT NOT NULL",          "position": 2        },        {          "name": "subtype",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    subtype TEXT NOT NULL",          "position": 3        },        {          "name": "name",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    name TEXT NOT NULL",          "position": 4        },        {          "name": "counterparty_person_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    counterparty_person_id TEXT",          "position": 5        },        {          "name": "currency",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    currency TEXT NOT NULL",          "position": 6        },        {          "name": "institution",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    institution TEXT",          "position": 7        },        {          "name": "number_mask",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    number_mask TEXT",          "position": 8        },        {          "name": "is_default",          "type": "INTEGER",          "default": "0",          "nullable": false,          "primary_key": false,          "declaration": "\n    is_default INTEGER NOT NULL DEFAULT 0",          "position": 9        },        {          "name": "is_pooled",          "type": "INTEGER",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    is_pooled INTEGER CHECK (is_pooled IS NULL OR is_pooled IN (0,1))",          "position": 10        },        {          "name": "archived_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    archived_at TEXT",          "position": 11        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_at TEXT NOT NULL",          "position": 12        },        {          "name": "updated_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    updated_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        },        {          "name": "trashed_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " trashed_at TEXT",          "position": 16        }      ],      "constraints": [        {          "declaration": "\n    CHECK (subtype IN ('bank', 'cash', 'credit_card', 'wallet', 'receivable', 'payable', 'loan', 'lent_out', 'fixed_asset'))",          "position": 17        },        {          "declaration": "\n    FOREIGN KEY (counterparty_person_id) REFERENCES cotton_people(id)",          "position": 18        },        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n  ",          "position": 19        }      ],      "prefix": "CREATE TABLE \"cotton_money_accounts\" (",      "suffix": ")",      "indexes": [        "CREATE UNIQUE INDEX uq_cotton_money_accounts_identity ON cotton_money_accounts (workspace_id, institution, number_mask) WHERE (institution IS NOT NULL) AND (number_mask IS NOT NULL)",        "CREATE INDEX idx_cotton_money_accounts_person ON cotton_money_accounts (counterparty_person_id) WHERE counterparty_person_id IS NOT NULL",        "CREATE INDEX idx_cotton_money_accounts_workspace ON cotton_money_accounts (workspace_id)",        "CREATE UNIQUE INDEX uq_cotton_money_accounts_default ON cotton_money_accounts (workspace_id) WHERE is_default = 1",        "CREATE INDEX IF NOT EXISTS idx_cotton_money_accounts_author ON cotton_money_accounts (substr(_hlc, 20), _hlc)"      ],      "full_text": [],      "triggers": []    }  ],  "picture": {    "photo": "photo:d3020bbe260bf41f313f8116af2a6ee38a7c9ee0ff72794fa86448e88d0b42e6",    "object": "tool-money"  },  "engine": "money",  "date": null,  "project": null,  "order": null,  "slip": {    "title": "name",    "subtitle": [      "kind",      "number_mask"    ],    "trailing": null,    "photo": null,    "toggle": null,    "figure": "balance_minor"  },  "tile": {    "face": "slip-list"  },  "page": [    {      "heading": null,      "columns": [        "name",        "kind",        "institution",        "is_pooled"      ],      "figure": "balance_minor"    },    {      "heading": "Statements",      "columns": [],      "list": {        "table": "statement",        "link": "account_id"      },      "role": "side"    }  ],  "add": false,  "record_route": "/money/accounts/[id]",  "delete": false,  "derived": true,  "parts": {    "shape": "sheet",    "head": {      "facts": [        "kind",        "institution"      ]    },    "links": [],    "lists": [      {        "table": "statement",        "relation": "account_id",        "heading": "Statements"      }    ],    "acts": {      "more": []    },    "cards": [      {        "column": "kind"      },      {        "column": "institution"      },      {        "column": "is_pooled"      }    ]  },  "card": {    "face": "account.statement",    "fields": [      {        "slot": "title",        "column": "name"      },      {        "slot": "subtitle",        "column": "institution"      },      {        "slot": "mask",        "column": "number_mask"      },      {        "slot": "amount",        "column": "balance_minor"      }    ]  }}