Phase 2: companies, stay records, deadlines
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.
This commit is contained in:
1 parent
2e009700a9
commit
83bc481952
37 files changed
+5515
-142
No files matched your search
+34
-18
@@ -1,6 +1,6 @@
|
||||
# visa.buildfor.life: plan
|
||||
|
||||
> Phase 1 built on November 17, 2026. **Resume here: phase 2, task 2.1.**
|
||||
> Phases 1 and 2 built on November 17, 2026. **Resume here: phase 3, task 3.1.**
|
||||
|
||||
visa.buildfor.life keeps the immigration records of the foreigners that B4L
|
||||
looks after: their passports, addresses in Thailand, arrivals with the Thailand
|
||||
@@ -28,6 +28,7 @@ The first round of questions was answered on November 17, 2026.
|
||||
| First extension pack | Non-B with a work permit, employer B4L, at Chiang Mai Immigration |
|
||||
| Reminders | the dashboard first; later a Matrix room message and an email to the person concerned |
|
||||
| Repository | private `B4L/visa`; the fleet then needs a read token for its flake input |
|
||||
| Employers | companies are records of their own under Companies; a person's employer and a work permit's employer are chosen from them, and a company's page adds people to it |
|
||||
|
||||
Kanidm keeps persons, groups and OAuth2 clients in one namespace, so the
|
||||
client cannot be called `visa` like the group. It is `visa-web`, as
|
||||
@@ -67,17 +68,18 @@ made of.
|
||||
|
||||
| Table | Holds | Phase |
|
||||
| -------------------- | --------------------------------------------------------------------------------------------------------------------------- | ----- |
|
||||
| `people` | names as in the passport, title, sex, birth date and place, nationality, occupation, employer, phone, email, notes; archiving | 1 |
|
||||
| `people` | names as in the passport, title, sex, birth date and place, nationality, occupation, employer (a company), phone, email, notes; archiving | 1 |
|
||||
| `passports` | number, issuing state, issue and expiry dates, issuing authority, the MRZ as read; the current one has the latest expiry | 1 |
|
||||
| `addresses` | the address in Thailand in the order Thai forms use, moving dates, the house master and the TM.30 receipt | 1 |
|
||||
| `sessions` | signed-in sessions | 1 |
|
||||
| `audit_log` | who viewed or changed which record, append-only | 1 |
|
||||
| `companies` | name in English and Thai, the 13-digit registration number with its check digit, address, the director who signs; archiving | 2 |
|
||||
| `visas` | visa category (Non-B, Non-O, DTV and others), number, place and date of issue, validity, entries | 2 |
|
||||
| `entries` | arrival date, port, flight, visa used, permitted-until date, TDAC number; departure date when the person left | 2 |
|
||||
| `arrivals` | arrival date, port, flight, visa used, permitted-until date, TDAC number; departure date when the person left | 2 |
|
||||
| `extensions` | extensions of stay: approval date, new permitted-until date, reason, office, receipt | 2 |
|
||||
| `reentry_permits` | TM.8 permits, single or multiple, valid until | 2 |
|
||||
| `ninety_day_reports` | the report date, the way it was filed, the receipt and the next due date printed on it | 2 |
|
||||
| `work_permits` | number, employer, position, validity | 2 |
|
||||
| `work_permits` | number, employer (a company), position, validity | 2 |
|
||||
| `documents` | encrypted uploads tied to a person and a record | 4 |
|
||||
|
||||
## Deadline rules
|
||||
@@ -91,14 +93,19 @@ shows a calculated date as an estimate until a receipt confirms it.
|
||||
receipt names the next date. Leaving Thailand ends the count; after the
|
||||
next arrival it starts again from day 1. A report in person, or by someone
|
||||
the person authorizes, is accepted from 15 days before to 7 days after the
|
||||
due date. Online it is accepted from 15 days before to 8 days before, and
|
||||
never after a new passport until one report was made in person. A late
|
||||
report costs 2,000 THB; being caught without one, up to 5,000 THB. The
|
||||
Immigration Bureau treats a first extension of stay as the first report.
|
||||
due date. Online it is accepted from 15 days before to 7 days before. The
|
||||
first report after a new passport, and the first after an extension of
|
||||
stay, is made in person. A late report costs 2,000 THB; being caught
|
||||
without one, up to 5,000 THB. An extension of stay starts the count again,
|
||||
so when the permission to stay ends before the next report is due, the app
|
||||
shows no report: the person either leaves or extends.
|
||||
- **Extension of stay (TM.7).** The application must be made before the
|
||||
permitted-until date. Chiang Mai accepts it from 30 days before (some
|
||||
categories 45); the app opens the window 30 days before and counts down to
|
||||
the last working day. An overstay costs 500 THB a day.
|
||||
the last working day, the Friday when the permission ends on a weekend.
|
||||
An overstay costs 500 THB a day, at most 20,000 THB. A first application
|
||||
for work is often stamped "under consideration" for 30 days; the app then
|
||||
shows the day to return for the decision.
|
||||
- **Passport.** An extension never runs past the passport's expiry, so the
|
||||
app warns 12 months before expiry and marks a passport with less than six
|
||||
months left.
|
||||
@@ -148,8 +155,8 @@ dark at desktop and phone width, a commit and a push.
|
||||
| Phase | Content | Status |
|
||||
| ----- | --------------------------------------------------------------------------------------------------------------- | ---------------------------- |
|
||||
| 1 | App, Kanidm login, people, passports with MRZ reading, addresses in Thailand, audit log, demo data, CI | built Nov 17, 2026 |
|
||||
| 2 | Stays: visas, arrivals with TDAC, extensions, re-entry permits, 90-day reports, work permits; deadlines | **next** |
|
||||
| 3 | On cnx01: flake package, fleet module, Kanidm client and group, bkk01 site, backups; real data from here on | |
|
||||
| 2 | Companies; stays: visas, arrivals with TDAC, extensions, re-entry permits, 90-day reports, work permits; deadlines | built Nov 17, 2026 |
|
||||
| 3 | On cnx01: flake package, fleet module, Kanidm client and group, bkk01 site, backups; real data from here on | **next** |
|
||||
| 4 | Documents: encrypted uploads (passport pages, TDAC, receipts, photo), viewing and download, all audited | |
|
||||
| 5 | Filled-in forms: TM.7, STM.2, the overstay acknowledgment, TM.47, TM.8 and STM.1 as PDF | |
|
||||
| 6 | The Non-B extension pack: B4L's company documents, the checklist, one PDF to print | |
|
||||
@@ -175,16 +182,25 @@ dark at desktop and phone width, a commit and a push.
|
||||
|
||||
### Phase 2: stays and deadlines
|
||||
|
||||
- [ ] 2.1 Visas and arrivals: arrival date, port, flight, visa used,
|
||||
- [x] 2.1 Visas and arrivals: arrival date, port, flight, visa used,
|
||||
permitted-until date, TDAC number and date; departures.
|
||||
- [ ] 2.2 Extensions of stay and re-entry permits.
|
||||
- [ ] 2.3 90-day reports with the next due date from the receipt.
|
||||
- [ ] 2.4 Work permits.
|
||||
- [ ] 2.5 The deadline engine as pure functions with unit tests for every
|
||||
- [x] 2.2 Extensions of stay and re-entry permits.
|
||||
- [x] 2.3 90-day reports with the next due date from the receipt.
|
||||
- [x] 2.4 Work permits.
|
||||
- [x] 2.5 The deadline engine as pure functions with unit tests for every
|
||||
rule above (arrival plus 89 days, the windows, a trip resetting the
|
||||
count, the extension window, passport and work permit expiry).
|
||||
- [ ] 2.6 Dashboard at `/`: every person's next deadlines sorted by urgency;
|
||||
a timeline on the person page.
|
||||
- [x] 2.6 Dashboard at `/`: every person's deadlines sorted by urgency, with
|
||||
a company filter; the person's status and deadlines on the Overview
|
||||
and the "Visa and stay" tab; the next deadline in the people list.
|
||||
- [x] 2.7 Companies: list, page, form, archive; the employer chosen from
|
||||
them on the person form and on work permits; people added to a
|
||||
company from its page; the people list filtered by employer.
|
||||
|
||||
The six kinds of stay record and companies share one description each
|
||||
(`Kind` in `src/records.rs`): one form template, one set of routes and the
|
||||
same audit entries serve them all. A new kind of record is a migration and
|
||||
one `Kind`.
|
||||
|
||||
### Phase 3: on cnx01
|
||||
|
||||
|
||||
Reference in new issue
Block a user