Phase 5: the Immigration Bureau's forms, filled in from the records
CI / secret scan (push) Successful in 5s
CI / fmt, clippy, tests (push) Successful in 39s

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/.
This commit is contained in:
grabowski committed 2026-11-18 12:30:03 +07:00
1 parent 2a6e972b68
commit a2cedcdd7e
40 files changed
+3404 -35

No files matched your search

+71
View File
@@ -336,3 +336,74 @@ async fn the_office_position_is_read_from_what_people_paste(pool: PgPool) {
let page = app.get(&format!("/companies/{id}")).await.text();
assert!(page.contains("Add the GPS position"), "{page}");
}
#[sqlx::test(migrator = "visa::db::MIGRATOR")]
async fn the_employer_s_figures_are_checked(pool: PgPool) {
let app = local(pool.clone());
let name = ("name", "Test Works Co., Ltd.");
let r = app
.post(
"/companies",
&[
name,
("capital_thb", "1,000,000"),
("paid_up_thb", "2,000,000"),
("revenue_thb", "-5"),
("thai_staff", "many"),
("figures_year", "1800"),
],
)
.await;
assert_eq!(r.status, StatusCode::UNPROCESSABLE_ENTITY);
let t = r.text();
for msg in [
"The paid-up capital is at most the registered capital.",
"Enter an amount of zero or more.",
"Enter a number of people, such as 12.",
"Enter the year, such as 2025.",
] {
assert!(t.contains(msg), "{msg}: {t}");
}
// the section headings of the form
assert!(t.contains("For the employer's certificate (STM.1)"));
// a Thai year becomes the Western one; a loss leaves the equity below zero
let r = app
.post(
"/companies",
&[
name,
("capital_thb", "2,000,000"),
("paid_up_thb", "2000000"),
("figures_year", "2568"),
("equity_thb", "-150,000"),
("thai_staff", "4"),
],
)
.await;
assert_eq!(r.status, StatusCode::SEE_OTHER, "{}", r.body);
let id = company_from(r.location());
let row: (Option<i64>, Option<i32>, Option<i64>, Option<i32>) = sqlx::query_as(
"SELECT capital_thb, figures_year, equity_thb, thai_staff FROM companies WHERE id = $1",
)
.bind(id)
.fetch_one(&pool)
.await
.unwrap();
assert_eq!(row, (Some(2_000_000), Some(2025), Some(-150_000), Some(4)));
// the company's page lists them for the forms
let t = app.get(&format!("/companies/{id}")).await.text();
for shown in ["For the forms", "2,000,000 THB", "-150,000 THB", "2025"] {
assert!(t.contains(shown), "{shown}: {t}");
}
assert!(!t.contains("Add them</a>"), "{t}");
// a company without them is asked for them
let r = app.post("/companies", &[("name", "Plain Co., Ltd.")]).await;
let plain = company_from(r.location());
let t = app.get(&format!("/companies/{plain}")).await.text();
assert!(
t.contains(&format!("/companies/{plain}/edit#f-capital_thb")),
"{t}"
);
}