Skip to main content
This example shows how to structure an Analytical Financial Report focused on account-level transaction analysis, in HTML format. The report includes:
  • Organization and Ledger information.
  • Per-account breakdown.
  • Detailed operation list.

Template code


Code breakdown


Organization and Ledger information

<p><strong>Generation Date:</strong> {% date_time "dd/MM/YYYY HH:mm" %}</p> This function applies the date and time when the template is rendered, using the dd/MM/YYYY HH:mm format. <p><strong>Organization:</strong> {{ midaz_onboarding.organization.0.legal_name }}</p> This line renders the legal name of the first Organization associated with the onboarding data.
  • midaz_onboarding.organization: the list of Organizations in the system.
  • 0: fetches the first item in the list.
  • legal_name: fetches the value of the legal_name field.
<p><strong>Ledger:</strong> {{ midaz_onboarding.ledger.0.name }}</p> This line renders the name of the first Ledger associated with the onboarding data.
  • midaz_onboarding.ledger: the list of Ledgers in the system.
  • 0: fetches the first item in the list.
  • name: fetches the value of the name field.

Looping through accounts

{% for account in midaz_onboarding.account %} This loop goes through each account in the midaz_onboardTing.account list.
  • This list represents all accounts linked to a customer or associated with an onboarding flow.
  • For each iteration, it creates a new scope where account refers to one specific item in that list.
{% with balance = filter(midaz_transaction.balance, "account_id", account.id)[0] %} Inside the loop, this line:
  • Uses the filter function to find a balance from the midaz_transaction.balance list where the account_id matches the current account’s ID.
  • The [0] gets the first matching balance (assuming there’s only one per account).
  • The result is stored in a temporary variable called balance, scoped only within this block.

Account information

<div class="section-title">Account: {{ account.alias }}</div> Displays a section title with the account alias (a friendly or readable name for the account). <p><strong>ID:</strong> {{ account.id }}</p> Shows the unique identifier of the account. <p><strong>Currency:</strong> {{ balance.asset_code }}</p> Displays the currency code (like “BRL” or “USD”) associated with the account’s balance. <p><strong>Current Balance:</strong> {{ balance.available }} Shows the current available balance.

Operations information

{% for operation in midaz_transaction.operation %} This loops through all operations from the midaz_transaction.operation list. {% if operation.account_id == account.id %} This line checks whether the current operation is related to the current account in the outer loop (from your earlier block) and only proceeds if:
  • The operation’s account_id matches the account.id in focus.
{% set original_amount = operation.amount %} This line sets a temporary variable named original_amount and gives it the value of the amount field in the operation object. {% set discount_amount = original_amount * 0.03 %} This line calculates a 3% discount on the original amount.
  • The result is saved as discount_amount.
{% set final_amount = original_amount - discount_amount %} This line subtracts the discount from the original amount.
  • The final result is stored in final_amount, which can be rendered later.

Table columns

This block outputs a clean, readable table row for each operation, including the following information: <td>{{ operation.id }}</td> Unique identifier for the operation. <td>{{ operation.type }}</td> Type of operation, such as credit or debit. <td>{{ original_amount|floatformat:2 }}</td> Shows the original (unadjusted) amount, formatted with 2 decimal places. <td>{{ discount_amount|floatformat:2 }}</td> Displays the calculated discount, also with 2 decimal places. <td>{{ final_amount|floatformat:2 }}</td> Shows the final amount after applying the 3% discount, nicely formatted. <td>{{ operation.description }}</td> Renders the description or label of the operation, such as “Transfer to savings”.
This line renders a footer at the bottom of the document, indicating that the content was automatically generated using Reporter by Lerian.
  • It also includes the legal document number of the first organization linked to the onboarding data, pulled dynamically using the {{ midaz_onboarding.organization.0.legal_document }} placeholder.

Template output


Rendered output


Example financial report rendered from the HTML template code shown above

Figure 1. An example of a financial report rendered from the HTML code in the example.