Cotton code
299 lines · 6.2 KB · JSONRaw
{  "id": "subscription",  "name": "Subscription",  "plural": "Subscriptions",  "picture": null,  "builtin": false,  "visibility": "owner",  "engine": null,  "columns": [    {      "key": "name",      "name": "Name",      "type": "text",      "required": true,      "placeholder": "What you pay for"    },    {      "key": "provider",      "name": "Provider",      "type": "text",      "placeholder": "Who bills it"    },    {      "key": "amount",      "name": "Amount",      "type": "amount",      "currency": "currency"    },    {      "key": "currency",      "name": "Currency",      "type": "text",      "placeholder": "USD"    },    {      "key": "cycle",      "name": "Cycle",      "type": "choice",      "choices": [        "weekly",        "monthly",        "quarterly",        "yearly"      ],      "format": "words"    },    {      "key": "per_month",      "name": "Per month",      "type": "text",      "readonly": true,      "placeholder": "about ₹1,700 a month"    },    {      "key": "monthly_inr",      "name": "Per month, ₹ (approx, for ordering)",      "type": "number",      "readonly": true    },    {      "key": "next_renewal",      "name": "Next renewal",      "type": "date"    },    {      "key": "status",      "name": "Status",      "type": "choice",      "choices": [        "active",        "paused",        "cancelled"      ],      "format": "words",      "tones": {        "active": "green",        "paused": "amber",        "cancelled": "red"      }    },    {      "key": "started",      "name": "Started",      "type": "date"    },    {      "key": "last_charged",      "name": "Last charged",      "type": "date",      "readonly": true    },    {      "key": "charges",      "name": "Charges recorded",      "type": "number",      "readonly": true,      "computed": {        "rollup": {          "table": "subscription_charge",          "link": "subscription",          "op": "count"        }      }    },    {      "key": "paid_total",      "name": "Paid in all",      "type": "amount",      "readonly": true,      "computed": {        "rollup": {          "table": "subscription_charge",          "link": "subscription",          "op": "sum",          "column": "amount"        }      }    },    {      "key": "cancel_url",      "name": "Cancel link",      "type": "text",      "placeholder": "https://"    },    {      "key": "notes",      "name": "Notes",      "type": "longtext",      "markdown": true    }  ],  "title": "name",  "date": "next_renewal",  "project": null,  "order": null,  "slip": {    "title": "name",    "subtitle": [      "provider",      "cycle",      "per_month"    ],    "trailing": "amount",    "photo": null,    "toggle": null  },  "tile": {    "face": "slip-list"  },  "page": [    {      "heading": null,      "columns": [        "name",        "provider",        "status"      ],      "actions": [        {          "label": "Pause",          "sets": {            "status": "paused"          },          "object": "snooze"        },        {          "label": "Cancel",          "sets": {            "status": "cancelled"          },          "object": "block"        },        {          "label": "Resume",          "sets": {            "status": "active"          },          "object": "retry"        }      ]    },    {      "heading": "Cost",      "columns": [        "amount",        "currency",        "cycle",        "per_month"      ]    },    {      "heading": "Dates",      "columns": [        "next_renewal",        "last_charged",        "started"      ]    },    {      "heading": "Cancelling",      "columns": [        "cancel_url"      ]    },    {      "heading": "Charges",      "list": {        "table": "subscription_charge",        "link": "subscription",        "empty": {          "title": "No charges recorded"        },        "limit": 36      },      "note": "Every charge, refund or failed attempt found in the receipts, newest first."    },    {      "heading": "Notes",      "columns": [        "notes"      ]    }  ],  "sort": {    "column": "monthly_inr",    "descending": true,    "tie": "name"  },  "group": {    "column": "status",    "sections": [      {        "heading": null,        "values": [          "active"        ]      },      {        "heading": "Paused",        "values": [          "paused"        ],        "closed": true      },      {        "heading": "Cancelled",        "values": [          "cancelled"        ],        "closed": true      }    ]  },  "empty": {    "title": "No subscriptions yet",    "message": "Add the things you pay for again and again."  },  "create": {    "label": "Add a subscription"  },  "instructions": "One row per thing the owner pays for again and again. amount is a whole number of minor units (1599 = 15.99) in the currency column's code; never guess an amount or a renewal date — ask. cycle is weekly, monthly or yearly. status moves active → paused → active, or to cancelled; a cancelled subscription keeps its row. next_renewal is the next charge date; move it forward one cycle only when the owner says the charge went through. cycle may also be quarterly. last_charged is the date of the latest charge; the subscription_charge table holds every charge, refund, credit and failed attempt linked to this row, written from receipts — never invent one. per_month and monthly_inr are the cost normalised to one month in rupees at an approximate rate, for ordering only; the charged amount and currency are the truth.",  "card": {    "face": "subscription",    "fields": [      {        "slot": "title",        "column": "name"      },      {        "slot": "subtitle",        "column": "provider"      },      {        "slot": "price",        "column": "amount"      },      {        "slot": "period",        "column": "cycle"      },      {        "slot": "next_charge",        "column": "next_renewal"      },      {        "slot": "state",        "column": "status",        "only": [          "paused",          "cancelled"        ]      },      {        "slot": "body",        "column": "notes"      }    ]  }}