# Calculations

Salary Calculations CRUD functionality as well as additional helper methods.

Salaxy API v03, **Finland only**. 22 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/calculations`

**Returns list of all calculations for the current employer. Both editable and readonly calculations are returned.**

| 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: `PageResultOfCalculationListItem`

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

## `POST /v03/api/calculations`

**Creates or updates a calculation.**

Request body: `Calculation` (required)

Response: `Calculation`

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

## `GET /v03/api/calculations/set`

**Returns Calculation objects for given identifiers.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `ids` | query | string[] |  | Unique identifiers for the objects. |

Response: `Calculation[]`

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

## `GET /v03/api/calculations/employment/{employmentId}`

**Gets the Calculation objects for a specific Employment relation.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `employmentId` | path | string | yes | The employment relation for which to list the Calculations. |

Response: `Calculation[]`

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

## `GET /v03/api/calculations/employment/set`

**Returns Calculation objects for given Employment relations.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `employmentIds` | query | string[] |  | Set of employmentIds for which to get the Calculation objects. |

Response: `Calculation[]`

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

## `GET /v03/api/calculations/{id}`

**Gets a single Calculation object based on identier**

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

Response: `Calculation`

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

## `DELETE /v03/api/calculations/{id}`

**Deletes a Calculation 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/calculations/DELETE/v03/api/calculations/{id})

## `GET /v03/api/calculations/new`

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

Response: `Calculation`

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

## `GET /v03/api/calculations/copy/{id}`

**Gets a copy of a paid or template calculation and creates a new draft based on that calculation.
Note that this method just returns a copy of the calculation, it does not save it yet to the DB.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Unique identifier for the object |
| `startDate` | query | string |  | Work start date for the new salary calculation |
| `endDate` | query | string |  | Work end date for the new salary calculation |
| `numberOfDays` | query | integer |  | &amp;gt;Number of days for the new calculation. |

Response: `Calculation`

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

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

**Cancels the invoice or payment processing for the given calculation.
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 Calculation to be cancelled. |

Response: `Calculation`

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

## `GET /v03/api/calculations/repair/{id}`

**Gets a copy of a paid calculation for repair.**

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

Response: `Calculation`

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

## `POST /v03/api/calculations/repair`

**Updates the repair calculation.**

Request body: `ReportingCalculation` (required)

Response: `Calculation`

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

## `POST /v03/api/calculations/repair/commit`

**Replaces the original calculation with the given calculation.
The original id field of the calculation is used to identify the original calculation.**

Request body: `ReportingCalculation` (required)

Response: `Calculation`

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

## `GET /v03/api/calculations/{id}/document-flow`

**Returns document flow for the given calculation.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Id of the calculation |

Response: `DocumentFlowItem`

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

## `POST /v03/api/calculations/sharing/{calculationId}`

**Create or remove a sharing to a given calculation.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `calculationId` | path | string | yes | Identifier of the calculation. |
| `type` | query | SharingUriType |  | Sharing method. For typical sharing scenarios, use 'url'. |
| `employerId` | query | string |  | Id of the employer to share the calculation with. |
| `to` | query | string |  | Employer email address. |
| `cc` | query | string |  | Adress for the copy of the email. |
| `message` | query | string |  | Message to the employer. |

Response: `CalculationSharing`

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

## `POST /v03/api/calculations/sharing/{calculationId}/notification`

**Notify the employer from the shared calculation.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `calculationId` | path | string | yes | Identifier of the calculation. |
| `to` | query | string |  | Employer email address. |
| `cc` | query | string |  | Adress for the copy of the email. |
| `message` | query | string |  | Message to the employer. |

Response: `boolean`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api.md#tag/calculations/POST/v03/api/calculations/sharing/{calculationId}/notification)

## `POST /v03/api/calculations/update-from-employment`

**Updates a calculation from employment relation by deleting all the rows and re-setting the employment.
If the calculation has an ID, it is saved, if not it is just recalculated.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `save` | query | boolean |  | If true, saves the calculation. If false just recalculates. If omitted, saves if the calculation has an id, otherwise just recalculates. The null value may be removed when all clients are updated (defaults to false). |
| `updateRows` | query | boolean |  | If true, updates also the default salary rows from employment data to calculation. False updates only other employment data. Null currently defaults to True for backward compatibility, but it may be removed (or default to false) in future versions (when all clients are updated). |

Request body: `Calculation` (required)

Response: `Calculation`

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

## `POST /v03/api/calculations/update-to-employment`

**Updates (saves) the employment related information from Calculation to Employment relation.
Currently only updates rows, OccupationCode and WorkDescription.**

Request body: `Calculation` (required)

Response: `string`

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

## `POST /v03/api/calculations/worktime`

**Gets the worktime data for Period recalculation from raw calc fetching holidays and absences data from storage.
These determine how holiday salaries etc. and absence deductions will be added as rows to calculations.
The idea is that user can still modify these before the actual calculation is done as often manual adjustments need to be made.
Also, providers that do not use HolidayYears and Absences can skip this step and use recalculate-worktime directly.**

Request body: `Calculation` (required)

Response: `CalcWorktime`

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

## `GET /v03/api/calculations/epr/{id}`

**Gets the EarningsPayment object for a specific calculation.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | The calculation for which to list the EarningsPayments. |

Response: `object`

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

## `POST /v03/api/calculations/epr`

**Converts a calculation to EarningsPayment object.**

Request body: `ReportingCalculation` (required)

Response: `object`

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

## `POST /v03/api/calculations/ir`

**Saves the IR related data (rows and salary date) to a calculation.**

Request body: `Calculation` (required)

Response: `Calculation`

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