# Finance settings

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

## GET /finance-settings/get

Get the tenant's finance settings (created with defaults on first access).

**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 GET 'https://api.bito.uz/integration-api/integration/api/v2/finance-settings/get' \
  -H "api-key: $BITO_API_KEY"
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/finance-settings/get', {
  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/finance-settings/get",
    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/finance-settings/get');
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);
```

:::

**So‘rov tanasi**

So‘rov tanasi talab qilinmaydi.

**Javob**

| Maydon | Tur | Tavsif |
|---|---|---|
| `_id` | `string` |  |
| `account_id` | `string` |  |
| `apply_in_main` | `boolean` |  |
| `service_cost_type` | `string` | Mumkin qiymatlar: `fixed`, `priced` |
| `multi_currency` | `boolean` |  |
| `expense_approval_enabled` | `boolean` |  |
| `expense_approval_limit` | `number` |  |
| `discount_below_min_price_policy` | `string` | Mumkin qiymatlar: `strict`, `warning`, `override` |
| `expense_approval_currency` | `object` |  |
| `expense_approval_currency._id` | `string` |  |
| `expense_approval_currency.name` | `string` |  |
| `expense_approval_currency.symbol` | `string` |  |
| `expense_approval_currency.value` | `number` |  |
| `expense_approval_type_limits` | `object[]` | Per-payment-type overrides of the expense approval threshold. An entry whose `limit` is null means that payment type never requires approval; a payment type with no entry falls back to `expense_approval_limit`. Read-only — not settable through Integration API v2. |
| `expense_approval_type_limits[].payment_type_id` | `string` | Payment type ObjectId (transaction_type = expense) |
| `expense_approval_type_limits[].payment_type_name` | `string` | Denormalized payment type name at the time the limit was saved |
| `expense_approval_type_limits[].limit` | `number` | Threshold in the approval currency. null = never requires approval. 0 = always requires approval. |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "string",
    "account_id": "string",
    "apply_in_main": false,
    "service_cost_type": "fixed",
    "multi_currency": false,
    "expense_approval_enabled": false,
    "expense_approval_limit": 0,
    "discount_below_min_price_policy": "strict",
    "expense_approval_currency": {
      "_id": "string",
      "name": "string",
      "symbol": "string",
      "value": 0
    },
    "expense_approval_type_limits": [
      {
        "payment_type_id": "string",
        "payment_type_name": "string",
        "limit": 0
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## PUT /finance-settings/set

Update the tenant's finance settings (partial patch). Setting expense_approval_currency_id denormalizes the currency; multi_currency cannot be disabled while more than one currency exists.

**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 PUT 'https://api.bito.uz/integration-api/integration/api/v2/finance-settings/set' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "apply_in_main": false,
  "service_cost_type": "fixed",
  "multi_currency": false,
  "expense_approval_enabled": false,
  "expense_approval_limit": 0,
  "expense_approval_currency_id": "string",
  "discount_below_min_price_policy": "strict"
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/finance-settings/set', {
  method: 'PUT',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "apply_in_main": false,
    "service_cost_type": "fixed",
    "multi_currency": false,
    "expense_approval_enabled": false,
    "expense_approval_limit": 0,
    "expense_approval_currency_id": "string",
    "discount_below_min_price_policy": "strict"
  }),
})
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/finance-settings/set",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "apply_in_main": False,
        "service_cost_type": "fixed",
        "multi_currency": False,
        "expense_approval_enabled": False,
        "expense_approval_limit": 0,
        "expense_approval_currency_id": "string",
        "discount_below_min_price_policy": "strict",
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "apply_in_main": false,
  "service_cost_type": "fixed",
  "multi_currency": false,
  "expense_approval_enabled": false,
  "expense_approval_limit": 0,
  "expense_approval_currency_id": "string",
  "discount_below_min_price_policy": "strict"
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/finance-settings/set');
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);
```

:::

**So‘rov tanasi**

| Maydon | Tur | Majburiy | Tavsif |
|---|---|---|---|
| `apply_in_main` | `boolean` | Yo‘q | Apply finance rules in the main organization |
| `service_cost_type` | `string` | Yo‘q | Service cost calculation type. Mumkin qiymatlar: `fixed`, `priced` |
| `multi_currency` | `boolean` | Yo‘q | Enable multi-currency. Cannot be turned off while more than one currency exists. |
| `expense_approval_enabled` | `boolean` | Yo‘q | Require owner approval for expenses above the limit |
| `expense_approval_limit` | `number` | Yo‘q | Approval threshold amount (in the approval currency) |
| `expense_approval_currency_id` | `string` | Yo‘q | Currency ObjectId the approval limit is denominated in |
| `discount_below_min_price_policy` | `string` | Yo‘q | Policy when a sale discount drops below the product minimum price. Mumkin qiymatlar: `strict`, `warning`, `override` |

```json
{
  "apply_in_main": false,
  "service_cost_type": "fixed",
  "multi_currency": false,
  "expense_approval_enabled": false,
  "expense_approval_limit": 0,
  "expense_approval_currency_id": "string",
  "discount_below_min_price_policy": "strict"
}
```

**Javob**

Javob tuzilishi quyidagi bilan bir xil: [GET /finance-settings/get](#get-finance-settings-get).

---

*Bu sahifa OpenAPI spetsifikatsiyasidan yaratilgan.*
