Create Document With Lines of Any Type

The CreateAnyDocumentWithLines API provides a flexible solution in OCS.io for creating documents of any type with multiple lines. This API is particularly useful when there’s a need to create complex documents with multiple items or services.

API Overview

Fields Required for Any Document Creation With Lines

The following table lists and describes the fields required to create any type of document with lines through the CreateAnyDocumentWithLines API:

Field Description

account

ID (Ref ID/ External ID ) of the Account.

externalDocumentNo

External number of the Document (generated by external system, e.g. OCS or CRM).

documentCategory

Category of the Document. Enumeration.

documentSource

Source of the Document. Document Source must be configured.

documentType

Type of the Document. Document Type must be configured.

documentIssuedDate

Date when Document was issued.

documentCode

Code of the Document as configured in external Product Catalogue.

documentName

Name of the Document as configured in external Product Catalogue.

currency

Currency ISO Code. Currency must be configured.

documentLines

Array of document lines (product code, product name, UoM, …​).

Fields Required for Document Lines

The following table lists and describes the fields required for each document line:

Field Description

seqno

Sequence number of the line.

productCode

Code of the Product as configured in external Product Catalogue.

productName

Name of the Product as configured in external Product Catalogue.

unitsOfMeasurement

Unit of Measure (UoM) of the Product. UoM must be configured.

itemPrice

Price of the Product per one item. Note: itemPrice is shifted by 6 decimals. For example, 1 EUR = 1000000.

quantity

Quantity of the Product.

quantityDecimals

Number of Decimals in Quantity, if Quantity should be considered as decimal number.

tax

Code of Tax. Tax must be configured.

glCode

GL Code of the product. GL Code must be configured.

Detailed API documentation and endpoint specifics are available here.

Request Validations

The following validations are performed when creating a document with lines:

Create Document With Lines Example

Use the following request’s body to create a document with lines:

{
  "requestId": "{{$guid}}",
  "user": "crm",
  "account": {
    "externalId": "account_external_id"
  },
  "externalDocumentNo": "external_document_no",
  "documentCategory": "document_category",
  "documentSource": "document_source",
  "documentType": "document_type",
  "documentIssuedDate": "2023-10-01T00:00:00Z",
  "documentCode": "document_code",
  "documentName": "document_name",
  "currency": "EUR",
  "documentLines": [
    {
      "seqno": 1,
      "productCode": "product_code_1",
      "productName": "product_name_1",
      "unitsOfMeasurement": "UoM_1",
      "itemPrice": 50000000,
      "quantity": 2,
      "quantityDecimals": 0,
      "tax": "tax_code_1",
      "glCode": "gl_code_1"
    },
    {
      "seqno": 2,
      "productCode": "product_code_2",
      "productName": "product_name_2",
      "unitsOfMeasurement": "UoM_2",
      "itemPrice": 30000000,
      "quantity": 1,
      "quantityDecimals": 0,
      "tax": "tax_code_2",
      "glCode": "gl_code_2"
    }
  ]
}

The outcome of the API call is as follows:

  • The document is created with the specified details.

  • The document includes multiple lines with the specified products and quantities.

  • The total amount is calculated based on the item prices and quantities.