# Fiscals

Fiscal device refers to receipt printer that prints cash register receipts (part of *ticket closing* procedure).

Fiscal device is represented by [`Fiscal`](https://developers.portos.sk/data-models#fiscal) class.

## API methods

### CRUD actions

These API methods allow for the management of fiscal resources, including creation, reading, updating, and deletion.

## Get fiscals

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

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

#### Query Parameters

| Name     | Type      | Description                                                                                                              |
| -------- | --------- | ------------------------------------------------------------------------------------------------------------------------ |
| name     | string    | 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. |
| isActive | bool      | Supports NData syntax.                                                                                                   |
| type     | string    | Supports NData syntax.                                                                                                   |
| dkp      | string    | Supports NData syntax.                                                                                                   |

#### Headers

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

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

```json
{
    "items":
    [
        {
            "name": "Virtual",
            "isActive": true,
            "type": "Virtual",
            "version": "",
            "dkp": "88811223344550000",
            "settings":
            {
                "Footer": "Ďakujeme za nákup!"
            },
            "_v": 1
        }
    ],
    "count": 1,
    "totalCount": 1
}
```

{% endtab %}
{% endtabs %}

## Get fiscal by name

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

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

#### Path Parameters

| Name                                   | Type   | Description         |
| -------------------------------------- | ------ | ------------------- |
| name<mark style="color:red;">\*</mark> | string | Unique fiscal name. |

#### Headers

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

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

```json
{
    "name": "fiscal1",
    "isActive": true,
    "type": "Virtual",
    "version": "",
    "dkp": "88811223344550000",
    "settings":
    {
        "Footer": "Ďakujeme za nákup!"
    },
    "_v": 1
}{
    "name": "fiscal1",
    "isActive": true,
    "type": "Virtual",
    "version": "",
    "dkp": "88811223344550000",
    "settings":
    {
        "Footer": "Ďakujeme za nákup!"
    },
    "_v": 1
}
```

{% endtab %}

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

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

{% endtab %}
{% endtabs %}

## Create fiscal

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

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

**Required rights**

Authorized user must have `FiscalCreate` [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> | Fiscal | Model to create. |

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

```javascript
{
    "name": "fiscal1",
    "isActive": true,
    "type": "Virtual",
    "version": "",
    "dkp": "88811223344550000",
    "settings":
    {
        "Footer": "Ďakujeme za nákup!"
    },
    "_v": 1
}
```

{% endtab %}
{% endtabs %}

## Create or update fiscal

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

Creates new or updates existing fiscal. Result is of type [Fiscal](https://developers.portos.sk/data-models#fiscal).

**Required rights**

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

#### Path Parameters

| Name                                   | Type   | Description         |
| -------------------------------------- | ------ | ------------------- |
| name<mark style="color:red;">\*</mark> | string | Unique fiscal name. |

#### 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> | Fiscal | Model to create or update. |

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

```json
{
    "name": "fiscal1",
    "isActive": true,
    "type": "Virtual",
    "version": "",
    "dkp": "88811223344550000",
    "settings":
    {
        "Footer": "Ďakujeme za nákup!"
    },
    "_v": 1
}
```

{% endtab %}
{% endtabs %}

## Delete fiscal by name

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

**Required rights**

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

#### Path Parameters

| Name                                   | Type   | Description         |
| -------------------------------------- | ------ | ------------------- |
| name<mark style="color:red;">\*</mark> | string | Unique fiscal name. |

#### Headers

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

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

```json
{
    "name": "fiscal1",
    "isActive": true,
    "type": "Virtual",
    "version": "",
    "dkp": "88811223344550000",
    "settings":
    {
        "Footer": "Ďakujeme za nákup!"
    },
    "_v": 1
}
```

{% endtab %}

{% tab title="403: Forbidden Fiscal device is marked as inactive" %}

```javascript
{
    "title": "Fiskálna tlačiareň 'eKasa' je označená ako neaktívna.",
    "status": 403
}
```

{% endtab %}
{% endtabs %}

### RPC actions

These API methods trigger specific actions on fiscal devices. However, it's important to note that depending on the type of fiscal device, some methods may not be supported. Additionally, attempting an action on a fiscal device that is marked as inactive will also result in failure. In both of these cases, making API calls will result in an HTTP status code of 403.

## Open cash drawer

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

Opens cash drawer on specified device.

**Required rights**

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

#### Path Parameters

| Name                                   | Type   | Description         |
| -------------------------------------- | ------ | ------------------- |
| name<mark style="color:red;">\*</mark> | string | Unique fiscal name. |

#### Headers

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

{% tabs %}
{% tab title="204: No Content Drawer successfully opened." %}
The response body contains no content.
{% endtab %}
{% endtabs %}

## Perform cash transfer

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

This method performs a cash transfer operation on a fiscal device specified by name. It updates the latest daily sales report for the device or creates a new report if none is currently opened. The updated daily sales report is then returned in the response body.

The method accepts [`CashTransfer`](https://developers.portos.sk/data-models#cashtransfer) in request body.

**Required rights**

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

#### Path Parameters

| Name                                   | Type   | Description         |
| -------------------------------------- | ------ | ------------------- |
| name<mark style="color:red;">\*</mark> | string | Unique fiscal name. |

#### 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> | CashTransfer | Cash transfer model. |

{% tabs %}
{% tab title="200: OK Cash transfer successfully.created." %}

<pre class="language-json"><code class="lang-json"><strong>
</strong></code></pre>

{% endtab %}
{% endtabs %}

## Print ticket copy

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

Prints copy of specified ticket on fiscal printer. Method accepts [`RecordCopyContext`](https://developers.portos.sk/data-models#recordcopycontext) in request body.

**Required rights**

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

#### Path Parameters

| Name                                   | Type   | Description         |
| -------------------------------------- | ------ | ------------------- |
| name<mark style="color:red;">\*</mark> | string | Unique fiscal name. |

#### 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> | RecordCopyContext | The record copy context. |

{% tabs %}
{% tab title="204: No Content Ticket copy printed successfully." %}
The response body contains no content.
{% endtab %}
{% endtabs %}

## Print last ticket copy

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

Prints copy of last ticket printed on fiscal printer.

**Required rights**

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

#### Path Parameters

| Name                                   | Type   | Description         |
| -------------------------------------- | ------ | ------------------- |
| name<mark style="color:red;">\*</mark> | string | Unique fiscal name. |

#### Headers

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

{% tabs %}
{% tab title="204: No Content Ticket copy printed successfully." %}
The response body contains no content.
{% endtab %}
{% endtabs %}

## Print overview sales report

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

Prints overview sales report on specified fiscal printer.

The overview sales report ("*Priebežná uzávierka*", "*Prehľadová uzávierka*" or "X uzávierka" in Slovak) includes financial information on sales from the last daily sales report.

**Required rights**

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

#### Path Parameters

| Name                                   | Type   | Description         |
| -------------------------------------- | ------ | ------------------- |
| name<mark style="color:red;">\*</mark> | string | Unique fiscal name. |

#### Headers

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

{% tabs %}
{% tab title="204: No Content Report printed successfully." %}
The response body contains no content.
{% endtab %}
{% endtabs %}

## Print summary interval sales report

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

Prints summary interval sales report on specified fiscal printer. The generated report consolidates financial information extracted from multiple daily sales reports.

The method accepts [`IntervalSalesReportContext`](https://developers.portos.sk/data-models#intervalsalesreportcontext) in request body.

**Required rights**

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

#### Path Parameters

| Name                                   | Type   | Description         |
| -------------------------------------- | ------ | ------------------- |
| name<mark style="color:red;">\*</mark> | string | Unique fiscal name. |

#### 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> | IntervalSalesReportContext | Model that specifies sales reports interval. |

{% tabs %}
{% tab title="204: No Content Report printed successfully." %}
The response body contains no content.
{% endtab %}
{% endtabs %}

## Print detailed interval sales report

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

Prints detailed interval sales report on specified fiscal printer. The generated report consolidates financial information extracted from multiple daily sales reports.

The method accepts [`IntervalSalesReportContext`](https://developers.portos.sk/data-models#intervalsalesreportcontext) in request body.

**Required rights**

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

#### Path Parameters

| Name                                   | Type   | Description         |
| -------------------------------------- | ------ | ------------------- |
| name<mark style="color:red;">\*</mark> | string | Unique fiscal name. |

#### 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> | IntervalSalesReportContext | Model that specifies sales reports interval. |

{% tabs %}
{% tab title="204: No Content Report printed successfully." %}
The response body contains no content.
{% endtab %}
{% endtabs %}

## Print daily sales report

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

Performs daily sales closure and prints daily sales report on specified fiscal printer. [`DailySalesReport`](https://developers.portos.sk/data-models#dailysalesreport) is returned in response body. It's important to note that certain fiscal devices only support one daily sales report per day, while other types of fiscal devices allow multiple closures to be performed within the same day.

**Required rights**

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

#### Path Parameters

| Name                                   | Type   | Description         |
| -------------------------------------- | ------ | ------------------- |
| name<mark style="color:red;">\*</mark> | string | Unique fiscal name. |

#### Headers

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

{% tabs %}
{% tab title="200: OK Report printed successfully." %}

```json
{
    "id": "649ad7516413d6a4de6c8cb4",
    "fiscalName": "eKasa",
    "number": 1,
    "fiscalMemorySerialNumber": "1326585810",
    "openDate": "2023-06-27T08:04:25.605Z",
    "closeDate": "2023-06-27T22:42:13.662Z",
    "currencyLabel": "EUR",
    "cashTransfers":
    [],
    "fiscalInfo":
    {
        "ticketsCount": 7,
        "ticketsAmountIncludingVat":
        {
            "amount": 80.65,
            "currencyLabel": "EUR"
        },
        "invalidTicketsCount": 0,
        "invalidTicketsAmountIncludingVat":
        {
            "amount": 0.0,
            "currencyLabel": "EUR"
        },
        "invoiceTicketsCount": 0,
        "invoiceTicketsAmountIncludingVat":
        {
            "amount": 0.0,
            "currencyLabel": "EUR"
        },
        "positiveTicketItemsCount": 8,
        "positiveTicketItemsAmountIncludingVat":
        {
            "amount": 80.65,
            "currencyLabel": "EUR"
        },
        "returnedContainerTicketItemsCount": 0,
        "returnedContainerTicketItemsAmountIncludingVat":
        {
            "amount": 0.0,
            "currencyLabel": "EUR"
        },
        "returnedTicketItemsCount": 0,
        "returnedTicketItemsAmountIncludingVat":
        {
            "amount": 0.0,
            "currencyLabel": "EUR"
        },
        "correctionTicketItemsCount": 0,
        "correctionTicketItemsAmountIncludingVat":
        {
            "amount": 0.0,
            "currencyLabel": "EUR"
        },
        "discountTicketItemsCount": 0,
        "discountTicketItemsAmountIncludingVat":
        {
            "amount": 0.0,
            "currencyLabel": "EUR"
        },
        "advanceTicketItemsCount": 0,
        "advanceTicketItemsAmountIncludingVat":
        {
            "amount": 0.0,
            "currencyLabel": "EUR"
        },
        "creditTicketItemsCount": 0,
        "creditTicketItemsAmountIncludingVat":
        {
            "amount": 0.0,
            "currencyLabel": "EUR"
        },
        "voucherTicketItemsCount": 0,
        "voucherTicketItemsAmountIncludingVat":
        {
            "amount": 0.0,
            "currencyLabel": "EUR"
        },
        "vatIncomes":
        [
            {
                "vatCategory": 1,
                "vatRate": 20.0,
                "totalAmount":
                {
                    "amount": 9.45,
                    "currencyLabel": "EUR"
                },
                "vatAmount":
                {
                    "amount": 1.58,
                    "currencyLabel": "EUR"
                }
            },
            {
                "vatCategory": 2,
                "vatRate": 10.0,
                "totalAmount":
                {
                    "amount": 71.2,
                    "currencyLabel": "EUR"
                },
                "vatAmount":
                {
                    "amount": 6.47,
                    "currencyLabel": "EUR"
                }
            },
            {
                "vatCategory": 3,
                "vatRate": 0.0,
                "totalAmount":
                {
                    "amount": 0.0,
                    "currencyLabel": "EUR"
                },
                "vatAmount":
                {
                    "amount": 0.0,
                    "currencyLabel": "EUR"
                }
            },
            {
                "vatCategory": 4,
                "vatRate": 0.0,
                "totalAmount":
                {
                    "amount": 0.0,
                    "currencyLabel": "EUR"
                },
                "vatAmount":
                {
                    "amount": 0.0,
                    "currencyLabel": "EUR"
                }
            },
            {
                "vatCategory": 5,
                "vatRate": 0.0,
                "totalAmount":
                {
                    "amount": 0.0,
                    "currencyLabel": "EUR"
                },
                "vatAmount":
                {
                    "amount": 0.0,
                    "currencyLabel": "EUR"
                }
            }
        ],
        "grandTotalAmountIncludingVat":
        {
            "amount": 1619.31,
            "currencyLabel": "EUR"
        },
        "roundingDown":
        {
            "amount": -0.02,
            "currencyLabel": "EUR"
        },
        "roundingUp":
        {
            "amount": 0.02,
            "currencyLabel": "EUR"
        }
    },
    "state": "Closed",
    "_v": 2
}
```

{% endtab %}
{% endtabs %}

## Print daily sales report copy

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

Prints copy of daily sales report associated with given fiscal printer. Method accepts [`DailySalesReportCopyContext`](https://developers.portos.sk/data-models#dailysalesreportcopycontext) in request body.

**Required rights**

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

#### Path Parameters

| Name                                   | Type   | Description         |
| -------------------------------------- | ------ | ------------------- |
| name<mark style="color:red;">\*</mark> | string | Unique fiscal name. |

#### Headers

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

#### Request Body

| Name   | Type                       | Description                                              |
| ------ | -------------------------- | -------------------------------------------------------- |
| (body) | DailySalesReportCopyContex | Context that specifies daily sales report to be printed. |

{% tabs %}
{% tab title="204: No Content Report copy printed successfully." %}
The response body contains no content.
{% endtab %}
{% endtabs %}

## Print last daily sales report copy

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

Prints copy of last daily sales report associated with given fiscal printer.

**Required rights**

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

#### Path Parameters

| Name                                   | Type   | Description         |
| -------------------------------------- | ------ | ------------------- |
| name<mark style="color:red;">\*</mark> | string | Unique fiscal name. |

#### Headers

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

{% tabs %}
{% tab title="204: No Content Report copy printed successfully." %}
The response body contains no content.
{% endtab %}
{% endtabs %}

## Print text

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

Prints text (nonfiscal record) on selected fiscal device. Method accepts [`NonfiscalRecordContext`](https://developers.portos.sk/data-models#nonfiscalrecordcontext) in request body.

**Required rights**

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

#### Path Parameters

| Name                                   | Type   | Description         |
| -------------------------------------- | ------ | ------------------- |
| name<mark style="color:red;">\*</mark> | string | Unique fiscal name. |

#### Headers

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

#### Request Body

| Name   | Type                   | Description                                |
| ------ | ---------------------- | ------------------------------------------ |
| (body) | NonfiscalRecordContext | Context that specifies text to be printed. |

{% tabs %}
{% tab title="204: No Content Text printed successfully." %}
The response body contains no content.
{% endtab %}
{% endtabs %}
