Run a work order
Plan the making of an item, see which component is short, finish a quantity and read the stock afterwards.
On this page
A work order makes a quantity of a made item from its bill of materials. One unit of Gift basket, Neamț selection takes 1 × Gift box, 30 × 20 cm, 2 × Sunflower oil, 1 l, 2 × Sugar, 1 kg, 2 × Cheese, 400 g. A work order is created for an item that has a bill of materials; for any other item the call is refused with not_made.
curl
curl -X POST "$RDC_BASE_URL/erp/v1/work-orders" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "d0495011-1877-40ec-b95d-2891ddeffeff",
"itemCode": "CO-0900",
"planned": "8"
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/work-orders`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "d0495011-1877-40ec-b95d-2891ddeffeff",
"itemCode": "CO-0900",
"planned": "8"
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/erp/v1/work-orders',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': 'd0495011-1877-40ec-b95d-2891ddeffeff',
'itemCode': 'CO-0900',
'planned': '8',
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "d0495011-1877-40ec-b95d-2891ddeffeff",
"itemCode": "CO-0900",
"planned": "8"
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/work-orders');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/erp/v1/work-orders");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "d0495011-1877-40ec-b95d-2891ddeffeff",
"itemCode": "CO-0900",
"planned": "8"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "d0495011-1877-40ec-b95d-2891ddeffeff",
"status": "accepted",
"aggregateId": "6a130089-fa08-45d4-b720-66dab824bbfa",
"aggregateRevision": 1
} Read the components
A work order lists its components for the planned quantity: what is needed, what is available now and what is short. operations lists the steps in the order they are done with the minutes the planned quantity takes. Components that are reserved for sales orders are not available.
A work order with a short component
curl
curl "$RDC_BASE_URL/erp/v1/work-orders/6c1303af-001b-4b52-9464-819e318a244b" \
-H "Authorization: Bearer $RDC_TOKEN" JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/work-orders/6c1303af-001b-4b52-9464-819e318a244b`, {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
},
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'GET',
f'{os.environ["RDC_BASE_URL"]}/erp/v1/work-orders/6c1303af-001b-4b52-9464-819e318a244b',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
)
result = response.json() PHP
<?php
$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/work-orders/6c1303af-001b-4b52-9464-819e318a244b');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/erp/v1/work-orders/6c1303af-001b-4b52-9464-819e318a244b");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"id": "6c1303af-001b-4b52-9464-819e318a244b",
"number": "OP-0212",
"itemCode": "CO-0900",
"itemName": "Gift basket, Neamț selection",
"planned": "20",
"produced": "0",
"status": "in_progress",
"components": [
{
"code": "CT-0610",
"name": "Gift box, 30 × 20 cm",
"needed": "20",
"available": "18",
"short": "2"
},
{
"code": "UL-0101",
"name": "Sunflower oil, 1 l",
"needed": "40",
"available": "92",
"short": "0"
},
{
"code": "ZA-0201",
"name": "Sugar, 1 kg",
"needed": "40",
"available": "210",
"short": "0"
},
{
"code": "LA-0307",
"name": "Cheese, 400 g",
"needed": "40",
"available": "72",
"short": "0"
}
],
"operations": [
{
"name": "Pick components",
"minutes": 60
},
{
"name": "Pack the basket",
"minutes": 120
},
{
"name": "Label and seal",
"minutes": 40
}
],
"revision": 2
} Start and finish
startWorkOrder moves the order to in_progress; nothing leaves stock yet. finishWorkOrder reports the quantity made, produced, which is at least 1 and at most the planned quantity (over_plan otherwise). In one step the components of that quantity leave onHand and the made items enter it, and the status becomes done.
curl
curl -X POST "$RDC_BASE_URL/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/start" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "ea412b87-44e9-4f49-bb35-277c6013c9b9",
"expectedRevision": 1
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/start`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "ea412b87-44e9-4f49-bb35-277c6013c9b9",
"expectedRevision": 1
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/start',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': 'ea412b87-44e9-4f49-bb35-277c6013c9b9',
'expectedRevision': 1,
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "ea412b87-44e9-4f49-bb35-277c6013c9b9",
"expectedRevision": 1
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/start');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/start");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "ea412b87-44e9-4f49-bb35-277c6013c9b9",
"expectedRevision": 1
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "ea412b87-44e9-4f49-bb35-277c6013c9b9",
"status": "accepted",
"aggregateId": "6b13021c-fb0b-4169-b41d-3415bf219529",
"aggregateRevision": 2
} curl
curl -X POST "$RDC_BASE_URL/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/finish" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "d66fade7-3459-4a34-8450-dc6912036bef",
"expectedRevision": 2,
"produced": "12"
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/finish`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "d66fade7-3459-4a34-8450-dc6912036bef",
"expectedRevision": 2,
"produced": "12"
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/finish',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': 'd66fade7-3459-4a34-8450-dc6912036bef',
'expectedRevision': 2,
'produced': '12',
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "d66fade7-3459-4a34-8450-dc6912036bef",
"expectedRevision": 2,
"produced": "12"
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/finish');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/erp/v1/work-orders/6b13021c-fb0b-4169-b41d-3415bf219529/finish");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "d66fade7-3459-4a34-8450-dc6912036bef",
"expectedRevision": 2,
"produced": "12"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "d66fade7-3459-4a34-8450-dc6912036bef",
"status": "accepted",
"aggregateId": "6b13021c-fb0b-4169-b41d-3415bf219529",
"aggregateRevision": 3
} When a component is short
If any component is not available in the quantity the produced units need, the call is refused with component_short and nothing changes: no component leaves stock and the order stays in_progress. You have two ways out. Receive the missing component, see Buy and receive goods, and finish the full quantity; or finish a smaller produced that the components cover. The work order is then done with the quantity made, and the rest is not made.