n8n flows
Notify: PO Line Item Discrepancy
Emails brand users when a received PO line item does not match the ordered quantity.
When a closed PO has a PO line item whose received quantity does not match what was ordered, this flow emails the relevant brand users. It respects per-user preferences and sends only once per line item.
At a glance
- Status: Active
- Trigger: Webhook (
POST /webhook/fa4e35de-c6fe-4ac3-bc89-8af1d30442ff), responds immediately. - Runs on:
purchase_order_line_item_discrepancy_triggerfiring whendiscrepancy_detectedturns true. The payload carries the line-item record id. The database only sets that flag once the PO is closed, so this flow never runs mid-receiving. See When a discrepancy is flagged. - Talks to: Supabase (PO Line Items, POs, Case/Base SKUs, Brands, userRoles, user_settings, Auth Admin API); Gmail.
How it works
- The webhook receives the record id; the flow reads the PO line item.
- It re-verifies the discrepancy by comparing
total_quantityagainstreceived_quantity; equal values stop the flow. - It checks
discrepancy_notification_sentand sets the flag before sending. - It resolves the SKU (via Case SKU or Base SKU records), then the purchase order, its account brand, and the brand's users.
Loop Over Userscheckssend_notificationsandinventory_management.inbound_pos_issues; opted-in users get a branded HTML Gmail alert detailing PO number, SKU, ordered vs received quantity, and the difference, linking to the receiving-discrepancies page.
Notes
- Double-guarded: it re-verifies the discrepancy and checks the sent flag before emailing.
- Opt-in gated on two preference flags.
- The flow itself does not check whether the PO is closed. It does not need to, because the database only raises
discrepancy_detectedfor a closed PO. If partial-receiving emails ever reappear, the cause is inupdate_purchase_order_line_items(), not here. discrepancy_notification_sentis set before sending and is never reset, so a line item emails at most once ever. A correction to the quantities afterwards produces no follow-up.
Related
Notify: New Draft PO Created
Emails brand users when a new draft purchase order is created, respecting their notification preferences.
Missing Shipment Data Pull 2.0 (Backup)
The live 2.0 flow that pulls missing ShipHero shipment data into Supabase for every active brand and reconciles the full shipment graph.