# Daily sales reports

The fiscal device sends record closure information after each closed ticket or cash transfer. If a daily sales report record does not already exist (identified by fiscal name, fiscal memory serial number, and daily sales report number), it is automatically created by API.&#x20;

Each ticket is associated with a specific daily sales report, and this information is stored in the [ticket](https://developers.portos.sk/data-models#ticket)'s `closeInfo` property.

Daily sales report record is modified by API after following actions are performed on fiscal device:

* cash transfer: new element is added to cash transfers collection
* daily sales report closure: fiscal info model is fulfilled and daily sales report is considered as *closed*.

Daily sales report is closed, when it's `state` property is set to `closed` or `manuallyClosed`. Closed daily sales reports cannot be modified.

Daily sales report is represented by [`DailySalesReport`](https://developers.portos.sk/data-models#dailysalesreport) class.

## API methods

## Get daily sales reports

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

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

#### Query Parameters

| Name                     | Type                   | Description                                                                                                              |
| ------------------------ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| isClosed                 | bool                   | 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. |
| id                       | bool                   | Supports NData syntax.                                                                                                   |
| openDate                 | DateTime               |                                                                                                                          |
| currencyLabel            | string                 |                                                                                                                          |
| fiscalMemorySerialNumber | string                 |                                                                                                                          |
| number                   | int                    |                                                                                                                          |
| fiscalName               | string                 |                                                                                                                          |
| state                    | DailySalesReportStatus |                                                                                                                          |
| closeDate                | DateTime               |                                                                                                                          |

#### 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":
    [
        {
            "id": "646f5d625527869ae467b117",
            "fiscalName": "eKasa",
            "number": 2,
            "fiscalMemorySerialNumber": "1326585810",
            "openDate": "2023-06-28T08:06:40Z",
            "closeDate": null,
            "currencyLabel": "EUR",
            "cashTransfers":
            [],
            "fiscalInfo": null,
            "state": "Open",
            "_v": 1
        },
        {
            "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":
                [
                    {
                        "vatRate": 20.0,
                        "totalAmount":
                        {
                            "amount": 9.45,
                            "currencyLabel": "EUR"
                        },
                        "vatAmount":
                        {
                            "amount": 1.58,
                            "currencyLabel": "EUR"
                        }
                    },
                    {
                        "vatRate": 10.0,
                        "totalAmount":
                        {
                            "amount": 71.2,
                            "currencyLabel": "EUR"
                        },
                        "vatAmount":
                        {
                            "amount": 6.47,
                            "currencyLabel": "EUR"
                        }
                    },
                    {
                        "vatRate": 0.0,
                        "totalAmount":
                        {
                            "amount": 0.0,
                            "currencyLabel": "EUR"
                        },
                        "vatAmount":
                        {
                            "amount": 0.0,
                            "currencyLabel": "EUR"
                        }
                    },
                    {
                        "vatRate": null,
                        "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
        }
    ],
    "count": 2,
    "totalCount": 2
}
```

{% endtab %}
{% endtabs %}

## Get daily sales report

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

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

#### Path Parameters

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

#### Headers

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

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

```javascript
{
    "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":
        [
            {
                "vatRate": 20.0,
                "totalAmount":
                {
                    "amount": 9.45,
                    "currencyLabel": "EUR"
                },
                "vatAmount":
                {
                    "amount": 1.58,
                    "currencyLabel": "EUR"
                }
            },
            {
                "vatRate": 10.0,
                "totalAmount":
                {
                    "amount": 71.2,
                    "currencyLabel": "EUR"
                },
                "vatAmount":
                {
                    "amount": 6.47,
                    "currencyLabel": "EUR"
                }
            },
            {
                "vatRate": 0.0,
                "totalAmount":
                {
                    "amount": 0.0,
                    "currencyLabel": "EUR"
                },
                "vatAmount":
                {
                    "amount": 0.0,
                    "currencyLabel": "EUR"
                }
            },
            {
                "vatRate":null,
                "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 %}

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

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

{% endtab %}
{% endtabs %}

## Create or update daily sales report

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

Creates new or updates existing (non-closed) daily sales report. Result is of type [DailySalesReport](https://developers.portos.sk/data-models#dailysalesreport).

**Required rights**

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

#### Path Parameters

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

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

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

```javascript
{
    "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":
        [
            {
                "vatRate": 20.0,
                "totalAmount":
                {
                    "amount": 9.45,
                    "currencyLabel": "EUR"
                },
                "vatAmount":
                {
                    "amount": 1.58,
                    "currencyLabel": "EUR"
                }
            },
            {
                "vatRate": 10.0,
                "totalAmount":
                {
                    "amount": 71.2,
                    "currencyLabel": "EUR"
                },
                "vatAmount":
                {
                    "amount": 6.47,
                    "currencyLabel": "EUR"
                }
            },
            {
                "vatRate": 0.0,
                "totalAmount":
                {
                    "amount": 0.0,
                    "currencyLabel": "EUR"
                },
                "vatAmount":
                {
                    "amount": 0.0,
                    "currencyLabel": "EUR"
                }
            },
            {
                "vatRate": null,
                "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 %}

{% tab title="403: Forbidden Attempt to edit closed daily sales report" %}

```json
{
    "title": "Cannot modify daily sales report that is aleady marked as closed.",
    "status": 403
}
```

{% endtab %}
{% endtabs %}

## Manually close daily sales report

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

Changes `state` of daily sales report to `manuallyClosed`. Result is of type [DailySalesReport](https://developers.portos.sk/data-models#dailysalesreport).

**Required rights**

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

#### Path Parameters

| Name | Type   | Description        |
| ---- | ------ | ------------------ |
| id   | string | Unique identifier. |

#### Headers

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

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

```javascript
{
    "id": "646f5d625527869ae467b117",
    "fiscalName": "eKasa",
    "number": 2,
    "fiscalMemorySerialNumber": "1326585810",
    "openDate": "2023-06-28T08:06:40Z",
    "closeDate": "2023-06-28T15:06:40Z",
    "currencyLabel": "EUR",
    "cashTransfers":
    [],
    "fiscalInfo": null,
    "state": "ManuallyClosed",
    "_v": 2
}
```

{% endtab %}
{% endtabs %}

## Delete daily sales report

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

**Required rights**

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

#### Path Parameters

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

#### Headers

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

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

```javascript
{
    "id": "646f5d625527869ae467b117",
    "fiscalName": "eKasa",
    "number": 2,
    "fiscalMemorySerialNumber": "1326585810",
    "openDate": "2023-06-28T08:06:40Z",
    "closeDate": null,
    "currencyLabel": "EUR",
    "cashTransfers":
    [],
    "fiscalInfo": null,
    "state": "Open",
    "_v": 1
}
```

{% endtab %}

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

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

{% endtab %}
{% endtabs %}
