# Payroll

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

Salaxy API v03, **Finland only**. 14 operations. Interactive version: [REST API reference](https://code.salaxy.com/reference/rest-api.md). Machine-readable: [OpenAPI document](https://code.salaxy.com/openapi/salaxy-03.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 /v03/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.md#tag/payroll/GET/v03/api/payroll)

## `POST /v03/api/payroll`

**Updates or creates a new Payroll object**

Request body: `PayrollDetails` (required)

Response: `PayrollDetails`

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

## `GET /v03/api/payroll/odata`

**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.md#tag/payroll/GET/v03/api/payroll/odata)

## `GET /v03/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.md#tag/payroll/GET/v03/api/payroll/{id})

## `DELETE /v03/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.md#tag/payroll/DELETE/v03/api/payroll/{id})

## `GET /v03/api/payroll/new`

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

Response: `PayrollDetails`

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

## `POST /v03/api/payroll/validate`

**Validates a Payroll object without storing it to the database.**

Request body: `PayrollDetails` (required)

Response: `PayrollDetails`

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

## `POST /v03/api/payroll/add-employment`

**Adds new calculations to the payroll and saves the payroll object.
The calculations are added based on employment relation ID's.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `ids` | query | string |  | A comma separated list of employment relation id's for which the a new calculation is added to the Payroll list. Also supports personal ID's when personal ID has an active employment relation as of SalaryDate (currently supports only Employers of up to 500 employment relations). |

Request body: `PayrollDetails` (required)

Response: `PayrollDetails`

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

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

**Saves changes to a Calculation that is part of a Payroll and returns the Paryoll validation data.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Payroll ID where calculation belongs to. Note, that the current implementation does not assure that the calculation is within a Payroll nor set the salary date and the payment channel for the Payroll. This may later be added without that being a breaking change. |

Request body: `Calculation` (required)

Response: `Calculation`

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

## `POST /v03/api/payroll/add-calc`

**Adds existing calculations to the payroll and saves the payroll object.
If calculation is read-only, a copy is made. If it is draft, the calculation is moved.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `ids` | query | string |  | A comma separated list of calculation id's that are copied / moved to the Payroll list. |

Request body: `PayrollDetails` (required)

Response: `PayrollDetails`

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

## `POST /v03/api/payroll/delete-calc`

**Remove calculations from the payroll and saves the payroll object.
The calculations are completely deleted.
This can only be done if the calculations and the payroll have not been paid yet.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `ids` | query | string |  | A comma separated list of calculation id's that are deleted. |

Request body: `PayrollDetails` (required)

Response: `PayrollDetails`

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

## `POST /v03/api/payroll/unlink-calc`

**Remove calculations from the payroll and saves the payroll object.
The calculations are unlinked and they become individual calculations in the draft list (and can then be processed individually).
This can only be done if the calculations and the payroll have not been paid yet.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `ids` | query | string |  | A comma separated list of calculation id's that are unlinked from the Payroll list. |

Request body: `PayrollDetails` (required)

Response: `PayrollDetails`

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

## `GET /v03/api/payroll/cancel/{id}`

**Cancels the invoice or payment processing for the given payroll.
Please note that this is possible only if the payment channel supports the cancel action.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Identifier of the Payroll to be cancelled. |

Response: `PayrollDetails`

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

## `GET /v03/api/payroll/{id}/absences`

**Gets absences for a single payroll report.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Payroll ID for which to fetch the absences. |

Response: `WorkerAbsencePeriod[]`

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