Skip to content

Reason ​

Configurable reasons used across business flows

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 /reason/create ​

Create a new reason. Reasons are configurable reference data used in business flows such as supplier returns, customer returns, purchase requests, order cancellations, transfers, write-offs, and more. name is required; type should be provided (model requires it — omitting type produces a validation error). is_active defaults to false.

So‘rov tanasi

MaydonTurMajburiyTavsif
namestringHaReason display name (required)
typestringYo‘qReason type — determines which business flow this reason applies to. Note: the model requires a type; omitting it will produce a Mongoose validation error.. Mumkin qiymatlar: supplier_return, customer_return, purchase_request, contract_cancel, order_cancel, transfer, transfer_cancel, write_off, visit_reject, delivery_order_cancel, task
descriptionstringYo‘qOptional description
is_activebooleanYo‘qWhether this reason is active. Defaults to false.
is_trashbooleanYo‘qWhether this reason is for trash/disposal flows.
codestringYo‘qOptional short code identifier for the reason.
order_numbernumberYo‘qSort order (ascending). Used to control display order.
colorstringYo‘qHex color code, format #RRGGBB (e.g. #FF5733)
json
{
  "name": "string",
  "type": "supplier_return",
  "description": "string",
  "is_active": false,
  "is_trash": false,
  "code": "string",
  "order_number": 0,
  "color": "string"
}

Javob

MaydonTurTavsif
_idstringReason ObjectId
namestringReason display name
typestringReason type — determines which business flow this reason applies to. Mumkin qiymatlar: supplier_return, customer_return, purchase_request, contract_cancel, order_cancel, transfer, transfer_cancel, write_off, visit_reject, delivery_order_cancel, task
descriptionstringOptional description
is_activebooleanWhether this reason is active
is_trashbooleanWhether this reason is for trash/disposal flows
codestringShort code identifier
order_numbernumberSort order (ascending)
colorstringHex color code, format #RRGGBB
created_atstring (date-time)Creation timestamp
updated_atstring (date-time)Last update timestamp
json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "string",
    "name": "string",
    "type": "supplier_return",
    "description": "string",
    "is_active": false,
    "is_trash": false,
    "code": "string",
    "order_number": 0,
    "color": "string",
    "created_at": "2025-05-01T12:00:00Z",
    "updated_at": "2025-05-01T12:00:00Z"
  },
  "time": "2025-05-01T12:00:00Z"
}

GET /reason/get-by-id/{id} ​

Fetch a single reason by its ObjectId.

Yo‘l parametrlari

ParametrTurMajburiyTavsif
idstringHaReason ObjectId

So‘rov tanasi

So‘rov tanasi talab qilinmaydi.

Javob

Javob tuzilishi quyidagi bilan bir xil: POST /reason/create.

POST /reason/get-paging ​

Paginated list of reasons. Filter by type (supplier_return, customer_return, purchase_request, contract_cancel, order_cancel, transfer, transfer_cancel, write_off, visit_reject, delivery_order_cancel, task) and/or is_active. Results sorted by order_number asc, _id desc (or sort_by override).

So‘rov tanasi

MaydonTurMajburiyTavsif
pagenumberHaStandart: 1
limitnumberHaStandart: 20
typestringYo‘qFilter by reason type. Omit to return reasons of all types.. Mumkin qiymatlar: supplier_return, customer_return, purchase_request, contract_cancel, order_cancel, transfer, transfer_cancel, write_off, visit_reject, delivery_order_cancel, task
is_activebooleanYo‘qFilter by active state. Omit to return both active and inactive reasons.
json
{
  "page": 1,
  "limit": 20,
  "type": "supplier_return",
  "is_active": false
}

Javob

MaydonTurTavsif
totalnumber
listobject[]
list[]._idstringReason ObjectId
list[].namestringReason display name
list[].typestringReason type — determines which business flow this reason applies to. Mumkin qiymatlar: supplier_return, customer_return, purchase_request, contract_cancel, order_cancel, transfer, transfer_cancel, write_off, visit_reject, delivery_order_cancel, task
list[].descriptionstringOptional description
list[].is_activebooleanWhether this reason is active
list[].is_trashbooleanWhether this reason is for trash/disposal flows
list[].codestringShort code identifier
list[].order_numbernumberSort order (ascending)
list[].colorstringHex color code, format #RRGGBB
list[].created_atstring (date-time)Creation timestamp
list[].updated_atstring (date-time)Last update timestamp
json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "list": [
      {
        "_id": "string",
        "name": "string",
        "type": "supplier_return",
        "description": "string",
        "is_active": false,
        "is_trash": false,
        "code": "string",
        "order_number": 0,
        "color": "string",
        "created_at": "2025-05-01T12:00:00Z",
        "updated_at": "2025-05-01T12:00:00Z"
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}

PUT /reason/update/{id} ​

Update an existing reason by ObjectId. All fields are optional; only provided fields are updated. name must be non-empty if provided.

Yo‘l parametrlari

ParametrTurMajburiyTavsif
idstringHaReason ObjectId to update

So‘rov tanasi

MaydonTurMajburiyTavsif
namestringYo‘qUpdated reason display name
typestringYo‘qUpdated reason type. Mumkin qiymatlar: supplier_return, customer_return, purchase_request, contract_cancel, order_cancel, transfer, transfer_cancel, write_off, visit_reject, delivery_order_cancel, task
descriptionstringYo‘qUpdated description
is_activebooleanYo‘qToggle active state
is_trashbooleanYo‘qToggle trash/disposal flag
codestringYo‘qUpdated short code identifier
order_numbernumberYo‘qUpdated sort order
colorstringYo‘qUpdated hex color code, format #RRGGBB
json
{
  "name": "string",
  "type": "supplier_return",
  "description": "string",
  "is_active": false,
  "is_trash": false,
  "code": "string",
  "order_number": 0,
  "color": "string"
}

Javob

Javob tuzilishi quyidagi bilan bir xil: POST /reason/create.

DELETE /reason/delete/{id} ​

Soft-delete a reason by ObjectId (sets is_deleted=true). Returns 400 if the reason is not found.

Yo‘l parametrlari

ParametrTurMajburiyTavsif
idstringHaReason ObjectId to delete

So‘rov tanasi

So‘rov tanasi talab qilinmaydi.

Javob

json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": "ok",
  "time": "2025-05-01T12:00:00Z"
}

Bu sahifa OpenAPI spetsifikatsiyasidan yaratilgan.

Bito 2.0 Integration API