POST/api/v1/delivery-notes/bulk-convert

Bulk Convert Delivery Notes

Converts multiple issued delivery notes into a single consolidated invoice. All line items from every delivery note are combined into one invoice. Each delivery note is then marked as converted.

This is useful for end-of-period billing where multiple deliveries to the same client should appear on one invoice.

Headers

NameTypeRequiredDescription
AuthorizationstringYesBearer token for authentication
X-CompanystringYesCompany UUID to scope the request
Content-TypestringYesMust be application/json

Request Body

FieldTypeRequiredDescription
idsstring[]YesArray of delivery note UUIDs to convert (minimum 2)

Request

cURL
curl -X POST https://api.storno.ro/api/v1/delivery-notes/bulk-convert \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "X-Company: company-uuid-here" \
  -H "Content-Type: application/json" \
  -d '{
    "ids": [
      "950e8400-e29b-41d4-a716-446655440000",
      "951e8400-e29b-41d4-a716-446655440001",
      "952e8400-e29b-41d4-a716-446655440002"
    ]
  }'
JavaScript
const response = await fetch('https://api.storno.ro/api/v1/delivery-notes/bulk-convert', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'X-Company': 'company-uuid-here',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    ids: [
      '950e8400-e29b-41d4-a716-446655440000',
      '951e8400-e29b-41d4-a716-446655440001',
      '952e8400-e29b-41d4-a716-446655440002'
    ]
  })
});

const invoice = await response.json();

Response

Returns the newly created invoice object in draft status:

{
  "uuid": "650e8400-e29b-41d4-a716-446655440222",
  "number": "FAC-2026-051",
  "status": "draft",
  "direction": "outgoing",
  "isCreditNote": false,
  "clientId": "750e8400-e29b-41d4-a716-446655440000",
  "client": {
    "uuid": "750e8400-e29b-41d4-a716-446655440000",
    "name": "Client SRL",
    "registrationNumber": "RO12345678",
    "email": "[email protected]"
  },
  "currency": "RON",
  "exchangeRate": 1.0,
  "issueDate": "2026-02-28",
  "dueDate": "2026-03-28",
  "lines": [
    {
      "uuid": "C10e8400-e29b-41d4-a716-446655440000",
      "lineNumber": 1,
      "description": "Laptop Dell Latitude 7420",
      "quantity": "10.00",
      "unitPrice": "450.00",
      "unitOfMeasure": "piece",
      "subtotal": "4500.00",
      "vatAmount": "855.00",
      "total": "5355.00"
    },
    {
      "uuid": "C20e8400-e29b-41d4-a716-446655440000",
      "lineNumber": 2,
      "description": "Wireless Mouse Logitech MX Master 3",
      "quantity": "5.00",
      "unitPrice": "50.00",
      "unitOfMeasure": "piece",
      "subtotal": "250.00",
      "vatAmount": "47.50",
      "total": "297.50"
    }
  ],
  "subtotal": "4750.00",
  "vatAmount": "902.50",
  "total": "5652.50",
  "deliveryNoteIds": [
    "950e8400-e29b-41d4-a716-446655440000",
    "951e8400-e29b-41d4-a716-446655440001",
    "952e8400-e29b-41d4-a716-446655440002"
  ],
  "createdAt": "2026-02-28T16:00:00Z",
  "updatedAt": "2026-02-28T16:00:00Z"
}

State Changes

Created Invoice

  • New invoice created in draft status
  • Lines from all delivery notes are merged in order
  • deliveryNoteIds lists all source delivery note UUIDs
  • Issue date defaults to today
  • The company's default invoice series is automatically assigned to the created invoice

Source Delivery Notes

  • Each delivery note status is changed from issuedconverted
  • convertedAt is set on each delivery note
  • convertedInvoiceId is set to the new invoice UUID

Validation Rules

All delivery notes in the ids array must:

  • Exist and belong to the same company
  • Be in issued status
  • Share the same client
  • Share the same currency
Validation FailureError CodeDescription
Different clientsvalidation_errorAll delivery notes must have the same client
Different currenciesvalidation_errorAll delivery notes must use the same currency
Non-issued statusvalidation_errorAll delivery notes must be in issued status
Not foundnot_foundOne or more delivery note UUIDs not found

Error Codes

Status CodeError CodeDescription
401unauthorizedMissing or invalid authentication token
403forbiddenInvalid or missing X-Company header
404not_foundOne or more delivery notes not found or not in this company
422validation_errorValidation failed (different clients, currencies, or non-issued status)
500internal_errorServer error occurred

Example Error Response

Mixed Clients

{
  "error": {
    "code": "validation_error",
    "message": "Cannot bulk convert delivery notes",
    "details": {
      "reason": "All delivery notes must belong to the same client",
      "conflictingIds": [
        "952e8400-e29b-41d4-a716-446655440002"
      ]
    }
  }
}

Workflow Integration

End-of-Period Billing Flow

  1. Issue delivery notes throughout the month
  2. At period end, collect all issued delivery note UUIDs for a client
  3. Bulk convert (POST /api/v1/delivery-notes/bulk-convert) ← You are here
  4. Review the consolidated invoice
  5. Upload to ANAF (POST /api/v1/invoices/{uuid}/upload)
  6. Send invoice to client