Commercial Real Estate Calculator
Overview
The commercial real estate (næringseiendom) valuation calculator has two implementations.
-
Backend (authoritative):
tritt.finsta.service.assreg.calculator.CommercialRealEstateCalculatorinfinsta-service, with year-specific classes (CommercialRealEstateCalculator_2023,_2024,_2025). -
Frontend (reactive subset):
commercial-real-estate.calculator-utils.tsinfinsta-frontend.
The backend is the source of truth. The frontend computes only the fields that need instant reactivity; the rest are populated on save/sync by the backend.
The FE/BE Split
Fields mirrored on both sides
The frontend updates these reactively as the user types; the backend overwrites them on save.
-
convertedGrossRentalIncome -
stipulatedRentalIncome -
averageRentalIncome -
rentalValueFromCalculations -
adjustedMarketValue -
rentalValueBeforeValuationDiscount -
taxValueAfterValuationDiscount -
rentalValueOfPercentageBeforeValuationDiscount -
taxValueOfPercentageAfterValuationDiscount
Keeping Frontend and Backend in Sync
Parity between the two implementations is enforced by shared JSON test fixtures at finsta-frontend/tests/shared-fixtures/commercial-real-estate-shared-test-spec.json.
Both the backend Spock tests (CommercialRealEstateCalculator_YYYYTest.groovy) and the frontend unit tests (commercial-real-estate.calculators.spec.ts) read from this file and assert against the same expected values.
A runtime safety net compares frontend-sent and backend-calculated values during sync and logs a warning on divergence (CommercialRealEstateReconciler).
Adding a New Year
-
Add a new
CommercialRealEstateCalculator_YYYY.groovymodelled on the most recent year. -
Update the
CommercialRealEstateCalculatordispatcher to routeYYYYto the new class. -
Add a new frontend file
commercial-real-estate.calculator-YYYY.tsmodelled on the most recent year. -
Add scenarios for the new year in
finsta-frontend/tests/shared-fixtures/commercial-real-estate-shared-test-spec.json. -
Add a new backend test class
CommercialRealEstateCalculator_YYYYTest.groovyreading the fixtures. -
The frontend test picks up the new scenarios automatically.
Adding a New Calculated Field
-
Decide whether it needs reactivity on the frontend. Does it update visually as the user types, or is it acceptable to appear only after save?
-
Add the calculation to the backend: in
CommercialRealEstateCalculatorUtilsif shared across years, or in year-specific calculators if year-varying. -
If reactive: mirror the calculation in the frontend calculator, and add a reminder comment pointing at the backend.
-
Add test scenarios for the new field in the shared fixtures.
-
Ensure the field is added to
SpecificationOfCommercialPropertyEntityif not already there, and toSpecificationOfCommercialPropertyon the API side.