Skip to content

Write off ​

Stock write-offs

INFO

Har bir javob umumiy konvertda qaytadi — code, message, messages, status_code, time — foydali yuk esa data ichida. Quyidagi jadvallar faqat data ichini tavsiflaydi.

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.

So‘rov tanasi

MaydonTurMajburiyTavsif
organization_idstringYo‘qOrganization ObjectId. Required when the tenant has multiple organizations.
codestringYo‘qOptional external reference code for the write-off
write_datestring (date-time)HaDate the write-off occurred
source_warehouse_idstringYo‘qSource warehouse ObjectId — the warehouse stock is deducted from
responsible_idstringHaEmployee ObjectId responsible for this write-off
reason_idstringHaReason ObjectId explaining why the stock is being written off
currency_idstringYo‘qCurrency ObjectId used for cost values. Defaults to the organization's base currency.
actionstringHaWrite-off action type. remove — permanent stock removal; defect — defective goods moved to a destination warehouse.. Mumkin qiymatlar: remove, defect
destination_warehouse_idstringYo‘qDestination warehouse ObjectId. Required when action is defect.
notestringYo‘qOptional free-text note
productsobject[]HaList of products to write off. At least one item is required.
products[].product_idstringHaProduct ObjectId
products[].amountnumberHaQuantity to write off (must be positive)
products[].box_countnumberYo‘qNumber of boxes (integer; defaults to 0)
products[].marksstring[]Yo‘qMark/serial codes for marked goods. Each mark must be unique within the request.
products[].expiration_datestring (date-time)Yo‘qExpiration date — required for perishable products that have has_expiration: true
json
{
  "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"
    }
  ]
}

Javob

MaydonTurTavsif
_idstring
numberstringAuto-generated write-off document number
codestringOptional external reference code
write_datestring (date-time)
actionstringMumkin qiymatlar: remove, defect
statestringMumkin qiymatlar: done, canceled
notestring
total_costnumber
organizationobject
organization._idstring
organization.namestring
responsible_employeeobject
responsible_employee._idstring
responsible_employee.full_namestring
reasonobject
reason._idstring
reason.namestring
currencyobject
currency._idstring
currency.namestring
source_warehouseobject
source_warehouse._idstring
source_warehouse.namestring
destination_warehouseobjectPopulated only when action is defect
destination_warehouse._idstring
destination_warehouse.namestring
productsobject[]
products[]._idstring
products[].product_idstring
products[].namestring
products[].barcodestring
products[].amountnumber
products[].box_countnumber
products[].costnumber
products[].total_costnumber
products[].marksstring[]
products[].expiration_datestring (date-time)
created_atstring (date-time)
updated_atstring (date-time)
json
{
  "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.

Yo‘l parametrlari

ParametrTurMajburiyTavsif
idstringHaWrite-off ObjectId

So‘rov tanasi

MaydonTurMajburiyTavsif
statusstringHaTarget status. Only canceled is accepted — write-offs are created directly in DONE state and the only permitted transition is DONE → canceled.. Mumkin qiymatlar: canceled
reasonstringYo‘qOptional free-text reason for the cancellation
json
{
  "status": "canceled",
  "reason": "string"
}

Javob

Javob tuzilishi quyidagi bilan bir xil: 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).

Yo‘l parametrlari

ParametrTurMajburiyTavsif
idstringHaWrite-off ObjectId

So‘rov tanasi

So‘rov tanasi talab qilinmaydi.

Javob

Javob tuzilishi quyidagi bilan bir xil: 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.

So‘rov tanasi

MaydonTurMajburiyTavsif
pagenumberHaStandart: 1
limitnumberHaStandart: 20
organization_idstringYo‘qFilter by organization ObjectId
warehouse_idstringYo‘qFilter by source warehouse ObjectId
responsible_idstringYo‘qFilter by responsible employee ObjectId
actionstringYo‘qFilter by write-off action type. Mumkin qiymatlar: remove, defect
json
{
  "page": 1,
  "limit": 20,
  "organization_id": "string",
  "warehouse_id": "string",
  "responsible_id": "string",
  "action": "remove"
}

Javob

MaydonTurTavsif
totalnumber
listobject[]
list[]._idstring
list[].numberstring
list[].codestring
list[].write_datestring (date-time)
list[].actionstringMumkin qiymatlar: remove, defect
list[].statestringMumkin qiymatlar: done, canceled
list[].total_costnumber
list[].organizationobject
list[].organization._idstring
list[].organization.namestring
list[].responsible_employeeobject
list[].responsible_employee._idstring
list[].responsible_employee.full_namestring
list[].reasonobject
list[].reason._idstring
list[].reason.namestring
list[].source_warehouseobject
list[].source_warehouse._idstring
list[].source_warehouse.namestring
list[].created_atstring (date-time)
json
{
  "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"
}

Bu sahifa OpenAPI spetsifikatsiyasidan yaratilgan.

Bito 2.0 Integration API