GET /api/daily_allowances/:id
Show daily allowance details


PUT /api/daily_allowances/:id/approve
Approve daily allowance. If daily allowance params are present, updates the daily allowance before approval

Approves expense. If params of the expense are present, updates the expense before approval


POST /api/daily_allowances/:id/disapprove
Disapprove daily allowance

Disapprove expense with a comment

Params

Param name Description
comment
optional

The reason of expense disapproval; will be displayed to user

Validations:

  • Must be a String


GET /api/daily_allowances/:id/conditional_values
Get values for the conditional fields of the daily allowance


GET /api/daily_allowances
Get the list of daily allowances

Get the list of all daily allowances accessible by the current user. Can be paginated and/or filtered by daily allowance state

Params

Param name Description
archived_after
optional

Return only daily allowances accounted on and after the supplied date. Date format: YYYYMMDD (example: 20180702)

Validations:

  • Must be a String

page
optional

Return only one page of daily allowances. Default per-page is 10

Validations:

  • Must be a Integer

per_page
optional

Number of daily allowances returned per page. Works only in combination with “page” param. Default value is 10

Validations:

  • Must be a Integer

state
optional

Validations:

  • Must be one of: draft, reviewing, unapproved, queue, accounted.


POST /api/daily_allowances
Create a daily allowance

Creates a new daily allowance

Params

Param name Description
draft
optional

If 1, the daily allowance is saved as a draft without validation.

Validations:

  • Must be a Integer

daily_allowance
required

Daily allowance hash

Validations:

  • Must be a Hash

daily_allowance[description]
required

Daily allowance description

Validations:

  • Must be a String

daily_allowance[date]
optional , nil allowed

Daily allowance date

Validations:

  • Must be a String

daily_allowance[cost_center_ids]
optional , nil allowed

Legacy/mobile only: cost center IDs applied to the first (or only) line. Ignored when “lines_attributes” is supplied

Validations:

  • Must be an array of Integer

daily_allowance[lines_attributes]
optional , nil allowed

Cost-center split lines. Each line carries its own cost centers and a percentage share of the cost; percentages must sum to exactly 1.0. Omit to keep legacy single cost-center behavior via “cost_center_ids”.

Validations:

  • Must be an Array of nested elements

daily_allowance[lines_attributes][id]
optional , nil allowed

Line ID (required for update)

Validations:

  • Must be a Integer

daily_allowance[lines_attributes][percentage]
required

Share of the cost as a fraction, e.g. “0.6” for 60%

Validations:

  • Must be a String

daily_allowance[lines_attributes][cost_center_ids]
optional , nil allowed

Cost center IDs for this line

Validations:

  • Must be an array of Integer

daily_allowance[lines_attributes][_destroy]
optional , nil allowed

Set to true to remove this line on update

Validations:

  • Must be one of: true, false, 1, 0.

daily_allowance[entries_attributes]
required

Daily allowance entries (country + time range)

Validations:

  • Must be an Array of nested elements

daily_allowance[entries_attributes][id]
optional , nil allowed

Entry ID (required for update)

Validations:

  • Must be a Integer

daily_allowance[entries_attributes][country_id]
required

ID of the Allowance country

Validations:

  • Must be a Integer

daily_allowance[entries_attributes][start_time]
required

Entry start time

Validations:

  • Must be a String

daily_allowance[entries_attributes][end_time]
required

Entry end time

Validations:

  • Must be a String

daily_allowance[free_meal_days_attributes]
optional , nil allowed

Free meal days

Validations:

  • Must be an Array of nested elements

daily_allowance[free_meal_days_attributes][id]
optional , nil allowed

Free meal day ID (for updates)

Validations:

  • Must be a Integer

daily_allowance[free_meal_days_attributes][date]
required

Date in YYYY-MM-DD format

Validations:

  • Must be a String

daily_allowance[free_meal_days_attributes][is_full]
optional , nil allowed

Whether the day is a full day

Validations:

  • Must be one of: true, false, 1, 0.

daily_allowance[free_meal_days_attributes][had_breakfast]
optional , nil allowed

Whether breakfast was provided

Validations:

  • Must be one of: true, false, 1, 0.

daily_allowance[free_meal_days_attributes][had_lunch]
optional , nil allowed

Whether lunch was provided

Validations:

  • Must be one of: true, false, 1, 0.

daily_allowance[free_meal_days_attributes][had_dinner]
optional , nil allowed

Whether dinner was provided

Validations:

  • Must be one of: true, false, 1, 0.

daily_allowance[free_meal_days_attributes][breakfast_is_taxable]
optional , nil allowed

Whether breakfast is taxable (Swedish calculator only)

Validations:

  • Must be one of: true, false, 1, 0.

daily_allowance[free_meal_days_attributes][lunch_is_taxable]
optional , nil allowed

Whether lunch is taxable (Swedish calculator only)

Validations:

  • Must be one of: true, false, 1, 0.

daily_allowance[free_meal_days_attributes][dinner_is_taxable]
optional , nil allowed

Whether dinner is taxable (Swedish calculator only)

Validations:

  • Must be one of: true, false, 1, 0.


PUT /api/daily_allowances/:id
Update a daily allowance

Updates a daily allowance

Params

Param name Description
draft
optional

If 1, a draft daily allowance is left as a draft without validation.

Validations:

  • Must be a Integer

daily_allowance
required

Daily allowance hash

Validations:

  • Must be a Hash

daily_allowance[description]
optional

Daily allowance description

Validations:

  • Must be a String

daily_allowance[date]
optional , nil allowed

Daily allowance date

Validations:

  • Must be a String

daily_allowance[cost_center_ids]
optional , nil allowed

Legacy/mobile only: cost center IDs applied to the first (or only) line. Ignored when “lines_attributes” is supplied

Validations:

  • Must be an array of Integer

daily_allowance[lines_attributes]
optional , nil allowed

Cost-center split lines. Each line carries its own cost centers and a percentage share of the cost; percentages must sum to exactly 1.0. Omit to keep legacy single cost-center behavior via “cost_center_ids”.

Validations:

  • Must be an Array of nested elements

daily_allowance[lines_attributes][id]
optional , nil allowed

Line ID (required for update)

Validations:

  • Must be a Integer

daily_allowance[lines_attributes][percentage]
optional

Share of the cost as a fraction, e.g. “0.6” for 60%

Validations:

  • Must be a String

daily_allowance[lines_attributes][cost_center_ids]
optional , nil allowed

Cost center IDs for this line

Validations:

  • Must be an array of Integer

daily_allowance[lines_attributes][_destroy]
optional , nil allowed

Set to true to remove this line on update

Validations:

  • Must be one of: true, false, 1, 0.

daily_allowance[entries_attributes]
optional

Daily allowance entries (country + time range)

Validations:

  • Must be an Array of nested elements

daily_allowance[entries_attributes][id]
optional , nil allowed

Entry ID (required for update)

Validations:

  • Must be a Integer

daily_allowance[entries_attributes][country_id]
optional

ID of the Allowance country

Validations:

  • Must be a Integer

daily_allowance[entries_attributes][start_time]
optional

Entry start time

Validations:

  • Must be a String

daily_allowance[entries_attributes][end_time]
optional

Entry end time

Validations:

  • Must be a String

daily_allowance[free_meal_days_attributes]
optional , nil allowed

Free meal days

Validations:

  • Must be an Array of nested elements

daily_allowance[free_meal_days_attributes][id]
optional , nil allowed

Free meal day ID (for updates)

Validations:

  • Must be a Integer

daily_allowance[free_meal_days_attributes][date]
optional

Date in YYYY-MM-DD format

Validations:

  • Must be a String

daily_allowance[free_meal_days_attributes][is_full]
optional , nil allowed

Whether the day is a full day

Validations:

  • Must be one of: true, false, 1, 0.

daily_allowance[free_meal_days_attributes][had_breakfast]
optional , nil allowed

Whether breakfast was provided

Validations:

  • Must be one of: true, false, 1, 0.

daily_allowance[free_meal_days_attributes][had_lunch]
optional , nil allowed

Whether lunch was provided

Validations:

  • Must be one of: true, false, 1, 0.

daily_allowance[free_meal_days_attributes][had_dinner]
optional , nil allowed

Whether dinner was provided

Validations:

  • Must be one of: true, false, 1, 0.

daily_allowance[free_meal_days_attributes][breakfast_is_taxable]
optional , nil allowed

Whether breakfast is taxable (Swedish calculator only)

Validations:

  • Must be one of: true, false, 1, 0.

daily_allowance[free_meal_days_attributes][lunch_is_taxable]
optional , nil allowed

Whether lunch is taxable (Swedish calculator only)

Validations:

  • Must be one of: true, false, 1, 0.

daily_allowance[free_meal_days_attributes][dinner_is_taxable]
optional , nil allowed

Whether dinner is taxable (Swedish calculator only)

Validations:

  • Must be one of: true, false, 1, 0.


POST /api/daily_allowances/calculate_cost
Get the cost of the Daily Allowance

Get the total cost, deduction cost, and taxalbe with tax (Swedish calculator only) of the daily allowance in cents, based on year values, entries, and free meals.

Examples

[
  {
    "entries": [
      {
        "country_id": 1,
        "start_time": 1716890400,
        "end_time": 1716976800
      }
    ],
    "year":2024,
    "free_meal_days": [
      {
        "date": "2024-05-28",
        "is_full": true,
        "had_lunch": true,
        "had_dinner": true
      }
      ],
      "user_id": 1,
      "time_zone": "Europe/Helsinki",
      "is_reverse": false
  }
] 

Params

Param name Description
user_id
required

Allowance User id

Validations:

  • Must be a Integer

time_zone
optional

Used Timezone

Validations:

  • Must be a Integer

year
required

Year in which allowance happens.

Validations:

  • Must be a Integer

is_reverse
required

If the allowance is a reverse of the other allowance

Validations:

  • Must be one of: true, false, 1, 0.

free_meal_days
required

An array with the specific meals attributes. At least one item should be present

Validations:

  • Must be a String

date
required

Date in YYYY-MM-DD format.

Validations:

  • Must be a String

is_full
required

Whether the day corresponding to that “free meal day” is a “full day” or a “half day”.

Validations:

  • Must be one of: true, false, 1, 0.

had_breakfast
optional

True if user had breakfast on that day. Only specific Allowance countries have breakfast free meals enabled.

Validations:

  • Must be one of: true, false, 1, 0.

had_lunch
optional

True if user had lunch on that day.

Validations:

  • Must be one of: true, false, 1, 0.

had_dinner
optional

True if user had dinner on that day.

Validations:

  • Must be one of: true, false, 1, 0.

breakfast_is_taxable
optional

Defines if breakfast is taxable (Swedish calculator only).

Validations:

  • Must be one of: true, false, 1, 0.

lunch_is_taxable
optional

Defines if lunch is taxable (Swedish calculator only).

Validations:

  • Must be one of: true, false, 1, 0.

dinner_is_taxable
optional

Defines if dinner is taxable (Swedish calculator only).

Validations:

  • Must be one of: true, false, 1, 0.

entries
required

An array with the specific entry attributes (country, start/end time in UNIX format) to pass to calculator. At least one item should be present in array

Validations:

  • Must be an Array of nested elements

entries[country_id]
required

ID of the Allowance country

Validations:

  • Must be a Integer

entries[start_time]
required

Start time in unix format: the seconds timestamp of the given date.

Validations:

  • Must be a Integer

entries[end_time]
required

End time in unix format: the seconds timestamp of the given date.

Validations:

  • Must be a Integer

Returns

Code: 200

Description:

Daily Allowance costs break down in cents

Param name Description
subtotal
required

Total cost of the Daily Allowance.

Validations:

  • Must be a Integer

deduction
required

Meal Deduction cost of the Daily Allowance.

Validations:

  • Must be a Integer

taxable
required

Total amount for taxalbe meals, including tax (Swedish calculator only).

Validations:

  • Must be a Integer

tax
required

Total tax (Swedish calculator only).

Validations:

  • Must be a Integer