ifixkart-admin/docs/synchronization/pos-sync.md
Adithiyan bbd3a3e959 feat: initial commit — full platform snapshot
- Backend: FastAPI app with all models, services, schemas, routes
- Admin Panel: Next.js dashboard with all modules
  (CRM, POS, repairs, warranties, billing, notifications, etc.)
- Ecommerce: storefront (submodule) + product catalog
- AI Agents: .agents/ skill library for Antigravity IDE
- Docs: architecture, billing, notification gateway markdown
- Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
2026-10-13 12:59:47 +05:30

42 lines
1.1 KiB
Markdown

# 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 }"]
```