Line Items

Line Items #

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

Tax Inclusive prices #

Problem #

You want to create a Line Item whose amount is inclusive of the Tax attached to the item.

Solution #

Tax Inclusive flag #

You can Create a Tax inclusive Line Item by calling the create Line Item endpoint with the tax_inclusive flag set to true.

Multiple Taxes
Tax inclusive Line Items can only have one Tax attached to them.

Request #

curl --location --request POST 'api.microbooks.io/books/v1/transaction' \
--data-raw '{
	"account_id": 1,
	"narration": "Test line item",
	"amount": 100,
	"tax_inclusive": true
}'
import requests

url = "https://api.microbooks.io/books/v1/transaction"
body = {
    "account_id": 1,
	"narration": "Test line item",
	"amount": 100,
	"tax_inclusive": true
}
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/transaction',
    'headers': {'Authorization': 'Bearer <bearer_token>'},
    'body': '{
        "account_id": 1,
        "narration": "Test line item",
        "amount": 100,
	    "tax_inclusive": true
    }'
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
$client = new Client();
$body = '{
    "account_id": 1,
	"narration": "Test line item",
	"amount": 100,
	"tax_inclusive": true
}';
$request = new Request('POST', 'https://api.microbooks.io/books/v1/transaction', 
    [headers' => ['Authorization' => 'Bearer <bearer_token>']], 
    $body
);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
var client = new RestClient("https://api.microbooks.io/books/v1/transaction");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = "{
    \"account_id\": 1,
	\"narration\": \"Test line item\",
	\"amount\": 100,
	\"tax_inclusive\": true
}";
request.AddParameter("text/plain", body,  ParameterType.RequestBody);
request.AddHeader("Authorization", "Bearer " + <bearer_token>);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Compound Taxes #

Problem #

You want to create a Line Item whose Taxes are applied in series, which each subsequent Tax being applied on the amount inclusive of already applied Taxes.

Solution #

Compound Tax flag #

You can Create a Compound Tax Line Item by calling the create Line Item endpoint with the compound_tax flag set to true.

Zero Rated Taxes
Line Items with Zero Rated Taxes attached cannot have compound Taxes.

Request #

curl --location --request POST 'api.microbooks.io/books/v1/transaction' \
--data-raw '{
	"account_id": 1,
	"narration": "Test line item",
	"amount": 100,
	"compound_tax": true
}'
import requests

url = "https://api.microbooks.io/books/v1/transaction"
body = {
    "account_id": 1,
	"narration": "Test line item",
	"amount": 100,
	"compound_tax": true
}
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/transaction',
    'headers': {'Authorization': 'Bearer <bearer_token>'},
    'body': '{
        "account_id": 1,
        "narration": "Test line item",
        "amount": 100,
	    "compound_tax": true
    }'
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
$client = new Client();
$body = '{
    "account_id": 1,
	"narration": "Test line item",
	"amount": 100,
	"compound_tax": true
}';
$request = new Request('POST', 'https://api.microbooks.io/books/v1/transaction', 
    [headers' => ['Authorization' => 'Bearer <bearer_token>']], 
    $body
);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
var client = new RestClient("https://api.microbooks.io/books/v1/transaction");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = "{
    \"account_id\": 1,
	\"narration\": \"Test line item\",
	\"amount\": 100,
	\"compound_tax\": true
}";
request.AddParameter("text/plain", body,  ParameterType.RequestBody);
request.AddHeader("Authorization", "Bearer " + <bearer_token>);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);