{ "format_version": 1, "id": "kitchen_customer", "name": "Customer", "plural": "Customers", "picture": { "photo": "photo:39655737b449b5a77c8eeca3db8f4f9d844fc4271f331043c3c1da729a88d760" }, "builtin": false, "engine": null, "visibility": "mine(person)", "columns": [ { "key": "name", "name": "Name", "type": "text", "required": true }, { "key": "person", "name": "Person", "type": "link", "link_to": "person", "contributes": { "label": "Kitchen" } }, { "key": "phone", "name": "Phone", "type": "text" }, { "key": "address", "name": "Address", "type": "longtext" }, { "key": "currency", "name": "Currency", "type": "text" }, { "key": "orders", "name": "Orders", "type": "number", "computed": { "rollup": { "table": "kitchen_order", "link": "customer", "op": "count" } }, "reading": "{value} orders" }, { "key": "orders_billed", "name": "Orders billed", "type": "amount", "computed": { "rollup": { "table": "kitchen_order", "link": "customer", "op": "sum", "column": "total" } }, "currency": "currency" }, { "key": "plans_billed", "name": "Plans billed", "type": "amount", "computed": { "rollup": { "table": "kitchen_subscription", "link": "customer", "op": "sum", "column": "price" } }, "currency": "currency" }, { "key": "billed", "name": "Billed", "type": "amount", "computed": { "formula": { "op": "sum", "of": [ "orders_billed", "plans_billed" ] } }, "currency": "currency" }, { "key": "paid", "name": "Paid", "type": "amount", "computed": { "rollup": { "table": "kitchen_payment", "link": "customer", "op": "sum", "column": "amount" } }, "currency": "currency" }, { "key": "owed", "name": "Owed", "type": "amount", "computed": { "formula": { "op": "difference", "of": [ "billed", "paid" ] } }, "currency": "currency" }, { "key": "last_order", "name": "Last order", "type": "date", "computed": { "rollup": { "table": "kitchen_order", "link": "customer", "op": "max", "column": "for_day" } } } ], "title": "name", "date": null, "project": null, "order": null, "slip": { "title": "name", "photo": null, "toggle": null, "subtitle": [ "orders", "last_order" ], "trailing": "owed" }, "tile": { "face": "slip-list" }, "page": [ { "heading": null, "columns": [ "name", "person", "phone", "address" ] }, { "heading": "Orders", "columns": [ "orders", "last_order" ] }, { "heading": "Money", "columns": [ "billed", "paid", "owed", "currency" ] } ], "sort": { "column": "name", "descending": false }, "empty": { "title": "No customers", "message": "Add the people who order." }, "instructions": "One row per customer, linked to their person. Owed is what their orders came to less what they paid, counted from rows.", "acts": [ { "id": "take_cash", "label": "Take cash", "object": "tick", "kind": "create", "verb": "create", "data": { "table": "kitchen_payment", "data": { "name": "Cash", "method": "cash" } }, "bindings": { "data.customer": "$id", "data.currency": "currency" }, "pick": { "kind": "number", "argument": "data.amount", "min": 1 } } ], "card": { "face": "plain", "fields": [ { "slot": "title", "column": "name" }, { "slot": "subtitle", "column": "phone" }, { "slot": "body", "column": "address" }, { "slot": "amount", "column": "owed" }, { "slot": "facts", "column": "orders", "also": [ "billed", "paid", "owed", "last_order" ] } ] } }