Organisation Rate Configuration Repository
Component Detail
Description
Fetches and caches the organisation-level per-km reimbursement rate and auto-approval threshold from Supabase. Provides reactive access so the UI can always reflect the current org configuration without manual refresh.
org-rate-config-repository
Summaries
This component ensures that reimbursement rates and approval thresholds set by administrators are immediately reflected across the entire peer mentor workforce without requiring app restarts or manual refresh actions. By centralising organisation-level policy configuration, it eliminates costly discrepancies where mentors submit claims at outdated rates, reducing finance reconciliation effort and dispute resolution overhead. Real-time policy propagation also means compliance with updated reimbursement policies is instantaneous, reducing the organisation's financial and regulatory exposure when rate changes are enacted.
This is a shared, low-complexity data component with a clear interface contract and a single upstream dependency on the Supabase adapter. Its reactive stream interface means consuming UI components must be designed to handle config change events, which is a coordination point requiring alignment with front-end feature teams. Caching logic should be tested for both online and offline scenarios, and cache invalidation on admin-triggered rate changes needs an end-to-end test covering the Supabase realtime subscription path. Risk is low given its well-scoped responsibility, but any delay in the Supabase adapter completion blocks integration testing of this component.
Implemented as a repository layer in the mobile app, this component wraps the `supabase-mileage-adapter` to provide domain-typed access to `OrgRateConfig` objects. It exposes both a one-shot `Future
All data model shapes are defined in the `organisation-configuration` schema.
Responsibilities
- Fetch the active per-km rate for the current organisation from Supabase
- Fetch the auto-approval threshold (default 50 km) for the current organisation
- Cache fetched config locally to reduce network calls within a session
- Expose a stream so consumers are notified when the config is updated by an admin
Interfaces
getOrgRateConfig(String orgId) → Future<OrgRateConfig>
watchOrgRateConfig(String orgId) → Stream<OrgRateConfig>
getRatePerKm(String orgId) → Future<double>
getApprovalThreshold(String orgId) → Future<double>
invalidateCache(String orgId) → void
Relationships
Related Data Entities (2)
Data entities managed by this component