Parts & inventory

Parts catalog, suppliers, stock locations and bins, on-hand quantities, re-order rules, part reservations and usage linked to work orders, and basic purchasing (requisitions, purchase orders, receipts). Set tenant context before calling these methods.

Overview

The client.partsInventory resource provides:

  • Parts catalog – list parts with or without aggregated stock (on-hand, reserved, available)
  • Suppliers – list and get by id; create/update via RPCs
  • Inventory locations – hierarchy (warehouse, aisle, shelf, bin); stock levels per part per bin
  • Reservations – parts reserved for work orders; list by work order
  • Part usage – parts issued/consumed on work orders; list by work order
  • Purchasing – open requisitions, open POs, PO receipt status; receive PO and create PO via RPCs
  • RPCs – reserve parts, issue parts to work order, receive PO, create PO, create/update part, create/update supplier

All data is tenant-scoped. Permissions (e.g. part.create, inventory.usage.record, purchase_order.receive) are enforced by the RPCs.

Parts and stock

Parts with aggregated stock (total on-hand, total reserved, available = on-hand − reserved). Use for dashboards and re-order logic.

client.partsInventory.listPartsWithStock()

await client.setTenant(tenantId)
const parts = await client.partsInventory.listPartsWithStock()
// Returns PartWithStockRow[]: id, part_number, name, unit, total_on_hand, total_reserved, available, reorder_point, ...

client.partsInventory.getPartWithStockById(id)

const part = await client.partsInventory.getPartWithStockById('uuid-of-part')
// Returns PartWithStockRow | null

Stock by part and inventory location (bin). Use for put-away and pick lists.

client.partsInventory.listStockByLocation()

const stock = await client.partsInventory.listStockByLocation()
// Returns StockByLocationRow[]: part_id, inventory_location_id, quantity, part_number, location_name, location_type, ...

Catalog-only list (no aggregates).

client.partsInventory.listParts() / getPartById(id)

const parts = await client.partsInventory.listParts()
const part = await client.partsInventory.getPartById('uuid-of-part')
// Returns PartRow[] or PartRow | null

Suppliers and inventory locations

client.partsInventory.listSuppliers() / getSupplierById(id)

const suppliers = await client.partsInventory.listSuppliers()
const supplier = await client.partsInventory.getSupplierById('uuid-of-supplier')
// Returns SupplierRow[] or SupplierRow | null

client.partsInventory.listInventoryLocations()

const locations = await client.partsInventory.listInventoryLocations()
// Returns InventoryLocationRow[]: id, parent_id, name, code, type ('warehouse' | 'aisle' | 'shelf' | 'bin'), ...

client.partsInventory.listStockLevels()

const levels = await client.partsInventory.listStockLevels()
// Returns StockLevelRow[]: part_id, inventory_location_id, quantity, updated_at

Reservations and usage

Parts reserved for work orders (status: reserved, issued, released, cancelled). Parts consumed on work orders.

client.partsInventory.listPartReservations()

const all = await client.partsInventory.listPartReservations()
const forWo = await client.partsInventory.listPartReservationsByWorkOrderId('uuid-of-work-order')
// Returns PartReservationRow[]

client.partsInventory.listPartUsage()

const all = await client.partsInventory.listPartUsage()
const forWo = await client.partsInventory.listPartUsageByWorkOrderId('uuid-of-work-order')
// Returns PartUsageRow[]

Purchasing

Open requisitions (draft, submitted, approved). Open POs (draft, sent, partially_received). PO receipt status (quantity ordered, received, balance per line).

client.partsInventory.listOpenRequisitions()

const reqs = await client.partsInventory.listOpenRequisitions()
// Returns OpenRequisitionRow[]

client.partsInventory.listOpenPurchaseOrders()

const pos = await client.partsInventory.listOpenPurchaseOrders()
// Returns OpenPurchaseOrderRow[]: id, order_number, supplier_name, status, ...

client.partsInventory.listPurchaseOrderReceiptStatus()

const all = await client.partsInventory.listPurchaseOrderReceiptStatus()
const forPo = await client.partsInventory.listPurchaseOrderReceiptStatusByPoId('uuid-of-po')
// Returns PurchaseOrderReceiptStatusRow[]: purchase_order_line_id, quantity_ordered, quantity_received, quantity_balance, part_number

RPCs (create/update)

All RPCs require tenant context and the appropriate permission. Pass tenantId in params for consistency.

Reserve parts – creates a reservation for a work order. Requires inventory.reservation.create.

client.partsInventory.reserveParts(params)

const reservationId = await client.partsInventory.reserveParts({
  tenantId: 'uuid-of-tenant',
  workOrderId: 'uuid-of-work-order',
  partId: 'uuid-of-part',
  quantity: 10,
  inventoryLocationId: 'uuid-of-bin', // optional
})
// Returns reservation id (string)

Issue parts to work order – decrements stock, creates inventory transaction and part_usage record; optionally marks a matching reservation as issued. Requires inventory.usage.record.

client.partsInventory.issuePartsToWorkOrder(params)

const usageId = await client.partsInventory.issuePartsToWorkOrder({
  tenantId: 'uuid-of-tenant',
  workOrderId: 'uuid-of-work-order',
  partId: 'uuid-of-part',
  quantity: 5,
  inventoryLocationId: null, // optional; if null, deducts from one bin with sufficient quantity
})
// Returns part_usage id (string)

Receive purchase order – creates a receipt and receipt lines, updates PO line quantity_received, and updates stock_levels when to_inventory_location_id is set. Requires purchase_order.receive.

client.partsInventory.receivePurchaseOrder(params)

const receiptId = await client.partsInventory.receivePurchaseOrder({
  tenantId: 'uuid-of-tenant',
  poId: 'uuid-of-po',
  lines: [
    { purchase_order_line_id: 'uuid-of-po-line', quantity_received: 20, to_inventory_location_id: 'uuid-of-bin' },
  ],
})
// Returns receipt id (string)

Create purchase order – creates a PO and optional lines. Requires purchase_order.create. Use externalId for ERP sync.

client.partsInventory.createPurchaseOrder(params)

const poId = await client.partsInventory.createPurchaseOrder({
  tenantId: 'uuid-of-tenant',
  supplierId: 'uuid-of-supplier',
  orderNumber: 'PO-2025-001',
  orderDate: '2025-03-15',
  expectedDeliveryDate: '2025-03-25',
  externalId: 'erp-po-123',
  notes: null,
  lines: [
    { part_id: 'uuid-of-part', quantity_ordered: 100, unit_price: 12.5 },
  ],
})
// Returns PO id (string)

Create part – requires part.create. Use externalId for ERP sync.

client.partsInventory.createPart(params)

const partId = await client.partsInventory.createPart({
  tenantId: 'uuid-of-tenant',
  partNumber: 'SKU-001',
  name: 'Filter cartridge',
  unit: 'each',
  preferredSupplierId: 'uuid-of-supplier',
  reorderPoint: 10,
  leadTimeDays: 7,
})
// Returns part id (string)

Update part – requires part.edit. Only provided fields are updated.

client.partsInventory.updatePart(params)

await client.partsInventory.updatePart({
  tenantId: 'uuid-of-tenant',
  partId: 'uuid-of-part',
  reorderPoint: 15,
  isActive: true,
})

Create supplier – requires supplier.create. Use externalId for ERP sync.

client.partsInventory.createSupplier(params)

const supplierId = await client.partsInventory.createSupplier({
  tenantId: 'uuid-of-tenant',
  name: 'Acme Supplies',
  code: 'ACME',
  externalId: 'erp-vendor-456',
  contactName: 'Jane Doe',
  email: 'jane@acme.com',
})
// Returns supplier id (string)

Update supplier – requires supplier.edit.

client.partsInventory.updateSupplier(params)

await client.partsInventory.updateSupplier({
  tenantId: 'uuid-of-tenant',
  supplierId: 'uuid-of-supplier',
  phone: '+1-555-0100',
})

Was this page helpful?