fix: correct order sync_status and historical import display
- Fix historical import to also update sync_status when it's out of sync with letzshop_state (e.g., confirmed orders showing as pending) - Fix frontend to read stats from response.statistics nested object - Orders with matching letzshop_state but wrong sync_status now get fixed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -622,11 +622,23 @@ class LetzshopOrderService:
|
||||
|
||||
if existing_order:
|
||||
# Check if we need to update (e.g., state changed)
|
||||
if existing_order.letzshop_state != shipment.get("state"):
|
||||
shipment_state = shipment.get("state")
|
||||
if existing_order.letzshop_state != shipment_state:
|
||||
self.update_order_from_shipment(existing_order, shipment)
|
||||
stats["updated"] += 1
|
||||
else:
|
||||
stats["skipped"] += 1
|
||||
# Also fix sync_status if it's out of sync with letzshop_state
|
||||
state_mapping = {
|
||||
"unconfirmed": "pending",
|
||||
"confirmed": "confirmed",
|
||||
"declined": "rejected",
|
||||
}
|
||||
expected_sync_status = state_mapping.get(shipment_state, "confirmed")
|
||||
if existing_order.sync_status != expected_sync_status:
|
||||
existing_order.sync_status = expected_sync_status
|
||||
stats["updated"] += 1
|
||||
else:
|
||||
stats["skipped"] += 1
|
||||
else:
|
||||
# Create new order
|
||||
self.create_order(vendor_id, shipment)
|
||||
|
||||
@@ -469,8 +469,10 @@ function adminMarketplaceLetzshop() {
|
||||
`/admin/letzshop/vendors/${this.selectedVendor.id}/import-history?state=confirmed`
|
||||
);
|
||||
|
||||
this.historicalImportResult = response;
|
||||
this.successMessage = `Historical import complete: ${response.imported} imported, ${response.updated} updated`;
|
||||
// Stats are nested under 'statistics' key
|
||||
this.historicalImportResult = response.statistics || response;
|
||||
const stats = this.historicalImportResult;
|
||||
this.successMessage = `Historical import complete: ${stats.imported} imported, ${stats.updated} updated`;
|
||||
|
||||
marketplaceLetzshopLog.info('Historical import result:', response);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user