Skip to content

OrderItem

The OrderItem entity represents a line item within an order. Each OrderItem references an article (catalog product) and includes quantity, pricing, and measurement units. OrderItems can be organized hierarchically to represent product kits or grouped items.


PropertyTypeDescriptionValidation
idUUIDUnique item identifierGenerated automatically
orderIdUUIDParent order referenceOptional, references Order entity
articleIdUUIDProduct referenceOptional, references Article entity
PropertyTypeDescriptionValidation
quantitynumberQuantity orderedRequired, must be positive
unitPricenumberPrice per unitOptional, double precision
totalPricenumberTotal line priceOptional, double precision, min: 0, default: 0
unitstringMeasurement unitOptional (e.g., “pcs”, “kg”, “m”)

Pricing Calculation: totalPrice = quantity * unitPrice

PropertyTypeDescriptionValidation
positionnumberDisplay order in listOptional, default: 1
parentIdUUIDParent item for hierarchyOptional, self-reference
PropertyTypeDescriptionValidation
createdByIdUUIDUser who created itemOptional, references User entity
commentIdUUIDAssociated commentOptional, references Comment entity
createdAtDateCreation timestampAuto-generated
updatedAtDateLast update timestampAuto-generated
deletedAtDateSoft delete timestampOptional, indexed

RelationshipTypeTarget EntityDescriptionRequired
orderMany-to-OneOrderParent orderNo
articleMany-to-OneArticleProduct referenceNo
parentMany-to-OneOrderItemParent item for hierarchyNo
childrenOne-to-ManyOrderItemChild items in hierarchyNo
createdByMany-to-OneUserUser who created itemNo
commentOne-to-OneCommentAssociated comment/noteNo

OrderItem can reference different types of products:

Description: References a catalog product (Article entity)

When to Use:

  • Ordering from product catalog
  • Standard inventory items
  • Pre-configured products

Properties Used:

  • articleId: Links to Article entity
  • Article provides: name, code, price, inventory status
  • Article may link to BriefElement for manufacturing specs

Example:

{
"orderId": "order-uuid",
"articleId": "article-uuid",
"quantity": 1000,
"unitPrice": 1.50,
"totalPrice": 1500.00,
"unit": "pcs"
}

Description: Item without article reference (rare)

When to Use:

  • Custom one-off items
  • Special pricing scenarios
  • Non-inventory items

Example:

{
"orderId": "order-uuid",
"quantity": 1,
"unitPrice": 500.00,
"totalPrice": 500.00,
"unit": "service"
}

OrderItems support parent-child relationships for complex order structures.

  1. Product Kits: Parent represents the kit, children are components
  2. Grouped Items: Organize related items under a parent
  3. Assembly Orders: Parent is assembled product, children are parts

Order with Product Kit:

Order
└── OrderItem (parent) → Product Kit
├── OrderItem (child) → Component A
├── OrderItem (child) → Component B
└── OrderItem (child) → Component C
└── OrderItem → Standalone Product

Implementation:

// 1. Create Parent Item (Kit)
POST /order-items
{
"orderId": "order-uuid",
"articleId": "kit-article-uuid",
"quantity": 100,
"unitPrice": 50.00,
"totalPrice": 5000.00,
"unit": "kits"
}
// Response: { "id": "parent-uuid", ... }
// 2. Create Child Items (Components)
POST /order-items
{
"orderId": "order-uuid",
"parentId": "parent-uuid",
"articleId": "component-a-uuid",
"quantity": 100,
"position": 1
}
POST /order-items
{
"orderId": "order-uuid",
"parentId": "parent-uuid",
"articleId": "component-b-uuid",
"quantity": 200,
"position": 2
}

OrderItems typically reference Articles for product details:

When articleId is set, the Article provides:

  • Product Information: code, name, description
  • Pricing: Default price (can be overridden in OrderItem)
  • Inventory: stocked, quantity (stock levels)
  • Manufacturing: briefElementId (links to production specifications)
  • ERP Integration: externalId (for external system sync)

Articles can link to BriefElements for manufacturing specifications:

Scenario 1: Article from Configured Product:

  • Article created after product configuration
  • Article.briefElementId → BriefElement (existing Brief)
  • Provides full manufacturing specs for production

Scenario 2: Article from ERP/Catalog:

  • Article created independently or from ERP
  • May auto-create BriefElement for manufacturing
  • May exist without BriefElement (non-packaging items)

Scenario 3: Standalone Article:

  • Article without BriefElement link
  • Used for non-manufactured items (e.g., tape, labels, services)

EndpointMethodDescription
/order-itemsPOSTCreate order item
/order-items/:idGETGet single item
/order-items/:idPATCHUpdate order item
/order-items/:idDELETEDelete order item
/order-itemsGETList order items

POST /order-items
{
"orderId": "order-uuid",
"articleId": "article-uuid",
"quantity": 500,
"unitPrice": 2.00,
"totalPrice": 1000.00,
"unit": "pcs",
"position": 1
}
PATCH /order-items/item-uuid
{
"quantity": 750,
"totalPrice": 1500.00
}
// Parent Item (Product Bundle)
POST /order-items
{
"orderId": "order-uuid",
"articleId": "bundle-uuid",
"quantity": 50,
"unitPrice": 100.00,
"totalPrice": 5000.00,
"unit": "bundles"
}
// Response: { "id": "parent-uuid" }
// Child Item 1
POST /order-items
{
"orderId": "order-uuid",
"parentId": "parent-uuid",
"articleId": "item-1-uuid",
"quantity": 100,
"position": 1
}
// Child Item 2
POST /order-items
{
"orderId": "order-uuid",
"parentId": "parent-uuid",
"articleId": "item-2-uuid",
"quantity": 150,
"position": 2
}

Example 4: Custom Item (No Article Reference)

Section titled “Example 4: Custom Item (No Article Reference)”
POST /order-items
{
"orderId": "order-uuid",
"quantity": 1,
"unitPrice": 250.00,
"totalPrice": 250.00,
"unit": "service",
"position": 10
}

  • Always ensure totalPrice = quantity * unitPrice
  • Update totalPrice when changing quantity or unit price
  • Use consistent decimal precision (typically 2 decimal places)
  • Use position to control display order
  • Increment positions (1, 2, 3…) for clear ordering
  • Update positions when reordering items
  • Create parent items first, then children
  • Use parentId to establish relationships
  • Ensure parent and children belong to same order
  • Prefer using articleId over standalone items
  • Verify article exists and is active before creating item
  • Use Article’s default price but allow overrides for special pricing
  • Use consistent unit naming (e.g., “pcs”, “kg”, “m”)
  • Match units to article specifications
  • Include unit in all item records for clarity