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.
danq9
signup: the person chooses the password and name on the confirm page
83c7aa6
2 weeks, 5 days ago
History
expenses.json · 6.0 KB · 64 lines
| 1 | { |
| 2 | "name": "expenses", |
| 3 | "title": "Expenses", |
| 4 | "version": 1, |
| 5 | "description": "Money the business spent, and sometimes money a client owes back. An expense is an accounting fact first and a billable item second, which is why it lives with the books rather than with the invoices: an unbillable expense still costs the company and still belongs in the ledger. It walks the same approval ladder as time (draft -> submitted -> approved -> billed) and for the same reason -- somebody other than the spender says yes before it becomes either a journal entry or a line on a client's bill. paid_by is the field most expense systems get wrong by omitting: a card the company holds and a card an employee holds produce DIFFERENT journals (credit the clearing account, or credit a liability owed back to the person), and guessing from the amount is not a strategy. markup_bps is in basis points to match invoice_lines' tax_rate_bps; it is stamped at approval alongside the billable amount, so re-running a bill can never apply this quarter's markup policy to last quarter's approved costs (docs/logic-decisions.md #1). Approved expenses are frozen: a mistaken one is corrected by a compensating entry or a credit, never by editing the record of what was spent (#5, #8).", |
| 6 | "fields": [ |
| 7 | {"name": "id"}, |
| 8 | {"name": "description", "type": "text", "required": true, "label": "Description", |
| 9 | "help": "What was bought. This is what a client reads on the invoice line, so write it for them."}, |
| 10 | {"name": "incurred_on", "type": "date", "required": true, "label": "Incurred", |
| 11 | "help": "The day the money was spent, which is the day the books belong to -- not the day somebody got round to entering it."}, |
| 12 | {"name": "amount_cents", "type": "integer", "required": true, "label": "Amount", |
| 13 | "help": "What it cost, in integer minor units (docs/logic-decisions.md #10). The cost, not the price to the client."}, |
| 14 | {"name": "currency", "type": "text", "default": "USD", "label": "Currency"}, |
| 15 | {"name": "project_id", "label": "Project", |
| 16 | "relation": {"collection": "projects", "display_field": "name"}, |
| 17 | "help": "What the spend was for. Required in practice to bill it: an expense with no project has no invoice to land on."}, |
| 18 | {"name": "account_id", "label": "Expense Account", |
| 19 | "relation": {"collection": "fin_accounts", "display_field": "name"}, |
| 20 | "help": "Which account to debit. Falls back to the expenses.journal.expense_account setting, so a business that has not built out a chart of accounts still gets a balanced entry."}, |
| 21 | {"name": "paid_by", "type": "enum", "default": "company", "label": "Paid By", |
| 22 | "enum": ["company", "personal"], |
| 23 | "help": "company credits the card/cash clearing account. personal credits a liability owed back to the person who paid -- a reimbursement the business owes, which is a real debt and not a footnote."}, |
| 24 | {"name": "billable", "type": "boolean", "default": "true", "label": "Billable", |
| 25 | "help": "Whether the client pays it back. Unbillable expenses still post to the books; they simply never reach an invoice."}, |
| 26 | {"name": "markup_bps", "type": "integer", "label": "Markup", |
| 27 | "help": "Basis points added when billing it on: 1500 is 15%. Deliberately has NO default, so that blank and zero can mean different things: blank takes the house policy (the billing.expense_markup_bps setting) at approval, while an explicit 0 says this one goes through at cost no matter what the house does. A default of 0 here would have made the two indistinguishable and quietly disabled the setting."}, |
| 28 | {"name": "billable_amount_cents", "type": "integer", "default": "0", |
| 29 | "label": "Billable Amount", |
| 30 | "help": "Stamped at approval: amount plus markup, rounded half-up once. What actually reaches the invoice."}, |
| 31 | {"name": "status", "type": "enum", "default": "draft", "label": "Status", |
| 32 | "enum": ["draft", "submitted", "approved", "rejected", "billed"], |
| 33 | "transitions": { |
| 34 | "draft": [{"to": "submitted", "when": {"owner_id": "$user_id"}}], |
| 35 | "submitted": ["approved", "rejected"], |
| 36 | "rejected": [{"to": "draft", "when": {"owner_id": "$user_id"}}], |
| 37 | "approved": ["billed", "rejected"], |
| 38 | "billed": [] |
| 39 | }, |
| 40 | "help": "Only the person who spent the money may submit it, and somebody else approves it. Approval is what composes the journal and what makes it billable. billed is terminal -- a disputed expense is a credit on the invoice, not a rewind."}, |
| 41 | {"name": "invoice_id", "label": "Invoice", |
| 42 | "relation": {"collection": "invoices", "display_field": "number"}, |
| 43 | "help": "Stamped when billed. An expense already carrying one is never billed again."}, |
| 44 | {"name": "receipt_ref", "type": "text", "label": "Receipt", |
| 45 | "help": "Where the evidence lives -- a file id, a scan id, a vendor reference. Becomes a relation to scanned documents when document intake lands; kept as free text until then rather than declaring a relation to a collection that does not exist yet."}, |
| 46 | {"name": "approved_by", "type": "text", "label": "Approved By"}, |
| 47 | {"name": "approved_at", "type": "datetime", "label": "Approved"}, |
| 48 | {"name": "notes", "type": "textarea", "label": "Notes"}, |
| 49 | {"name": "owner_id", "type": "text", "label": "Owner"}, |
| 50 | {"name": "entity_id", "type": "text", "label": "Entity", |
| 51 | "relation": {"collection": "entities", "display_field": "name"}}, |
| 52 | {"name": "created_at", "type": "datetime", "read_only": true, "label": "Created"} |
| 53 | ], |
| 54 | "hooks": {"before_write": "hook_expenses"}, |
| 55 | "search": {"fields": ["description", "notes", "receipt_ref"]}, |
| 56 | "forms": {"default": {"fields": ["description", "incurred_on", "amount_cents", |
| 57 | "currency", "project_id", "account_id", |
| 58 | "paid_by", "billable", "markup_bps", |
| 59 | "receipt_ref", "notes"]}}, |
| 60 | "views": {"list_mode": "table", |
| 61 | "list_fields": ["incurred_on", "description", "amount_cents", |
| 62 | "paid_by", "billable", "status"], |
| 63 | "filter_fields": ["status", "billable", "paid_by", "project_id"]} |
| 64 | } |