Classes and properties
What a class decides, how the class and the amount of a document give its approvers, and which properties of a draft you can change.
On this page
A class is one of contract, invoice, offer or report. It decides who approves a document, whether it is signed, how long it is kept and who opens it.
curl
curl "$RDC_BASE_URL/documents/v1/classes?limit=20" \
-H "Authorization: Bearer $RDC_TOKEN" JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/documents/v1/classes?limit=20`, {
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"]}/documents/v1/classes?limit=20',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
)
result = response.json() PHP
<?php
$curl = curl_init(getenv('RDC_BASE_URL') . '/documents/v1/classes?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#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/documents/v1/classes?limit=20");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"items": [
{
"id": "contract",
"signed": true,
"keepYears": 10,
"readers": [
"finance",
"sales",
"purchasing"
],
"approval": {
"limit": "100000.00",
"approvers": [
"ioana-marin",
"ana-rusu"
]
}
},
{
"id": "invoice",
"signed": false,
"keepYears": 10,
"readers": [
"finance",
"purchasing"
],
"approval": {
"limit": "25000.00",
"approvers": [
"ioana-marin",
"ana-rusu"
]
}
},
{
"id": "offer",
"signed": true,
"keepYears": 3,
"readers": [
"finance",
"sales"
],
"approval": {
"limit": "50000.00",
"approvers": [
"ioana-marin",
"ana-rusu"
]
}
},
{
"id": "report",
"signed": false,
"keepYears": 5,
"readers": [
"finance",
"warehouse"
],
"approval": {
"limit": null,
"approvers": [
"ana-rusu"
]
}
}
],
"nextCursor": null
} Read the classes
listClasses returns each class with its approval, signed, keepYears and readers. They are settings of the company, so read them instead of copying them.
| Class | Approvers, in order | Limit | Signed | Years kept |
|---|---|---|---|---|
contract | ioana-marin, ana-rusu | 100000.00 RON | yes | 10 |
invoice | ioana-marin, ana-rusu | 25000.00 RON | no | 10 |
offer | ioana-marin, ana-rusu | 50000.00 RON | yes | 3 |
report | ana-rusu | none | no | 5 |
A class that is signed goes to the recipients after its last approval, and an invoice or a report is archived directly. The years of keepYears are explained in Retention.
How the approvers are chosen
When a document is submitted, its amount is compared with the limit of its class. An amount at or under the limit goes to the first approver only; a larger amount goes to every approver, in order.
| Document | Route |
|---|---|
| An invoice of 25000.00 RON, the limit itself | `ioana-marin` |
| An invoice of 25000.01 RON | `ioana-marin`, `ana-rusu` |
| A report, whatever its amount | `ana-rusu` |
The route is fixed at submission and is read in approval.route. A class with a limit needs an amount before the submission; a class with no limit does not.
Change the properties of a draft
updateProperties changes the name, the counterparty, the project, the date or the amount of a draft. Send only what changes, with the expectedRevision you read.
curl
curl -X POST "$RDC_BASE_URL/documents/v1/documents/417fc646-2924-483f-b1d7-b2c07692e924/properties" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "66a3c447-ac92-4bec-8056-4be113f4de08",
"expectedRevision": 1,
"by": "sorin-avram",
"name": "Transport agreement 2027, Transbistrița Logistic",
"amount": "64500.00"
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/documents/v1/documents/417fc646-2924-483f-b1d7-b2c07692e924/properties`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "66a3c447-ac92-4bec-8056-4be113f4de08",
"expectedRevision": 1,
"by": "sorin-avram",
"name": "Transport agreement 2027, Transbistrița Logistic",
"amount": "64500.00"
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/documents/v1/documents/417fc646-2924-483f-b1d7-b2c07692e924/properties',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': '66a3c447-ac92-4bec-8056-4be113f4de08',
'expectedRevision': 1,
'by': 'sorin-avram',
'name': 'Transport agreement 2027, Transbistrița Logistic',
'amount': '64500.00',
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "66a3c447-ac92-4bec-8056-4be113f4de08",
"expectedRevision": 1,
"by": "sorin-avram",
"name": "Transport agreement 2027, Transbistrița Logistic",
"amount": "64500.00"
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/documents/v1/documents/417fc646-2924-483f-b1d7-b2c07692e924/properties');
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")}/documents/v1/documents/417fc646-2924-483f-b1d7-b2c07692e924/properties");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "66a3c447-ac92-4bec-8056-4be113f4de08",
"expectedRevision": 1,
"by": "sorin-avram",
"name": "Transport agreement 2027, Transbistrița Logistic",
"amount": "64500.00"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "66a3c447-ac92-4bec-8056-4be113f4de08",
"status": "accepted",
"aggregateRevision": 2
} | Property | What it holds | Refused with |
|---|---|---|
name | Text of 1 to 280 characters. | name_required |
counterpartyId | The id of a customer, a supplier or a carrier of your account. | counterparty_not_found |
project | Text of up to 280 characters. | name_required |
date | A real day, YYYY-MM-DD. The keep-until date follows it. | date_not_valid |
amount | A decimal string above zero, with at most two decimals. | amount_not_valid |
A request that changes nothing is refused with nothing_to_change. A document that is not a draft is refused with document_not_draft. Each accepted change adds a line to the audit trail that names the properties it changed.
Before you submit
The owner of a document is set when it is created, and the properties of a draft do not include it. An owner who is on the route cannot submit: nobody approves what they own.
| Code | Cause | What to do |
|---|---|---|
amount_required | The class has a limit and the document has no amount. | Set the amount with updateProperties, then submit. |
owner_is_approver | The owner is on the route that the amount gives. | Create the document again with another owner. |
revision_required | An approver returned the draft. | Add a version with reviseDocument, then submit. |
extraction_unresolved | An invoice created with extract has values that are not accepted. fields names them. | Accept or correct each one, then submit. |