Write off
Stock write-offs
INFO
Каждый ответ приходит в общем конверте — code, message, messages, status_code, time — а полезная нагрузка лежит в data. Таблицы ниже описывают содержимое data.
POST /write-off/create
Create a new write-off (stock loss). The document is immediately persisted in DONE state; stock is decremented and a linked invoice is created inside the same transaction.
Тело запроса
| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
organization_id | string | Нет | Organization ObjectId. Required when the tenant has multiple organizations. |
code | string | Нет | Optional external reference code for the write-off |
write_date | string (date-time) | Да | Date the write-off occurred |
source_warehouse_id | string | Нет | Source warehouse ObjectId — the warehouse stock is deducted from |
responsible_id | string | Да | Employee ObjectId responsible for this write-off |
reason_id | string | Да | Reason ObjectId explaining why the stock is being written off |
currency_id | string | Нет | Currency ObjectId used for cost values. Defaults to the organization's base currency. |
action | string | Да | Write-off action type. remove — permanent stock removal; defect — defective goods moved to a destination warehouse.. Допустимые значения: remove, defect |
destination_warehouse_id | string | Нет | Destination warehouse ObjectId. Required when action is defect. |
note | string | Нет | Optional free-text note |
products | object[] | Да | List of products to write off. At least one item is required. |
products[].product_id | string | Да | Product ObjectId |
products[].amount | number | Да | Quantity to write off (must be positive) |
products[].box_count | number | Нет | Number of boxes (integer; defaults to 0) |
products[].marks | string[] | Нет | Mark/serial codes for marked goods. Each mark must be unique within the request. |
products[].expiration_date | string (date-time) | Нет | Expiration date — required for perishable products that have has_expiration: true |
{
"organization_id": "string",
"code": "string",
"write_date": "2025-05-01T12:00:00Z",
"source_warehouse_id": "string",
"responsible_id": "string",
"reason_id": "string",
"currency_id": "string",
"action": "remove",
"destination_warehouse_id": "string",
"note": "string",
"products": [
{
"product_id": "string",
"amount": 0,
"box_count": 0,
"marks": [],
"expiration_date": "2025-05-01T12:00:00Z"
}
]
}Ответ
| Поле | Тип | Описание |
|---|---|---|
_id | string | |
number | string | Auto-generated write-off document number |
code | string | Optional external reference code |
write_date | string (date-time) | |
action | string | Допустимые значения: remove, defect |
state | string | Допустимые значения: done, canceled |
note | string | |
total_cost | number | |
organization | object | |
organization._id | string | |
organization.name | string | |
responsible_employee | object | |
responsible_employee._id | string | |
responsible_employee.full_name | string | |
reason | object | |
reason._id | string | |
reason.name | string | |
currency | object | |
currency._id | string | |
currency.name | string | |
source_warehouse | object | |
source_warehouse._id | string | |
source_warehouse.name | string | |
destination_warehouse | object | Populated only when action is defect |
destination_warehouse._id | string | |
destination_warehouse.name | string | |
products | object[] | |
products[]._id | string | |
products[].product_id | string | |
products[].name | string | |
products[].barcode | string | |
products[].amount | number | |
products[].box_count | number | |
products[].cost | number | |
products[].total_cost | number | |
products[].marks | string[] | |
products[].expiration_date | string (date-time) | |
created_at | string (date-time) | |
updated_at | string (date-time) |
{
"code": 0,
"message": "Success",
"status_code": 200,
"data": {
"_id": "string",
"number": "string",
"code": "string",
"write_date": "2025-05-01T12:00:00Z",
"action": "remove",
"state": "done",
"note": "string",
"total_cost": 0,
"organization": {
"_id": "string",
"name": "string"
},
"responsible_employee": {
"_id": "string",
"full_name": "string"
},
"reason": {
"_id": "string",
"name": "string"
},
"currency": {
"_id": "string",
"name": "string"
},
"source_warehouse": {
"_id": "string",
"name": "string"
},
"destination_warehouse": {
"_id": "string",
"name": "string"
},
"products": [
{
"_id": "string",
"product_id": "string",
"name": "string",
"barcode": "string",
"amount": 0,
"box_count": 0,
"cost": 0,
"total_cost": 0,
"marks": [],
"expiration_date": "2025-05-01T12:00:00Z"
}
],
"created_at": "2025-05-01T12:00:00Z",
"updated_at": "2025-05-01T12:00:00Z"
},
"time": "2025-05-01T12:00:00Z"
}PUT /write-off/set-status/{id}
Transition a write-off to CANCELED state. This is the only valid state transition — it reverses stock, cancels the linked invoice, and posts a CREDIT reconciliation act. Only status: "canceled" is accepted; write-offs are created directly in DONE state.
Параметры пути
| Параметр | Тип | Обязательно | Описание |
|---|---|---|---|
id | string | Да | Write-off ObjectId |
Тело запроса
| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
status | string | Да | Target status. Only canceled is accepted — write-offs are created directly in DONE state and the only permitted transition is DONE → canceled.. Допустимые значения: canceled |
reason | string | Нет | Optional free-text reason for the cancellation |
{
"status": "canceled",
"reason": "string"
}Ответ
Структура ответа совпадает с POST /write-off/create.
GET /write-off/get-by-id/{id}
Fetch a single write-off by ObjectId with full detail (products, organization, responsible employee, reason, currency, warehouses, attachments).
Параметры пути
| Параметр | Тип | Обязательно | Описание |
|---|---|---|---|
id | string | Да | Write-off ObjectId |
Тело запроса
Тело запроса не требуется.
Ответ
Структура ответа совпадает с POST /write-off/create.
POST /write-off/get-paging
Paginated list of write-offs. Filterable by organization, warehouse, responsible employee, action type, and date range.
Тело запроса
| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
page | number | Да | По умолчанию: 1 |
limit | number | Да | По умолчанию: 20 |
organization_id | string | Нет | Filter by organization ObjectId |
warehouse_id | string | Нет | Filter by source warehouse ObjectId |
responsible_id | string | Нет | Filter by responsible employee ObjectId |
action | string | Нет | Filter by write-off action type. Допустимые значения: remove, defect |
{
"page": 1,
"limit": 20,
"organization_id": "string",
"warehouse_id": "string",
"responsible_id": "string",
"action": "remove"
}Ответ
| Поле | Тип | Описание |
|---|---|---|
total | number | |
list | object[] | |
list[]._id | string | |
list[].number | string | |
list[].code | string | |
list[].write_date | string (date-time) | |
list[].action | string | Допустимые значения: remove, defect |
list[].state | string | Допустимые значения: done, canceled |
list[].total_cost | number | |
list[].organization | object | |
list[].organization._id | string | |
list[].organization.name | string | |
list[].responsible_employee | object | |
list[].responsible_employee._id | string | |
list[].responsible_employee.full_name | string | |
list[].reason | object | |
list[].reason._id | string | |
list[].reason.name | string | |
list[].source_warehouse | object | |
list[].source_warehouse._id | string | |
list[].source_warehouse.name | string | |
list[].created_at | string (date-time) |
{
"code": 0,
"message": "Success",
"status_code": 200,
"data": {
"total": 0,
"list": [
{
"_id": "string",
"number": "string",
"code": "string",
"write_date": "2025-05-01T12:00:00Z",
"action": "remove",
"state": "done",
"total_cost": 0,
"organization": {
"_id": null,
"name": null
},
"responsible_employee": {
"_id": null,
"full_name": null
},
"reason": {
"_id": null,
"name": null
},
"source_warehouse": {
"_id": null,
"name": null
},
"created_at": "2025-05-01T12:00:00Z"
}
]
},
"time": "2025-05-01T12:00:00Z"
}Эта страница сгенерирована из спецификации OpenAPI.