Skip to content

Production plan ​

Production planning

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 /production-plan/create ​

Create a production plan for a given year and organization. This is a year-keyed upsert — if a plan already exists for the given (year, organization_id) it is updated rather than duplicated. Items carry per-product monthly targets.

So‘rov tanasi

MaydonTurMajburiyTavsif
yearnumberHaThe production plan year (e.g. 2025). Together with organization_id this is the upsert key — submitting a plan for the same year + organization updates the existing plan.
organization_idstringHaOrganization ObjectId this plan belongs to
notestringYo‘qOptional free-text note
itemsobject[]HaPer-product monthly production targets (at least one item required)
items[].product_idstringHaProduct ObjectId
items[].monthsobject[]HaMonthly target entries for this product (at least one month required)
items[].months[].amountnumberHaPlanned production quantity for this month
items[].months[].month_numbernumberHaCalendar month (1 = January … 12 = December). Each month_number must be unique within an item.
json
{
  "year": 2025,
  "organization_id": "string",
  "note": "string",
  "items": [
    {
      "product_id": "string",
      "months": []
    }
  ]
}

Javob

MaydonTurTavsif
_idstringProduction plan ObjectId
numberstringAuto-generated plan number
yearnumberPlan year
notestringFree-text note
organization_idstringOrganization ObjectId
organizationobject
organization._idstring
organization.namestring
created_byobject
created_by._idstring
created_by.numberstring
created_by.full_namestring
updated_byobject
updated_by._idstring
updated_by.numberstring
updated_by.full_namestring
created_atstring (date-time)
updated_atstring (date-time)
itemsobject[]
items[].product_idstringProduct ObjectId
items[].productobject
items[].product._idstring
items[].product.namestring
items[].product.skustring
items[].product.barcodestring
items[].monthsobject[]
items[].months[].amountnumberPlanned quantity
items[].months[].month_numbernumberCalendar month (1–12)
items[].months[].producednumberActual produced quantity so far
json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "string",
    "number": "string",
    "year": 0,
    "note": "string",
    "organization_id": "string",
    "organization": {
      "_id": "string",
      "name": "string"
    },
    "created_by": {
      "_id": "string",
      "number": "string",
      "full_name": "string"
    },
    "updated_by": {
      "_id": "string",
      "number": "string",
      "full_name": "string"
    },
    "created_at": "2025-05-01T12:00:00Z",
    "updated_at": "2025-05-01T12:00:00Z",
    "items": [
      {
        "product_id": "string",
        "product": {
          "_id": null,
          "name": null,
          "sku": null,
          "barcode": null
        },
        "months": []
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}

PUT /production-plan/update/{id} ​

Update a production plan. Internally performs the same year-keyed upsert as create — the {id} path parameter is standard-shape only; the real dedup key is body year + organization_id. Send the full plan payload including items.

Yo‘l parametrlari

ParametrTurMajburiyTavsif
idstringHaProduction plan ObjectId (standard-shape; upsert key is year + organization_id in body)

So‘rov tanasi

MaydonTurMajburiyTavsif
yearnumberHaThe production plan year (e.g. 2025). Together with organization_id this is the upsert key — submitting a plan for the same year + organization updates the existing plan.
organization_idstringHaOrganization ObjectId this plan belongs to
notestringYo‘qOptional free-text note
itemsobject[]HaPer-product monthly production targets (at least one item required)
items[].product_idstringHaProduct ObjectId
items[].monthsobject[]HaMonthly target entries for this product (at least one month required)
items[].months[].amountnumberHaPlanned production quantity for this month
items[].months[].month_numbernumberHaCalendar month (1 = January … 12 = December). Each month_number must be unique within an item.
json
{
  "year": 2025,
  "organization_id": "string",
  "note": "string",
  "items": [
    {
      "product_id": "string",
      "months": []
    }
  ]
}

Javob

Javob tuzilishi quyidagi bilan bir xil: POST /production-plan/create.

GET /production-plan/get-by-id/{id} ​

Fetch a single production plan by ObjectId, with aggregated items and per-product monthly targets.

Yo‘l parametrlari

ParametrTurMajburiyTavsif
idstringHaProduction plan ObjectId

So‘rov tanasi

So‘rov tanasi talab qilinmaydi.

Javob

Javob tuzilishi quyidagi bilan bir xil: POST /production-plan/create.

POST /production-plan/get-paging ​

Paginated list of production plans. The search field matches against the plan number.

So‘rov tanasi

MaydonTurMajburiyTavsif
pagenumberHaStandart: 1
limitnumberHaStandart: 20
searchstringYo‘qSearch string matched against plan number
json
{
  "page": 1,
  "limit": 20,
  "search": "string"
}

Javob

MaydonTurTavsif
totalnumber
listobject[]
list[]._idstring
list[].numberstring
list[].yearnumber
list[].notestring
list[].organization_idstring
list[].organizationobject
list[].organization._idstring
list[].organization.namestring
list[].created_byobject
list[].created_by._idstring
list[].created_by.numberstring
list[].created_by.full_namestring
list[].updated_byobject
list[].updated_by._idstring
list[].updated_by.numberstring
list[].updated_by.full_namestring
list[].created_atstring (date-time)
list[].updated_atstring (date-time)
json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "list": [
      {
        "_id": "string",
        "number": "string",
        "year": 0,
        "note": "string",
        "organization_id": "string",
        "organization": {
          "_id": null,
          "name": null
        },
        "created_by": {
          "_id": null,
          "number": null,
          "full_name": null
        },
        "updated_by": {
          "_id": null,
          "number": null,
          "full_name": null
        },
        "created_at": "2025-05-01T12:00:00Z",
        "updated_at": "2025-05-01T12:00:00Z"
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}

POST /production-plan/delete-many ​

Soft-delete one or more production plans by their ObjectIds. Sets is_deleted=true; no physical deletion.

So‘rov tanasi

MaydonTurMajburiyTavsif
idsstring[]HaProduction plan ObjectIds to soft-delete (at least one required)
json
{
  "ids": [
    "string"
  ]
}

Javob

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

POST /production-plan/get-by-year ​

Fetch the production plan for a year + organization. Together these are the plan's natural key — the same pair create/update upsert on — so this is the lookup to use when you hold the business key rather than the ObjectId. Returns an empty object when no plan exists for that pair.

So‘rov tanasi

MaydonTurMajburiyTavsif
yearnumberHaCalendar year of the plan, e.g. 2026
organization_idstringHaOrganization ObjectId the plan belongs to
json
{
  "year": 2026,
  "organization_id": "string"
}

Javob

Javob tuzilishi quyidagi bilan bir xil: POST /production-plan/create.


Bu sahifa OpenAPI spetsifikatsiyasidan yaratilgan.

Bito 2.0 Integration API