## Problem to solve

Synchronize billing events and financial state between Beacon and ERP without duplication or context loss.

## Recommended pattern

- Beacon as source-of-truth for operational events.
- ERP as source-of-truth for consolidated accounting.
- Event-driven integration with scheduled reconciliation.

## Integration data model

| Field | Origin | Purpose |
| --- | --- | --- |
| `eventId` | Beacon webhook/event | Duplicate detection |
| `organizationId` | Beacon | Multi-tenant isolation |
| `externalReference` | ERP | Bidirectional reconciliation |
| `status` | Both | Divergence handling |

## Reliability strategy

<Steps>
  <Step title="1) Idempotent ingestion">Use a technical key per event to prevent double writes in ERP.</Step>
  <Step title="2) Retry with backoff">Retry transient failures with limits and telemetry.</Step>
  <Step title="3) Daily reconciliation">Compare totals and statuses per period to close divergences.</Step>
  <Step title="4) Exception queue">Route non-automatable cases for manual triage.</Step>
</Steps>

<Tip title="Scalability">As volume grows, split queues by domain (billing, refunds, fiscal) to reduce blast radius.</Tip>
