# Report analysis

::: 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 /reports/analysis/abc/by-month

ABC analysis aggregated by month — classifies products into A/B/C buckets by contribution to revenue.

**Kerakli ruxsat:** yo‘q — ruxsat e’lon qilgan ilova uchun yopiq · [ruxsatlar qanday ishlaydi](https://docs.bito.uz/api/permissions.md)

**So‘rov namunasi**

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/reports/analysis/abc/by-month' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "a": 0,
  "b": 0,
  "c": 0
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/reports/analysis/abc/by-month', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "a": 0,
    "b": 0,
    "c": 0
  }),
})
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/reports/analysis/abc/by-month",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "a": 0,
        "b": 0,
        "c": 0,
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "a": 0,
  "b": 0,
  "c": 0
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/reports/analysis/abc/by-month');
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);
```

:::

**So‘rov tanasi**

| Maydon | Tur | Majburiy | Tavsif |
|---|---|---|---|
| `sale_type` | `string` | Yo‘q | Mumkin qiymatlar: `receipt`, `sale_contract`, `trade` |
| `from_date` | `string (date-time)` | Yo‘q | Start of the reporting window. |
| `to_date` | `string (date-time)` | Yo‘q | End of the reporting window. |
| `organizations` | `string[]` | Yo‘q |  |
| `employees` | `string[]` | Yo‘q |  |
| `responsible_ids` | `string[]` | Yo‘q |  |
| `mediator_ids` | `string[]` | Yo‘q |  |
| `field` | `string` | Yo‘q | Metric the chart plots.. Mumkin qiymatlar: `gross_sales`, `refund`, `discount`, `gift`, `net_sales`, `profit`. Standart: `"gross_sales"` |
| `organization_id` | `string` | Yo‘q | Organization ObjectId. |
| `category_id` | `string` | Yo‘q |  |
| `customer_category_id` | `string` | Yo‘q |  |
| `supplier_id` | `string` | Yo‘q |  |
| `supplier_category_id` | `string` | Yo‘q |  |
| `product_id` | `string` | Yo‘q |  |
| `product_ids` | `string[]` | Yo‘q |  |
| `contract_id` | `string` | Yo‘q |  |
| `report_by` | `string` | Yo‘q | Mumkin qiymatlar: `created_by`, `responsible` |
| `a` | `number` | Ha |  |
| `b` | `number` | Ha |  |
| `c` | `number` | Ha |  |
| `type` | `string` | Yo‘q | Mumkin qiymatlar: `product`, `customer`, `employee`, `payment`, `category` |

```json
{
  "sale_type": "receipt",
  "from_date": "2025-05-01T12:00:00Z",
  "to_date": "2025-05-01T12:00:00Z",
  "organizations": [
    "64b7f4d9e2b3b6a0b7c5d7ff"
  ],
  "employees": [
    "64b7f4d9e2b3b6a0b7c5d7ff"
  ],
  "responsible_ids": [
    "64b7f4d9e2b3b6a0b7c5d7ff"
  ],
  "mediator_ids": [
    "64b7f4d9e2b3b6a0b7c5d7ff"
  ],
  "field": "gross_sales",
  "organization_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "category_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "customer_category_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "supplier_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "supplier_category_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "product_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "product_ids": [
    "64b7f4d9e2b3b6a0b7c5d7ff"
  ],
  "contract_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "report_by": "created_by",
  "a": 0,
  "b": 0,
  "c": 0,
  "type": "product"
}
```

**Javob**

| Maydon | Tur | Tavsif |
|---|---|---|
| `list` | `object[]` |  |
| `total` | `number` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "list": [
      {}
    ],
    "total": 0
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## POST /reports/analysis/abc/by-product

ABC analysis aggregated by product over the reporting window.

**Kerakli ruxsat:** yo‘q — ruxsat e’lon qilgan ilova uchun yopiq · [ruxsatlar qanday ishlaydi](https://docs.bito.uz/api/permissions.md)

**So‘rov namunasi**

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/reports/analysis/abc/by-product' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "a": 0,
  "b": 0,
  "c": 0
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/reports/analysis/abc/by-product', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "a": 0,
    "b": 0,
    "c": 0
  }),
})
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/reports/analysis/abc/by-product",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "a": 0,
        "b": 0,
        "c": 0,
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "a": 0,
  "b": 0,
  "c": 0
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/reports/analysis/abc/by-product');
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);
```

:::

**So‘rov tanasi**

| Maydon | Tur | Majburiy | Tavsif |
|---|---|---|---|
| `sale_type` | `string` | Yo‘q | Mumkin qiymatlar: `receipt`, `sale_contract`, `trade` |
| `from_date` | `string (date-time)` | Yo‘q | Start of the reporting window. |
| `to_date` | `string (date-time)` | Yo‘q | End of the reporting window. |
| `organizations` | `string[]` | Yo‘q |  |
| `employees` | `string[]` | Yo‘q |  |
| `responsible_ids` | `string[]` | Yo‘q |  |
| `mediator_ids` | `string[]` | Yo‘q |  |
| `field` | `string` | Yo‘q | Metric the chart plots.. Mumkin qiymatlar: `gross_sales`, `refund`, `discount`, `gift`, `net_sales`, `profit`. Standart: `"gross_sales"` |
| `organization_id` | `string` | Yo‘q | Organization ObjectId. |
| `category_id` | `string` | Yo‘q |  |
| `customer_category_id` | `string` | Yo‘q |  |
| `supplier_id` | `string` | Yo‘q |  |
| `supplier_category_id` | `string` | Yo‘q |  |
| `product_id` | `string` | Yo‘q |  |
| `product_ids` | `string[]` | Yo‘q |  |
| `contract_id` | `string` | Yo‘q |  |
| `report_by` | `string` | Yo‘q | Mumkin qiymatlar: `created_by`, `responsible` |
| `a` | `number` | Ha |  |
| `b` | `number` | Ha |  |
| `c` | `number` | Ha |  |
| `type` | `string` | Yo‘q | Mumkin qiymatlar: `product`, `customer`, `employee`, `payment`, `category` |

```json
{
  "sale_type": "receipt",
  "from_date": "2025-05-01T12:00:00Z",
  "to_date": "2025-05-01T12:00:00Z",
  "organizations": [
    "64b7f4d9e2b3b6a0b7c5d7ff"
  ],
  "employees": [
    "64b7f4d9e2b3b6a0b7c5d7ff"
  ],
  "responsible_ids": [
    "64b7f4d9e2b3b6a0b7c5d7ff"
  ],
  "mediator_ids": [
    "64b7f4d9e2b3b6a0b7c5d7ff"
  ],
  "field": "gross_sales",
  "organization_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "category_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "customer_category_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "supplier_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "supplier_category_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "product_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "product_ids": [
    "64b7f4d9e2b3b6a0b7c5d7ff"
  ],
  "contract_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "report_by": "created_by",
  "a": 0,
  "b": 0,
  "c": 0,
  "type": "product"
}
```

**Javob**

Javob tuzilishi quyidagi bilan bir xil: [POST /reports/analysis/abc/by-month](#post-reports-analysis-abc-by-month).

## POST /reports/analysis/customers/abc-xyz

ABC/XYZ analysis on customers — combines revenue contribution (ABC) with demand variability (XYZ).

**Kerakli ruxsat:** yo‘q — ruxsat e’lon qilgan ilova uchun yopiq · [ruxsatlar qanday ishlaydi](https://docs.bito.uz/api/permissions.md)

**So‘rov namunasi**

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/reports/analysis/customers/abc-xyz' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "limit": 0,
  "page": 0
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/reports/analysis/customers/abc-xyz', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "limit": 0,
    "page": 0
  }),
})
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/reports/analysis/customers/abc-xyz",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "limit": 0,
        "page": 0,
    },
)
print(res.json())
```

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

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/reports/analysis/customers/abc-xyz');
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);
```

:::

**So‘rov tanasi**

| Maydon | Tur | Majburiy | Tavsif |
|---|---|---|---|
| `limit` | `number` | Ha | Maximum number of rows to return. |
| `page` | `number` | Ha | Page number, starting from 1. |
| `organization_id` | `string` | Yo‘q | Organization ObjectId. |
| `warehouse_id` | `string` | Yo‘q |  |
| `category_id` | `string` | Yo‘q |  |
| `customer_category_id` | `string` | Yo‘q |  |
| `supplier_id` | `string` | Yo‘q |  |
| `supplier_category_id` | `string` | Yo‘q |  |
| `product_id` | `string` | Yo‘q |  |
| `product_ids` | `string[]` | Yo‘q |  |
| `customer_id` | `string` | Yo‘q |  |
| `date_from` | `string (date-time)` | Yo‘q | Start of the date range. |
| `date_to` | `string (date-time)` | Yo‘q | End of the date range. |
| `sort` | `object` | Yo‘q |  |
| `sort.name` | `integer` | Yo‘q | Mumkin qiymatlar: `1`, `-1` |
| `report_by` | `string` | Yo‘q | Mumkin qiymatlar: `created_by`, `responsible` |
| `abc_class` | `string` | Yo‘q | Mumkin qiymatlar: `A`, `B`, `C`, `C-LOSS` |
| `xyz_class` | `string` | Yo‘q | Mumkin qiymatlar: `X`, `Y`, `Z`, `Z-NEW` |
| `segment` | `string` | Yo‘q | Mumkin qiymatlar: `AX`, `AY`, `AZ`, `AZ-NEW`, `BX`, `BY`, `BZ`, `BZ-NEW`, `CX`, `CY`, `CZ`, `CZ-NEW`, `C-LOSSX`, `C-LOSSY`, `C-LOSSZ`, `C-LOSSZ-NEW` |
| `customer_type` | `string` | Yo‘q | Mumkin qiymatlar: `legal`, `natural` |

```json
{
  "limit": 0,
  "page": 0,
  "organization_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "warehouse_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "category_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "customer_category_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "supplier_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "supplier_category_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "product_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "product_ids": [
    "64b7f4d9e2b3b6a0b7c5d7ff"
  ],
  "customer_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "date_from": "2025-05-01T12:00:00Z",
  "date_to": "2025-05-01T12:00:00Z",
  "sort": {
    "name": 1
  },
  "report_by": "created_by",
  "abc_class": "A",
  "xyz_class": "X",
  "segment": "AX",
  "customer_type": "legal"
}
```

**Javob**

Javob tuzilishi quyidagi bilan bir xil: [POST /reports/analysis/abc/by-month](#post-reports-analysis-abc-by-month).

---

*Bu sahifa OpenAPI spetsifikatsiyasidan yaratilgan.*
