# Entries

Entries (_entry_) are financial movements between registered balances in the form of double-entry bookkeeping (a debit and a credit) at the time of transaction execution.

Each Entry represents a specific event and in a transaction. One or more Entries can be atomically recorded, such as the principal amount of a transaction along with a specific fee.

Along with the Entries, the system records - atomically during the transaction - the Statements (_journal_) of each involved account, both for debits and credits.

Entries capture all the necessary information for the analysis of the transaction history:

| Field                       | Description                                                                        |
| --------------------------- | ---------------------------------------------------------------------------------- |
| _id_                        | Unique identifier of the entry                                                     |
| _external\_id_              | User-defined identifier for the entry at the time of transaction creation          |
| _parent\_transaction\_id_   | User-defined identifier for a prior transaction related to the current transaction |
| _transaction\_id_           | Transaction identifier                                                             |
| _transaction\_type_         | Transaction type used                                                              |
| _entry\_order_              | Order of creation of the entry as determined in the _setup_                        |
| _entry\_type_               | User-defined identifier name for the current entry                                 |
| _currency_                  | Currency used in the entry                                                         |
| _amount_                    | Value of the entry                                                                 |
| _debit\_balance\_id_        | Identifier of the debited balance                                                  |
| _debit\_balance\_after_     | Balance amount after the debit                                                     |
| _debit\_balance\_seq\_num_  | Sequential value movement of the debited balance                                   |
| _credit\_account\_id_       | Identifier of the credited balance                                                 |
| _credit\_balance\_after_    | Balance amount after the credit                                                    |
| _credit\_balance\_seq\_num_ | Sequential value movement of the credited balance                                  |
| _created\_at_               | Creation datetime of the transaction                                               |
| _settled\_at_               | Reference date of the transaction (optionally provided)                            |

## Entries Query <a href="#entries-query" id="entries-query"></a>

The Entries can be queried using the GET /transaction/{id}/entry method, using parameters as shown in the following example.

Example of Entry query:

```json
GET /transaction/96296a5c-0cf4-4025-dbc4-1a53f0a3afc6/entry
```

Response example:

```json
{
  "entries": [
    {
      "id": "ea355ff5-6a2e-a57e-708c-7ab94e79c7f6",
      "external_id": "our id 1234",
      "parent_transaction_id": "ea355ff5-6a2e-a57e-708c-7ab94e79c7f6",
      "transaction_id": "96296a5c-0cf4-4025-dbc4-1a53f0a3afc6",
      "transaction_type": "card_purchase",
      "entry_order": 1,
      "entry_type": "main_amount",
      "currency": "brl",
      "amount": 10000,
      "debit_balance_id": "a8f5f167-f44f-4964-e6c9-98dee827110c",
      "debit_balance_after": 300,
      "debit_balance_seq_num": 345,
      "credit_balance_id": "3634bee6-1e59-f282-4f76-d61db9007f70",
      "credit_balance_after": 10000,
      "credit_balance_seq_num": 12361,
      "created_at": "2023-06-05T11:26:17.325Z",
      "settled_at": "2023-06-05",
      "metadata": {
        "key": "value"  
      }
    }
  ]
}
```
