Repository navigation
Compute LSZE landing fees on the server - #924
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 thelspltariff was ported.
This PR ports the
lszetariff and fixes a problem that server pricing would cause when an arrival is edited in theapp.
Commits
aircraftDataSource(registryormanual) nextto 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.jsonand invalidateMovement. New cases in the sharedmovementCasestable, whichalso 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.)
functions/fees/landingFeeStrategies/lsze.js(+lsze_data.json, a copy of the client's) is a port oflsze.ts: fees including VAT, net rounded to cents, CHF 20 per started ton above 3000 kg, helicopters ontheir own table, no go-around fee, 8.1 % VAT.
functions/fees/index.js.fees.spec.js:lsze.spec.ts;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:landingFeesStrategyand server-side pricing.Switching it on (after merge and the lsze-test deploy)
In the lsze-test Realtime Database, set
/settings/landingFeesStrategyto"lsze"in the Firebase console. Afterthat, 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:
/aircraftswhere the registration is known. The pilot's declared values stay as theyare.
Without the setting nothing changes. Production is not touched.
Unchanged
Test plan
npm test: 353 suites / 7847 testsnpm run typechecknpm run test:functions: 108 suites / 4614 testsnpm 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
then edit that arrival in the app
Generated by Claude Code