Turning statutory calculations into code — sourced pure functions, verified against official worked examples
Japanese unemployment benefit — daily amount, benefit days, payout schedule — implemented as pure functions annotated with their statutes and checked against 30 published worked examples. How taishokun is built.
Free (runs in the browser, no sign-up). The site carries affiliate advertising. Japanese-language product.
Listed in Japanese as たいしょくん
Why this is in a consulting portfolio
Systems that compute benefits or fees rarely fail because a formula is wrong. They fail because they keep running on last year's numbers. taishokun separates every number that changes each year from the logic, and verifies every calculation against worked examples the government itself has published.
Why I built it
People thinking about leaving a job in Japan want to know when and how much, not how the system works. The formula for the basic allowance is public, but once the 7-day waiting period and the benefit restriction are in the way, working out roughly which day of which month how much will arrive is left to you.
Technically, it was a subject for turning law-bound calculations into code whose sources can be traced. Payroll, premiums, subsidies and tax come up constantly in client work, and nearly always get built with “who confirms this is right, and how?” left vague.
The hardest part
Three things.
- The numbers change every year. The caps and floors on the daily wage and the daily allowance are revised every 1 August. Hardcode them and the code starts quietly going wrong a year later.
- Exceptions switch on by date. A reform on 1 April 2025 shortened the benefit restriction from two months to one, in principle. The preferential benefit days for people whose fixed-term contract wasn't renewed are a temporary measure limited to separations on or before 31 March 2027. Both must be decided by the separation date, not by today.
- Nothing tells you when you're wrong. Off by one yen, the screen keeps showing a plausible number.
How I decided (and what I gave up)
The statutory numbers are separated from the logic as dated data. The table carries its effective date, the next scheduled revision, the source URL and the date the primary source was accessed. A revision touches only that file and the test expectations — never the calculation code.
Calculations are side-effect-free pure functions, each annotated with the statute or public source behind it. Date-dependent reforms branch on the separation date passed in as an argument.
For correctness, the government's published worked examples are the test expectations as they stand. The public verification page and the tests read the same array, so a result that hasn't passed its test structurally cannot appear on the page.
What I gave up: covering every individual circumstance. Eligibility and the final amount are decided by Hello Work (Japan's public employment office), and the site says so.
What actually runs
Every calculation runs in the browser. The only thing sent to a server is the contact form, the raw salary and age you enter are stripped from the URL, and analytics receives only coarse bands such as an age band and a ¥100,000 wage band (disclosed in the privacy policy).
Apart from the contact API, every page is statically generated. The CSP forbids eval, so input validation runs Zod in its no-eval mode.
Revenue comes from affiliate advertising for job-change and resignation services. Ad slots are allocated by smoothing each slot's results with empirical Bayes (beta-binomial shrinkage) and then running seeded batch Thompson sampling, so the output is a deterministic table: the same data always gives the same allocation.
Numbers counted from the code
84 commits between 2026-08-17 and 09-21. 30 checks against government-published worked examples, 93 test files and 8 Playwright E2E specs.
33 quick-reference pages are generated from separation reason × age × length of service. The sitemap lists 89 pages, 44 of them explanatory articles.
The statutory table's effective date (1 August 2026) and next scheduled revision (1 August 2027) are held as data.
What this proves for your project
Fee calculation, premium and benefit decisions, subsidy eligibility checks, payroll. In any project that turns rules or regulations into code, whether “who confirms this is right, and how” is designed in decides how much rework follows once it's live.
taishokun is a worked example: revised numbers separated into data, official worked examples as test expectations, and the verification results served from the same data as the public page. Keeping raw personal input on the user's device carries over too.
The code for pure calculation functions tested against official worked examples is in implementing statutory calculations in TypeScript.
I take on this kind of work as business systems and calculator development.
Numbers counted from the code
- Checks against official worked examples
- 30 casesThe public verification page and the tests read the same array — a result that fails its test cannot appear on the page
- Tests
- 93 filesPlus 8 Playwright E2E specs
- Quick-reference pages
- 33 pagesGenerated from separation reason × age × length of service
FAQ
- Are taishokun's results accurate?
- Every test run confirms they match 30 worked examples published by the government, and the results are shown on a public verification page. Eligibility and the actual amount are decided by Hello Work, so the final answer should be confirmed there.
- Is the salary or age I enter sent anywhere?
- The raw values are not. Every calculation runs in the browser and inputs are stripped from the URL. Analytics records only coarse bands such as age band and a ¥100,000 wage band, as the privacy policy states.
- How does it keep up with yearly revisions?
- The caps and floors on the daily allowance are revised every 1 August, so they are held as a dated table separate from the logic. A revision updates only that table and the test expectations. The next scheduled revision is 1 August 2027.
- Does it reflect the April 2025 change to the benefit restriction?
- Yes. From 1 April 2025 the benefit restriction for voluntary resignation became one month in principle, down from two. Which rule applies is decided by the separation date, not the date of the calculation.
- Is it free, and how does it make money?
- It is free and needs no sign-up. The site carries affiliate advertising for job-change and resignation services, which is the revenue source, and the advertising is labelled as such on the site.
Try taishokun
Free (runs in the browser, no sign-up). The site carries affiliate advertising. Japanese-language product.
同様の課題、抱えていませんか?
あなたのビジネス課題も、最新の技術で解決できます。 まずは30分の無料技術相談から、状況をお聞かせください。
自社の課題もSaaS化できるか相談するプロジェクト単位(請負)・技術顧問、どちらにも対応可能です