Implement BenefitMultiplierConfig repository
epic-benefit-calculator-core-logic-task-002 — Implement the BenefitMultiplierConfigRepository that loads organisation-specific multiplier configuration (hourly value rate, travel cost per km, health system offset factor) from local assets or a remote config endpoint. Expose a Future<BenefitMultiplierConfig> fetchConfig() method used by the BLoC on initialisation.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 1 - 540 tasks
Can start after Tier 0 completes
Implementation Notes
Define IBenefitMultiplierConfigRepository as an abstract class with a single fetchConfig() method so tests can inject a FakeBenefitMultiplierConfigRepository without hitting Supabase. The concrete implementation uses the app's existing Supabase client singleton. For the asset fallback, use rootBundle.loadString() inside the repository. Keep the JSON schema flat: { "hourly_value_rate": 247.0, "travel_cost_per_km": 4.03, "health_offset_factor": 0.12 } — these default values align with Norwegian public sector estimates (NAV time value ~247 NOK/hr, Statsforvalteren km rate).
Register the repository as a Riverpod Provider or equivalent to match the app's DI pattern.
Testing Requirements
Unit tests using flutter_test with a mocked Supabase client. Test scenarios: (1) successful remote fetch returns correct BenefitMultiplierConfig; (2) remote returns empty result — falls back to asset and returns defaults; (3) network timeout — falls back to asset; (4) remote returns invalid values (zero, negative) — falls back to asset; (5) asset JSON is malformed — throws ConfigFetchException; (6) returned config has all three fields populated with positive values. Use Mockito or mocktail to stub the Supabase client.
The exact formulas for SROI social value (public health system cost offset) may not be agreed upon with the client organisations or Bufdir. If formulas are disputed post-implementation, the service and all downstream tests will need to be revised.
Mitigation & Contingency
Mitigation: Document the two formulas and their multiplier inputs explicitly in the BenefitCalculationService source file and obtain sign-off from the product owner before implementation begins. Store formula multipliers exclusively in the Supabase config table so adjustments require only a config update, not a code deployment.
Contingency: If formulas are revised after implementation, the pure-function architecture means changes are isolated to BenefitCalculationService. Update the service, adjust unit tests, and re-run the test suite. No UI components need modification.
The BLoC must handle the asynchronous config fetch from the multiplier repository during initialisation. Race conditions between the config loading state and the first InputChanged event could result in calculations running against null or stale multiplier values.
Mitigation & Contingency
Mitigation: Guard all InputChanged event handlers in the BLoC with a null check on the loaded config state. Emit BenefitCalculationLoading until config resolves. Write a BLoC test that fires InputChanged before config loads and asserts the state remains BenefitCalculationLoading.
Contingency: If race conditions surface in integration testing, add an explicit config-loaded flag and queue InputChanged events until the flag is set, draining the queue on config resolution.