Register mileage reimbursement with automatic amount calculation
After selecting 'Kilometre allowance' as the expense type, the wizard renders the Mileage Calculator Widget. The user enters the journey distance in kilometres; the widget reads the per-kilometre rate from the Expense Rules Riverpod Provider which fetches and caches organisation-specific rates from Supabase. As the user types, the calculated reimbursement amount updates in real time. The Distance Validation Utility checks that the entered distance is within configured minimum and maximum bounds for the organisation and optionally cross-checks against route estimates to flag implausible values. The BLoC accumulates the validated distance and calculated amount for the final submission payload.
User Story
Acceptance Criteria
- Given the user has selected 'Kilometre allowance' and entered a distance, when the distance field value changes, then the calculated reimbursement amount updates immediately using the organisation's configured per-kilometre rate
- Given the organisation has a per-kilometre rate of NOK 4.90, when the user enters 25 km, then the preview shows NOK 122.50 before any user action to proceed
- Given the user enters a distance below the configured minimum or above the configured maximum, when they attempt to advance in the wizard, then a validation error message specifying the allowed range is shown and progression is blocked
- Given an implausible distance is entered (e.g., 900 km for a local visit), when the distance validation utility flags it, then a warning is displayed prompting the user to confirm the value before proceeding
- Given the organisation's per-kilometre rate has been updated in Supabase, when the provider fetches the latest rules, then the new rate is used for all subsequent calculations in the session
Business Value
Mileage reimbursement is one of the most frequently submitted expense types for peer mentors who travel to visit members. Automating the rate calculation removes the need for volunteers to look up rates, reduces arithmetic errors, and makes the process fast enough that more mentors will actually claim what they are entitled to. This directly supports volunteer retention and reduces the administrative burden of correcting manually calculated claims.
Components
- Expense Registration Screen ui
- Mileage Calculator Widget ui
- Expense Registration BLoC service
- Expense Rules Riverpod Provider service
- Distance Validation Utility infrastructure
- Expense Validation Service service