# Vats

Each VAT rate is identified by its numeric category identifier and associated VAT rate with value between 0 and 100. The VAT data model is represented by [`Vat`](https://developers.portos.sk/data-models#vat) class.

## API methods

## Get VATs

<mark style="color:blue;">`GET`</mark> `http://{server-address}/vats`

Returns all VATs that matches query parameters. Result is of type [`QueryResult<Vat>`](https://developers.portos.sk/data-models#queryresult).

#### Query Parameters

| Name     | Type      | Description                                                                                                              |
| -------- | --------- | ------------------------------------------------------------------------------------------------------------------------ |
| category | decimal   | Supports NData syntax.                                                                                                   |
| rate     | decimal   | Supports NData syntax.                                                                                                   |
| $skip    | int       | Pagination property. Describing number of records to skip from beginning of result collection.                           |
| $take    | int       | Pagination property. Maximum count of items to be returned.                                                              |
| $sort    | string\[] | <p>Comma separated list of property names. Please see NData syntax.<br></p>                                              |
| $count   | bool      | If set to `true`, response will not contain `items` collection. Use to get resource count, not the resources themselves. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK Successful response" %}

```javascript
{
    "items":
    [
        {
            "category": 1,
            "rate": 20.0,
            "plannedRateChange":
            {
                "effectiveFrom": "2024-12-31T23:00:00Z",
                "rate": 23.0
            },
            "lastModifiedAt": null,
            "_v": 1
        },
        {
            "category": 2,
            "rate": 10.0,
            "plannedRateChange":
            {
                "effectiveFrom": "2024-12-31T23:00:00Z",
                "rate": 5.0
            },
            "lastModifiedAt": null,
            "_v": 1
        },
        {
            "category": 3,
            "rate": 0.0,
            "plannedRateChange": null,
            "lastModifiedAt": null,
            "_v": 1
        },
        {
            "category": 4,
            "rate": 0.0,
            "plannedRateChange": null,
            "lastModifiedAt": null,
            "_v": 1
        },
        {
            "category": 5,
            "rate": 0.0,
            "plannedRateChange": null,
            "lastModifiedAt": null,
            "_v": 1
        },
        {
            "category": 6,
            "rate": 10.0,
            "plannedRateChange":
            {
                "effectiveFrom": "2024-12-31T23:00:00Z",
                "rate": 19.0
            },
            "lastModifiedAt": null,
            "_v": 1
        },
        {
            "category": 7,
            "rate": 0.0,
            "plannedRateChange": null,
            "lastModifiedAt": null,
            "_v": 1
        },
        {
            "category": 8,
            "rate": 0.0,
            "plannedRateChange": null,
            "lastModifiedAt": null,
            "_v": 1
        },
        {
            "category": 9,
            "rate": 0.0,
            "plannedRateChange": null,
            "lastModifiedAt": null,
            "_v": 1
        },
        {
            "category": 10,
            "rate": null,
            "plannedRateChange": null,
            "lastModifiedAt": null,
            "_v": 1
        }
    ],
    "count": 5,
    "totalCount": 5
}
```

{% endtab %}
{% endtabs %}

## Get VAT by category

<mark style="color:blue;">`GET`</mark> `http://{server-address}/vats/{category}`

Result is of type [Vat](https://developers.portos.sk/data-models#vat).

#### Path Parameters

| Name                                       | Type | Description          |
| ------------------------------------------ | ---- | -------------------- |
| category<mark style="color:red;">\*</mark> | int  | Unique VAT category. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK Resource found." %}

```javascript
{
    "category": 1,
    "rate": 20.0,
    "plannedRateChange":
    {
        "effectiveFrom": "2024-12-31T23:00:00Z",
        "rate": 23.0
    },
    "lastModifiedAt": null,
    "_v": 1
}
```

{% endtab %}

{% tab title="404: Not Found VAT with given category is not found." %}

```javascript
{
    "title": "Zdroj nebol nájdený",
    "status": 404
}
```

{% endtab %}
{% endtabs %}

## Create VAT

<mark style="color:green;">`POST`</mark> `http://{server-address}/vats`

Creates new VAT. Result is of type [Vat](https://developers.portos.sk/data-models#vat).

**Required rights**

Authorized user must have `VatCreate` [right ](https://developers.portos.sk/user-rights)assigned.

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name                                     | Type | Description         |
| ---------------------------------------- | ---- | ------------------- |
| (body)<mark style="color:red;">\*</mark> | VAT  | VAT model to create |

{% tabs %}
{% tab title="201: Created Successfuly created." %}

```javascript
{
    "category": 1,
    "rate": 20.0,
    "plannedRateChange":
    {
        "effectiveFrom": "2024-12-31T23:00:00Z",
        "rate": 23.0
    },
    "lastModifiedAt": null,
    "_v": 1
}
```

{% endtab %}
{% endtabs %}

## Create or update VAT

<mark style="color:orange;">`PUT`</mark> `http://{server-address}/vats/{category}`

Updates existing or creates new VAT. Result is of type [Vat](https://developers.portos.sk/data-models#vat).

**Required rights**

Authorized user must have assigned `VatCreate` or `VatUpdate` [right](https://developers.portos.sk/user-rights).

#### Path Parameters

| Name                                       | Type | Description          |
| ------------------------------------------ | ---- | -------------------- |
| category<mark style="color:red;">\*</mark> | int  | Unique VAT category. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name                                     | Type | Description                    |
| ---------------------------------------- | ---- | ------------------------------ |
| (body)<mark style="color:red;">\*</mark> | VAT  | VAT model to create or update. |

{% tabs %}
{% tab title="200: OK Successfuly created or updated." %}

```javascript
{
    "category": 1,
    "rate": 20.0,
    "plannedRateChange":
    {
        "effectiveFrom": "2024-12-31T23:00:00Z",
        "rate": 23.0
    },
    "lastModifiedAt": null,
    "_v": 2
}
```

{% endtab %}
{% endtabs %}

## Delete VAT by category

<mark style="color:red;">`DELETE`</mark> `http://{server-address}/vats/{category}`

**Required rights**

Authorized user must have `VatDelete` [right ](https://developers.portos.sk/user-rights)assigned.

#### Path Parameters

| Name                                       | Type | Description          |
| ------------------------------------------ | ---- | -------------------- |
| category<mark style="color:red;">\*</mark> | int  | Unique VAT category. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK Successfuly deleted." %}

```javascript
{
    "category": 1,
    "rate": 20.0,
    "plannedRateChange":
    {
        "effectiveFrom": "2024-12-31T23:00:00Z",
        "rate": 23.0
    },
    "lastModifiedAt": null,
    "_v": 2
}
```

{% endtab %}

{% tab title="404: Not Found Given resource was not found." %}

```javascript
{
    "title": "Zdroj nebol nájdený",
    "status": 404
}
```

{% endtab %}
{% endtabs %}
