# Offline POS Synchronization Protocol & Conflict Resolution ## Sync Request Specification Managed via `PosSyncRouter.py`. ### Endpoint: `POST /api/v1/pos/sync` Payload Body: ```json { "device_id": "DEV_CHN_01", "terminal_id": "POS_02", "store_id": "STORE_CHN", "transactions": [ { "pos_transaction_id": "TX_01J8X9A", "local_sequence": 452, "invoice_no": "C1P2-26-000452", "total_amount": 149.99, "created_at": "2026-08-13T10:15:00Z", "items": [ { "variant_id": "var_01J8X9", "qty": 1, "unit_price": 149.99 } ] } ] } ``` --- ## Server Idempotency & Conflict Resolution ```mermaid flowchart TD Req["POST /api/v1/pos/sync"] --> CheckTx{"Lookup pos_transaction_id\nin MySQL DB"} CheckTx -->|Exists| AlreadyProcessed["Return Existing ACK & Status\n(No Duplicate Sale Created)"] CheckTx -->|New Transaction| ProcessTx["1. Write POS Sale to MySQL\n2. Create POS_SALE Ledger Entry\n3. Write Invoices Record"] ProcessTx --> ReturnACK["Return Success ACK { pos_transaction_id, synced: true }"] ```