Attach Receipt When Offline and Sync When Connected
Peer mentors often register expenses immediately after visits in locations with poor connectivity. The app must allow offline capture and form completion, caching the receipt image locally. When connectivity is restored, the pending upload is processed automatically in the background and the claim is submitted. The user is notified of successful background submission via an in-app notification. If the background sync fails, the claim remains in a 'pending upload' state visible in the expense list with a retry option. This is particularly important for rural or hospital-visit scenarios where connectivity is unreliable.
User Story
Acceptance Criteria
- Given I have no internet connection, When I capture a receipt and fill in the expense form, Then I can complete the form and the claim is saved locally in a pending state
- Given a claim is in pending state due to no connectivity, When I view the expense list, Then the pending claim is shown with a 'Waiting for connection' indicator
- Given connectivity is restored, When the app detects the network, Then pending uploads are processed automatically in the background without requiring me to reopen the form
- Given the background upload and submission succeed, When the operation completes, Then I receive an in-app notification confirming the claim was submitted
- Given the background sync fails after connectivity returns, When I view the pending claim, Then a Retry button is available and the failure reason is shown in plain language
- Given an image is cached locally for offline use, When it is successfully uploaded, Then the local cache is cleared to free device storage
Business Value
Offline capability is essential for the core use case: peer mentors visiting contacts at home, in hospitals, or in rural areas where connectivity is unreliable. Forcing online-only expense registration introduces friction that leads to the underreporting problem all three organizations identified as critical. Background sync ensures no claims are lost while maintaining data integrity through atomic upload-before-submit semantics.
Components
- Receipt Camera Sheet ui
- Receipt Attachment Service service
- Receipt Image Compressor service
- Receipt Storage Repository data
- Claim Receipt Repository data
- Expense Form BLoC service
- Expense Submission Service service
- Supabase Storage Adapter infrastructure
- Notification List Item Widget ui
- Plain Language Error Display ui