# Order Item

## Overview

Order Items are the line items on orders, specifying which products are being ordered, in what quantities, at what prices, and with what delivery expectations. While the order represents the overall transaction with a customer or supplier, order items provide the product-level detail that drives fulfillment, purchasing, and financial calculations.

Each order item specifies a product, quantity, and unit price. For sales orders, the price is what the customer pays. For purchase orders, it's what you pay the supplier. The line total is calculated from quantity times price. These line totals sum together with any order-level adjustments (discounts or fees) to form the order total, which is the financial foundation of the transaction.

Order items can specify where products should be sourced or delivered. For sales orders, this might indicate which warehouse should fulfill the item. For purchase orders, it specifies which facility should receive the goods. For transfer orders, items specify origin and destination sublocations. This location information drives fulfillment planning and warehouse operations.

Lot control on order items is important for lot-tracked products. Sales order items can specify that products should come from a specific lot - for example, to ensure all items in a shipment have the same expiration date. Purchase order items can assign incoming goods to a specific lot ID. This lot-level control supports inventory management policies around expiration dates, quality control, and customer requirements.

Linked relationships connect order items to related transactions. Sales order items link to fulfillment order items, which link to shipment items, which link to invoice items. This creates a complete trace from initial order through fulfillment to billing. You can see exactly which shipment fulfilled which order line, and which invoice line billed it, supporting customer service and reconciliation.

Calculated fields on order items support operational decision-making. Available quantity shows how much stock is available to fulfill the item. Backordered quantity indicates shortfall. Reserved quantity shows what's already allocated. These calculations help fulfillment planners understand what can ship now versus what must wait for restocking.

Order item status tracking shows fulfillment progress. Items can be unfulfilled, partially fulfilled, or fully fulfilled based on related shipments. They can be uninvoiced, partially invoiced, or fully invoiced based on related invoices. These statuses drive workflow and reporting, helping operations teams prioritize work and customer service teams answer status questions.

### GraphQL API

The `orderItem` collection provides access to orderItem data via the GraphQL API. All queries use the Relay connection specification with cursor-based pagination.

**Query Name:**`orderItemViewConnection`

**Available Features:**

- Cursor-based pagination (first/last/after/before)
- 1 relations to other collections

## Query Examples

### Basic Query

The `orderItem` collection is accessed via the `orderItemViewConnection` query, which returns a Relay-style connection with pagination support.

GraphQL

```graphql
query {
  orderItemViewConnection(first: 10) {
    edges {
      node {
        allocatedAdjustments
        allocatedMiscellaneous
        averageCost
        averageCostPerUnit
        averageCostPerUnitShipped
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
```

### Pagination

Use cursor-based pagination to retrieve large datasets:

GraphQL

```graphql
# First page
query {
  orderItemViewConnection(first: 50) {
    edges {
      node { supplierProductId }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}

# Subsequent pages
query {
  orderItemViewConnection(first: 50, after: "cursor-from-previous-page") {
    edges {
      node { supplierProductId }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
```

### Relations

Query related data:

GraphQL

```graphql
query {
  orderItemViewConnection(first: 10) {
    edges {
      node {
        supplierProductId
        product {
          title
          productUrl
        }
      }
    }
  }
}
```

## Summary and Aggregation

This collection supports data aggregation and dimensional analysis through the `summary` field. You can calculate metrics (like totals, averages, counts) and group them by dimensions (like category, date, status).

### Query Structure

GraphQL

```graphql
orderItemViewConnection(filters...) {
  summary {
    errorCode
    errorMessage
    groupBy {
      # Group by dimensions (see table below)
    }
    metrics {
      # Calculated metrics (see table below)
    }
  }
}
```

### Available Metrics

This collection provides 35 metrics that can be aggregated:

| Metric | Parameters | Description |
| --- | --- | --- |
| `orderOrderDate` | `transform`, `operator` | orderOrderDate for orderItem |
| `orderSubtotal` | `transform`, `operator` | orderSubtotal for orderItem |
| `orderTaxableSubtotal` | `transform`, `operator` | orderTaxableSubtotal for orderItem |
| `orderTotal` | `transform`, `operator` | orderTotal for orderItem |
| `orderNetSales` | `transform`, `operator` | orderNetSales for orderItem |
| `orderTotalUnits` | `transform`, `operator`, `productUrlList` | orderTotalUnits for orderItem |
| `orderTotalTaxDiscountsAndFees` | `transform`, `operator` | orderTotalTaxDiscountsAndFees for orderItem |
| `orderTotalAverageCost` | `transform`, `operator` | orderTotalAverageCost for orderItem |
| `orderGrossIncome` | `transform`, `operator` | orderGrossIncome for orderItem |
| `orderGrossMargin` | `transform`, `operator` | orderGrossMargin for orderItem |
| `orderShipmentPendingValue` | `transform`, `operator` | orderShipmentPendingValue for orderItem |
| `productNeqPerUnit` | `transform`, `operator` | productNeqPerUnit for orderItem |
| `productLastPurchaseLandedCostPerUnit` | `transform`, `operator` | productLastPurchaseLandedCostPerUnit for orderItem |
| `productLastPurchasePrice` | `transform`, `operator` | productLastPurchasePrice for orderItem |
| `productAverageGrossSalesPerUnit` | `transform`, `operator`, `dateRange`, `facilityUrlList` | productAverageGrossSalesPerUnit for orderItem |
| `productAverageUnitsPerSale` | `transform`, `operator`, `dateRange`, `facilityUrlList` | productAverageUnitsPerSale for orderItem |
| `productCogsSales` | `transform`, `operator`, `dateRange`, `facilityUrlList` | productCogsSales for orderItem |
| `productCountSales` | `transform`, `operator`, `dateRange`, `facilityUrlList` | productCountSales for orderItem |
| `productGrossSales` | `transform`, `operator`, `dateRange`, `facilityUrlList` | productGrossSales for orderItem |
| `productMarginSales` | `transform`, `operator`, `dateRange`, `facilityUrlList` | productMarginSales for orderItem |
| `productUnitSales` | `transform`, `operator`, `dateRange`, `facilityUrlList` | productUnitSales for orderItem |
| `productUnitSalesForSalesVelocity` | `transform`, `operator`, `dateRange`, `facilityUrlList` | productUnitSalesForSalesVelocity for orderItem |
| `productReorderQuantityToOrder` | `transform`, `operator`, `facilityUrlList`, `facilityUrl`, `reservedSublocationFacilityUrlList` | productReorderQuantityToOrder for orderItem |
| `productReorderQuantityToOrderEditable` | `transform`, `operator`, `facilityUrlList`, `facilityUrl`, `reservedSublocationFacilityUrlList` | productReorderQuantityToOrderEditable for orderItem |
| `productReplenishmentQuantityToOrder` | `transform`, `operator`, `facilityUrlList`, `facilityUrl`, `reservedSublocationFacilityUrlList` | productReplenishmentQuantityToOrder for orderItem |
| `productReplenishmentQuantityToOrderEditable` | `transform`, `operator`, `facilityUrlList`, `facilityUrl`, `reservedSublocationFacilityUrlList` | productReplenishmentQuantityToOrderEditable for orderItem |
| `productStock` | `transform`, `operator`, `aggregate`, `count`, `facilityUrlList`, `includeBom`, `includeSupplier`, `lotIdSearch`, `stockType` | productStock for orderItem |
| `productStockOnHand` | `transform`, `operator`, `aggregate`, `count`, `facilityUrlList`, `includeBom`, `includeSupplier`, `lotIdSearch`, `reservedSublocationFacilityUrlList` | productStockOnHand for orderItem |
| `productStockReserved` | `transform`, `operator`, `aggregate`, `count`, `facilityUrlList`, `includeBom`, `lotIdSearch`, `reservationType` | productStockReserved for orderItem |
| `productStockOnOrder` | `transform`, `operator`, `aggregate`, `count`, `facilityUrlList`, `includeBom`, `lotIdSearch` | productStockOnOrder for orderItem |
| `productStockAvailable` | `transform`, `operator`, `aggregate`, `count`, `facilityUrlList`, `includeBom`, `includeSupplier`, `lotIdSearch`, `reservedSublocationFacilityUrlList` | productStockAvailable for orderItem |
| `productStockRemaining` | `transform`, `operator`, `aggregate`, `count`, `facilityUrlList`, `includeBom`, `includeSupplier`, `lotIdSearch` | productStockRemaining for orderItem |
| `productAverageCost` | `transform`, `operator` | productAverageCost for orderItem |
| `productValuation` | `transform`, `operator`, `facilityUrlList`, `lotIdSearch` | productValuation for orderItem |
| `count` | None | Count of items in the result set |

**Common Parameters:**

- `operator` - Aggregation function: `sum`, `mean`, `min`, `max`
- `transform` - Mathematical transformation: `abs`
- `dateRange` - Filter to specific date range
- `facilityUrlList` - Filter to specific facilities

### GroupBy Dimensions

Group metrics by these dimensions:

| Dimension | Description |
| --- | --- |
| `orderOrderDate` | orderOrderDate for orderItem |
| `orderReceiveDate` | orderReceiveDate for orderItem |
| `orderShipDate` | orderShipDate for orderItem |
| `orderStatus` | orderStatus for orderItem |
| `orderType` | Type of order |
| `orderFulfillment` | orderFulfillment for orderItem |
| `orderShippingService` | orderShippingService for orderItem |
| `orderSaleSource` | orderSaleSource for orderItem |
| `orderCustomer` | orderCustomer for orderItem |
| `orderCustomerPartyId` | orderCustomerPartyId for orderItem |
| `orderEligibleToShip` | orderEligibleToShip for orderItem |
| `orderSupplier` | orderSupplier for orderItem |
| `orderSupplierPartyId` | orderSupplierPartyId for orderItem |
| `orderOrigin` | orderOrigin for orderItem |
| `orderDestination` | orderDestination for orderItem |
| `orderProcessingSublocation` | orderProcessingSublocation for orderItem |
| `orderTerms` | orderTerms for orderItem |
| `orderDueDate` | orderDueDate for orderItem |
| `orderPriceLevel` | orderPriceLevel for orderItem |
| `orderBillToStateRegion` | orderBillToStateRegion for orderItem |
| `orderBillToCountry` | orderBillToCountry for orderItem |
| `orderBillToCountryIso3166Alpha2` | orderBillToCountryIso3166Alpha2 for orderItem |
| `orderShipToStateRegion` | orderShipToStateRegion for orderItem |
| `orderShipToCountry` | orderShipToCountry for orderItem |
| `orderShipToCountryIso3166Alpha2` | orderShipToCountryIso3166Alpha2 for orderItem |
| `orderShipFromStateRegion` | orderShipFromStateRegion for orderItem |
| `orderShipFromCountry` | orderShipFromCountry for orderItem |
| `orderShipFromCountryIso3166Alpha2` | orderShipFromCountryIso3166Alpha2 for orderItem |
| `productCategory` | productCategory for orderItem |
| `productSupplier1` | productSupplier1 for orderItem |
| `productSupplier2` | productSupplier2 for orderItem |
| `productSupplier3` | productSupplier3 for orderItem |

All dimensions accept a `formatter` parameter: `"html"`, `"none"`, `"abbreviated"`, `"blank-zero"`.

### Example 1: Basic Aggregation

Calculate metrics for orderItem:

GraphQL

```graphql
query {
  orderItemViewConnection(first: 1) {
    summary {
      errorCode
      errorMessage
      groupBy {
        # Add dimensions here
      }
      metrics {
        totalCount: count
      }
    }
  }
}
```

## Fields

This collection has 51 fields:

- 51 simple fields
- 0 enum fields (with predefined values)
- 0 parameterized fields (accept query options)

### Simple Fields

These fields return values directly without additional options.

#### `allocatedAdjustments`
**Label:** Allocated adjustments

#### `allocatedMiscellaneous`
**Label:** Allocated miscellaneous

#### `averageCost`
**Label:** COGS (estimated)

#### `averageCostPerUnit`
**Label:** COGS per unit (estimated)

#### `averageCostPerUnitShipped`
**Label:** Shipped average cost per unit (estimated)

#### `averageCostShipped`
**Label:** Shipped valuation (estimated)

#### `cbm`
**Label:** CBM subtotal

#### `class`
**Label:** Class

#### `cost`
**Label:** Std accounting cost amount

#### `descriptionItemNote`
**Label:** Description / item note

#### `discount`
**Label:** Discount

#### `extendedProductListPrice`
**Label:** Extended product list price

#### `grossIncome`
**Label:** Gross income (estimated)

#### `incomeAfterAdjustments`
**Label:** Income after adjustments (estimated)

#### `incomeAfterAdjustmentsPerUnit`
**Label:** Income after adjustments per unit (estimated)

#### `itemIndex`
**Label:** Item index

#### `itemNote`
**Label:** Item note

#### `landedCost`
**Label:** Landed cost (estimated)

#### `landedCostPerUnit`
**Label:** Landed cost per unit (estimated)

#### `marginPercentage`
**Label:** Margin percentage (estimated)

#### `nativeNeq`
**Label:** Native NEQ subtotal

#### `nativeWeight`
**Label:** Native Weight subtotal

#### `neq`
**Label:** NEQ subtotal

#### `packing`
**Label:** Packing

#### `pricePerUnit`
**Label:** Price per unit

#### `productCaseOrCaseEquivalentReceived`
**Label:** Product case equivalents received

#### `productReorderVariance`
**Label:** Product reorder variance

#### `productUnitsOrdered`
**Label:** Product units ordered

#### `productUnitsPacked`
**Label:** Product units packed

#### `productUnitsPackedShippedOrReceived`
**Label:** Product units packed, shipped, or received

#### `productUnitsPackedShippedOrReceivedLessReturns`
**Label:** Product units packed, shipped, or received less returns

#### `productUnitsReceived`
**Label:** Product units received

#### `productUnitsRemainingToBePackedShippedOrReceived`
**Label:** Product units remaining to be packed, shipped, or received

#### `productUnitsRemainingToBeShipped`
**Label:** Product units remaining to be shipped

#### `productUnitsReturned`
**Label:** Product units returned

#### `productUnitsShipped`
**Label:** Product units shipped

#### `productUnitsVariance`
**Label:** Product units variance

#### `quantity`
**Label:** Quantity

#### `quantityCaseOrCaseEquivalent`
**Label:** Quantity, case or case equivalent

#### `quantityCaseStock`
**Label:** Quantity, case stock

#### `quantityOpenStock`
**Label:** Quantity, open stock

#### `shortCode`
**Label:** Short code

#### `subtotal`
**Label:** Amount

#### `supplierProductId`
**Label:** Supplier product ID

#### `supplierProductIdOrProductId`
**Label:** Supplier product ID or product ID

#### `unitListPrice`
**Label:** List price

#### `unitPrice`
**Label:** Unit price

#### `units`
**Label:** Units

#### `unitsPerCase`
**Label:** Units per case

#### `warning`
**Label:** Warning

#### `weight`
**Label:** Weight subtotal

## Relations

### product 
- **Related Collection:** product
- **Label:** Product

**Example Query:**

GraphQL

```graphql
query {
  orderItemViewConnection(first: 10) {
    edges {
      node {
        product {
          title
          productUrl
        }
      }
    }
  }
}
```

## Filters
No filters available.

Updated 9 months ago
