TECHNICAL PROOF A

Field Service to Invoice

A reference architecture mapping a mobile technician's payload into a canonical model, guaranteeing idempotency and robust retries before syncing to an accounting API.

1. Problem

When field technicians complete jobs via a mobile app, network drops or API rate limits can cause the accounting system to miss the invoice or duplicate it. We must guarantee that one completed job results in exactly one invoice.

2. Reference Architecture

[MOBILE CLIENT] 
   │ (Job Completion Payload)
   ▼
[API GATEWAY] (Auth & Validation)
   │
   ▼
[DOMAIN LOGIC] (Generate Canonical Model + Idempotency Key)
   │
   ▼
[QUEUE / BACKGROUND JOB] 
   │ (Exponential Backoff & Retries)
   ▼
[ACCOUNTING API] (Xero / QuickBooks / Exact)
      

3. Canonical Model

We do not pass the mobile payload directly to the accounting system. We first transform it into our internal, standard `InvoiceCommand` format.

4. Sample Payload & Mapping

Source (Mobile Payload)
{
  "job_id": "JOB-9821",
  "client_ref": "CUST-44",
  "parts_used": [{"id": 12, "qty": 2}]
}
Destination (Canonical)
{
  "idempotency_key": "inv_JOB-9821",
  "contact_id": "ext-44",
  "line_items": [{"sku": "P-12", "q": 2}]
}

5. Idempotency & Retries

  • Idempotency: The queue job generates a unique hash based on the `job_id`. The accounting API checks this key. If the request is sent twice, the API ignores the second attempt.
  • Retries: If the accounting API responds with a `429 Too Many Requests` or `5xx Server Error`, the job is released back to the queue with exponential backoff.

6. Replay & Audit

Every payload is logged to an `audit_logs` table before transmission. If a catastrophic failure occurs, administrators can press a "Replay" button in the dashboard to push the exact canonical payload through the queue again.

7. Automated Tests

✓ it_transforms_mobile_payload_to_canonical_model (12ms)
✓ it_generates_consistent_idempotency_key_per_job (8ms)
✓ it_retries_on_http_500_response (15ms)
✓ it_prevents_duplicate_invoicing_on_success (11ms)
      

8. Demonstration (Deferral)

Documented Deferral: A 3-minute video demonstration is deferred in this public proof to protect proprietary UI components of the staging application. Access to the underlying code repository is available under NDA.

9. Limitations & Vendor Boundaries

  • Limitations: This architecture handles transient network failures. It does not handle semantic data errors (e.g., the technician entering an invalid SKU). Semantic errors require human intervention via the audit dashboard.
  • Vendor Boundaries: If the destination Accounting API alters its JSON schema without versioning, the Canonical mapping layer will safely catch the validation failure and prevent corrupt data insertion.

10. Documentation Package

This page serves as the public README. For full code excerpts, architecture SVG, and automated test repositories, please initiate contact.

Discuss your Integration