---
title: "Execută o comandă de producție | Documentație | ERP by R&D Copilot"
description: "Planifică producția unui articol, vezi ce componentă nu ajunge, finalizează o cantitate și citește apoi stocul."
canonical: "https://erp.rdcopilot.com/ro/docs/guides/run-a-work-order/"
language: ro
updated: 2026-11-22
---

# Execută o comandă de producție

Planifică producția unui articol, vezi ce componentă nu ajunge, finalizează o cantitate și citește apoi stocul.

O comandă de producție realizează o cantitate dintr-un articol produs, conform listei sale de materiale. Pentru o unitate de Coș cadou, selecția Neamț sunt necesare următoarele componente: 1 × Cutie cadou, 30 × 20 cm, 2 × Ulei de floarea-soarelui, 1 l, 2 × Zahăr, 1 kg, 2 × Telemea, 400 g. Comanda de producție se creează pentru un articol cu listă de materiale; pentru orice alt articol, apelul este refuzat cu `not_made`.

curl

```bash
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

```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

```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
<?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#

```csharp
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();
```

Răspuns 202

```json
{
  "operationId": "d0495011-1877-40ec-b95d-2891ddeffeff",
  "status": "accepted",
  "aggregateId": "6a130089-fa08-45d4-b720-66dab824bbfa",
  "aggregateRevision": 1
}
```

## Citește componentele

O comandă de producție listează în `components` ce este necesar pentru cantitatea planificată: cât este `needed`, cât este `available` acum și cât lipsește (`short`). `operations` listează pașii în ordinea executării, cu minutele necesare pentru cantitatea planificată. Componentele rezervate pentru comenzi de vânzare nu sunt disponibile.

O comandă de producție cu stoc insuficient la o componentă

curl

```bash
curl "$RDC_BASE_URL/erp/v1/work-orders/6c1303af-001b-4b52-9464-819e318a244b" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```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

```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
<?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#

```csharp
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();
```

Răspuns 200

```json
{
  "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
}
```

## Pornește și finalizează

`startWorkOrder` trece comanda în `in_progress`; din stoc nu iese încă nimic. `finishWorkOrder` raportează cantitatea produsă, `produced`, care trebuie să fie de cel puțin 1 și de cel mult cantitatea planificată (altfel se răspunde cu `over_plan`). Într-un singur pas, componentele pentru acea cantitate ies din `onHand`, produsele finite intră în el, iar starea devine `done`.

curl

```bash
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

```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

```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
<?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#

```csharp
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();
```

Răspuns 202

```json
{
  "operationId": "ea412b87-44e9-4f49-bb35-277c6013c9b9",
  "status": "accepted",
  "aggregateId": "6b13021c-fb0b-4169-b41d-3415bf219529",
  "aggregateRevision": 2
}
```

curl

```bash
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

```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

```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
<?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#

```csharp
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();
```

Răspuns 202

```json
{
  "operationId": "d66fade7-3459-4a34-8450-dc6912036bef",
  "status": "accepted",
  "aggregateId": "6b13021c-fb0b-4169-b41d-3415bf219529",
  "aggregateRevision": 3
}
```

## Când o componentă nu ajunge

Dacă vreo componentă nu este disponibilă în cantitatea necesară pentru unitățile produse, apelul este refuzat cu `component_short` și nu se modifică nimic: nicio componentă nu iese din stoc, iar comanda rămâne `in_progress`. Ai două variante. Fie recepționezi componenta lipsă și finalizezi toată cantitatea, fie finalizezi o cantitate `produced` mai mică, acoperită de componentele disponibile. În acest caz comanda devine `done` cu cantitatea produsă, iar restul nu se mai produce. Pentru recepție, vezi [Cumpără și recepționează mărfuri](https://erp.rdcopilot.com/ro/docs/guides/buy-and-receive-goods/).

Comenzile de vânzare și cele de producție folosesc același stoc liber. Componentele rezervate pentru o comandă rămân rezervate; finalizarea unei comenzi de producție nu le poate consuma.
