Skip to content

Compute LSZE landing fees on the server - #924

Merged
rzueger merged 2 commits into
developfrom
claude/magical-dirac-ww38gt
Nov 20, 2026
Merged

rzueger merged 2 commits into
developfrom
claude/magical-dirac-ww38gt

Conversation

@rzueger

@rzueger rzueger commented Nov 20, 2026

Copy link
Copy Markdown
Member

Summary

Arrivals recorded through the movement API by the Open Digital MCP hub (a pilot in Claude, see #923) carry no
landing fees. In LSZE the app computes the fees in the browser and saves them with the arrival. The API stores what
it is sent, and the hub sends no fees. Flightbox can already price arrivals on the server, whoever writes them:
computeArrivalFeesOnWrite, switched on per project with /settings/landingFeesStrategy. So far only the lspl
tariff was ported.

This PR ports the lsze tariff and fixes a problem that server pricing would cause when an arrival is edited in the
app.

Commits

  1. Allow aircraftDataSource on arrivals. The trigger writes aircraftDataSource (registry or manual) next
    to the fee fields. When an arrival is edited, the app loads the whole record into the wizard and saves it back,
    so the field comes back from the client. The database rules ($other: false) and the movement API rejected it,
    so once the server had priced an arrival, the app could no longer edit it. The two values are now accepted in
    firebase-rules-template.json and in validateMovement. New cases in the shared movementCases table, which
    also run against the built rules: both values, any other value, the field on a departure, and the update of a
    priced arrival as the app sends it. (This would affect lspl too, wherever the setting is on.)
  2. Compute LSZE landing fees on the server.
    • functions/fees/landingFeeStrategies/lsze.js (+ lsze_data.json, a copy of the client's) is a port of
      lsze.ts: fees including VAT, net rounded to cents, CHF 20 per started ton above 3000 kg, helicopters on
      their own table, no go-around fee, 8.1 % VAT.
    • Registered in functions/fees/index.js.
    • Parity tests in fees.spec.js:
      • the cases of lsze.spec.ts;
      • the same tariff for every flight type and origin;
      • totals: 1157 kg, 1 landing → net 27.75, VAT 2.25, gross 30.00; 3 landings → 60.00;
      • the server's tariff data (lspl, lsze) is identical to the client's JSON.
    • computeArrivalFees.spec.js: an LSZE arrival without fees gets all fee fields, with the registry as source.
    • projects/Configuration.md: landingFeesStrategy and server-side pricing.

Switching it on (after merge and the lsze-test deploy)

In the lsze-test Realtime Database, set /settings/landingFeesStrategy to "lsze" in the Firebase console. After
that, every arrival that is written in lsze test is priced by the server, from the app or the API. The behaviour is
the existing lspl one:

  • MTOW and category come from /aircrafts where the registration is known. The pilot's declared values stay as they
    are.
  • Arrivals stored before are priced at their next change.

Without the setting nothing changes. Production is not touched.

Unchanged

  • The app's own fee computation and the payment flow.
  • All other projects' tariffs.
  • The trigger's logic.

Test plan

  • npm test: 353 suites / 7847 tests
  • npm run typecheck
  • npm run test:functions: 108 suites / 4614 tests
  • npm run test:rules (database emulator): rule assertions; domain/rules parity lsze 596/596, lszt 578/578,
    lspv 578/578, lsze-lockOnDateTime 596/596; movement API writes
  • After merge and deploy: set the setting in lsze test, record an arrival via Claude, check the fee in the app,
    then edit that arrival in the app

Generated by Claude Code

The server-side fee computation (functions/fees) writes
aircraftDataSource ('registry' or 'manual') next to the fee fields.
The app loads the whole arrival into the wizard when it is edited and
saves it back, so the field returns from the client, but the database
rules ($other) and the movement API rejected it: once an arrival was
priced by the server, it could no longer be edited in the app.

Accept the two values in the rules and the movement domain. Cases in
the shared table (also run against the built rules): both values,
other values, the field on a departure, and the update of a priced
arrival as the app sends it.
Arrivals recorded through the movement API (by the Open Digital MCP
hub for a pilot in Claude) carry no fees: the app computes them in
the browser, the API stores what it is sent. Port the lsze tariff to
functions/fees so computeArrivalFeesOnWrite can price LSZE arrivals,
whoever writes them, once /settings/landingFeesStrategy is 'lsze'.

- landingFeeStrategies/lsze.js: the tariff of lsze.ts (fees including
  VAT, net rounded to cents, CHF 20 per started ton above 3000 kg)
- parity tests: the cases of lsze.spec.ts, totals (1157 kg: CHF 30),
  and a check that the server's tariff data (lspl, lsze) is identical
  to the client's
- trigger test: an LSZE arrival without fees gets them
- Configuration.md: landingFeesStrategy and the server-side pricing
@rzueger
rzueger merged commit 5c0d07d into develop Nov 20, 2026
2 checks passed
@rzueger
rzueger deleted the claude/magical-dirac-ww38gt branch November 20, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants