Lanna Desk's larger work is contracts, general ones and artists', for
clients who are Thai or foreign, people or organizations, with several
lawyers in the team. The back office gets a Legal section (phase 9 in
docs/PLAN.md):
- Lawyers: license number, contact, the login of one who uses the app
(then "My contracts"), in the team or left.
- Clients, as record cards: person or organization, names in English and
Thai, stage name or brand, a Thai ID number (checked), a passport or a
registration number, the lawyer in charge.
- Contracts: code LD-<year>-<n>, the general kinds and the artist kinds
(recording, management, publishing, performance, license,
merchandise), other party, status, lawyer, dates and value; a contract
in force shows its notice day and its end ahead. Filters: general or
artists, a lawyer, mine, those over.
- Versions: a text kept here, a file (PDF or scan, encrypted as the
client's document) or both. They never change: the database refuses
UPDATE and DELETE, a version's file cannot be deleted and no document's
checksum can change. Any version reads against the one before as a
line diff.
- Paper copies: the id <code>-P<n> to write on the paper or print as a
90 x 50 mm label with a QR code; where it lies, its state and holder,
each move journaled; found again by its id.
- The journal: every change in words, in the change's transaction, each
entry chained to the one before by SHA-256. The database refuses to
change, delete or truncate it; /journal checks the chain and every
version's text and fingerprints against its entry, shows the last hash
and exports CSV.
The sidebar groups its sections: Legal, Visas and stays, Office. Demo data
(seed-demo) adds three lawyers, six clients and seven contracts with
versions, papers and moves. Documents take a third owner, the client
(migration 0009).
Checks: fmt, clippy, 115 unit and 62 integration tests (new: versions and
the journal, the database refusing changes, a change around the app
breaking the chain, paper ids and moves, the demo checking whole);
screenshots of the new pages in light, dark and on a phone.
A Forms tab on each person fills in TM.7, STM.2, STM.9, STM.11 and STM.1
for an extension of stay, TM.47 for a 90-day report and TM.8 for a re-entry
permit. The Bureau's blank pages (forms/, with their sources and checksums)
go unchanged into a new PDF, and the values are written on the dotted lines
in Sarabun; boxes are ticked and the title circled where a form asks.
scripts/gen_layout.py measures the blanks into src/papers/layout.rs.
The tab says what would stay blank and links to where it is added. What only
the application says (the date, the office, the reason, the days, a trip) is
carried in the links and never stored. The extension's five forms also come
in one PDF. Opening or downloading a form is audited as entity "form" with
the forms' codes, never their values.
Migration 0005 adds what STM.1 and STM.11 ask of the company (capital,
revenue, equity, staff, a coordinator), a work permit's salary and contract
dates, and where an arrival came from. The Nix package now takes forms/.
The company form has a field for the office's GPS position (migration
0004, column companies.office_gps). It takes what people have at hand:
the numbers Google Maps copies, a link to the place on Google Maps or
OpenStreetMap, a geo: URI, or degrees, minutes and seconds. It keeps
decimal degrees with six decimals and refuses a position outside Thailand,
which catches a swapped pair; a short maps.app.goo.gl link is refused with
a hint, as it holds no position (src/gps.rs, with unit tests).
The company's page has an Office card: the position with links that open
it on OpenStreetMap and Google Maps, the newest photo of the office, and a
strip that uploads a photo (kind "Photo of the office") and returns to the
card. The photos are documents like any other: encrypted on the server and
audited. A refused photo shows its errors on the card only; office photos
that are PDFs are counted under Company documents.
The demo company has a position. Tests: the position read from a link,
from degrees, minutes and seconds, the three refusals, the audit entry and
its removal; a photo uploaded from the card, shown, and its errors placed.
Chromium's date input lets the year part take six digits when the input
has no max, so typing 2026 and then 11 for the month gave 202611-12-05
(reported on the live app). Every date input now carries
min="1900-01-01" and max="2100-12-31", so the year part stops at four
digits and moves on to the month. Checked in Edge: typing 20261112 gives
2026-11-12, where it left the field empty before.
The server checks the same years for every date field
(dates::parse_form_date). Person, passport and address dates were only
parsed, so a two-digit year such as 0026-11-12 would have been saved;
stay records had the range already. A six-digit year never parsed, so no
such date can be in the database.
Tests: the parser's cases; the person, passport and arrival forms refuse
both years and save nothing; every date input on every page carries the
limits (pages.rs).
Companies become records of their own, and the stay in Thailand is
recorded in full; from these records the app works out each person's
deadlines (docs/PLAN.md, phase 2).
- Companies: list, page, form, archive; Thai name, the 13-digit
registration number with its check digit verified, address and the
director who signs. The employer is chosen from them on the person form
and on work permits; a company's page adds people to it; the people
list and the Deadlines page filter by employer. Migration 0002 turns
the free-text employers into companies.
- Stay records, each one `Kind` in src/records.rs with one form, one set
of routes and the same audit entries: arrivals and departures with the
TDAC, extensions of stay (approved, under consideration, refused),
90-day reports with the receipt's next date, visas, re-entry permits and
work permits. Passports, visas and companies are chosen from the
person's own records; the server checks the choice.
- The deadline engine (src/deadlines.rs, a pure function with a unit
test per rule): the 90-day report from day 1 of each arrival, reset by
a report or an extension, with the in-person and online windows and the
in-person rule after a new passport or an extension; the extension
window from 30 days before to the last working day; the decision to
collect; overstay with its fine; TM.30 after each arrival; passport and
work permit expiry; re-entry permits; visas still to be used.
- The Deadlines page at /, the person's status and deadlines on the
Overview and the new "Visa and stay" tab, the person's Activity tab,
and the next deadline in the people list.
- The online 90-day window ends 7 days before the due date (the plan
said 8; the Immigration Bureau's TM.47 manual says 7).
- 69 tests: 45 unit tests and 24 integration tests.