Execution Rules

Execution is a transaction that will perform, in a unique and atomic way, one or more financial entries (double-entries in debit and credit) and return the ID of the created transaction.

The rules for execution determine the accounting mapping of each entry involved and its order of execution, control of the balance of each part and which accounts will be received as an input parameter at the time of its creation, with up to two accounts permitted.

The rules for execution are controlled by transaction type, which are terms freely chosen by the user.

Entries

The entries are the debits and credits that will be executed atomically in the transaction and must have their accounting functioning mapped.

Entry types

The entry types are terms freely chosen by the user, except for the main_amount type, which refers to the main value informed when creating the transaction. The main_amount type is usually mapped as the first in a list of entries, but is not mandatory if the execution receives the value zero during its creation.

Entry order

Each entry receives a number to order its sequential execution as determined by the user. Entries are carried out in this order, first debits and then credits.

Source of accounts

For both debits and credits, the source of the account involved must be specified. This can be one of the accounts mapped and created as unique in the system (unique_account) or originating from one of the accounts that were informed in the transaction input parameters (param_account_1 or param_account_2).

Accounts descriptions

For both debits and credits, the description of the account involved must be specified. The description must exist in the account rules record.

Balance type

For both debits and credits, you must specify the type of balance to be moved. The balance type must exist, for that account description, in the account rules record. The permitted types are available, pending and blocked.

Balance validation

For both debits and credits, you must specify what type of balance validation will be carried out. The allowed validations are:

Validation
Description

positive

the system will not allow the desired balance to become negative

negative

the system will not allow the desired balance to become positive

no_validation

the system will not validate the desired balance

Create or Update an Execution Rule

The PUT /execution_rules method is used to create or update an execution rule individually or in batch, based on the transaction_type field.

Example of creating/updating rules:

PUT /execution_rules

{
  "data": [
    {
      "transaction_type": "pix_in",
      "param_account_1": true,
      "param_account_2": false,
      "entries": [
        {
          "entry_type": "main_amount",
          "entry_order": 1,
          "debit_account_source": "unique_account",
          "debit_account_description": "spi",
          "debit_balance_type": "available",
          "debit_balance_validation": "negative",
          "credit_account_source": "param_account_1",
          "credit_account_description": "payment_account",
          "credit_balance_type": "available",
          "credit_balance_validation": "no_validation"
        }
      ]
    }  
  ]
}

Delete of an Execution Rule

The DELETE /execution_rules method is used do delete an execution rule individually or in batch.

Example of deleting rules:

DELETE /execution_rules?transaction_types=[<transaction_types>]

Execution Rules query

The GET /execution_rules method is used to query the rules.

Rules query example:

GET /execution_rules

Example response:

{
  "data": [
    {
      "transaction_type": "pix_in",
      "param_account_1": true,
      "param_account_2": false,
      "entries": [
        {
          "entry_type": "main_amount",
          "entry_order": 1,
          "debit_account_source": "unique_account",
          "debit_account_description": "spi",
          "debit_balance_type": "available",
          "debit_balance_validation": "negative",
          "credit_account_source": "param_account_1",
          "credit_account_description": "payment_account",
          "credit_balance_type": "available",
          "credit_balance_validation": "no_validation"
        }
      ]
    }  
  ]
}

Last updated