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, 41 minutes ago History
time_logs.json · 6.4 KB · 158 lines
1{
2 "name": "time_logs",
3 "title": "Time Logs",
4 "version": 6,
5 "description": "Work time against tasks. A running timer is a row with is_running true and no ended_at. Server-enforced by /timers/start, /timers/stop, /timers/running (62 - Timer, plan/vocabulary/62-timer-spec.md) -- see packages/app-timers/objects/site/timer_actions.py. v4 makes an entry billable: consulting hours are a usage metric with an APPROVAL GATE, and that gate is the only structural difference between time-and-materials billing and metered cloud billing -- both then run the same meter -> rate -> line -> invoice spine. status walks draft -> submitted -> approved -> billed, and the rate is STAMPED at approval from rate_cards (docs/logic-decisions.md #1), so a rate change next quarter can never reprice work somebody already approved. An approved or billed entry is frozen: correcting it is a compensating entry or a credit on the invoice, never an edit to the evidence of what happened (#5, #8). v5 moves that freeze into the schema: locked_when on approved/billed lets an update change only status, invoice_id and notes and refuses a delete, inside the write lock and for every writer (docs/validation-and-logic.md). The hook carried the same allow-list but never ran on delete, so the person who logged an approved, rated entry could delete it -- and the manager's approval with it. v6: relation.requires: read on the task, project and rate card time is logged against, update on the invoice it is billed on.",
6 "locked_when": [
7 {
8 "when": {"status": ["approved", "billed"]},
9 "except": ["status", "invoice_id", "notes"],
10 "message": "This time entry is approved or billed, and its record of what happened is settled: only status, invoice_id and notes may change, and it cannot be deleted. Correct it with a compensating entry or a credit on the invoice."
11 }
12 ],
13 "fields": [
14 {
15 "name": "id"
16 },
17 {
18 "name": "task_id",
19 "label": "Task",
20 "relation": {
21 "collection": "tasks",
22 "display_field": "title",
23 "requires": "read"}
24 },
25 {
26 "name": "project_id",
27 "label": "Project",
28 "relation": {
29 "collection": "projects",
30 "display_field": "name",
31 "requires": "read"},
32 "help": "What the hours are billed against. Also half of the rate-card lookup: a rate scoped to this project beats the house default."
33 },
34 {
35 "name": "started_at",
36 "type": "datetime",
37 "required": true,
38 "label": "Started"
39 },
40 {
41 "name": "ended_at",
42 "type": "datetime",
43 "label": "Ended"
44 },
45 {
46 "name": "is_running",
47 "type": "boolean",
48 "label": "Running",
49 "default": "false"
50 },
51 {
52 "name": "notes",
53 "type": "text",
54 "label": "Notes"
55 },
56 {
57 "name": "billable",
58 "type": "boolean",
59 "default": "true",
60 "label": "Billable",
61 "help": "Time worth recording is not always time worth charging for. Unbillable hours still count toward a project's cost -- they are simply never rated."
62 },
63 {
64 "name": "status",
65 "type": "enum",
66 "default": "draft",
67 "label": "Status",
68 "enum": ["draft", "submitted", "approved", "rejected", "billed"],
69 "transitions": {
70 "draft": [{"to": "submitted", "when": {"owner_id": "$user_id"}}],
71 "submitted": ["approved", "rejected"],
72 "rejected": [{"to": "draft", "when": {"owner_id": "$user_id"}}],
73 "approved": ["billed", "rejected"],
74 "billed": []
75 },
76 "help": "Only the person who logged the time may submit it, and only somebody else's hand moves it to approved -- an approval you can grant yourself is not an approval. rejected returns to draft so the hours can be corrected and resubmitted rather than lost. approved -> billed is machine-advanced by the invoice generator; billed is terminal, because a disputed hour is a credit on the invoice, not a rewind."
77 },
78 {
79 "name": "hourly_rate_cents",
80 "type": "integer",
81 "default": "0",
82 "label": "Rate",
83 "help": "Stamped at approval from the rate card in force on the day the work happened. Once stamped it belongs to this entry -- later rate changes never reprice approved work."
84 },
85 {
86 "name": "amount_cents",
87 "type": "integer",
88 "default": "0",
89 "label": "Amount",
90 "help": "Stamped alongside the rate: round(billable seconds / 3600 * rate), half-up, once. The entry is what a client disputes, so it is the thing whose arithmetic they can reproduce."
91 },
92 {
93 "name": "rate_card_id",
94 "label": "Rate Card",
95 "relation": {"collection": "rate_cards", "display_field": "label", "requires": "read"},
96 "help": "Which card was chosen. Keeps 'why am I being charged this?' answerable years later."
97 },
98 {
99 "name": "invoice_id",
100 "label": "Invoice",
101 "relation": {"collection": "invoices", "display_field": "number", "requires": "update"},
102 "help": "Stamped when the entry is billed. An entry already carrying one is never billed again -- that is what makes re-running the generator safe."
103 },
104 {
105 "name": "approved_by",
106 "type": "text",
107 "label": "Approved By"
108 },
109 {
110 "name": "approved_at",
111 "type": "datetime",
112 "label": "Approved"
113 },
114 {
115 "name": "created_at",
116 "type": "datetime",
117 "read_only": true,
118 "label": "Created"
119 },
120 {
121 "name": "owner_id",
122 "type": "text",
123 "label": "Owner"
124 },
125 {
126 "name": "duration_seconds",
127 "type": "integer",
128 "label": "Duration (seconds)",
129 "help": "Stamped by the stop verb: floor(ended_at - started_at). Never client-writable in practice -- omitted from forms.default, not schema read_only (update_collection_record has no preserve_read_only escape hatch; see packages/app-invoices/objects/system/invoice_totals.py for the same finding and the same workaround)."
130 }
131 ],
132 "hooks": {"before_write": "hook_time_logs"},
133 "forms": {
134 "default": {
135 "fields": [
136 "task_id",
137 "project_id",
138 "started_at",
139 "ended_at",
140 "is_running",
141 "billable",
142 "notes"
143 ]
144 }
145 },
146 "views": {
147 "list_mode": "table",
148 "list_fields": [
149 "task_id",
150 "project_id",
151 "started_at",
152 "duration_seconds",
153 "status",
154 "amount_cents"
155 ],
156 "filter_fields": ["status", "billable", "project_id"]
157 }
158}