fix(connect): store cloud order id locally to enable reliable status mirroring

The Phase 4 _mirror_status_to_cloud function had no way to look up the
cloud order's numeric id once it was marked synced (not in the pending
list anymore), so status updates from local staff could silently fail.

Fix:
  - models/order.py: online_order_cloud_id INTEGER column added to Order
  - main.py: migration for the new column
  - schemas/order.py: online_order_cloud_id exposed in OrderOut
  - cloud_sync.py: stores cloud_order["id"] as online_order_cloud_id
    when creating the local order during the pull
  - connect_orders.py: _mirror_status_to_cloud now takes the integer
    cloud id directly — no more pending-list lookup; function body
    reduced from ~50 lines to ~15

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-01 00:14:43 +03:00
parent 4b1201ecaa
commit 80842d9be3
5 changed files with 17 additions and 57 deletions

View File

@@ -122,6 +122,7 @@ class OrderOut(BaseModel):
# Xenia Connect — online order fields
source: str = "pos"
online_order_ref: Optional[str] = None
online_order_cloud_id: Optional[int] = None
online_status: Optional[str] = None
online_customer_name: Optional[str] = None
online_customer_phone: Optional[str] = None