# Income

::: info
Каждый ответ приходит в общем конверте — `code`, `message`, `messages`, `status_code`, `time` — а полезная нагрузка лежит в `data`. Таблицы ниже описывают содержимое `data`.
:::

## POST /income/create

This method allows adding income into the account.

**Нужное разрешение:** `income_create` · [как работают разрешения](https://docs.bito.uz/ru/api/permissions.md)

**Пример запроса**

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/income/create' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "organization_id": "64b7f4d9e2b3b6a0b7c5d7f2",
  "responsible_id": "64b7f4d9e2b3b6a0b7c5d7f3",
  "date": "2024-07-20T10:30:00Z",
  "supplier_id": "64b7f4d9e2b3b6a0b7c5d7f4",
  "warehouse_id": "64b7f4d9e2b3b6a0b7c5d7f6",
  "currency_id": "64b7f4d9e2b3b6a0b7c5d7f7",
  "purchases": [
    {
      "purchase_id": "64b7f4d9e2b3b6a0b7c5d7f8",
      "products": []
    }
  ]
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/income/create', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "organization_id": "64b7f4d9e2b3b6a0b7c5d7f2",
    "responsible_id": "64b7f4d9e2b3b6a0b7c5d7f3",
    "date": "2024-07-20T10:30:00Z",
    "supplier_id": "64b7f4d9e2b3b6a0b7c5d7f4",
    "warehouse_id": "64b7f4d9e2b3b6a0b7c5d7f6",
    "currency_id": "64b7f4d9e2b3b6a0b7c5d7f7",
    "purchases": [
      {
        "purchase_id": "64b7f4d9e2b3b6a0b7c5d7f8",
        "products": []
      }
    ]
  }),
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "POST",
    "https://api.bito.uz/integration-api/integration/api/v2/income/create",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "organization_id": "64b7f4d9e2b3b6a0b7c5d7f2",
        "responsible_id": "64b7f4d9e2b3b6a0b7c5d7f3",
        "date": "2024-07-20T10:30:00Z",
        "supplier_id": "64b7f4d9e2b3b6a0b7c5d7f4",
        "warehouse_id": "64b7f4d9e2b3b6a0b7c5d7f6",
        "currency_id": "64b7f4d9e2b3b6a0b7c5d7f7",
        "purchases": [
            {
                "purchase_id": "64b7f4d9e2b3b6a0b7c5d7f8",
                "products": [],
            },
        ],
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "organization_id": "64b7f4d9e2b3b6a0b7c5d7f2",
  "responsible_id": "64b7f4d9e2b3b6a0b7c5d7f3",
  "date": "2024-07-20T10:30:00Z",
  "supplier_id": "64b7f4d9e2b3b6a0b7c5d7f4",
  "warehouse_id": "64b7f4d9e2b3b6a0b7c5d7f6",
  "currency_id": "64b7f4d9e2b3b6a0b7c5d7f7",
  "purchases": [
    {
      "purchase_id": "64b7f4d9e2b3b6a0b7c5d7f8",
      "products": []
    }
  ]
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/income/create');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY'), 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
```

:::

**Тело запроса**

| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
| `code` | `string` | Нет |  |
| `organization_id` | `string` | Да |  |
| `responsible_id` | `string` | Да |  |
| `date` | `string (date-time)` | Да |  |
| `supplier_id` | `string` | Да |  |
| `supplier_assistant_id` | `string` | Нет |  |
| `warehouse_id` | `string` | Да |  |
| `currency_id` | `string` | Да |  |
| `note` | `string` | Нет |  |
| `purchases` | `object[]` | Да |  |
| `purchases[].purchase_id` | `string` | Да |  |
| `purchases[].products` | `object[]` | Да |  |
| `purchases[].products[].purchase_item_id` | `string` | Да |  |
| `purchases[].products[].amount` | `number` | Да | По умолчанию: `0` |
| `purchases[].products[].box_count` | `number` | Нет | По умолчанию: `0` |
| `purchases[].products[].box_item` | `number` | Нет | По умолчанию: `0` |
| `purchases[].products[].product_id` | `string` | Да |  |
| `purchases[].products[].cost` | `number` | Да | По умолчанию: `0` |
| `purchases[].products[].extra_cost` | `number` | Нет | По умолчанию: `0` |
| `purchases[].products[].marks` | `string[]` | Нет |  |
| `purchases[].products[].extra_costs` | `object[]` | Нет |  |
| `purchases[].products[].used_measure` | `object` | Нет |  |
| `purchases[].products[].expiration_date` | `string (date-time)` | Нет |  |
| `additional_costs` | `object[]` | Нет |  |
| `additional_costs[].cost_id` | `string` | Да |  |
| `additional_costs[].amount` | `number` | Да | По умолчанию: `0` |
| `additional_costs[].customer_id` | `string` | Нет |  |
| `additional_costs[].person_id` | `string` | Нет |  |
| `additional_costs[].supplier_id` | `string` | Нет |  |
| `additional_costs[].employee_id` | `string` | Нет |  |

```json
{
  "code": "INC-2024-001",
  "organization_id": "64b7f4d9e2b3b6a0b7c5d7f2",
  "responsible_id": "64b7f4d9e2b3b6a0b7c5d7f3",
  "date": "2024-07-20T10:30:00Z",
  "supplier_id": "64b7f4d9e2b3b6a0b7c5d7f4",
  "supplier_assistant_id": "64b7f4d9e2b3b6a0b7c5d7f5",
  "warehouse_id": "64b7f4d9e2b3b6a0b7c5d7f6",
  "currency_id": "64b7f4d9e2b3b6a0b7c5d7f7",
  "note": "Some notes about the income",
  "purchases": [
    {
      "purchase_id": "64b7f4d9e2b3b6a0b7c5d7f8",
      "products": []
    }
  ],
  "additional_costs": [
    {
      "cost_id": "64b7f4d9e2b3b6a0b7c5d7fc",
      "amount": 0,
      "customer_id": "64b7f4d9e2b3b6a0b7c5d7fd",
      "person_id": "64b7f4d9e2b3b6a0b7c5d7fe",
      "supplier_id": "64b7f4d9e2b3b6a0b7c5d7ff",
      "employee_id": "64b7f4d9e2b3b6a0b7c5d800"
    }
  ]
}
```

**Ответ**

| Поле | Тип | Описание |
|---|---|---|
| `created_at` | `string (date-time)` |  |
| `updated_at` | `number (date-time)` |  |
| `code` | `string` |  |
| `number` | `string` |  |
| `organization_id` | `string` |  |
| `organization` | `object` |  |
| `organization._id` | `string` |  |
| `organization.name` | `string` |  |
| `date` | `string (date-time)` |  |
| `warehouse_id` | `string` |  |
| `warehouse` | `object` |  |
| `warehouse._id` | `string` |  |
| `warehouse.name` | `string` |  |
| `responsible_id` | `string` |  |
| `responsible` | `object` |  |
| `responsible._id` | `string` |  |
| `responsible.full_name` | `string` |  |
| `supplier_id` | `string` |  |
| `supplier` | `object` |  |
| `supplier._id` | `string` |  |
| `supplier.name` | `string` |  |
| `currency_id` | `string` |  |
| `currency` | `object` |  |
| `currency._id` | `string` |  |
| `currency.name` | `string` |  |
| `currency.symbol` | `string` |  |
| `currency.uuid` | `number` |  |
| `currency.value` | `number` |  |
| `currency.side` | `string` |  |
| `note` | `string` |  |
| `total_amount` | `number` |  |
| `total_cost` | `number` |  |
| `additional_costs` | `object[]` |  |
| `additional_costs[].cost_id` | `string` |  |
| `additional_costs[].amount` | `number` |  |
| `additional_costs[].cost` | `object` |  |
| `additional_costs[].cost.name` | `string` |  |
| `additional_costs[].cost.is_affect_price` | `boolean` |  |
| `additional_costs[].cost.distribution_method` | `string` |  |
| `additional_costs[].cost.recommended_amount` | `number` |  |
| `additional_costs[].cost.max_amount` | `number` |  |
| `additional_costs[].cost.currency_id` | `string` |  |
| `purchases` | `object[]` |  |
| `state` | `string` |  |
| `created_by` | `object` |  |
| `created_by._id` | `number` |  |
| `created_by.full_name` | `string` |  |
| `created_by.phone_number` | `string` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "created_at": "2025-05-01T12:00:00Z",
    "updated_at": 0,
    "code": "INC-2024-001",
    "number": "string",
    "organization_id": "string",
    "organization": {
      "_id": "string",
      "name": "string"
    },
    "date": "2025-05-01T12:00:00Z",
    "warehouse_id": "string",
    "warehouse": {
      "_id": "string",
      "name": "string"
    },
    "responsible_id": "string",
    "responsible": {
      "_id": "string",
      "full_name": "string"
    },
    "supplier_id": "string",
    "supplier": {
      "_id": "string",
      "name": "string"
    },
    "currency_id": "string",
    "currency": {
      "_id": "string",
      "name": "string",
      "symbol": "string",
      "uuid": 0,
      "value": 0,
      "side": "string"
    },
    "note": "string",
    "total_amount": 0,
    "total_cost": 0,
    "additional_costs": [
      {
        "cost_id": "string",
        "amount": 0,
        "cost": {
          "name": null,
          "is_affect_price": null,
          "distribution_method": null,
          "recommended_amount": null,
          "max_amount": null,
          "currency_id": null
        }
      }
    ],
    "purchases": [
      {}
    ],
    "state": "string",
    "created_by": {
      "_id": 0,
      "full_name": "string",
      "phone_number": "string"
    }
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## PUT /income/cancel

Cancel income

**Нужное разрешение:** `income` · [как работают разрешения](https://docs.bito.uz/ru/api/permissions.md)

Приложению, которое отменяет документ, стоит запросить и `income_cancel`.

**Пример запроса**

::: code-group

```bash [curl]
curl -X PUT 'https://api.bito.uz/integration-api/integration/api/v2/income/cancel' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "_id": "64b7f4d9e2b3b6a0b7c5d801"
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/income/cancel', {
  method: 'PUT',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "_id": "64b7f4d9e2b3b6a0b7c5d801"
  }),
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "PUT",
    "https://api.bito.uz/integration-api/integration/api/v2/income/cancel",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "_id": "64b7f4d9e2b3b6a0b7c5d801",
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "_id": "64b7f4d9e2b3b6a0b7c5d801"
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/income/cancel');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY'), 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
```

:::

**Тело запроса**

| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
| `_id` | `string` | Да |  |
| `cancel_extra_cost` | `boolean` | Нет |  |
| `with_transactions` | `boolean` | Нет |  |

```json
{
  "_id": "64b7f4d9e2b3b6a0b7c5d801",
  "cancel_extra_cost": true,
  "with_transactions": true
}
```

**Ответ**

Структура ответа совпадает с [POST /income/create](#post-income-create).

## GET /income/get-by-id/{id}

Get income using its _id

**Нужное разрешение:** `income` · [как работают разрешения](https://docs.bito.uz/ru/api/permissions.md)

**Пример запроса**

::: code-group

```bash [curl]
curl -X GET 'https://api.bito.uz/integration-api/integration/api/v2/income/get-by-id/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY"
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/income/get-by-id/6712f0a9c4d1e87b3a0f9911', {
  method: 'GET',
  headers: { 'api-key': process.env.BITO_API_KEY },
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "GET",
    "https://api.bito.uz/integration-api/integration/api/v2/income/get-by-id/6712f0a9c4d1e87b3a0f9911",
    headers={"api-key": os.environ["BITO_API_KEY"]},
)
print(res.json())
```

```php [PHP]
<?php
$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/income/get-by-id/6712f0a9c4d1e87b3a0f9911');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY')],
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
```

:::

**Параметры пути**

| Параметр | Тип | Обязательно | Описание |
|---|---|---|---|
| `id` | `string` | Да |  |

**Тело запроса**

Тело запроса не требуется.

**Ответ**

Структура ответа совпадает с [POST /income/create](#post-income-create).

## POST /income/get-paging

Get income by paging

**Нужное разрешение:** `income` · [как работают разрешения](https://docs.bito.uz/ru/api/permissions.md)

**Пример запроса**

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/income/get-paging' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "page": 1,
  "limit": 20
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/income/get-paging', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "page": 1,
    "limit": 20
  }),
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "POST",
    "https://api.bito.uz/integration-api/integration/api/v2/income/get-paging",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "page": 1,
        "limit": 20,
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "page": 1,
  "limit": 20
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/income/get-paging');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY'), 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
```

:::

**Тело запроса**

| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
| `page` | `number` | Да | По умолчанию: `1` |
| `limit` | `number` | Да | По умолчанию: `20` |
| `search` | `string` | Нет |  |
| `supplier_id` | `string` | Нет |  |
| `organization_id` | `string` | Нет |  |
| `responsible_id` | `string` | Нет |  |
| `date_from` | `string (date-time)` | Нет |  |
| `date_to` | `string (date-time)` | Нет |  |
| `updated_at` | `string (date-time)` | Нет |  |

```json
{
  "page": 1,
  "limit": 20,
  "search": "string",
  "supplier_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "organization_id": "64b7f4d9e2b3b6a0b7c5d800",
  "responsible_id": "64b7f4d9e2b3b6a0b7c5d801",
  "date_from": "2024-07-01T00:00:00Z",
  "date_to": "2024-07-31T23:59:59Z",
  "updated_at": "2024-07-20T10:30:00Z"
}
```

**Ответ**

`data.total` — общее количество записей, `data.data[]` — записи текущей страницы. Таблица ниже описывает одну запись.

| Поле | Тип | Описание |
|---|---|---|
| `created_at` | `string (date-time)` |  |
| `updated_at` | `number (date-time)` |  |
| `code` | `string` |  |
| `number` | `string` |  |
| `organization_id` | `string` |  |
| `organization` | `object` |  |
| `organization._id` | `string` |  |
| `organization.name` | `string` |  |
| `date` | `string (date-time)` |  |
| `responsible_id` | `string` |  |
| `responsible` | `object` |  |
| `responsible._id` | `string` |  |
| `responsible.full_name` | `string` |  |
| `supplier_id` | `string` |  |
| `supplier` | `object` |  |
| `supplier._id` | `string` |  |
| `supplier.name` | `string` |  |
| `currency_id` | `string` |  |
| `currency` | `object` |  |
| `currency._id` | `string` |  |
| `currency.name` | `string` |  |
| `currency.symbol` | `string` |  |
| `currency.uuid` | `number` |  |
| `currency.value` | `number` |  |
| `currency.side` | `string` |  |
| `note` | `string` |  |
| `total_amount` | `number` |  |
| `total_cost` | `number` |  |
| `state` | `string` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "data": [
      {
        "created_at": "2025-05-01T12:00:00Z",
        "updated_at": 0,
        "code": "INC-2024-001",
        "number": "string",
        "organization_id": "string",
        "organization": {
          "_id": "string",
          "name": "string"
        },
        "date": "2025-05-01T12:00:00Z",
        "responsible_id": "string",
        "responsible": {
          "_id": "string",
          "full_name": "string"
        },
        "supplier_id": "string",
        "supplier": {
          "_id": "string",
          "name": "string"
        },
        "currency_id": "string",
        "currency": {
          "_id": "string",
          "name": "string",
          "symbol": "string",
          "uuid": 0,
          "value": 0,
          "side": "string"
        },
        "note": "string",
        "total_amount": 0,
        "total_cost": 0,
        "state": "string"
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}
```

---

*Эта страница сгенерирована из спецификации OpenAPI.*
