> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sourcemedium.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# obt_purchase_order_lines

> One row per current purchase-order line from GoodDay or Pipe17, with ordered, received, and open units, landed-cost inputs, and inbound arrival dates.

One row per current purchase-order line from your ERP or OMS ([GoodDay](https://docs.sourcemedium.com/docs/data-inputs/platform-integration-instructions/goodday-integration.md) and [Pipe17](https://docs.sourcemedium.com/docs/data-inputs/platform-integration-instructions/pipe17-integration.md)), with vendor details, PO status, destination location, SKU, quantities, vendor cost inputs, derived landed cost per unit, and inbound shipment dates.

* **Grain:** One row per (`sm_store_id`, `source_system`, `purchase_order_line_id`).
* **Date fields:** `purchase_order_date`, `planned_ready_date`, `expected_fulfillment_date`, `actual_fulfillment_date`, `shipment_expected_arrival_date`, and `shipment_actual_arrival_date`.
* **Filters to start with:** `source_system` (`goodday` or `pipe17`), especially if you keep the same purchase order in both systems.
* **Joins:** Join [`obt_inventory_positions`](https://docs.sourcemedium.com/docs/data-activation/data-tables/sm_transformed_v2/obt_inventory_positions) on `lower(trim(po.sku)) = inv.sku` (and `sm_store_id`), because `obt_inventory_positions.sku` is lowercased and trimmed while `obt_purchase_order_lines.sku` preserves source casing. Join [`dim_product_variants`](https://docs.sourcemedium.com/docs/data-activation/data-tables/sm_transformed_v2/dim_product_variants) on `sku` (and `sm_store_id`) for catalog attributes.

## When to use this table

Use `obt_purchase_order_lines` to track open purchase orders, inbound inventory arriving by SKU and location, vendor lead times, and unit landed cost breakdowns (vendor price, freight, fees, tariffs, and duties).

> [!WARNING]
>
> If you manage the same purchase order in both GoodDay and Pipe17, it appears once per system. Filter on `source_system` before summing `ordered_units`, `received_units`, `open_units`, or `extended_landed_cost` so you do not double-count.

## Reading the columns

* **Open units:** `open_units` is `ordered_units` minus `received_units`, clamped at zero so over-receipts never produce negative open units.
* **Landed cost:** `landed_cost_per_unit` is `vendor_price * (1 + tariff_rate + duty_rate) + freight_price + fees`. It is NULL whenever any required input is missing, including on every Pipe17 line (Pipe17 records vendor price, not freight, duty, or fee inputs). `extended_landed_cost` is `landed_cost_per_unit * ordered_units`.
* **Currency:** Prices and costs are denominated in `currency_code`. Group or filter by `currency_code` before summing costs across multi-currency purchase orders.

## Example: open purchase-order units and value by SKU

```sql theme={null}
SELECT
  sku,
  ANY_VALUE(item_title) AS item_title,
  currency_code,
  SUM(open_units) AS total_open_units,
  SUM(open_units * landed_cost_per_unit) AS open_landed_value,
  MIN(expected_fulfillment_date) AS next_expected_receipt
FROM `your_project.sm_transformed_v2.obt_purchase_order_lines`
WHERE sm_store_id = 'your-sm_store_id'
  AND source_system = 'goodday'
  AND purchase_order_status = 'open'
  AND open_units > 0
GROUP BY sku, currency_code
ORDER BY total_open_units DESC
```

## Columns

| Column | Type | Description |
| - | - | - |
| `sm_store_id` | STRING | SourceMedium store identifier. |
| `actual_fulfillment_date` | TIMESTAMP | When the line's shipment group was received. |
| `block_position` | INT64 | Position of the line's shipment group (GoodDay block) within the purchase order. |
| `currency_code` | STRING | Currency of the line's prices. |
| `duty_rate` | NUMERIC | Import duty rate as a fraction of vendor price. |
| `expected_fulfillment_date` | TIMESTAMP | When the line is expected to be received. |
| `extended_landed_cost` | NUMERIC | Landed cost per unit times ordered units. |
| `fees` | NUMERIC | Other fees per unit (for example brokerage or inspection). |
| `freight_price` | NUMERIC | Freight allocated per unit. |
| `item_id` | STRING | Item identifier in the source system. |
| `item_title` | STRING | Item title. |
| `landed_cost_per_unit` | NUMERIC | Vendor price times (1 + tariff rate + duty rate), plus freight and fees per unit. |
| `line_item_number` | INT64 | Line position within the purchase order. |
| `line_status` | STRING | Line status as the source reports it. |
| `open_units` | NUMERIC | Units still to arrive, ordered minus received, never below zero. |
| `ordered_units` | NUMERIC | Units currently on order (after any revision or partial cancellation). |
| `original_units` | NUMERIC | Units originally ordered. |
| `original_vendor_cost` | NUMERIC | Vendor price when the line was opened, to compare against revisions. |
| `planned_ready_date` | TIMESTAMP | When the vendor expects the goods to be ready to ship. |
| `purchase_order_date` | TIMESTAMP | Date the merchant placed the order with the vendor. |
| `purchase_order_id` | STRING | Purchase order identifier in the source system. |
| `purchase_order_line_id` | STRING | Line identifier in the source system. |
| `purchase_order_number` | STRING | Purchase order number the merchant sees (for example PO-0042). |
| `purchase_order_status` | STRING | Purchase order status as the source reports it (GoodDay: draft, open, closed, cancelled). |
| `purchase_order_type` | STRING | Purchase order type (GoodDay: standard or work\_order). |
| `received_units` | NUMERIC | Units received into inventory so far. |
| `ship_to_location_id` | STRING | Destination location identifier. |
| `ship_to_location_name` | STRING | Destination location name. |
| `shipment_actual_arrival_date` | TIMESTAMP | Inbound shipment actual arrival. |
| `shipment_expected_arrival_date` | TIMESTAMP | Inbound shipment expected arrival. |
| `shipment_id` | STRING | Inbound shipment carrying the line, once booked. |
| `shipment_status` | STRING | Inbound shipment status. |
| `sku` | STRING | Item SKU. |
| `source_synced_at` | TIMESTAMP | When SourceMedium last read the line from the source. |
| `source_system` | STRING | Purchasing system the line comes from (goodday or pipe17). |
| `tariff_rate` | NUMERIC | Tariff rate as a fraction of vendor price (0.05 is 5%). |
| `unit_of_measure` | STRING | Unit the quantities are counted in. |
| `vendor_id` | STRING | Vendor identifier in the source system. |
| `vendor_name` | STRING | Vendor display name. |
| `vendor_price` | NUMERIC | Price paid to the vendor per unit, excluding freight, duty and fees. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.