Skip to main content
Version: v1.0.0(int)

W146: Get sales order detail

Returns a single SO with everything the detail page needs: header, items, SKUs, timeline notes, documents, and a computed fulfillment status derived from the FG ledger. Triggered by clicking an SO in the list.

Steps

  1. Load the SO header. Call SalesOrders.getSoById.

  2. Load items and hydrate SKUs. Call SalesOrders.listItemsBySo and Products.getSkusByIds for the referenced SKUs.

  3. Derive the computed fulfillment status. For each line, sum CONSUME quantities from the FG ledger via listEntries({ refLike: soNumber, eventType: 'CONSUME' }); compare against expected to derive Pending, Partial, or Fulfilled.

  4. Return both computed and stored fulfillment status. When they differ, the page surfaces the computed value and keeps the stored value visible as the "user-set override" indicator.

  5. Load timeline notes and documents. SalesOrders.listTimelineNotesBySo and Documents.listByEntity('sales_order', soId).

Returns

The merged hydrated view: header plus items plus SKUs plus computed fulfillment status plus timeline notes plus documents.

Business rules

  • Computed vs. stored fulfillment status is deliberate. The ledger is the source of truth, but a manual override gives sales ops a release valve when reality diverges from the data. A future iteration may collapse the two into a derived-only field.

Errors

  • NotFoundError. The SO was not found.