# Payroll

**Beta:**
Salaxy API v04 is in beta: it may change, and it is not used in production yet. Build on v03, the current version.

Payroll Controller provides CRUD functionality as well as additional methods for Payroll objects

Salaxy API v04 (beta), **Finland only**. 12 operations. Interactive version: [REST API reference](https://code.salaxy.com/reference/rest-api-v04.md). Machine-readable: [OpenAPI document](https://code.salaxy.com/openapi/salaxy-04.json).

**The reference wins:**
These pages are generated from the OpenAPI document. If a guide and this reference disagree about a field, follow the reference. Error responses are not in the document — see [Errors](https://code.salaxy.com/reference/errors.md).

## `GET /v04/api/payroll`

**Performs an OData query to the search index.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `$search` | query | string |  |  |
| `$filter` | query | string |  | Specifies the logic to pull back a subset of records. |
| `$orderby` | query | string |  | Specifies the values used to sort the collection of entries. |
| `$select` | query | string |  | The $select system query option allows the clients to requests a limited set of properties for each entry. |
| `$top` | query | number |  | Specifies the subset of entries by count. |
| `$skip` | query | number |  | Specifies the count of entries to skip. |
| `$count` | query | boolean |  | Indicates whether or not to include a total entry count. |

Response: `PageResultOfPayrollListItem`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/payroll/GET/v04/api/payroll)

## `POST /v04/api/payroll`

**Updates or creates a new Payroll object.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `applyEmploymentDefaultRows` | query | boolean |  | If true, when creating a new payroll, the default rows from the employment should be updated. |

Request body: `PayrollDetails` (required)

Response: `PayrollDetails`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/payroll/POST/v04/api/payroll)

## `GET /v04/api/payroll/{id}`

**Gets a single Payroll object based on identier.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Unique identifier for the object. |

Response: `PayrollDetails`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/payroll/GET/v04/api/payroll/{id})

## `DELETE /v04/api/payroll/{id}`

**Deletes a Payroll object from the storage**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Unique identifier for the object. |

Response: `string`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/payroll/DELETE/v04/api/payroll/{id})

## `GET /v04/api/payroll/new`

**Factory method that creates a new Payroll object**

Response: `PayrollDetails`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/payroll/GET/v04/api/payroll/new)

## `POST /v04/api/payroll/{id}/employments`

**Adds new calculations based on given employments to the Payroll and saves the Payroll object.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | The id of the Payroll. |

Request body: `string[]` (required)

Response: `CalculationListItem[]`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/payroll/POST/v04/api/payroll/{id}/employments)

## `GET /v04/api/payroll/{id}/calcs`

**Performs an OData query to the search index containing payroll calculations.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes |  |
| `$search` | query | string |  |  |
| `$filter` | query | string |  | Specifies the logic to pull back a subset of records. |
| `$orderby` | query | string |  | Specifies the values used to sort the collection of entries. |
| `$select` | query | string |  | The $select system query option allows the clients to requests a limited set of properties for each entry. |
| `$top` | query | number |  | Specifies the subset of entries by count. |
| `$skip` | query | number |  | Specifies the count of entries to skip. |
| `$count` | query | boolean |  | Indicates whether or not to include a total entry count. |

Response: `PageResultOfCalculationListItem`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/payroll/GET/v04/api/payroll/{id}/calcs)

## `POST /v04/api/payroll/{id}/calcs`

**Adds/updates the calculations for a Payroll and returns the added/updated calculations as list items.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | The id of the Payroll. |
| `isMerge` | query | boolean |  | If true, the included calculations should be merged into the existing calculations. |
| `rowMergeOption` | query | RowMergeOption |  | Merging option for the rows. |
| `sourceId` | query | string |  | Source id for the merged rows. Please note that if the RowMergeOption is RemoveImportedRows and the source ID is set, only the rows with the given source ID will be removed, otherwise if the source ID is not set, all rows with any source ID will be removed. |
| `applyEmploymentDefaultRows` | query | boolean |  | If true, any calculation should be added with the default rows from the employment. |
| `applyWorktime` | query | boolean |  | If true, resolves, recalculates and updates holidays and absences to the given calculations. |

Request body: `PayrollCalculationsCollection` (required)

Response: `CalculationListItem[]`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/payroll/POST/v04/api/payroll/{id}/calcs)

## `DELETE /v04/api/payroll/{id}/calcs/{calcId}`

**Removes the calculation from the payroll and saves the payroll object.
This can only be done if the calculation and the payroll have not been paid yet.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | The id of the Payroll. |
| `calcId` | path | string | yes | The id of the calculation to be removed from the Payroll list. |
| `delete` | query | boolean |  | If true the calculation is completely deleted, otherwise only unlinked. |

Response: `PayrollDetails`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/payroll/DELETE/v04/api/payroll/{id}/calcs/{calcId})

## `POST /v04/api/payroll/{id}/cancel-invoices`

**Cancels the invoice or payment processing for the given Payroll calculations.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | The id of the Payroll. |
| `excludePeriodicInvoices` | query | boolean |  | If true, does not return periodic invoices. Only calculation specific invoices are returned. |

Request body: `string[]` (required)

Response: `PayrollDetails`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/payroll/POST/v04/api/payroll/{id}/cancel-invoices)

## `POST /v04/api/payroll/{id}/preview-invoices`

**Previews the invoices for the given Payroll calculations.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | The id of the Payroll. |
| `excludePeriodicInvoices` | query | boolean |  | If true, does not return periodic invoices. Only calculation specific invoices are returned. |

Request body: `string[]` (required)

Response: `InvoicePreview[]`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/payroll/POST/v04/api/payroll/{id}/preview-invoices)

## `POST /v04/api/payroll/{id}/create-invoices`

**Creates the invoices for the given Payroll calculations.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | The id of the Payroll. |
| `excludePeriodicInvoices` | query | boolean |  | If true, does not return periodic invoices. Only calculation specific invoices are returned. |

Request body: `string[]` (required)

Response: `Invoice[]`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/payroll/POST/v04/api/payroll/{id}/create-invoices)
