askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
goodwill.json · 2.9 KB · 37 lines
| 1 | { |
| 2 | "name": "goodwill", |
| 3 | "title": "Goodwill", |
| 4 | "version": 1, |
| 5 | "description": "Something given to a customer whose charge was right: a free coffee next time, a voucher, money back as a kindness. SEPARATE FROM REFUNDS on purpose. Corner Cup (a Haiku simulation of a counter cafe) could only express 'we gave her something' by refunding or editing the sale, which says the charge was wrong when it was not, and the complaint history then reads as a pricing mistake. A goodwill row records the value, the reason code, who approved it (the row's owner: only a shift lead, manager or owner may create one, and the server stamps the creator), and the words the customer was given. charge_was_correct defaults to true; the sale it is about is left exactly as charged. When the goodwill is money back, a refund cites it (refunds.goodwill_id, reason_code goodwill) and the ledger refuses refunds citing it beyond value_cents. Never edited or deleted afterwards (owner fallback off): a mistake is a further record. hook_goodwill checks the reason code against correction_reasons and fills the customer wording from it when none is typed.", |
| 6 | "hooks": {"before_write": "hook_goodwill"}, |
| 7 | "views": { |
| 8 | "list_mode": "table", |
| 9 | "list_fields": ["created_at", "customer_email", "form", "value_cents", "reason_code", "owner_id"], |
| 10 | "filter_fields": ["form", "reason_code"] |
| 11 | }, |
| 12 | "forms": { |
| 13 | "default": {"fields": ["order_id", "order_line_id", "customer_email", "form", "value_cents", "reason_code", "customer_wording", "charge_was_correct", "note"]} |
| 14 | }, |
| 15 | "fields": [ |
| 16 | {"name": "id"}, |
| 17 | {"name": "order_id", "type": "relation", "label": "Order", |
| 18 | "relation": {"collection": "orders", "display_field": "number", "requires": "read"}}, |
| 19 | {"name": "order_line_id", "type": "text", "label": "Item", "validation": {"max_length": 64}}, |
| 20 | {"name": "customer_id", "subject": "relation", "label": "Customer", |
| 21 | "relation": {"collection": "contacts", "display_field": "first_name", "requires": "read"}}, |
| 22 | {"name": "customer_email", "subject": "email", "type": "text", "label": "Customer email", |
| 23 | "validation": {"max_length": 254}}, |
| 24 | {"name": "form", "type": "enum", "required": true, "default": "free_item", "label": "Given as", |
| 25 | "enum": ["free_item", "voucher", "money_back", "discount_next_visit", "other"]}, |
| 26 | {"name": "value_cents", "type": "integer", "required": true, "label": "Value (cents)", |
| 27 | "validation": {"min": 0}}, |
| 28 | {"name": "reason_code", "type": "text", "required": true, "label": "Reason code", |
| 29 | "validation": {"max_length": 64}}, |
| 30 | {"name": "charge_was_correct", "type": "boolean", "default": "true", "label": "Charge was correct"}, |
| 31 | {"name": "customer_wording", "type": "text", "label": "What the customer was told", |
| 32 | "validation": {"max_length": 300}}, |
| 33 | {"name": "note", "type": "textarea", "label": "Note"}, |
| 34 | {"name": "owner_id", "type": "text", "label": "Approved by"}, |
| 35 | {"name": "created_at", "type": "datetime", "read_only": true} |
| 36 | ] |
| 37 | } |