Skip to content

Order Actor

The Order Actor is the most central actor in Hantera, being an Order Management System. It provides access to managing orders, deliveries, order lines, invoices and order journals. It supports a dynamic data model with fields that can be added at will.

The Order Actor is a core component of Hantera. As the central actor within the platform, it provides the functionality to manage various aspects of an order’s lifecycle, including orders, deliveries, order lines, invoices, and order journals.

Designed with flexibility in mind, the Order Actor leverages a dynamic data model that allows for easy customization. This means fields and attributes can be added or modified according to the specific needs of your business processes, ensuring a highly adaptable and scalable solution for order management.

By utilizing the Order Actor, developers can seamlessly interact with Hantera to handle the entire order flow, from creation to fulfillment and beyond.

Commands

The Order Actor utilizes commands to execute operations on orders, deliveries, order lines, invoices etc. Commands can be sent using the applyCommands, and may also be included in the initial create message to the Order Actor. Rules within Hantera can emit order commands from order hooks to automate processes based on specific events.

For a full reference of all available commands, go to Order Commands.

Rule Hooks

Related Rule Hooks are:

Examples

Creating a new Order
POST https://<hantera-hostname>/resources/actors/order/new
Authorization: Bearer <YOUR TOKEN>
Content-Type: application/json
[{
"type": "create",
"body": {
"currencyCode": "EUR",
"taxIncluded": true,
"commands": [{
"type": "createDelivery",
"deliveryId": "65812410-bd14-4d6d-ab79-374789a976c1",
"shippingPrice": 100
},{
"type": "createOrderLine",
"deliveryId": "65812410-bd14-4d6d-ab79-374789a976c1",
"productNumber": "P1",
"quantity": 1,
"unitPrice": 90,
"taxFactor": 0.25
}
]
}
}]
Applying commands on existing Order
POST https://<hantera-hostname>/resources/actors/order/ec806cf5-d976-49de-b390-03b303da8117
Authorization: Bearer <YOUR TOKEN>
Content-Type: application/json
[{
"type": "applyCommands",
"body": {
"commands": [{
"type": "addTag",
"key": "blocked"
}
]
}
}]
Rule to automatically invoice completed/cancelled deliveries
invoiceOrders.rule
param input: OnOrderCommands
let shouldInvoice (old, new) =>
from new.deliveryState is 'completed' | 'cancelled' | 'cancelledByOrder' and new.deliveryState != old.deliveryState
let completedDeliveries =
input.before.deliveries as old
join input.order.deliveries as new on deliveryId
where (old, new) => new match
value |> shouldInvoice(old, new)
|> false
select (old, new) => new.deliveryId
from match
when completedDeliveries count > 0 |> effects.order.command.invoiceDeliveries {
deliveryIds = completedDeliveries
mixed = true
}