Accountabilities

This section describes the API of the accountability resource.

Parameters

id: integer
title: string
description: string
status: string
Valid statuses: opened, ready_to_review, analyzed, approved, finished
expense_ids: Array of expense_ids
payer: JSON object
receiver: JSON object

Example of Accountability

    {
      "id": 1,
      "title": "Accountability title",
      "description": "Accountability description",
      "status": "opened",
      "expense_ids": [1, 2],
      "payer": {
        "id": 1,
        "name": "Company Inc.",
        "type": "Organization",
        "logo": [
          {
            "style": "original",
            "url": "https://rexpense-uploads.s3.amazonaws.com/organization_logo/1/original/logo.png",
            "expiration": "2014-06-27T20:31:43Z"
          },
          {
            "style": "medium",
            "url": "https://rexpense-uploads.s3.amazonaws.com/organization_logo/1/medium/logo.png",
            "expiration": "2014-06-27T20:31:43Z"
          },
          {
            "style": "thumb",
            "url": "https://rexpense-uploads.s3.amazonaws.com/organization_logo/1/thumb/logo.png",
            "expiration": "2014-06-27T20:31:43Z"
          }
          {
            "style": "tiny",
            "url": "https://rexpense-uploads.s3.amazonaws.com/organization_logo/1/tiny/logo.png",
            "expiration": "2014-06-27T20:31:43Z"
          }
        ]
      },
      "receiver": {
        "id": 1,
        "name": "John",
        "type": "User",
        "avatar": [
          {
            "style": "original",
            "url": "https://rexpense-uploads.s3.amazonaws.com/user_avatar/1/original/avatar.png",
            "width": 716,
            "height": 655,
            "expiration": "2014-06-27T20:31:43Z"
          },
          {
            "style": "medium",
            "url": "https://rexpense-uploads.s3.amazonaws.com/user_avatar/1/medium/avatar.png",
            "width": 300,
            "height": 300,
            "expiration": "2014-06-27T20:31:43Z"
          },
          {
            "style": "thumb",
            "url": "https://rexpense-uploads.s3.amazonaws.com/user_avatar/1/thumb/avatar.png",
            "width": 100,
            "height": 100,
            "expiration": "2014-06-27T20:31:43Z"
          }
          {
            "style": "tiny",
            "url": "https://rexpense-uploads.s3.amazonaws.com/user_avatar/1/tiny/avatar.png",
            "width": 48,
            "height": 48,
            "expiration": "2014-06-27T20:31:43Z"
          }
        ]
      }
    }
    

List all accountabilities

Parameters

page: integer
per_page: integer limit to 100

Definition

GET https://app.rexpense.com/api/v1/accountabilities

Example Request

$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/accountabilities \
      -H 'Accept: application/json' \
      -H 'Content-type: application/json'

Response Example

    {
      "count": 1,
      "accountabilities": [
        {
          'id' => 1,
          'title' => "Agrupamento de contas da viagem a SP",
          'description' => "Viagem de negócios",
          'status' => 'opened',
          'activities_count' => 1,
          'payer' => ...,
          'receiver' => ...
        }
      ]
    }
    

Create an accountability

Accountabilities can be created without expenses, and you can update the accountability with new expenses.

Parameters

title: string
description: string
expense_ids: Array of integers
payer: payer object attributes required
id: integer
type: string
receiver: receiver object attributes required
id: integer
type: string

Definition

PUT/PATCH https://app.rexpense.com/api/v1/accountability/:id

Example Request

$ curl -u $YOUR_API_TOKEN:X -X PATCH https://app.rexpense.com/api/v1/accountability/:id \
        -H 'Accept: application/json' \
        -H 'Content-type: application/json' \
        -d '{"title": "titulo atualizado", "expense_ids": [1, 2, 3]}'

Response Example Success

HTTP 200 OK
    {
      "id": 1,
      ...
    }
    

Example Response Failure when update expense_ids and accountability not have opened status

HTTP 402 Payment Required
    {
      "errors": {
        "message": "Expenses can not be changed when accountability not have opened status"
      }
    }
    

Show an accountability

This request shows the accountability complete information.

Parameters

id: integer required

Definition

GET https://app.rexpense.com/api/v1/accountability/:id

Example Request

$ curl -u $YOUR_API_TOKEN:X -X POST https://app.rexpense.com/api/v1/accountability/1 \
        -H 'Accept: application/json' \
        -H 'Content-type: application/json'

Response Example Success

HTTP 200 OK
    {
      "id": 1,
      ...
    }
    

Response Example Failure

HTTP 404 Record Not Found
    {
      "errors": {
        "message": "Record Not Found"
      }
    }
    

Update an accountability

The accountability can be updated by any user, but a member can add or remove expenses when accountability have status opened. The analyst, manager and admin can add or remove expenses when accountability have status read_to_review.

Parameters

title: string
description: string
expense_ids: Array of integers
payer: payer object attributes required
id: integer
type: string
receiver: receiver object attributes required
id: integer
type: string

Definition

PUT/PATCH https://app.rexpense.com/api/v1/accountability/:id

Example Request

$ curl -u $YOUR_API_TOKEN:X -X PATCH https://app.rexpense.com/api/v1/accountability/:id \
        -H 'Accept: application/json' \
        -H 'Content-type: application/json' \
        -d '{"title": "titulo atualizado", "expense_ids": [1, 2, 3]}'

Response Example Success

HTTP 200 OK
    {
      "id": 1,
      ...
    }
    

Example Response Failure when update expense_ids and accountability not have opened status

HTTP 402 Payment Required
    {
      "errors": {
        "message": "Expenses can not be changed when accountability not have opened status"
      }
    }
    

Destroy an accountability

To destroy a accountability you have to be an Organization's Administrator or Manager (have any relation with the payer).

Definition

DELETE https://app.rexpense.com/api/v1/accountability/:id

Example Request

$ curl -u $YOUR_API_TOKEN:X -X DELETE https://app.rexpense.com/api/v1/accountability/:id \
        -H 'Accept: application/json' \
        -H 'Content-type: application/json'
      

Response Example

HTTP 204 NO CONTENT

Change accountability status

The accountability can have the status: ['opened', 'ready_to_review', 'analyzed', 'approved', 'finished']

opened means that the user is still adding expenses in accountability

read_to_review means that the accountability is ready to be reviwed by analysts, managers and admins. In this status only analysts, managers and admins can add or remove expenses from accountability

analyzed means that the accountability is ready to be approved

approved will verify if all expenses are approved and the prepare accountability to be finished

finished will execute actions to liquidate all expenses by yours liquidate forms (create reimbursement, change status to liquidated of expenses liquidated by advancement)

Parameters

status: string

Definition

PUT https://app.rexpense.com/api/v1/accountability/:id/status

Example Request

$ curl -u $YOUR_API_TOKEN:X -X PUT https://app.rexpense.com/api/v1/accountability/:id/status \
        -H 'Accept: application/json' \
        -H 'Content-type: application/json'
        -d '{"status": "finished"}'
      

Response Example