Taxation

Step 4: Taxes #

The quickstart scenario will feature Value Added Taxes (VAT). To keep things simple, we will only consider tax exclusive amounts (i.e. taxes are added onto the item amount).

Output VAT #

Output VAT is a tax that is added onto the amounts of items sold by the Entity. To create a Tax in the system. We need to specify a name, a short code and a rate. We’ll also need to include the account id of the Output Vat account created in step 2.

Request #

curl --location --request POST 'https://api.microbooks.io/books/v1/tax' \
--header "Authorization: Bearer <bearer_token>" \
--data-raw '{
    "name": "Output Vat",
    "code": "OTP",
    "rate": 10,
    "account_id": <id of a Output Vat account>
}'
import requests

url = "https://api.microbooks.io/books/v1/tax"
body = {
    "name": "Output Vat",
    "code": "OTP",
    "rate": 10,
    "account_id": <id of a Output Vat account>
}
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/tax',
    'headers': {'Authorization': 'Bearer <bearer_token>'},
    'body': '{
        "name": "Output Vat",
        "code": "OTP",
        "rate": 10,
        "account_id": <id of a Output Vat account>
    }'
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
$client = new Client();
$body = '{
    "name": "Output Vat",
    "code": "OTP",
    "rate": 10,
    "account_id": <id of a Output Vat account>
}';
$request = new Request('POST', 'https://api.microbooks.io/books/v1/tax', 
    [headers' => ['Authorization' => 'Bearer <bearer_token>']], 
    $body
);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
var client = new RestClient("https://api.microbooks.io/books/v1/tax");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = "{
    \"name\": \"Output Vat\",
    \"code\": \"OTP\"
    \"rate\": 10,
    \"account_id\": <id of a Output Vat account>
}";
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": "Tax: Output Vat (OTP) at 10.00% created successfully",
    "resource": {
        "name": "Output Vat",
        "code": "OTP",
        "rate": 10,
        "account_id": "<id of a Output Vat account>",
        "entity_id": 1,
        "id": 1,
        "account_type": [
            "CONTROL"
        ],
        "account": {
            "uuid": "e34d34f3-ea49-4765-a7cc-02f23f0e2c32",
            "id": "<id of a Output Vat account>",
            "entity_id": 1,
            "category_id": null,
            "currency_id": 1,
            "code": 2101,
            "name": "Output VAT Account",
            "description": null,
            "type": "Control",
            "is_closed": false
        }
    }
}

Input VAT #

Inpu VAT is a tax that is charged on items purchased by the Entity. The procedure for creating one is identical to that of the Output Vat, only the account id should be that of the Input Vat account created in step 2.

Request #

curl --location --request POST 'https://api.microbooks.io/books/v1/tax' \
--header "Authorization: Bearer <bearer_token>" \
--data-raw '{
    "name": "Input Vat",
    "code": "OTP",
    "rate": 10,
    "account_id": <id of a Input Vat account>
}'
import requests

url = "https://api.microbooks.io/books/v1/tax"
body = {
    "name": "Input Vat",
    "code": "OTP",
    "rate": 10,
    "account_id": <id of a Input Vat account>
}
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/tax',
    'headers': {'Authorization': 'Bearer <bearer_token>'},
    'body': '{
        "name": "Input Vat",
        "code": "OTP",
        "rate": 10,
        "account_id": <id of a Input Vat account>
    }'
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
$client = new Client();
$body = '{
    "name": "Input Vat",
    "code": "OTP",
    "rate": 10,
    "account_id": <id of a Input Vat account>
}';
$request = new Request('POST', 'https://api.microbooks.io/books/v1/tax', 
    [headers' => ['Authorization' => 'Bearer <bearer_token>']], 
    $body
);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
var client = new RestClient("https://api.microbooks.io/books/v1/tax");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = "{
    \"name\": \"Input Vat\",
    \"code\": \"OTP\"
    \"rate\": 10,
    \"account_id\": <id of a Input Vat account>
}";
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": "Tax: Input Vat (OTP) at 10.00% created successfully",
    "resource": {
        "name": "Input Vat",
        "code": "OTP",
        "rate": 10,
        "account_id": "<id of a Output Vat account>",
        "entity_id": 1,
        "id": 2,
        "account_type": [
            "CONTROL"
        ],
        "account": {
            "uuid": "c56cc14d-c199-4599-883c-d17af6210a3b",
            "id": "<id of a Output Vat account>",
            "entity_id": 1,
            "category_id": null,
            "currency_id": 1,
            "code": 2102,
            "name": "Input VAT Account",
            "description": null,
            "type": "Control",
            "is_closed": false
        }
    }
}

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