Add

[POST] .../v1/docinventory/add

Creates a new inventory document. Use this method to create an inventory document before adding counted item rows with InventoryOperation/Add or InventoryOperation/AddBulk. The request requires the inventory add permission and the stock inventory tariff option; open_date, stock_id, price_type_id and compare_type are required, description is limited by the controller and attached_user_id defaults to the current request user when omitted or 0. The created document stores stock, price type, full inventory mode, create_docinout mode, optional external_id and optional responsible user; when full is true the API forces create_docinout to true. Business errors such as missing body, invalid IDs or dates, denied permission, disabled tariff option, unavailable stock, stock access denial, unknown price type, excessive description length, database failures or action log failures are returned as HTTP 200 ErrorResult.

Request Parameters

Name Type Required Description
attached_user_id Int64 Optional Responsible user ID. If omitted or 0, the current request user is used.
compare_type String Required Matching type: open_date - by opening date, close_date - by closing date, operation_date - by operation date. Allowed values: open_date, close_date, operation_date.
create_docinout Boolean Optional Indicates whether write-off/receipt documents should be created automatically from the inventory document when inventory is closed: true - create, false - do not create. Default is true. When create_docinout is true, closing the inventory document with DocInventory/Close creates write-off/receipt documents based on the inventory document. The created documents are not linked to the inventory document, so reopening and closing the inventory document again creates new write-off/receipt documents.
description String Optional Additional description.
external_id String Optional External system document ID.
full Boolean Optional Indicates whether the inventory is full. true - full, false - partial. Default is true. When true, closing the inventory document with DocInventory/Close adds all items from the document stock that have non-zero balances. Added rows use actual quantity 0 and accounting quantity equal to the stock balance: by opening date when matching type is open_date, otherwise by document closing date. When full is set, manually adding all items to the document is unavailable.
open_date Int64 Required Inventory opening date as Unix time in seconds.
price_type_id Int64 Required Price type ID for adding a document operation.
stock_id Int64 Required Stock ID.

Request Example

{
  "attached_user_id": 1,
  "compare_type": "open_date",
  "create_docinout": true,
  "description": "string",
  "external_id": "string",
  "full": true,
  "open_date": 1,
  "price_type_id": 1,
  "stock_id": 1
}

Response Parameters

Name Type Description
ok Boolean Indicates whether the request completed successfully.
result Insert Created record result.

Response Example

{
  "ok": true,
  "result": {
    "new_id": 1
  }
}