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.
supplier_payments.json · 3.7 KB · 43 lines
| 1 | { |
| 2 | "name": "supplier_payments", |
| 3 | "title": "Supplier Payments", |
| 4 | "version": 1, |
| 5 | "description": "Money the business paid a supplier: one transfer, on one date, with one reference, spread over one or more bills by its lines (supplier_payment_lines: how much of this payment went to which bill, which may be less than the bill's total). What a bill still owes is DERIVED from these lines and from credit notes applied to it (supplier_bills.outstanding_cents), never typed: a part payment is a payment of part, not a bill marked paid. Sending a payment to the supplier's box (app-exchange, action_exchange_send collection=supplier_payments) makes the signed remittance, which says exactly what was paid on each bill; the supplier records exactly that, once a person there has seen it in the bank. From that moment the payment is a fact both companies hold: the exchange stamps remitted=true and the row, and every line of it, is frozen (locked_when), and no line can be added to it (the rules let its owner update it only while it is not remitted, and a line needs update on its payment). A mistake is corrected by a new payment or a credit note, never by editing what the supplier was told. amount_cents is the sum of the lines (a rollup).", |
| 6 | "fields": [ |
| 7 | {"name": "id"}, |
| 8 | {"name": "supplier_name", "type": "text", "required": true, "label": "Supplier", |
| 9 | "validation": {"min_length": 1, "max_length": 200}}, |
| 10 | {"name": "supplier_domain", "type": "text", "label": "Supplier's Box", |
| 11 | "validation": {"max_length": 253}}, |
| 12 | {"name": "currency", "type": "text", "required": true, "default": "USD", "label": "Currency", |
| 13 | "validation": {"pattern": "^[A-Z]{3}$"}}, |
| 14 | {"name": "paid_on", "type": "date", "required": true, "label": "Paid On"}, |
| 15 | {"name": "payment_reference", "type": "text", "label": "Payment Reference", |
| 16 | "help": "What the bank transfer carried, ideally a structured reference (ISO 11649 RF...), so the supplier can match it on its statement.", |
| 17 | "validation": {"max_length": 120}}, |
| 18 | {"name": "method", "type": "enum", "default": "transfer", "enum": ["transfer", "card", "cash", "check", "other"], |
| 19 | "label": "Method"}, |
| 20 | {"name": "amount_cents", "type": "computed", "label": "Amount", |
| 21 | "rollup": {"collection": "supplier_payment_lines", "fk_field": "payment_id", "op": "sum", |
| 22 | "field": "amount_cents"}}, |
| 23 | {"name": "remitted", "type": "boolean", "default": "false", |
| 24 | "permissions": {"edit": ["role:admin"], "default": "read"}, "label": "Supplier Told", |
| 25 | "help": "Stamped by the exchange when the remittance is made. From then on the payment is frozen."}, |
| 26 | {"name": "remittance_document_id", "type": "text", "read_only": true, "label": "Remittance Document"}, |
| 27 | {"name": "exchange_status", "type": "text", "read_only": true, "label": "Exchange", |
| 28 | "help": "What the supplier's box said about the remittance, when it refused it."}, |
| 29 | {"name": "notes", "type": "textarea", "label": "Notes"}, |
| 30 | {"name": "owner_id", "type": "text"}, |
| 31 | {"name": "created_at", "type": "datetime", "read_only": true, "label": "Created"} |
| 32 | ], |
| 33 | "locked_when": [ |
| 34 | {"when": {"remitted": "true"}, "except": ["notes"], |
| 35 | "message": "The supplier has been told about this payment; it is a fact both companies hold. Correct it with a new payment or a credit note."} |
| 36 | ], |
| 37 | "forms": {"default": {"fields": ["supplier_name", "supplier_domain", "currency", "paid_on", |
| 38 | "payment_reference", "method", "notes"]}}, |
| 39 | "views": {"list_mode": "table", |
| 40 | "list_fields": ["paid_on", "supplier_name", "amount_cents", "payment_reference", "remitted"], |
| 41 | "filter_fields": ["remitted"]}, |
| 42 | "search": {"fields": ["supplier_name", "payment_reference"]} |
| 43 | } |