Purchase Order Update Handler
Processes a single queued ShipHero PO update end-to-end and triggers an on-hand inventory recount.
The live, per-event workhorse for purchase-order sync. It processes one ShipHero PO update at a time: it fetches the latest state, upserts the purchase order and its line items, resolves SKU catalog links, removes line items no longer on the PO, and kicks off an inventory recount.
At a glance
- Status: Active
- Trigger: Webhook (
POST /webhook/new-po-order-update), answered by a Respond-to-Webhook node. A manual trigger exists for testing. - Runs on: Queued PO updates. The payload carries
po_uuid,po_number,warehouse_id,query.brand, andquery.queue_id. - Talks to: ShipHero (GraphQL); Supabase (Inventory Purchase Orders and Line Items, Warehouses, Case/Base/Product SKUs, Brands,
purchase_order_updates_queue); the Update On-Hand Inventory sub-workflow.
How it works
- The webhook stores the payload, responds immediately to acknowledge, then picks a single input to process.
- It fans out to mark the queue row
processedinpurchase_order_updates_queueand to fetch the brand. Get Purchase Order From Shipheroretrieves the latest state; the flow finds, creates, or updates the PO record and resolves the warehouse link.- A counter loop creates or updates each PO line item.
Create Line Item RecordandUpdate Line Item Recordboth writeshiphero_sku, the raw code from ShipHero. Resolve SKU For Line Itemasks the SKU Information Handler to resolve the code, andSKU Found?routes on the answer.- When a SKU comes back, the line item is linked to its Case SKU or Base SKU, then
Mark Line Item Classifiedsetssku_classification_statusto'resolved', stampssku_classified_at, and clearspending_queue_id. - When no SKU comes back,
Mark Line Item Pending Classificationsetssku_classification_statusto'pending_classification'and recordspending_queue_id. No SKU is attached and no Base SKU is created. - Reconciliation compares stored line items against the current PO and deletes any that ShipHero removed.
Update On-Hand Inventoryruns as a non-blocking sub-workflow (P01aHgb9xIQVmzlb) to recount stock.
An unclassified code holds the line item, it does not block the PO
If a code has not been classified yet, the line item is saved with no SKU attached and the code is parked in the review queue. Receiving and closing still work exactly as before, because PO status comes from ShipHero.
The held quantity counts toward nothing until the code is classified. With no Base SKU there is no Inventory row for on-hand to attach to, and the inbound trigger scores a line item with no SKU as 0. See Purchase Orders in the database reference.
Notes
- Reads its queue item from
purchase_order_updates_queue(populated by ShipHero PO Update → Queue) and marks it processed. - Largest workflow in the domain (~78 nodes).
- Linking held line items back to a SKU happens in the portal, not here. Classifying a code from the queue links every line item still holding it. See Resolve the SKU queue.
- Shared
error-handlerset as the error workflow.