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
invoice_lines.json · 3.3 KB · 108 lines
| 1 | { |
| 2 | "name": "invoice_lines", |
| 3 | "title": "Invoice Lines", |
| 4 | "version": 1, |
| 5 | "description": "Line items belonging to one invoice/quote/credit note. line_total_cents and line_tax_cents are stamped by the invoice_totals handler on every create/update/delete. See plan/vocabulary/20-invoice-spec.md.", |
| 6 | "fields": [ |
| 7 | { |
| 8 | "name": "id" |
| 9 | }, |
| 10 | { |
| 11 | "name": "invoice_id", |
| 12 | "type": "relation", |
| 13 | "required": true, |
| 14 | "relation": { |
| 15 | "collection": "invoices", |
| 16 | "display_field": "number" |
| 17 | }, |
| 18 | "label": "Invoice", |
| 19 | "help": "Set once at creation and not intended to change after. Not schema read_only -- see dbbasic-package.json's description for why (a required, client-submitted-at-creation field cannot also be read_only on this platform: the server rejects any client submission of a read_only field, even the first one)." |
| 20 | }, |
| 21 | { |
| 22 | "name": "description", |
| 23 | "type": "text", |
| 24 | "required": true, |
| 25 | "label": "Description", |
| 26 | "validation": { |
| 27 | "min_length": 1, |
| 28 | "max_length": 300 |
| 29 | } |
| 30 | }, |
| 31 | { |
| 32 | "name": "quantity", |
| 33 | "type": "number", |
| 34 | "default": "1", |
| 35 | "label": "Quantity", |
| 36 | "help": "A count/measure, not money -- may be fractional (e.g. 2.5 hours). This is the one deliberate use of a float-shaped field in this package; every *_cents field stays integer." |
| 37 | }, |
| 38 | { |
| 39 | "name": "unit_price_cents", |
| 40 | "type": "integer", |
| 41 | "required": true, |
| 42 | "label": "Unit Price (cents)" |
| 43 | }, |
| 44 | { |
| 45 | "name": "discount_bps", |
| 46 | "type": "integer", |
| 47 | "label": "Discount %", |
| 48 | "help": "A negotiated reduction on THIS line, in basis points (1000 = 10%). Not a promotion -- a promo code applies to the whole basket and is rounded once (app-promotions); this comes off one row and prints beside it. Tax is charged on the discounted amount, because a discount on goods reduces the taxable base. A flat per-unit reduction is a negative modifier_cents; the percentage is what nothing else could express." |
| 49 | }, |
| 50 | { |
| 51 | "name": "line_discount_cents", |
| 52 | "type": "integer", |
| 53 | "label": "Discount", |
| 54 | "help": "Computed from discount_bps." |
| 55 | }, |
| 56 | { |
| 57 | "name": "line_total_cents", |
| 58 | "type": "integer", |
| 59 | "default": "0", |
| 60 | "label": "Line Total (cents)", |
| 61 | "help": "Stamped by invoice_totals: floor(quantity * unit_price_cents). Never user-entered." |
| 62 | }, |
| 63 | { |
| 64 | "name": "tax_rate_bps", |
| 65 | "type": "integer", |
| 66 | "label": "Tax Rate (bps)", |
| 67 | "help": "Basis points, e.g. 825 = 8.25%. Optional; blank or 0 means no tax on this line." |
| 68 | }, |
| 69 | { |
| 70 | "name": "line_tax_cents", |
| 71 | "type": "integer", |
| 72 | "default": "0", |
| 73 | "label": "Line Tax (cents)", |
| 74 | "help": "Stamped by invoice_totals: line_total_cents * tax_rate_bps // 10000 (floor, not round)." |
| 75 | }, |
| 76 | { |
| 77 | "name": "owner_id", |
| 78 | "type": "text", |
| 79 | "label": "Owner" |
| 80 | }, |
| 81 | { |
| 82 | "name": "created_at", |
| 83 | "type": "datetime", |
| 84 | "label": "Created", |
| 85 | "read_only": true |
| 86 | } |
| 87 | ], |
| 88 | "forms": { |
| 89 | "default": { |
| 90 | "fields": [ |
| 91 | "invoice_id", |
| 92 | "description", |
| 93 | "quantity", |
| 94 | "unit_price_cents", |
| 95 | "tax_rate_bps" |
| 96 | ] |
| 97 | } |
| 98 | }, |
| 99 | "views": { |
| 100 | "list_mode": "table", |
| 101 | "list_fields": [ |
| 102 | "description", |
| 103 | "quantity", |
| 104 | "unit_price_cents", |
| 105 | "line_total_cents" |
| 106 | ] |
| 107 | } |
| 108 | } |