---
title: "Construiește o declarație din datele registrelor | Documentație | Tax Filing by R&D Copilot"
description: "Construiește rândurile unei declarații din registre, citește din ce provine fiecare rând și reconstruiește când se schimbă registrele."
canonical: "https://declarations.rdcopilot.com/ro/docs/guides/build-a-return-from-ledger-data/"
language: ro
updated: 2026-11-22
---

# Construiește o declarație din datele registrelor

Construiește rândurile unei declarații din registre, citește din ce provine fiecare rând și reconstruiește când se schimbă registrele.

Produsul citește înregistrările registrelor tale pentru perioadă, le însumează în rândurile formularului și înregistrează ce instantaneu al registrelor a citit. Nu trimiți cifre. Dacă o cifră este greșită, cauza este în registre, iar remedierea este acolo.

1.  Așteaptă încheierea perioadei
    
    O perioadă se construiește după ultima ei zi. Înainte de acel moment, [generateReturn](https://declarations.rdcopilot.com/ro/docs/api-reference/returns/#generate-return) răspunde `period_open`. Vezi [Perioade și termene](https://declarations.rdcopilot.com/ro/docs/concepts/periods-and-due-dates/).
    
2.  Construiește declarația
    
    Trimite revizia citită. Răspunsul este `accepted`; declarația devine `generated` și preia cel mai nou instantaneu.
    
3.  Citește rândurile
    
    Fiecare rând are o `key`, o `label`, cifra, TVA și `from`, soldurile din registre din care a fost însumat.
    
4.  Compară cu contabilitatea ta
    
    Compară totalurile cu balanța pe care o ții. O diferență indică o înregistrare, nu declarația.
    

curl

```bash
curl -X POST "$RDC_BASE_URL/declarations/v1/returns/dff3b09f-8bbd-488b-8b7d-f71eb11ef3af/generate" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "4b6f8fbf-33e1-4464-9142-f9ed6bf73a4b",
  "expectedRevision": 1
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/declarations/v1/returns/dff3b09f-8bbd-488b-8b7d-f71eb11ef3af/generate`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "4b6f8fbf-33e1-4464-9142-f9ed6bf73a4b",
    "expectedRevision": 1
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/declarations/v1/returns/dff3b09f-8bbd-488b-8b7d-f71eb11ef3af/generate',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '4b6f8fbf-33e1-4464-9142-f9ed6bf73a4b',
        'expectedRevision': 1,
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "4b6f8fbf-33e1-4464-9142-f9ed6bf73a4b",
  "expectedRevision": 1
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/declarations/v1/returns/dff3b09f-8bbd-488b-8b7d-f71eb11ef3af/generate');
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")}/declarations/v1/returns/dff3b09f-8bbd-488b-8b7d-f71eb11ef3af/generate");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "4b6f8fbf-33e1-4464-9142-f9ed6bf73a4b",
  "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": "4b6f8fbf-33e1-4464-9142-f9ed6bf73a4b",
  "status": "accepted",
  "aggregateId": "dff3b09f-8bbd-488b-8b7d-f71eb11ef3af",
  "aggregateRevision": 2
}
```

## Citește rândurile

curl

```bash
curl "$RDC_BASE_URL/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/rows?limit=20" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/rows?limit=20`, {
  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"]}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/rows?limit=20',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/rows?limit=20');
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")}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/rows?limit=20");
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
{
  "items": [
    {
      "key": "sales-21",
      "label": "Supplies at 21%",
      "ref": null,
      "unit": "amount",
      "value": "2947.04",
      "vat": "618.89",
      "partner": null,
      "code": null,
      "from": [
        "707 credit, 21%",
        "4427 credit, 21%"
      ]
    },
    {
      "key": "sales-11",
      "label": "Supplies at 11%",
      "ref": null,
      "unit": "amount",
      "value": "57329.70",
      "vat": "6306.27",
      "partner": null,
      "code": null,
      "from": [
        "707 credit, 11%",
        "4427 credit, 11%"
      ]
    },
    {
      "key": "ic-acquisitions",
      "label": "Acquisitions from other member states",
      "ref": null,
      "unit": "amount",
      "value": "5252.00",
      "vat": "1102.92",
      "partner": null,
      "code": null,
      "from": [
        "371 debit",
        "4427 credit"
      ]
    },
    {
      "key": "purchases-21",
      "label": "Domestic purchases at 21%",
      "ref": null,
      "unit": "amount",
      "value": "3067.50",
      "vat": "644.18",
      "partner": null,
      "code": null,
      "from": [
        "371 debit, 21%",
        "4426 debit, 21%"
      ]
    },
    {
      "key": "purchases-11",
      "label": "Domestic purchases at 11%",
      "ref": null,
      "unit": "amount",
      "value": "48236.00",
      "vat": "5305.96",
      "partner": null,
      "code": null,
      "from": [
        "371 debit, 11%",
        "4426 debit, 11%"
      ]
    },
    {
      "key": "deductible-ic",
      "label": "Deductible VAT on acquisitions from other member states",
      "ref": null,
      "unit": "amount",
      "value": null,
      "vat": "1102.92",
      "partner": null,
      "code": null,
      "from": [
        "4426 debit"
      ]
    },
    {
      "key": "total-collected",
      "label": "Total VAT collected",
      "ref": 19,
      "unit": "amount",
      "value": null,
      "vat": "8028.08",
      "partner": null,
      "code": null,
      "from": [
        "4427 credit"
      ]
    },
    {
      "key": "total-deductible",
      "label": "Total VAT deductible",
      "ref": 30,
      "unit": "amount",
      "value": null,
      "vat": "7053.06",
      "partner": null,
      "code": null,
      "from": [
        "4426 debit"
      ]
    },
    {
      "key": "total-deducted",
      "label": "Total VAT deducted",
      "ref": 35,
      "unit": "amount",
      "value": null,
      "vat": "7053.06",
      "partner": null,
      "code": null,
      "from": [
        "4426 debit"
      ]
    },
    {
      "key": "recoverable",
      "label": "Negative amount of VAT of the period",
      "ref": 36,
      "unit": "amount",
      "value": null,
      "vat": "0.00",
      "partner": null,
      "code": null,
      "from": [
        "4427 credit",
        "4426 debit"
      ]
    },
    {
      "key": "payable",
      "label": "VAT payable in the period",
      "ref": 37,
      "unit": "amount",
      "value": null,
      "vat": "975.02",
      "partner": null,
      "code": null,
      "from": [
        "4427 credit",
        "4426 debit"
      ]
    }
  ],
  "nextCursor": null
}
```

Rândurile decontului de TVA pentru octombrie sunt 11. Un rând din D394 poartă codul fiscal al partenerului așa cum îl au registrele: un cod greșit în registre este un cod greșit în declarație, iar autoritatea va răspunde `nok`. [Tratează o respingere](https://declarations.rdcopilot.com/ro/docs/guides/handle-a-rejection/) arată drumul înapoi.

## Când se schimbă registrele

Un document înregistrat cu întârziere creează un instantaneu mai nou. Declarația păstrează instantaneul din care a fost construită până o reconstruiești cu [regenerateReturn](https://declarations.rdcopilot.com/ro/docs/api-reference/returns/#regenerate-return), care îi înlocuiește dovezile și o readuce la `generated`. O reconstruire fără un instantaneu mai nou al registrelor este refuzată cu `source_unchanged`.

curl

```bash
curl -X POST "$RDC_BASE_URL/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/regenerate" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "e3f2c9a7-7037-4de9-bb01-7ad37d5f67af",
  "expectedRevision": 4
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/regenerate`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "e3f2c9a7-7037-4de9-bb01-7ad37d5f67af",
    "expectedRevision": 4
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/regenerate',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': 'e3f2c9a7-7037-4de9-bb01-7ad37d5f67af',
        'expectedRevision': 4,
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "e3f2c9a7-7037-4de9-bb01-7ad37d5f67af",
  "expectedRevision": 4
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/regenerate');
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")}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/regenerate");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "e3f2c9a7-7037-4de9-bb01-7ad37d5f67af",
  "expectedRevision": 4
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Răspuns 202

```json
{
  "operationId": "e3f2c9a7-7037-4de9-bb01-7ad37d5f67af",
  "status": "accepted",
  "aggregateId": "3b559a77-5de4-4b9a-9e2e-ca6625d123f2",
  "aggregateRevision": 5
}
```
