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
invoice_lines.json · 10.7 KB · 285 lines
1{
2 "name": "invoice_lines",
3 "title": "Invoice Lines",
4 "version": 8,
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. v2: invoice_id declares relation.requires update. A registered user's own line could be added to anybody's invoice, changing what that customer is billed. v3: what a line charges is staff's to set. A line on a customer-owned invoice (checkout, the subscription biller) is owned by that customer, and v2 let them PUT unit_price_cents=0 and have the totals handler restate the bill. invoice_id and every quantity, price, rate and stamped amount are field permissions {edit: role:manager, role:admin; default: read}; the totals handler writes in process and is untouched. v4: unit_code (UN/ECE Rec 20), staff-only like quantity, sent with the line to a partner's box. v5 freezes a billed line: the locked check settled_line (system_invoice_line_freeze, lock ledger, rule shared with order_lines in object_corrections) refuses any priced change or delete once money has been received, and anything but a void once the invoice is issued; lines may still be added to an issued unpaid invoice, never to a paid one. order_line_id links a line to the order line it bills. unit_code (what the quantity counts) is a term of the sale and freezes with the quantity; partner_line_id is a reference and does not. v6: credits_line_id, on a credit note's line the credited invoice's line (one credit-note model: the counter's and the exchange's credit notes cite the same way). v7: line_tax_cents is the line's share of the document's tax, computed once per rate group and rounded half-up (decision 2, 2026-11-30); it was floored per line. An issued invoice's lines are not refolded. v8: service_start and service_end, the period a line bills (stamped by the subscription biller, read_only). A subscription's base fee is billed in advance and its usage in arrears, and on accrual books a line billed before its service ends posts to Deferred Revenue and is released monthly (decision 4, 2026-11-30).",
6 "fields": [
7 {
8 "name": "id"
9 },
10 {
11 "name": "invoice_id",
12 "subject": "relation",
13 "type": "relation",
14 "required": true,
15 "relation": {
16 "collection": "invoices",
17 "display_field": "number",
18 "requires": "update"
19 },
20 "label": "Invoice",
21 "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).",
22 "permissions": {
23 "edit": [
24 "role:manager",
25 "role:admin"
26 ],
27 "default": "read"
28 }
29 },
30 {
31 "name": "description",
32 "type": "text",
33 "required": true,
34 "label": "Description",
35 "validation": {
36 "min_length": 1,
37 "max_length": 300
38 }
39 },
40 {
41 "name": "quantity",
42 "type": "number",
43 "default": "1",
44 "label": "Quantity",
45 "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.",
46 "permissions": {
47 "edit": [
48 "role:manager",
49 "role:admin"
50 ],
51 "default": "read"
52 }
53 },
54 {
55 "name": "unit_code",
56 "type": "text",
57 "label": "Unit",
58 "help": "What the quantity counts, as a UN/ECE Recommendation 20 code: KGM kilogram, C62 one, H87 piece, LTR litre, XBG bag, XBX box, HUR hour. Blank means the product's unit (its free-text unit, coded when the line is sent to a partner's box), or C62 for a line with no product. Ten kilograms and ten bags are different orders; this is what says which.",
59 "validation": {
60 "pattern": "^[A-Z0-9]{1,3}$"
61 },
62 "permissions": {
63 "edit": [
64 "role:manager",
65 "role:admin"
66 ],
67 "default": "read"
68 }
69 },
70 {
71 "name": "unit_price_cents",
72 "type": "integer",
73 "required": true,
74 "label": "Unit Price (cents)",
75 "permissions": {
76 "edit": [
77 "role:manager",
78 "role:admin"
79 ],
80 "default": "read"
81 }
82 },
83 {
84 "name": "discount_bps",
85 "type": "integer",
86 "label": "Discount %",
87 "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.",
88 "permissions": {
89 "edit": [
90 "role:manager",
91 "role:admin"
92 ],
93 "default": "read"
94 }
95 },
96 {
97 "name": "line_discount_cents",
98 "type": "integer",
99 "label": "Discount",
100 "help": "Computed from discount_bps.",
101 "permissions": {
102 "edit": [
103 "role:manager",
104 "role:admin"
105 ],
106 "default": "read"
107 }
108 },
109 {
110 "name": "line_total_cents",
111 "type": "integer",
112 "default": "0",
113 "label": "Line Total (cents)",
114 "help": "Stamped by invoice_totals: floor(quantity * unit_price_cents). Never user-entered.",
115 "permissions": {
116 "edit": [
117 "role:manager",
118 "role:admin"
119 ],
120 "default": "read"
121 }
122 },
123 {
124 "name": "tax_rate_bps",
125 "type": "integer",
126 "label": "Tax Rate (bps)",
127 "help": "Basis points, e.g. 825 = 8.25%. Optional; blank or 0 means no tax on this line.",
128 "permissions": {
129 "edit": [
130 "role:manager",
131 "role:admin"
132 ],
133 "default": "read"
134 }
135 },
136 {
137 "name": "line_tax_cents",
138 "type": "integer",
139 "default": "0",
140 "label": "Line Tax (cents)",
141 "help": "This line's share of the document's tax: the rate is stamped at issue, the tax is computed once per rate group (sum of the group's nets x rate, rounded half-up) and shared out, the odd cent to the line with the largest remainder (object_lines.allocate_tax). Never recalculated after issue (decision 2, 2026-11-30).",
142 "permissions": {
143 "edit": [
144 "role:manager",
145 "role:admin"
146 ],
147 "default": "read"
148 }
149 },
150 {
151 "name": "order_line_id",
152 "type": "text",
153 "read_only": true,
154 "label": "Order line",
155 "validation": {
156 "max_length": 64
157 },
158 "description": "The order line this invoice line bills (stamped by app-shop's checkout). It is how a void removes a line from the order and its invoice together, and how a correction cites what it corrects; before it existed the two documents were linked only by matching descriptions, and drifted."
159 },
160 {
161 "name": "credits_line_id",
162 "type": "text",
163 "label": "Credits line",
164 "validation": {
165 "max_length": 64
166 },
167 "permissions": {
168 "edit": [
169 "role:manager",
170 "role:admin"
171 ],
172 "default": "read"
173 },
174 "description": "On a credit note's line: the line of the credited invoice (invoices.credits_invoice_id) it gives back. app-counter's action_counter_correct stamps it with order_line_id; on a hand-made credit note staff may set it. Sending the credit note through the exchange carries it as the line's ref_line_id, so the customer's box knows which line of the invoice it already holds is credited."
175 },
176 {
177 "name": "service_start",
178 "type": "date",
179 "label": "Service from",
180 "help": "The first day of the service this line bills, when it bills a period (a subscription's base fee or its usage). With service_end it is what tells revenue earned from revenue billed in advance: on accrual books a line whose service has not ended when the invoice is issued posts to Deferred Revenue and is released month by month as the service is delivered (decision 4, 2026-11-30). Blank for goods and one-off services.",
181 "read_only": true
182 },
183 {
184 "name": "service_end",
185 "type": "date",
186 "label": "Service to",
187 "help": "The day the billed service period ends (exclusive: the next period starts on it).",
188 "read_only": true
189 },
190 {
191 "name": "voided_at",
192 "type": "datetime",
193 "read_only": true,
194 "label": "Voided at",
195 "description": "When this line was voided (app-counter's action_counter_void). A voided line keeps its row and its reason: quantity and amounts go to zero, on the order line and the invoice line billing it together. Server-stamped."
196 },
197 {
198 "name": "void_reason_code",
199 "type": "text",
200 "read_only": true,
201 "label": "Void reason",
202 "validation": {
203 "max_length": 64
204 },
205 "description": "Why it was voided: a correction_reasons code (app-counter). Server-stamped by the void."
206 },
207 {
208 "name": "voided_by",
209 "type": "text",
210 "read_only": true,
211 "label": "Voided by",
212 "validation": {
213 "max_length": 120
214 },
215 "description": "Who voided it. Server-stamped by the void."
216 },
217 {
218 "name": "owner_id",
219 "type": "text",
220 "label": "Owner"
221 },
222 {
223 "name": "created_at",
224 "type": "datetime",
225 "label": "Created",
226 "read_only": true
227 }
228 ],
229 "forms": {
230 "default": {
231 "fields": [
232 "invoice_id",
233 "description",
234 "quantity",
235 "unit_code",
236 "unit_price_cents",
237 "tax_rate_bps"
238 ]
239 }
240 },
241 "views": {
242 "list_mode": "table",
243 "list_fields": [
244 "description",
245 "quantity",
246 "unit_code",
247 "unit_price_cents",
248 "line_total_cents"
249 ]
250 },
251 "locked_checks": [
252 {
253 "name": "settled_line",
254 "object": "system_invoice_line_freeze",
255 "function": "LOCKED_CHECK",
256 "reads": [
257 "invoices",
258 "payments",
259 "refunds",
260 "order_lines"
261 ],
262 "lock": "ledger",
263 "on": {
264 "create": true,
265 "update": [
266 "invoice_id",
267 "order_line_id",
268 "description",
269 "quantity",
270 "unit_code",
271 "unit_price_cents",
272 "discount_bps",
273 "line_discount_cents",
274 "line_total_cents",
275 "tax_rate_bps",
276 "line_tax_cents",
277 "voided_at",
278 "void_reason_code",
279 "voided_by"
280 ],
281 "delete": true
282 }
283 }
284 ]
285}