National Commerce Docs
n8n flows

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, and query.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

  1. The webhook stores the payload, responds immediately to acknowledge, then picks a single input to process.
  2. It fans out to mark the queue row processed in purchase_order_updates_queue and to fetch the brand.
  3. Get Purchase Order From Shiphero retrieves the latest state; the flow finds, creates, or updates the PO record and resolves the warehouse link.
  4. A counter loop creates or updates each PO line item. Create Line Item Record and Update Line Item Record both write shiphero_sku, the raw code from ShipHero.
  5. Resolve SKU For Line Item asks the SKU Information Handler to resolve the code, and SKU Found? routes on the answer.
  6. When a SKU comes back, the line item is linked to its Case SKU or Base SKU, then Mark Line Item Classified sets sku_classification_status to 'resolved', stamps sku_classified_at, and clears pending_queue_id.
  7. When no SKU comes back, Mark Line Item Pending Classification sets sku_classification_status to 'pending_classification' and records pending_queue_id. No SKU is attached and no Base SKU is created.
  8. Reconciliation compares stored line items against the current PO and deletes any that ShipHero removed.
  9. Update On-Hand Inventory runs 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-handler set as the error workflow.

On this page