Balances

Step 3: Balances #

Balances are amounts outstanding from transactions in previous reporting periods. The arise when Balance Sheet accounts have not been cleared at the end of a period and are carried forward into the next.

We will create opening balances for all the Balance Sheet accounts created in Step 2 except the ones to do with Taxation and the Fixed Asset. The Transaction Date should be the last date of the previous year.

Capital Account Balance #

Request #

curl --location --request POST 'https://api.microbooks.io/books/v1/balance' \
--header "Authorization: Bearer <bearer_token>" \
--data-raw '{
    "account_id": "<id of Capital Account created in Step 2>",
    "balance_type": "CREDIT",
    "transaction_type": "JN",
    "transaction_date": "20XX-12-31", 
    "balance": 100
}'
import requests

url = "https://api.microbooks.io/books/v1/balance"
body = {
    "account_id": "<id of Capital Account created in Step 2>",
    "balance_type": "CREDIT",
    "transaction_type": "JN",
    "transaction_date": "20XX-12-31", 
    "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': '{
        "account_id": "<id of Capital Account created in Step 2>",
        "balance_type": "CREDIT",
        "transaction_type": "JN",
        "transaction_date": "20XX-12-31", 
        "balance": 100
    }'
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
$client = new Client();
$body = '{
    "account_id": "<id of Capital Account created in Step 2>",
    "balance_type": "CREDIT",
    "transaction_type": "JN",
    "transaction_date": "20XX-12-31", 
    "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 = "{
    \"account_id\": "<id of Capital Account created in Step 2>",
    \"balance_type\": \"CREDIT\",
    \"transaction_type\": \"JN\",
    \"transaction_date\": \"20XX-12-31\", 
    \"balance\": 100
}";
request.AddParameter("text/plain", body,  ParameterType.RequestBody);
request.AddHeader("Authorization", "Bearer " + <bearer_token>);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Response #

{
    "status": "success",
    "message": "Credit Balance: Capital Account for year 2022 created successfully",
    "resource": {
        "reporting_period_id": 1,
        "exchange_rate_id": 1,
        "balance_type": "CREDIT",
        "account_id": "1",
        "transaction_date": "2021-11-23",
        "balance": 100,
        "currency_id": 1,
        "transaction_no": "1USD2022",
        "entity_id": 1,
        "id": 1,
        "transaction_name": "Journal Entry",
        "amount": 100,
        "type": "Credit",
        "is_posted": true,
        "is_credited": true,
        "exchange_rate": {...},
        "account": {...},
        "currency": {...},
        "reporting_period": {...}
    }
}

Bank Account Balance #

curl --location --request POST 'https://api.microbooks.io/books/v1/balance' \
--header "Authorization: Bearer <bearer_token>" \
--data-raw '{
    "account_id": "<id of Bank Account created in Step 2>",
    "balance_type": "DEBIT",
    "transaction_type": "JN",
    "transaction_date": "20XX-12-31", 
    "balance": 100
}'
import requests

url = "https://api.microbooks.io/books/v1/balance"
body = {
    "account_id": "<id of Bank Account created in Step 2>",
    "balance_type": "DEBIT",
    "transaction_type": "JN",
    "transaction_date": "20XX-12-31", 
    "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': '{
        "account_id": "<id of Bank Account created in Step 2>",
        "balance_type": "DEBIT",
        "transaction_type": "JN",
        "transaction_date": "20XX-12-31", 
        "balance": 100
    }'
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
$client = new Client();
$body = '{
    "account_id": "<id of Bank Account created in Step 2>",
    "balance_type": "DEBIT",
    "transaction_type": "JN",
    "transaction_date": "20XX-12-31", 
    "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 = "{
    \"account_id\": "<id of Bank Account created in Step 2>",
    \"balance_type\": \"DEBIT\",
    \"transaction_type\": \"JN\",
    \"transaction_date\": \"20XX-12-31\", 
    \"balance\": 100
}";
request.AddParameter("text/plain", body,  ParameterType.RequestBody);
request.AddHeader("Authorization", "Bearer " + <bearer_token>);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Response #

{
    "status": "success",
    "message": "Debit Balance: Bank Account for year 2022 created successfully",
    "resource": {
        "reporting_period_id": 1,
        "exchange_rate_id": 1,
        "balance_type": "DEBIT",
        "account_id": "2",
        "transaction_date": "2021-11-23",
        "balance": 100,
        "currency_id": 1,
        "transaction_no": "2USD2022",
        "entity_id": 1,
        "id": 2,
        "transaction_name": "Journal Entry",
        "amount": 100,
        "type": "Debit",
        "is_posted": true,
        "is_credited": false,
        "exchange_rate": {...},
        "account": {...},
        "currency": {...},
        "reporting_period": {...}
    }
}

Receivable Account Balance #

curl --location --request POST 'https://api.microbooks.io/books/v1/balance' \
--header "Authorization: Bearer <bearer_token>" \
--data-raw '{
    "account_id": "<id of Receivable Account created in Step 2>",
    "balance_type": "DEBIT",
    "transaction_type": "IN",
    "transaction_date": "20XX-12-31", 
    "balance": 100
}'
import requests

url = "https://api.microbooks.io/books/v1/balance"
body = {
    "account_id": "<id of Receivable Account created in Step 2>",
    "balance_type": "DEBIT",
    "transaction_type": "IN",
    "transaction_date": "20XX-12-31", 
    "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': '{
        "account_id": "<id of Receivable Account created in Step 2>",
        "balance_type": "DEBIT",
        "transaction_type": "IN",
        "transaction_date": "20XX-12-31", 
        "balance": 100
    }'
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
$client = new Client();
$body = '{
    "account_id": "<id of Receivable Account created in Step 2>",
    "balance_type": "DEBIT",
    "transaction_type": "IN",
    "transaction_date": "20XX-12-31", 
    "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 = "{
    \"account_id\": "<id of Receivable Account created in Step 2>",
    \"balance_type\": \"DEBIT\",
    \"transaction_type\": \"IN\",
    \"transaction_date\": \"20XX-12-31\", 
    \"balance\": 100
}";
request.AddParameter("text/plain", body,  ParameterType.RequestBody);
request.AddHeader("Authorization", "Bearer " + <bearer_token>);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Response #

{
    "status": "success",
    "message": "Debit Balance: Receivable Account for year 2022 created successfully",
    "resource": {
        "reporting_period_id": 1,
        "exchange_rate_id": 1,
        "balance_type": "DEBIT",
        "account_id": "3",
        "transaction_date": "2021-11-23",
        "balance": 100,
        "currency_id": 1,
        "transaction_no": "3USD2022",
        "entity_id": 1,
        "id": 3,
        "transaction_name": "Client Invoice",
        "amount": 100,
        "type": "Debit",
        "is_posted": true,
        "is_credited": false,
        "exchange_rate": {...},
        "account": {...},
        "currency": {...},
        "reporting_period": {...}
    }
}

Payable Account Balance #

curl --location --request POST 'https://api.microbooks.io/books/v1/balance' \
--header "Authorization: Bearer <bearer_token>" \
--data-raw '{
    "account_id": "<id of Payable Account created in Step 2>",
    "balance_type": "CREDIT",
    "transaction_type": "BL",
    "transaction_date": "20XX-12-31", 
    "balance": 100
}'
import requests

url = "https://api.microbooks.io/books/v1/balance"
body = {
    "account_id": "<id of Payable Account created in Step 2>",
    "balance_type": "CREDIT",
    "transaction_type": "BL",
    "transaction_date": "20XX-12-31", 
    "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': '{
        "account_id": "<id of Payable Account created in Step 2>",
        "balance_type": "CREDIT",
        "transaction_type": "BL",
        "transaction_date": "20XX-12-31", 
        "balance": 100
    }'
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
$client = new Client();
$body = '{
    "account_id": "<id of Payable Account created in Step 2>",
    "balance_type": "CREDIT",
    "transaction_type": "BL",
    "transaction_date": "20XX-12-31", 
    "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 = "{
    \"account_id\": "<id of Payable Account created in Step 2>",
    \"balance_type\": \"CREDIT\",
    \"transaction_type\": \"BL\",
    \"transaction_date\": \"20XX-12-31\", 
    \"balance\": 100
}";
request.AddParameter("text/plain", body,  ParameterType.RequestBody);
request.AddHeader("Authorization", "Bearer " + <bearer_token>);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Response #

{
    "status": "success",
    "message": "Credit Balance: Payable Account for year 2022 created successfully",
    "resource": {
        "reporting_period_id": 1,
        "exchange_rate_id": 1,
        "balance_type": "CREDIT",
        "account_id": "5",
        "transaction_date": "2021-11-23",
        "balance": 100,
        "currency_id": 1,
        "transaction_no": "5USD2022",
        "entity_id": 1,
        "id": 4,
        "transaction_name": "Supplier Bill",
        "amount": 100,
        "type": "Credit",
        "is_posted": true,
        "is_credited": true,
        "exchange_rate": {...},
        "account": {...},
        "currency": {...},
        "reporting_period": {...}
    }
}

Opening Balance Sheet #

To verify that the balances have been posted correctly you can use the opening-balances endpoint. The credit and debit values should match exactly.

Request #

curl --location --request GET 'https://api.microbooks.io/books/v1/balance/opening-balances' \
--header "Authorization: Bearer <bearer_token>" 
import requests

url = "https://api.microbooks.io/books/v1/balance/opening-balances"
body = {}
headers = {"Authorization": "Bearer <bearer_token>"}
response = requests.request("GET", url, headers=headers, json=body)

print(response.text)
var request = require('request');

var options = {
    'method': 'GET',
    'url': 'https://api.microbooks.io/books/v1/balance/opening-balances',
    'headers': {'Authorization': 'Bearer <bearer_token>'},
    'body': null
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
$client = new Client();
$body = null;
$request = new Request('GET', 'https://api.microbooks.io/books/v1/balance/opening-balances', 
    [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/opening-balances");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer " + <bearer_token>);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Response #

{
    "status": "success",
    "balances": {
        "balances": {
        "debit": 200,
        "credit": -200
    },
    "accounts": [...]
    }
}

For more details on the Balance endpoint check out the How To Guide page as well as the Postman API Reference.