Android: Leads and commission
Technical specification for lead and commission tracking in the PestControlOS Android app.
Data model
- Collection: Firestore
Leads. Documents include: lead details, assignment (technician), invoice status, commission fields, materials cost, payment status. - Invoice status: Pending, Sent, Paid, Overdue. Used for filtering and UI.
- Commission: Auto-calculation from configurable structure; materials cost tracked separately.
Permissions
- Mark as paid / Add–Edit materials: Restricted to admins only (user IDs 001, 002, 004). Implemented via role check before showing or enabling these actions.
- User 003 (technician): Can view leads assigned to them; cannot mark invoices as paid or edit materials cost. Firestore rules should enforce write restrictions on these fields by role.
- Admin edits: Lead updates (e.g. commission change) can trigger in-app notification to assigned technician for audit trail. Write to
notifications/{user}/items.
Filtering
- Filter by technician or lead type. Admin sees all; tech sees only assigned leads. Enforced by Firestore query and rules (e.g.
AssignedTechKey == request.auth.token.contractKey).