Skip to content

feat: sync sales order if not found during invoice preparation#425

Open
devinvento wants to merge 2 commits intofrappe:version-16from
devinvento:fix/sync-sales-order-race-condition
Open

feat: sync sales order if not found during invoice preparation#425
devinvento wants to merge 2 commits intofrappe:version-16from
devinvento:fix/sync-sales-order-race-condition

Conversation

@devinvento
Copy link
Copy Markdown

No description provided.

@devinvento devinvento requested a review from ankush as a code owner April 8, 2026 06:08
@devinvento
Copy link
Copy Markdown
Author

Fix: Handle Shopify Webhook Race Conditions

This update ensures reliable synchronization between Shopify and ERPNext by handling out-of-order webhook execution.

Problem

Shopify may send orders/paid before orders/create, causing Sales Invoice creation to fail due to a missing Sales Order.

Solution

Added a fallback mechanism in prepare_sales_invoice:

If the Sales Order is not found, call sync_sales_order(order, request_id) to create it immediately.
Re-fetch the Sales Order and proceed with invoice creation.
Benefits
Improved reliability: Prevents "Sales Order not found" errors.
Ensures data integrity: Guarantees every paid order creates both Sales Order and Sales Invoice.
No duplicates: Existing checks prevent duplicate record creation.

…voices, Delivery Notes, and Sales Orders during Shopify order cancellation
@devinvento devinvento force-pushed the fix/sync-sales-order-race-condition branch from 787a981 to 3995e42 Compare April 8, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant