# Calculator

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

Anonymous methods for calculating salary previews and testing without committing data to database.

Salaxy API v04 (beta), **Finland only**. 14 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/calculator/new`

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

Response: `Calculation`

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

## `POST /v04/api/calculator/recalculate`

**Takes in a calculation and recalculates it.**

Request body: `Calculation` (required)

Response: `Calculation`

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

## `POST /v04/api/calculator/recalculate-worktime`

**Recalculates the Worktime into the rest of the calculation:
Mainly adds (recreates) rows for absences and holidays to the calculation.**

Request body: `Calculation` (required)

Response: `Calculation`

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

## `POST /v04/api/calculator/recalculate-worktime/{type}`

**Returns the planned absence, holiday salary or holiday compensations rows based on holiday/absence calendar and settings or given periods.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `type` | path | string | yes | Type of the planned rows. |

Request body: `PlannedRowsRequest` (required)

Response: `UserDefinedRow[]`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/calculator/POST/v04/api/calculator/recalculate-worktime/{type})

## `POST /v04/api/calculator/worktime`

**Gets the worktime data for Period recalculation from raw calc, holidays andabsences data.
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.
NOTE: This is the anonymous method that can be called without storage.
There is a corresponding method in Calculations-service that fetches the holidayYear and Absences automatically.**

Request body: `PeriodRecalculationData` (required)

Response: `CalcWorktime`

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

## `POST /v04/api/calculator/salary`

**Sets the salary for the calculation and returns it with full recalculated data.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `kind` | query | SalaryKind |  | Type of the salary being calculated |
| `amount` | query | number |  | Amount of e.g. hours, months for the salary. Default is 1. |
| `price` | query | number |  | Price of one unit - e.g. hour, month. |
| `unit` | query | string |  | E.g. hour, month. Typically this parameter can be left empty/null and the unit is set according to type. |
| `message` | query | string |  | Optional message for the salary row that is shown in reports. If null, will be set according to type. |
| `isHouseholdDeductible` | query | boolean |  | If set to true, will calculate the household deduction. Applies only to natural persons - as oppsed to companies. |
| `taxDeductionCategories` | query | TaxDeductionWorkCategories |  | If tax IsHouseholdDeductible is set to true, please also select the category (categories). Note that "OwnPropety" is a default, it does not need to be set: Only set RelativesProperty if necessary. |

Request body: `Calculation` (required)

Response: `Calculation`

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

## `POST /v04/api/calculator/workerset`

**Sets the a worker with the specified ID to the given calculation and returns the calculation with full data.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `profileId` | query | string |  | Text identifying the person that should be set as the Worker. Value is one of the following: 1) Guid: Identifier of the real existing Person object 2) "me": Sets the current authenticated user as the worker 3) "new": Creates a new Person object that is editable by the employer and sets that as the Worker 4) "example-[17/pensioner/default]": Sets the Person as one of the predefined example Persons |

Request body: `Calculation` (required)

Response: `Calculation`

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

## `POST /v04/api/calculator/taxdeduction`

**Sets the household deduction true or false and returns the calculation with full data.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `setHouseHoldDeduction` | query | boolean |  | If true, the household deduction (kotitalousvähennys) is calculated as part of the salary calculation. |

Request body: `Calculation` (required)

Response: `Calculation`

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

## `POST /v04/api/calculator/work`

**Stores information about the work type start- and end date as well as Framework and returns the calculation with full data.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `type` | query | FrameworkAgreement |  | Type of the work framework |
| `subType` | query | TesSubtype |  | Subtype when one framework has several options |
| `isTesIncludedInSalary` | query | boolean |  | Marker that the payments defined by framework agreement are included in the salary (will not be added by the calculation). |
| `unionPayment` | query | UnionPaymentType |  | Type of the union payment |
| `unionPaymentPercent` | query | number |  | Percent of the union payment |
| `numberOfDays` | query | integer |  | Number of days may affect calculation of different payments calculated based on a Framework agreement |
| `dailyTravelExpenses` | query | number |  | Travel expences per day |
| `dailyTravelExpensesKm` | query | number |  | The amount of kilometers travelled by day - used to define the amount of travel expenses in aomse framework agreements. |
| `dailyExpenses` | query | number |  | Daily expenses amount |
| `isYksityisenHoidonTuki` | query | boolean |  | If true will calculate the Finnish child care subsidy |
| `yksityisenHoidonTukiAmount` | query | number |  | Amount of Finnish child care subsidy |
| `isEntrepreneurPensionContract` | query | boolean |  | If true, the Worker has his own entrepreneur contract. |
| `isEntrepreneurPensionContractForFarmer` | query | boolean |  | If true, the Worker has his own Pension farmer contract. |
| `isEntrepreneurPensionContractForAthlete` | query | boolean |  | If true, the Worker has his own Pension farmer contract. |
| `startDate` | query | string |  | Work start date |
| `endDate` | query | string |  | Work end date |
| `description` | query | string |  | Detail description of the work (e.g. when framework is Other). |

Request body: `Calculation` (required)

Response: `Calculation`

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

## `POST /v04/api/calculator/setunionpayment`

**Changes the union payment for the calculation and returns it with full data recalculated.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `paymentType` | query | UnionPaymentType |  | Type of the union payment - some known types also se the the percent (e.g. Raksa). |
| `unionPaymentPercent` | query | number |  | Percent for the union payment- default is zero. |

Request body: `Calculation` (required)

Response: `Calculation`

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

## `POST /v04/api/calculator/addrow`

**Adds a calculation row: An expenses, benefits or other such row and returns the recalculated calculation with full data.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `rowType` | query | CalculationRowType |  | Type of the calculation row that should be added |
| `message` | query | string |  | Message text for end user - used in salary calculation |
| `price` | query | number |  | Price for the row (e.g. €/h, €/km, €/month. Default is 0. |
| `count` | query | number |  | Count of the items - default is 1. |
| `sourceId` | query | string |  |  |

Request body: `Calculation` (required)

Response: `Calculation`

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

## `POST /v04/api/calculator/deleterow`

**Deletes a calculation row: Expenses, benefits etc. item and returns the recalculated calculation with full data.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `rowIndex` | query | integer |  | Zero based row index of the row that should be deleted. |

Request body: `Calculation` (required)

Response: `Calculation`

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

## `GET /v04/api/calculator/yearlyNumbers/{forDate}`

**Gets salary calculation parameters that are changing yearly.
The method is designed for the end-of-year and as such it only supports 2 years:
the current / previous year (from Jan to Nov) OR current / next year (in approx. December).**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `forDate` | path | string | yes | Date for which the numbers are fetched |

Response: `YearlyChangingNumbers`

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

## `GET /v04/api/calculator/yearlyHolidays/{forDate}`

**Returns holidays for the given year.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `forDate` | path | string | yes | Year for which the holidays are fetched |

Response: `YearlyHolidays`

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