Android: Contracts
Technical specification for contract management in the PestControlOS Android app.
Data model
- Collections: Contracts stored per technician in Firestore collections named
"[User] Contracts"(e.g. per user ID). Collection name fromStaffDirectory.getContractsCollectionName(id). Document fields: customer/address, visit frequency, last visit, next visit, status. - Status logic: Overdue, Due Soon, Up-to-date (or Behind/Due/On Schedule/No Date). Used for filtering and UI.
Operations
- Add contract: Create document in technician’s contract collection. Admin (002, 004) can add to another technician’s list; assigned technician receives in-app notification (
notifications/{user}/items). - Update visits / mark done: Update last/next visit. Firestore rules enforce permissions.
- Open in Maps: Launch Google Maps with contract address.
- View Reports: Prompt for year; search Firebase Storage
ReportsYY; matching case/spacing/underscore tolerant.
Firestore rules
- Allow read/write for
"[User] Contracts"for authenticated user or admin. Production: scope byrequest.authand optionally custom claim matching collection user.
Role-aware assignment
- Admin can add contracts to any technician’s list. Document may store
AssignedTech/AssignedTechKey; assignment triggers in-app notification.