Implement MileageClaimRepository CRUD via Supabase adapter
epic-mileage-reimbursement-entry-data-layer-task-005 — Build the concrete MileageClaimRepository using the supabase-mileage-adapter. Implement insert-with-initial-status, fetchByUser (ordered descending by activity date, paginated), fetchForCoordinator (org-scoped, filterable by status), updateStatus for coordinator approve/reject actions, and softDelete guarded by correction window timestamp check. Apply row-level security context for all queries.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 1 - 540 tasks
Can start after Tier 0 completes
Implementation Notes
Place the concrete class in lib/data/mileage_claim/supabase_mileage_claim_repository.dart. Create a private _fromJson(Map
Consider wrapping softDelete in a Supabase RPC call to make the window check atomic on the server side. Map Supabase 401/403 responses to an AuthorizationException in the domain layer.
Testing Requirements
Unit tests (flutter_test) using a fake/mock Supabase adapter: test insert maps fields correctly including forced 'pending' status; test fetchByUser passes correct query parameters and maps response to List
If OrgRateConfigRepository caches the per-km rate aggressively and an admin updates the rate mid-session, ongoing form interactions will show the old rate until the Stream emits. This could result in the UI showing a rate that differs from what is stored when the claim is submitted, causing confusion or disputes.
Mitigation & Contingency
Mitigation: Subscribe to a Supabase Realtime channel for the org_configuration table so config changes propagate within seconds. Document the eventual-consistency window in code comments.
Contingency: If Realtime subscription proves unreliable in test, add a polling fallback with a configurable interval (default 5 minutes) and display a 'rate updated' toast when the stream emits a changed value.
The correction window within which a claim can be deleted or voided is not explicitly specified in the feature documentation. Implementing the wrong window (e.g. 24 hours vs 7 days) could lock users out of corrections or allow inappropriate post-approval modifications.
Mitigation & Contingency
Mitigation: Raise the correction window definition as a blocking question to the HLF product owner before implementing the delete/void path in MileageClaimRepository. Implement the window duration as an org-level configuration value rather than a hardcoded constant.
Contingency: If the question cannot be resolved before implementation, default to 24 hours as the most conservative option and flag the value for review in the first user-acceptance test.