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
mileage_logs.json · 5.6 KB · 71 lines
1{
2 "name": "mileage_logs",
3 "title": "Mileage Log",
4 "version": 1,
5 "description": "One business trip: the vehicle, the day, the odometer at each end (or the miles, when nobody wrote the odometer down), where from and to, and what business it was for -- the record an auditor asks for in place of a receipt (IRC 274(d) names mileage among the expenses that must be substantiated by adequate records; IRS Publication 463 describes the log). It walks the same ladder as an expense: the driver submits, somebody else approves. Approving it STAMPS the year's rate from mileage_rates and the reimbursement (miles times rate, half-up once) onto the log (docs/logic-decisions.md #1), and system_mileage_expenses then creates one approved, personally-paid expense for that amount in the mileage category, stamped generated_from mileage_logs/{id} and unique, so a replayed event books nothing twice (#7). A log on a BUSINESS vehicle is approved as evidence and reimburses nothing. The LOCKED_CHECK mileage_rules refuses, for every writer and inside the write lock, an end reading at or below the start, miles that disagree with the readings, an odometer range that overlaps another live log on the same vehicle (two trips cannot have used the same miles), and an approval whose stamped rate is not the year's row. Approved logs are frozen; a wrong one is rejected (which rejects its expense, and the books reverse) and logged again.",
6 "fields": [
7 {"name": "id"},
8 {"name": "vehicle_id", "required": true, "label": "Vehicle",
9 "relation": {"collection": "vehicles", "display_field": "name", "requires": "update"},
10 "help": "Only somebody who may update the vehicle (its driver) logs trips in it, so nobody else's typo can occupy its odometer."},
11 {"name": "trip_date", "type": "date", "required": true, "label": "Date"},
12 {"name": "start_odometer", "type": "integer", "label": "Odometer at start",
13 "validation": {"min": 0}},
14 {"name": "end_odometer", "type": "integer", "label": "Odometer at end",
15 "validation": {"min": 0},
16 "help": "Give both readings and the miles are worked out; a later trip may start at the reading this one ended on."},
17 {"name": "miles", "type": "integer", "required": true, "label": "Business miles",
18 "validation": {"min": 1},
19 "help": "Whole miles. Filled from the odometer when both readings are given; typed in when they are not."},
20 {"name": "from_place", "type": "text", "required": true, "label": "From",
21 "validation": {"max_length": 200}},
22 {"name": "to_place", "type": "text", "required": true, "label": "To",
23 "validation": {"max_length": 200}},
24 {"name": "business_purpose", "type": "textarea", "required": true, "label": "Business purpose",
25 "validation": {"min_length": 3},
26 "help": "Who you went to see and why. Commuting between home and a regular workplace is not business mileage."},
27 {"name": "status", "type": "enum", "default": "draft", "label": "Status",
28 "enum": ["draft", "submitted", "approved", "rejected"],
29 "transitions": {
30 "draft": [{"to": "submitted", "when": {"owner_id": "$user_id"}}],
31 "submitted": ["approved", "rejected"],
32 "rejected": [{"to": "draft", "when": {"owner_id": "$user_id"}}],
33 "approved": ["rejected"]
34 },
35 "help": "The driver submits; somebody else approves. Rejecting an approved log rejects the expense it created, and the books reverse."},
36 {"name": "rate_year", "type": "integer", "label": "Rate year",
37 "validation": {"required_when": {"status": "approved"}},
38 "help": "Stamped at approval: the calendar year of the trip, whose rate applied."},
39 {"name": "rate_hundredths_cent", "type": "integer", "label": "Rate (hundredths of a cent per mile)",
40 "validation": {"min": 1, "required_when": {"status": "approved"}},
41 "help": "Stamped at approval from mileage_rates. Correcting that table later restates nothing approved."},
42 {"name": "reimbursement_cents", "type": "integer", "label": "Reimbursement",
43 "validation": {"min": 0, "required_when": {"status": "approved"}},
44 "help": "Stamped at approval: miles times the rate, rounded half-up once. 0 on a business vehicle."},
45 {"name": "approved_by", "type": "text", "label": "Approved By"},
46 {"name": "approved_at", "type": "datetime", "label": "Approved"},
47 {"name": "notes", "type": "textarea", "label": "Notes"},
48 {"name": "owner_id", "type": "text", "label": "Driver"},
49 {"name": "created_at", "type": "datetime", "read_only": true, "label": "Created"}
50 ],
51 "locked_when": [
52 {"when": {"status": "approved"},
53 "except": ["status", "notes"],
54 "message": "This trip is approved: its miles, rate and reimbursement are settled. Reject it to correct it."}
55 ],
56 "locked_checks": [
57 {"name": "mileage_rules", "object": "hook_mileage_logs", "function": "LOCKED_CHECK",
58 "reads": ["mileage_rates", "vehicles"],
59 "on": {"create": true,
60 "update": ["vehicle_id", "trip_date", "start_odometer", "end_odometer", "miles",
61 "status", "rate_year", "rate_hundredths_cent", "reimbursement_cents"],
62 "delete": false}}
63 ],
64 "hooks": {"before_write": "hook_mileage_logs"},
65 "search": {"fields": ["from_place", "to_place", "business_purpose", "notes"]},
66 "forms": {"default": {"fields": ["vehicle_id", "trip_date", "start_odometer", "end_odometer",
67 "miles", "from_place", "to_place", "business_purpose", "notes"]}},
68 "views": {"list_mode": "table",
69 "list_fields": ["trip_date", "from_place", "to_place", "miles", "reimbursement_cents", "status"],
70 "filter_fields": ["status", "vehicle_id"]}
71}