Advancements Balances

This section describes the API of the Advancements balances resource. A balance present a balance of the expenses and the advancements of an user in an organization in a currency.

Parameters

amount: float
currency: string
payer: JSON object
receiver: JSON object

Example of Balance

    {
      "amount": 1256.33,
      "currency": "USD",
      "payer": {
        "id": 1,
        "name": "Company Inc.",
        "type": "Organization"
      },
      "receiver": {
        "id": 1,
        "name": "John",
        "type": "User",
      },
    }
    

List balances

List all balances of the current user logged in the request.

Available payers and available receivers

In the same response body. This API will respond all available payers and receivers for filtering.

Definition

GET https://app.rexpense.com/api/v1/advancements/balances

Example request

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

Response Example Success

HTTP 200 OK
    {
      "available_payers" : [
        {"id": 1, "name": "Company Inc.", ...},
      ],
      "available_receivers" : [
        {"id": 1, "name": "John Snow", ...},
      ],
      "my_balances" : {
        "count": 1,
        "objects" : [{
          "amount": 56.33,
          "currency": "BRL",
          "payer": {
            "id": 1,
            "name": "Company Inc.",
            "type": "Organization"
          },
          "receiver": {
            "id": 1,
            "name": "John",
            "type": "User",
          },
        }]
      },
      "other_balances" : {
        "count": 0,
        "objects" : []
      }
    }
    

List organizations balances

List all balances from the organizations where the current logged in user is Administrator or Manager. The balances collection does not include any information about the current logged in user (this can be achievied in the endpoint above).

Parameters

page: integer
per_page: integer limit to 100

Definition

GET https://app.rexpense.com/api/v1/advancements/balances/organizations

Example request

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

Response Example Success

HTTP 200 OK
    {
      "count": 3,
      "current_page": 1,
      "total_pages": 2,
      "balances": [
        {
          "amount": 956.66,
          "currency": "JPY",
          "payer": {
            "id": 1,
            ...
          },
          "receiver": {
            "id": 1,
            ...
          }
        },
        ...
      ]
    }
    

Show balance

Show a balance according to the given user (receiver_id), organization (payer_id) and currency.

Parameters

payer_id: integer required
receiver_id: integer required
currency: string required

Definition

GET https://app.rexpense.com/api/v1/advancements/balances/:payer_id

Example request

$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/advancements/balances/1 \
      -H 'Accept: application/json' \
      -H 'Content-type: application/json' \
      -d '{"currency":"USD","receiver_id":1}'
    

Response Example Success

HTTP 200 OK
    {
      "amount": 956.66,
      "currency": "USD",
      "payer": {
        "id": 1,
        ...
      },
      "receiver": {
        "id": 1,
        ...
      }
    }
    

Filtering advancement balances

You can filter the list of advancement balances.

Parameters

All parameters must be nested a 'q' parameter.

Payers and Receivers

You have to use the information provided in the nodes available_payers and available_receivers to filter those fields.

balance_gteq: float
balance_lteq: float
receiver_id: integer
payer_id: integer
currency: string

Definition

GET https://app.rexpense.com/api/v1/advancements/balances

Request example

$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/advancements/balances \
      -H 'Accept: application/json' \
      -H 'Content-type: application/json' \
      -d '{"q": {"currency":"BRL"}}'

Response Example

    {
      "available_payers" : [
        {"id": 1, "name": "Company Inc.", ...},
      ],
      "available_receivers" : [
        {"id": 1, "name": "John Snow", ...},
      ],
      "my_balances" : {
        "count": 1,
        "objects" : [{
          "amount": 1256.33,
          "currency": "BRL",
          "payer": {
            "id": 1,
            "name": "Company Inc.",
            "type": "Organization"
          },
          "receiver": {
            "id": 1,
            "name": "John",
            "type": "User",
          },
        }]
      },
      "other_balances" : {
        "count": 1,
        "objects" : [{
          "amount": 1256.33,
          "currency": "BRL",
          "payer": {
            "id": 1,
            "name": "Company Inc.",
            "type": "Organization"
          },
          "receiver": {
            "id": 1,
            "name": "John",
            "type": "User",
          },
        }]
      }
    }