Saltar al contenido principal
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


<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Analytical Financial Report</title>
  <style>
    body {
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      background-color: #f4f6f9;
      color: #333;
      padding: 40px;
    }

    .container {
      max-width: 900px;
      margin: auto;
      background: #ffffff;
      padding: 30px 40px;
      border-radius: 8px;
      box-shadow: 0 0 10px rgba(0,0,0,0.1);
    }

    h1 {
      text-align: center;
      font-size: 24px;
      color: #004080;
      margin-bottom: 10px;
    }

    .subtitle {
      text-align: center;
      font-size: 14px;
      color: #777;
      margin-bottom: 30px;
    }

    .section-title {
      font-weight: bold;
      font-size: 16px;
      margin-top: 30px;
      margin-bottom: 10px;
      color: #004080;
      border-bottom: 1px solid #ccc;
      padding-bottom: 4px;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      margin-top: 15px;
    }

    th, td {
      padding: 10px;
      text-align: left;
      border: 1px solid #ccc;
    }

    th {
      background-color: #e8f0fe;
      font-weight: bold;
      color: #003366;
    }

    .info p {
      margin: 4px 0;
    }

    .footer {
      margin-top: 40px;
      text-align: center;
      font-size: 12px;
      color: #999;
    }
  </style>
</head>
<body>
  <div class="container">
    <h1>Analytical Financial Report</h1>
    <div class="subtitle">Detailed analysis of movements by linked accounts.</div>

    <div class="info">
      <p><strong>Generation Date:</strong> {% date_time "dd/MM/YYYY HH:mm" %}</p>
      <p><strong>Organization:</strong> {{ midaz_onboarding.organization.0.legal_name }}</p>
      <p><strong>Ledger:</strong> {{ midaz_onboarding.ledger.0.name }}</p>
    </div>

    {% for account in midaz_onboarding.account %}
      {% with balance = filter(midaz_transaction.balance, "account_id", account.id)[0] %}
        <div class="section-title">Account: {{ account.alias }}</div>
        <div class="info">
          <p><strong>ID:</strong> {{ account.id }}</p>
          <p><strong>Currency:</strong> {{ balance.asset_code }}</p>
          <p><strong>Current Balance:</strong> {{ balance.available }}</p>
        </div>

        <table>
          <thead>
            <tr>
              <th>Operation ID</th>
              <th>Type</th>
              <th>Original Amount</th>
              <th>Discount (3%)</th>
              <th>Final Amount</th>
              <th>Description</th>
            </tr>
          </thead>
          <tbody>
            {% for operation in midaz_transaction.operation %}
              {% if operation.account_id == account.id %}
                {% set original_amount = operation.amount %}
                {% set discount_amount = original_amount * 0.03  %}
                {% set final_amount = original_amount - discount_amount %}
                <tr>
                  <td>{{ operation.id }}</td>
                  <td>{{ operation.type }}</td>
                  <td>{{ original_amount|floatformat:2 }}</td>
                  <td>{{ discount_amount|floatformat:2 }}</td>
                  <td>{{ final_amount|floatformat:2 }}</td>
                  <td>{{ operation.description }}</td>
                </tr>
              {% endif %}
            {% endfor %}
          </tbody>
        </table>
      {% endwith %}
    {% endfor %}

    <div class="footer">
      Document generated automatically via Reporter - Lerian · {{ midaz_onboarding.organization.0.legal_document }}
    </div>
  </div>
</body>
</html>

Code breakdown


Organization and Ledger information

    <div class="info">
      <p><strong>Generation Date:</strong> {% date_time "dd/MM/YYYY HH:mm" %}</p>
      <p><strong>Organization:</strong> {{ midaz_onboarding.organization.0.legal_name }}</p>
      <p><strong>Ledger:</strong> {{ midaz_onboarding.ledger.0.name }}</p>
    </div>
<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 %}
      {% with balance = filter(midaz_transaction.balance, "account_id", account.id)[0] %}  
{% 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>
        <div class="info">
          <p><strong>ID:</strong> {{ account.id }}</p>
          <p><strong>Currency:</strong> {{ balance.asset_code }}</p>
          <p><strong>Current Balance:</strong> {{ balance.available }}</p>
        </div>
<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 %}
              {% if operation.account_id == account.id %}
                {% set original_amount = operation.amount %}
                {% set discount_amount = original_amount * 0.03  %}
                {% set final_amount = original_amount - discount_amount %}
{% 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

                <tr>
                  <td>{{ operation.id }}</td>
                  <td>{{ operation.type }}</td>
                  <td>{{ original_amount|floatformat:2 }}</td>
                  <td>{{ discount_amount|floatformat:2 }}</td>
                  <td>{{ final_amount|floatformat:2 }}</td>
                  <td>{{ operation.description }}</td>
                </tr>
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”.
    <div class="footer">
      Document generated automatically via Reporter - Lerian · {{ midaz_onboarding.organization.0.legal_document }}
    </div>
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


<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Analytical Financial Report</title>
  <style>
    body {
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      background-color: #f4f6f9;
      color: #333;
      padding: 40px;
    }

    .container {
      max-width: 900px;
      margin: auto;
      background: #ffffff;
      padding: 30px 40px;
      border-radius: 8px;
      box-shadow: 0 0 10px rgba(0,0,0,0.1);
    }

    h1 {
      text-align: center;
      font-size: 24px;
      color: #004080;
      margin-bottom: 10px;
    }

    .subtitle {
      text-align: center;
      font-size: 14px;
      color: #777;
      margin-bottom: 30px;
    }

    .section-title {
      font-weight: bold;
      font-size: 16px;
      margin-top: 30px;
      margin-bottom: 10px;
      color: #004080;
      border-bottom: 1px solid #ccc;
      padding-bottom: 4px;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      margin-top: 15px;
    }

    th, td {
      padding: 10px;
      text-align: left;
      border: 1px solid #ccc;
    }

    th {
      background-color: #e8f0fe;
      font-weight: bold;
      color: #003366;
    }

    .info p {
      margin: 4px 0;
    }

    .footer {
      margin-top: 40px;
      text-align: center;
      font-size: 12px;
      color: #999;
    }
  </style>
</head>
<body>
  <div class="container">
    <h1>Analytical Financial Report</h1>
    <div class="subtitle">Detailed analysis of movements by linked accounts.</div>

    <div class="info">
      <p><strong>Generation Date:</strong> 23/05/2025 14:08</p>
      <p><strong>Organization:</strong> Mante - Pfannerstill</p>
      <p><strong>Ledger:</strong> Rice, Rowe and O'Hara</p>
    </div>    
        <div class="section-title">Account: @external/USD</div>
        <div class="info">
          <p><strong>ID:</strong> 0196d97e-a58d-7814-8eb3-e510b818f6a5</p>
          <p><strong>Currency:</strong> USD</p>
          <p><strong>Current Balance:</strong> 499950.00</p>
        </div>

        <table>
          <thead>
            <tr>
              <th>Operation ID</th>
              <th>Type</th>
              <th>Original Amount</th>
              <th>Discount (3%)</th>
              <th>Final Amount</th>
              <th>Description</th>
            </tr>
          </thead>
          <tbody>            
                <tr>
                  <td>0196d982-4085-7e1d-b698-3aad306df721</td>
                  <td>CREDIT</td>
                  <td>500000.00</td>
                  <td>15000.00</td>
                  <td>485000.00</td>
                  <td>Duplicated account test</td>
                </tr>
                <tr>
                  <td>0196d983-a2c2-7dce-ad14-78eb36d9f2d1</td>
                  <td>DEBIT</td>
                  <td>20.00</td>
                  <td>0.60</td>
                  <td>19.40</td>
                  <td>Loan payment person1</td>
                </tr>
                <tr>
                  <td>0196d983-a2c2-7e0d-a246-45d5234138e3</td>
                  <td>DEBIT</td>
                  <td>30.00</td>
                  <td>0.90</td>
                  <td>29.10</td>
                  <td>Loan payment person1</td>
                </tr>
          </tbody>
        </table>      
    <div class="footer">
      Document generated automatically via Reporter - Lerian · 123.456.789-0001/00
    </div>
  </div>
</body>
</html>

Rendered output


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

I