Assignments

Assignments #

Assignments relate Transactions that have opposite effects on the balance of the Account which they have in common. Assignable Transactions such as Client Receipts have Clearable Transactions such as Client Invoices assigned to them for clearance.

Properties #

Direct Properties #

PropertyTypeDefinition
TypeStringThe type of the Resource that is cleared by this assignment, either Transaction or Balance

Indirect Properties #

PropertyTypeDefinition
TransactionDictionaryThe Transaction being assigned
ClearedDictionaryThe Transaction being cleared
Forex AccountDictionaryIn case the Transactions are in a foreign currency, and there is a difference between the Exchange Rate of the Transaction being cleared and being assigned, the gain or loss from this difference is posted to this Account

Basics #

The parameters required to create an Assignment are the Id of the Transaction being assigned, a list of Id’s of the Resources to be cleared, the amount to be cleared on each and the type of each (Transaction or Balance).

Request #

curl --location --request POST 'api.microbooks.io/books/v1/assignment/assign-transactions' \
--data-raw '{
	"transaction_id": 1,
    "cleared_ids": [4,1],
    "cleared_amounts": [25,15],
    "cleared_types": ["Transaction","Balance"]
}'
import requests

url = "https://api.microbooks.io/books/v1/assignment/assign-transactions"
body = {
    "transaction_id": 1,
    "cleared_ids": [4,1],
    "cleared_amounts": [25,15],
    "cleared_types": ["Transaction","Balance"]
}
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/assignment/assign-transactions',
    'headers': {'Authorization': 'Bearer <bearer_token>'},
    'body': '{
        "transaction_id": 1,
        "cleared_ids": [4,1],
        "cleared_amounts": [25,15],
        "cleared_types": ["Transaction","Balance"]
    }'
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
$client = new Client();
$body = '{
    "transaction_id": 1,
    "cleared_ids": [4,1],
    "cleared_amounts": [25,15],
    "cleared_types": ["Transaction","Balance"]
}';
$request = new Request('POST', 'https://api.microbooks.io/books/v1/assignment/assign-transactions', 
    [headers' => ['Authorization' => 'Bearer <bearer_token>']], 
    $body
);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
var client = new RestClient("https://api.microbooks.io/books/v1/assignment/assign-transactions");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = "{
    \"transaction_id\": 1,
    \"cleared_ids\": [4,1],
    \"cleared_amounts\": [25,15],
    \"cleared_types\": [\"Transaction\",\"Balance\"]
}";
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": "Journal Entry: JN01/0001 for 100.00 Transactions assigned successfully"
    "assigned": [
        {
            "id": 4,
            "amount": 25,
            "type": "Transaction"
        },
        {
            "id": 1,
            "amount": 15,
            "type": "Balance"
        }
    ]
}

Variations #

Bulk Assignment #

When a settlement is made against the outanding balance on an Account without specifying which individual Transactions should be assigned to it, calling this endpoint will assign the amount on the settlling Transaction to the outstanding Transactions on the Account on a First in First out basis until its exhausted.

Request #

curl --location --request POST 'api.microbooks.io/books/v1/assignment/bulk-assign-outstanding' \
--data-raw '{
	"transaction_id": 1
}'
import requests

url = "https://api.microbooks.io/books/v1/assignment/bulk-assign-outstanding"
body = {
    "transaction_id": 1,
}
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/assignment/bulk-assign-outstanding',
    'headers': {'Authorization': 'Bearer <bearer_token>'},
    'body': '{
        "transaction_id": 1,
    }'
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});
$client = new Client();
$body = '{
    "transaction_id": 1,
}';
$request = new Request('POST', 'https://api.microbooks.io/books/v1/assignment/bulk-assign-outstanding', 
    [headers' => ['Authorization' => 'Bearer <bearer_token>']], 
    $body
);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
var client = new RestClient("https://api.microbooks.io/books/v1/assignment/bulk-assign-outstanding");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = "{
    \"transaction_id\": 1,
}";
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": "Journal Entry: JN01/0001 for 100.00 Transactions bulk assigned successfully",
    "assigned": [
        {
            "id": 4,
            "number": "JN01/0003",
            "amount": 75
        },
        {
            "id": 6,
            "number": "JN01/0005",
            "amount": 25
        }
    ]
}

Errors #

Below are the Errors that are returned by the Assignment Resource.

Detail CodeNameDefinition
101Missing EntityThe Assignment Resource requires an existing Entity because it is applied to Transactions, for the purpose of preparing Financial Statements which are scoped to an Entity
102Negative AmountAn Assignment cannot be made for negative amounts
103Mixed AssignmentA Transaction has been Cleared cannot be Assigned and vide versa
104Missing Forex AccountForex Account Resource selected for the Transaction does not exist
105Invalid Clearance EntryA Transaction in an Assignment must have the opposite effect on the balance of the Account to that of the Transaction being cleared
106Unclearable TransactionOnly Transactions of types Client Invoice, Supplier Bill and Journal Entry can be cleared
107Unassignable TransactionOnly Transactions of types Client Receipt, Supplier Payment, Credit Note, Debit Note and Journal Entry can be cleared
108OverclearanceA Transaction cannot be cleared beyond its total amount
109Self ClearanceA Transaction clearing itself is meaningless
110Insufficient BalanceThe Assignment Transaction has an unassigned amount less than the Assignment amount
111Missing Forex AccountThe Assignment requires a Forex Account where the differences from the Exchange Rates of the Assigned and Cleared Transactions will be posted
112Invalid Account TypeThe Forex Account must be of type Account::EQUITY if the Transaction being cleared is from a previous Reporting Period (A Balance Resource) or of type Account::NON_OPERATING_REVENUE if from within the current Reporting Period
113Unposted AssignmentA Transaction must be posted to be Assigned
114Invalid Clearance AccountThe Assignment and Cleared Transactions must have the same Main Account
115Invalid Clearance CurrencyThe Assignment and Cleared Transactions must have the same Main Currency
116Invalid ClearableThe Transaction or Balance Resource selected to be assigned does not exist
117Invalid TransactionCompound Transactions can neither be Assigned nor Cleared
nullResource Not FoundThe Transaction/Balance Resource could not be found