---
status: complete
phase: 12-orders-invoices-company-matching
source: [12-01-SUMMARY.md, 12-02-SUMMARY.md, 12-03-SUMMARY.md, 12-04-SUMMARY.md, 12-05-SUMMARY.md]
started: 2026-07-11T11:29:27Z
updated: 2026-07-11T11:35:57Z
---

## Current Test

[testing complete]

## Tests

### 1. Cold Start Smoke Test
expected: Restart the app container from scratch. Migrations 093/094/095 apply (or are already applied) without error, the app boots, and a basic health query against pax8_order_items/pax8_companies returns live data.
result: pass

### 2. Full PAX8 sync populates historical order items
expected: Triggering a full PAX8 sync (POST /api/pax8/sync) populates pax8_order_items with per-company id, billing period, and dual-cost data across the full historical invoice set (not a partial subset).
result: pass

### 3. Confident company auto-matches are created and correct
expected: pax8_companies rows exist with autotask_company_id set and match_confidence >= 0.90 (pg_trgm), and a sample of these auto-matches are genuinely the same real company on both sides.
result: pass

### 4. Ambiguous/no-match companies are flagged, never silently guessed
expected: PAX8 companies with no clear Autotask match, or multiple similarly-scored candidates, get a pax8_company_match_review row instead of being auto-linked.
result: pass

### 5. Re-running sync is idempotent for resolved matches
expected: Running the sync a second time does not change the auto-match set already established (same pax8_company_id/autotask_company_id/match_confidence triples).
result: pass

### 6. Partner cost figures retain full decimal precision (CR-01 regression check)
expected: partner_cost/partner_cost_total values with more than 2 decimal places (e.g. real PAX8 costs like 0.0182 or 22.176) are stored without silent rounding.
result: pass

### 7. Sync History does not show fabricated deletion counts (CR-02 regression check)
expected: A sync run that flags companies for manual review does not report those flagged companies as "records_deleted" in sync_history / the admin Sync History table.
result: pass

## Summary

total: 7
passed: 7
issues: 0
pending: 0
skipped: 0

## Gaps

[none]
