Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

9 downloads

Install on DigitalOcean Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Daniel Quellhorst Changelog for this batch. 65ef78d 3 hours, 42 minutes ago History
supplier_bills.json · 7.0 KB · 88 lines
1{
2 "name": "supplier_bills",
3 "title": "Supplier Bills",
4 "version": 2,
5 "description": "What the business owes its suppliers: an invoice or a credit note FROM a supplier, the payable side that app-invoices (what customers owe us) does not cover. Typed in by hand, or made by the exchange from a partner's signed invoice or credit note (source = exchange, exchange_document_id names it). A bill starts `received` and waits for a person: approved, then paid by somebody who paid it, or disputed or void. Nothing on this server pays a bill or moves it to paid on its own (docs/box-to-box-exchange.md, 'Invoices are never paid automatically'). A bill that came through the exchange is the supplier's document: its number, supplier, currency, dates and amounts are frozen from creation (locked_when on source=exchange), so a disagreement is a dispute or a credit note, never an edit (docs/logic-decisions.md #8, independent evidence is never edited). An approved or paid bill is frozen except its status, payment fields and notes. Amounts are integer minor units of `currency` (subtotal = lines; charge = carriage and other document-level charges; tax; total = what is payable). v2: what a bill still owes is derived, never typed: paid_cents is the sum of the supplier_payment_lines that pay it (any amount: 60% of a bill is a line of 60%), credited_cents the supplier credit notes applied to it (supplier_bill_credits), and outstanding_cents is total less both. A credit note's own outstanding is its total less what of it has been applied (credit_applied_cents, which includes a credit standing on account), so a credit note never reads as money we owe; credit_unapplied_cents is what of it waits on account. The status stays a person's: approved, then paid when they say so.",
6 "fields": [
7 {"name": "id"},
8 {"name": "doc_type", "type": "enum", "default": "invoice", "enum": ["invoice", "credit_note"],
9 "label": "Type"},
10 {"name": "number", "type": "text", "required": true, "label": "Supplier's Number",
11 "validation": {"min_length": 1, "max_length": 100}},
12 {"name": "supplier_name", "type": "text", "required": true, "label": "Supplier",
13 "validation": {"min_length": 1, "max_length": 200}},
14 {"name": "supplier_domain", "type": "text", "label": "Supplier's Box",
15 "validation": {"max_length": 253}},
16 {"name": "currency", "type": "text", "default": "USD", "label": "Currency",
17 "validation": {"pattern": "^[A-Z]{3}$"}},
18 {"name": "issue_date", "type": "date", "label": "Issued"},
19 {"name": "due_date", "type": "date", "label": "Due"},
20 {"name": "subtotal_cents", "type": "integer", "default": "0", "label": "Lines"},
21 {"name": "charge_cents", "type": "integer", "default": "0", "label": "Charges"},
22 {"name": "tax_cents", "type": "integer", "default": "0", "label": "Tax"},
23 {"name": "total_cents", "type": "integer", "default": "0", "label": "Total"},
24 {"name": "paid_cents", "type": "computed", "label": "Paid",
25 "rollup": {"collection": "supplier_payment_lines", "fk_field": "bill_id", "op": "sum",
26 "field": "amount_cents"}},
27 {"name": "credited_cents", "type": "computed", "label": "Credited",
28 "rollup": {"collection": "supplier_bill_credits", "fk_field": "bill_id", "op": "sum",
29 "field": "amount_cents"}},
30 {"name": "credit_applied_cents", "type": "computed", "label": "Credit Applied",
31 "rollup": {"collection": "supplier_bill_credits", "fk_field": "credit_bill_id", "op": "sum",
32 "field": "amount_cents"}},
33 {"name": "credit_unapplied_cents", "type": "computed", "label": "Credit On Account",
34 "rollup": {"collection": "supplier_bill_credits", "fk_field": "credit_bill_id", "op": "sum",
35 "field": "amount_cents", "where": {"bill_id": ""}}},
36 {"name": "outstanding_cents", "type": "computed", "label": "Outstanding",
37 "formula": "total_cents - paid_cents - credited_cents - credit_applied_cents"},
38 {"name": "status", "type": "enum", "default": "received", "label": "Status",
39 "enum": ["received", "approved", "paid", "disputed", "void"],
40 "transitions": {
41 "received": [{"to": "approved", "when": {"owner_id": "$user_id"}},
42 {"to": "disputed", "when": {"owner_id": "$user_id"}},
43 {"to": "void", "when": {"owner_id": "$user_id"}}],
44 "approved": [{"to": "paid", "when": {"owner_id": "$user_id"}},
45 {"to": "disputed", "when": {"owner_id": "$user_id"}}],
46 "disputed": [{"to": "received", "when": {"owner_id": "$user_id"}},
47 {"to": "void", "when": {"owner_id": "$user_id"}}],
48 "paid": [],
49 "void": []
50 }},
51 {"name": "paid_on", "type": "date", "label": "Paid On",
52 "validation": {"required_when": {"status": ["paid"]}}},
53 {"name": "payment_reference", "type": "text", "label": "Payment Reference",
54 "validation": {"max_length": 120}},
55 {"name": "purchase_order_id", "type": "text", "label": "Our Purchase Order",
56 "validation": {"max_length": 64}},
57 {"name": "credited_bill_id", "type": "text", "label": "Credits Bill",
58 "validation": {"max_length": 64}},
59 {"name": "source", "type": "enum", "default": "manual", "enum": ["manual", "exchange"],
60 "label": "Source"},
61 {"name": "exchange_document_id", "type": "text", "label": "Exchange Document",
62 "validation": {"max_length": 128}},
63 {"name": "exchange_status", "type": "text", "read_only": true, "label": "Exchange",
64 "help": "What the supplier's box said back about this bill, when it said something (a refusal)."},
65 {"name": "notes", "type": "textarea", "label": "Notes"},
66 {"name": "owner_id", "type": "text"},
67 {"name": "created_at", "type": "datetime", "read_only": true, "label": "Created"}
68 ],
69 "unique": [{"fields": ["exchange_document_id"], "scope": ["supplier_domain"],
70 "message": "That supplier document is already a bill."}],
71 "locked_when": [
72 {"when": {"source": "exchange"},
73 "fields": ["doc_type", "number", "supplier_name", "supplier_domain", "currency", "issue_date",
74 "due_date", "subtotal_cents", "charge_cents", "tax_cents", "total_cents", "source",
75 "exchange_document_id", "purchase_order_id", "credited_bill_id"],
76 "message": "This bill is the supplier's signed document; dispute it or ask for a credit note instead of editing it."},
77 {"when": {"status": ["approved", "paid"]},
78 "except": ["status", "paid_on", "payment_reference", "notes"],
79 "message": "An approved bill is settled; only its payment is recorded now."}
80 ],
81 "forms": {"default": {"fields": ["doc_type", "number", "supplier_name", "currency", "issue_date",
82 "due_date", "subtotal_cents", "charge_cents", "tax_cents",
83 "total_cents", "status", "paid_on", "payment_reference", "notes"]}},
84 "views": {"list_mode": "table",
85 "list_fields": ["supplier_name", "number", "status", "total_cents", "outstanding_cents", "due_date"],
86 "filter_fields": ["status", "doc_type", "source"]},
87 "search": {"fields": ["supplier_name", "number"]}
88}