> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lerian.studio/llms.txt
> Use this file to discover all available pages before exploring further.

# TXT template

> Build a transaction receipt template in plain text with Reporter — a simple .tpl file that renders into a printable TXT proof of payment.

This page guides you through the creation of a transaction receipt template using **Reporter** in `.txt` format.

## Template code

***

<CodeGroup>
  ```text Text expandable theme={null}
  ##########################################
  #            PROOF OF PAYMENT            #
  ##########################################

  Generation Date: {% date_time "dd/MM/YYYY HH:mm" %}
  Ledger Name: {{ midaz_onboarding.ledger.0.name }}

  {%- for transaction in midaz_transaction.transaction %}
  -----------------------------------------
  Transaction ID: {{ transaction.id }}
  Transaction Date: {{ transaction.created_at }}
  Total Amount: {{ transaction.amount }}
  Transaction Status: {{transaction.status}}
  ------------------------------------------

  Source Accounts:
  {%- for operation in filter(midaz_transaction.operation, "transaction_id", transaction.id) %} 
  {%- if operation.type == "DEBIT" %} 
  - Alias: {{operation.account_alias }} 
  - Debit Amount: {{ operation.amount }} 
  {%- endif %}
  {%- endfor %}

  Target Accounts:
  {%- for operation in filter(midaz_transaction.operation, "transaction_id", transaction.id) %} 
  {%- if operation.type == "CREDIT" %} 
  - Alias: {{operation.account_alias }} 
  - Credit Value: {{operation.amount }} 
  {%- endif %}
  {%- endfor %}

  {%- endfor %}
  ------------------------------------------
  Automatically generated document.
  ```
</CodeGroup>

## Code breakdown

***

\*\* `Generation Date: {% date_time "dd/MM/YYYY HH:mm" %}`\*\*

Renders the **current date and time** when the template is processed.

* Uses the format `dd/MM/YYYY HH:mm` (e.g., `26/05/2025 11:45`).

\*\* `Ledger Name: {{ midaz_onboarding.ledger.0.name }}`\*\*

Displays the **name of the ledger** associated with this report.

* `midaz_onboarding.ledger` is a list, and `[0]` selects the **first ledger**.
* `.name` fetches the name property, like `"Corporate Ledger"`.

\*\* `{% for transaction in midaz_transaction.transaction %}`\*\*

This loop iterates over **each transaction** in the `midaz_transaction.transaction` list. For every transaction, the code below will run once to display its information.

### Transaction header block

Each transaction prints the following details:

<CodeGroup>
  ```txt Text theme={null}
  -----------------------------------------
  Transaction ID: {{ transaction.id }}
  Transaction Date: {{ transaction.created_at }}
  Total Amount: {{ transaction.amount }}
  Transaction Status: {{ transaction.status }}
  ------------------------------------------
  ```
</CodeGroup>

* `transaction.id`: Unique ID of the transaction.
* `transaction.created_at`: Timestamp when the transaction was created.
* `transaction.amount`: The raw amount of the transaction.
* `transaction.status`: Current status such as `COMPLETED`, `PENDING`, or `FAILED`.

### Source accounts section

<CodeGroup>
  ```txt Text theme={null}
  Source Accounts:
  {% for operation in filter(midaz_transaction.operation, "transaction_id", transaction.id) %}
    {% if operation.type == "DEBIT" %}
      - Alias: {{ operation.account_alias }}
      - Debit Amount: {{ operation.amount }}
    {% endif %}
  {% endfor %}
  ```
</CodeGroup>

* Filters the operations list to include only operations linked to the **current transaction**.
* Further filters it to only show operations with `type == "DEBIT"` (funds leaving an account).
* For each matching debit:
  * Displays the **account alias**.
  * Displays the **debit amount**.

### Target accounts section

<CodeGroup>
  ```txt Text theme={null}
  Target Accounts:
  {% for operation in filter(midaz_transaction.operation, "transaction_id", transaction.id) %}
    {% if operation.type == "CREDIT" %}
      - Alias: {{ operation.account_alias }}
      - Credit Value: {{ operation.amount }}
    {% endif %}
  {% endfor %}
  ```
</CodeGroup>

* Same logic as the debit block, but filters for `type == "CREDIT"` (funds received).
* For each matching credit:
  * Displays the **account alias**.
  * Displays the **credit amount**.

### Footer text

<CodeGroup>
  ```text Text theme={null}
  ------------------------------------------
  Automatically generated document.
  ```
</CodeGroup>

* Simple text footer that marks the end of the report.
* Indicates that the file was generated automatically, typically for traceability.

## Template output

***

<CodeGroup>
  ```text Text expandable theme={null}
  ##########################################
  #            PROOF OF PAYMENT            #
  ##########################################

  Generation Date: 23/05/2025 14:08
  Ledger Name: Rice, Rowe and O'Hara

  -----------------------------------------
  Transaction ID: 75906707-8c31-479c-b354-aa805c4cefbc
  Transaction Date: 2025-05-22T14:15:22.123Z
  Total Amount: 5000.00
  Transaction Status: ACTIVE
  ------------------------------------------

  Source Accounts:
  - Alias: @external|USD 
  - Debit Amount: 1500.00

  Target Accounts:
  - Alias: @wallet_12345 
  - Credit Value: 1500.00

  ------------------------------------------
  Automatically generated document.
  ```
</CodeGroup>
