Balances

Balances #

The sections below demonstrate how to solve common book keeping problems revolving around the Balance resource.

Outstanding Transaction Balances #

Problem #

You want to record the balances outstanding on individual Transactions that constitue the lumpsum balance of an Account. This allows for the clearing of the outstanding amounts in the new Reporting Period.

Solution #

Balance per Transaction #

A Balance Resource will need to be recorded for each of the Transactions by calling the Create Balance Endpoint for each. Passing the Transaction No as the reference of the Balance links the original with the balance

Request #

curl --location --request POST 'api.microbooks.io/books/v1/balance' \
--data-raw '{
    "currency_id" : 2,
    "exchange_rate_id" : 1,
    "account_id" : 1,
    "reference" : "IN01/0001",
    "reporting_period_id" : 2,
    "balance_type" : "DEBIT",
    "transaction_type" : "IN",
    "transaction_date" : "2021-10-21",
    "balance" : 100
}'
import requests

url = "https://api.microbooks.io/books/v1/balance"
body = {
    "currency_id" : 2,
    "exchange_rate_id" : 1,
    "account_id" : 1,
    "reference" : "IN01/0001",
    "reporting_period_id" : 2,
    "balance_type" : "DEBIT",
    "transaction_type" : "IN",
    "transaction_date" : "2021-10-21",
    "balance" : 100
}
headers = {"Authorization": "Bearer <bearer_token>"}

response = requests.request("POST", url, headers=headers, json=body)

print(response.text)
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://api.microbooks.io/books/v1/balance',
    'headers': {'Authorization': 'Bearer <bearer_token>'},
    'body': '{
        "currency_id" : 2,
        "exchange_rate_id" : 1,
        "account_id" : 1,
        "reference" : "IN01/0001",
        "reporting_period_id" : 2,
        "balance_type" : "DEBIT",
        "transaction_type" : "IN",
        "transaction_date" : "2021-10-21",
        "balance" : 100
    }'
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
$client = new Client();
$body = '{
    "currency_id" : 2,
    "exchange_rate_id" : 1,
    "account_id" : 1,
    "reference" : "IN01/0001",
    "reporting_period_id" : 2,
    "balance_type" : "DEBIT",
    "transaction_type" : "IN",
    "transaction_date" : "2021-10-21",
    "balance" : 100
}';
$request = new Request('POST', 'https://api.microbooks.io/books/v1/balance', 
    [headers' => ['Authorization' => 'Bearer <bearer_token>']], 
    $body
);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
var client = new RestClient("https://api.microbooks.io/books/v1/balance");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = "{
    \"currency_id\" : 2,
    \"exchange_rate_id\" : 1,
    \"reference\" : \"IN01/0001\",
    \"account_id\" : 1,
    \"reporting_period_id\" : 2,
    \"balance_type\" : \"DEBIT\",
    \"transaction_type\" : \"IN\",
    \"transaction_date\" : \"2021-10-21\",
    \"balance\" : 100
}";
request.AddParameter("text/plain", body,  ParameterType.RequestBody);
request.AddHeader("Authorization", "Bearer " + <bearer_token>);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Lumpsum Account Balance #

Problem #

You want to record the balance outstanding on an Account from a previous Reporting Period but individual Tranasctions cannot be identified/distinguished.

Solution #

Single Balance #

A single Balance Resource will be recorded for the whole amount by calling the Create Balance Endpoint. Passing a custom reference for identifying the balance in the Accounts’s schedules (eg 2022USD{account_id}]) may also be passed with the rest of the Balance’s attribues.

Request #

curl --location --request POST 'api.microbooks.io/books/v1/balance' \
--data-raw '{
    "currency_id" : 2,
    "exchange_rate_id" : 1,
    "account_id" : 1,
    "reference" : "2022USD16",
    "reporting_period_id" : 2,
    "balance_type" : "DEBIT",
    "transaction_type" : "IN",
    "transaction_date" : "2021-10-21",
    "balance" : 100
}'
import requests

url = "https://api.microbooks.io/books/v1/balance"
body = {
    "currency_id" : 2,
    "exchange_rate_id" : 1,
    "account_id" : 1,
    "reference" : "2022USD16",
    "reporting_period_id" : 2,
    "balance_type" : "DEBIT",
    "transaction_type" : "IN",
    "transaction_date" : "2021-10-21",
    "balance" : 100
}
headers = {"Authorization": "Bearer <bearer_token>"}

response = requests.request("POST", url, headers=headers, json=body)

print(response.text)
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://api.microbooks.io/books/v1/balance',
    'headers': {'Authorization': 'Bearer <bearer_token>'},
    'body': '{
        "currency_id" : 2,
        "exchange_rate_id" : 1,
        "account_id" : 1,
        "reference" : "2022USD16",
        "reporting_period_id" : 2,
        "balance_type" : "DEBIT",
        "transaction_type" : "IN",
        "transaction_date" : "2021-10-21",
        "balance" : 100
    }'
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
$client = new Client();
$body = '{
    "currency_id" : 2,
    "exchange_rate_id" : 1,
    "account_id" : 1,
    "reference" : "2022USD16",
    "reporting_period_id" : 2,
    "balance_type" : "DEBIT",
    "transaction_type" : "IN",
    "transaction_date" : "2021-10-21",
    "balance" : 100
}';
$request = new Request('POST', 'https://api.microbooks.io/books/v1/balance', 
    [headers' => ['Authorization' => 'Bearer <bearer_token>']], 
    $body
);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
var client = new RestClient("https://api.microbooks.io/books/v1/balance");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = "{
    \"currency_id\" : 2,
    \"exchange_rate_id\" : 1,
    \"reference\" : \"2022USD16\",
    \"account_id\" : 1,
    \"reporting_period_id\" : 2,
    \"balance_type\" : \"DEBIT\",
    \"transaction_type\" : \"IN\",
    \"transaction_date\" : \"2021-10-21\",
    \"balance\" : 100
}";
request.AddParameter("text/plain", body,  ParameterType.RequestBody);
request.AddHeader("Authorization", "Bearer " + <bearer_token>);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);