> For the complete documentation index, see [llms.txt](https://developers.portos.sk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.portos.sk/api-reference/tickets/ticket-operations-and-user-rights.md).

# Ticket Operations and User Rights

Navigating Access for Ticket Actions

This section describes [user rights](/user-rights.md) required when performing [Ticket API methods](/api-reference/tickets.md).

## **Creating and modifying ticket**

When creating or modifying [ticket](/data-models.md#ticket), specific [user rights](/user-rights.md) are required, based on payload data and whether ticket with given identifier already exists.

* `ticketCreate`: necessary when no existing ticket with given identifier is found.
* `ticketUpdate`: necessary when attempting to modify an open ticket with a given identifier. This applies when the ticket is linked to an authorized user (determined through the `employee.userName` property).
* `ticketUpdateAny`: necessary when attempting to modify an open ticket with a given identifier. This applies when the ticket is linked to a user other than the authorized user (determined through the `employee.userName` property).
* `ticketRename`: necessary when attempting to modify `name` property of an existing open ticket.
* `ticketSetDiscount`: necessary when attempting to set a non-zero value for the `discountRate` property of a new ticket or changing it from an existing ticket. If the ticket is associated with a [customer](/data-models.md#customer) (through the `customer` property), setting a value equal to the customer's discount rate (`customer.discountRate`) is allowed and doesn't require this right.
* `ticketSetCustomer`: necessary when attempting to set non-null value for `customer` property of a new ticket or changing it for an existing ticket.
* `ticketHandover`: necessary when attempting to associate ticket with user other than the authorized user (determined through the `employee.userName` property).
* `ticketTakeover`: necessary when attempting to switch the association of a ticket from a user other than the authorized user (identified through the `employee.userName` property) to the authorized user. The execution of this operation also required `ticketUpdateAny` [user right](/user-rights.md).

## **Deleting ticket**

When deleting existing opened ticket, specific [user rights](/user-rights.md) are required, based on properties of existing ticket.

* `ticketDelete`: necessary when deleting ticket associated with authorized user (determined through the `employee.userName` property).
* `ticketUpdateAny`: necessary deleting ticket linked to a user other than the authorized user (determined through the `employee.userName` property).
* `storno`: necessary when deleting ticket containing at least one [ticket item](/data-models.md#ticketitem) in `items` collection with a quantity greater than zero.

## Closing ticket

When closing ticket, following [user rights](/user-rights.md) are required:

* `ticketClose`: necessary when closing ticket.
* `ticketCloseAny`: necessary when closing ticket linked to a user other than the authorized user (determined through the `employee.userName` property).
* `ticketCloseAs`: necessary when closing ticket in behalf of user other than the authorized user (determined through the `user.userName` property of [`TicketCloseContext`](/data-models.md#ticketclosecontext)).
* `ticketCloseToAnyFiscal`: necessary when closing a ticket on a [fiscal device](/data-models.md#fiscal) that is not the *default* fiscal device. For more details on how to evaluate the default fiscal device, please refer to the [Evaluating the Default Fiscal Name](#evaluating-the-default-fiscal-name) section.
* `ticketUpdate`: necessary when ticket is linked to an authorized user (determined through the `employee.userName` property).
* `ticketUpdateAny`: necessary when ticket is linked to a user other than the authorized user (determined through the `employee.userName` property).

### **Evaluating the Default Fiscal Name**

This section outlines the procedure for determining the default [fiscal device](/data-models.md#fiscal) for a [ticket](/data-models.md#ticket)

1. **Using Zone's defaultFiscalName Property:** The default fiscal name is extracted from the `defaultFiscalName` property of the [Zone](/data-models.md#zone) linked to the [Ticket](/data-models.md#ticket) through the [Ticket](/data-models.md#ticket)'s `location` property. If the `location` property is empty (equal to `null`), move on to the next step.
2. **Checking Device's Settings.DefaultFiscalName Property:** The `Settings.DefaultFiscalName` property of the [Device](/data-models.md#device) associated with the authorized user is checked. If the property value is equal to `null`, proceed to the next step.
3. **No Default Fiscal Name Set:** If none of the above steps yield a default fiscal name, it means that the default fiscal name is not configured. In such cases, the `ticketCloseToAnyFiscal` [user right](/user-rights.md) is not required.

## Printing preliminary ticket

When printing preliminary ticket, following [user rights](/user-rights.md) are required:

* `ticketPrintPreliminary`
* `ticketUpdate`: necessary when ticket is linked to an authorized user (determined through the `employee.userName` property).
* `ticketUpdateAny`: necessary when ticket is linked to a user other than the authorized user (determined through the `employee.userName` property).
