Mapping Field Interventions to Electronic Invoices
3. Direct Answer
To guarantee accurate billing, mobile payload completion data must first be transformed into an internal canonical InvoiceCommand containing an idempotency key before it hits the accounting API, completely decoupling the field app from the billing engine.
4. Context
Operational businesses lose revenue when technicians complete work but the associated billing data fails to reach the accounting software due to mismatched data structures.
5. Failure Scenario
A technician in an area with poor 4G taps "Submit" multiple times. The payload hits the server three times, resulting in the customer receiving three identical invoices.
6. Systems Involved
- Mobile PWA / Native App
- Core API Gateway
- Background Queue Worker
- Destination API (Xero, Quickbooks, etc.)
7. Technical Model
The system enforces strict decoupling. The mobile app only knows how to submit InterventionReport. It knows nothing of pricing or tax codes.
8. Normal Flow
- Technician submits
InterventionReportpayload. - API validates and saves the intervention.
- API pushes a job to
CalculateInvoiceTotals. - Job generates an
InvoiceCommandwith a unique hash of thejob_id. - Job dispatches to the accounting API.
9. Failure Flow
If the accounting API returns HTTP 429 (Rate Limit) or 503 (Unavailable), the worker catches the exception, retains the InvoiceCommand, and retries in 5 minutes (exponential backoff).
10. Controls
- Idempotency Key: Protects against duplicate charges.
- Dead-Letter Queue: Catches permanently malformed payloads for manual inspection.
11. Decision Options
- Synchronous vs Asynchronous: Always asynchronous. Never make the technician wait for the accounting API to respond before closing the app.
12. Limitations
This model relies on a static pricing matrix in the core API. If field techs need to override prices dynamically, the payload validation becomes significantly more complex.
13. Checklist
- [ ] Are mobile payloads validated before processing?
- [ ] Is an idempotency key generated per job?
- [ ] Are third-party API calls moved to a queue?
14. Proof
See the Field Service to Invoice Proof for exact payload mapping.
15. Relevant Service
16. Sources
Elevya field service operational audits, 2024–2026.
17. Author
Anass Benameur