> ## 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.

# Fees Engine

> Understand how the Fees Engine lets you define, simulate, and apply fee rules to Transactions in the Midaz Module.

The **Fees Engine** is a plugin available in the Midaz Module that allows you to configure and manage transaction fees through a visual interface. Define fee rules, test calculations, and apply charges to transactions without writing code.

## What is the Fees Engine?

***

The Fees Engine provides a complete fee management system that integrates with your Midaz Core infrastructure. It allows you to:

* **Define flexible fee rules**: Create fees based on flat amounts, percentages, or a combination of both
* **Target specific transactions**: Apply fees to particular transaction routes, segments, or ledgers
* **Set amount thresholds**: Configure minimum and maximum transaction amounts for fee application
* **Waive fees selectively**: Exempt specific accounts from fees when needed
* **Test before deploying**: Use the fee calculator to estimate charges before enabling them

## Accessing the Fees Engine

***

To access the Fees Engine in Lerian Console:

<Steps>
  <Step title="Open the Midaz Module">
    From the Lerian Console home page, select the Midaz product card.
  </Step>

  <Step title="Navigate to Plugins">
    In the left sidebar, locate the **Plugins** section.
  </Step>

  <Step title="Select Fees Engine">
    Click on **Fees Engine** to access the fee management interface.
  </Step>
</Steps>

## Key concepts

***

Before working with the Fees Engine, understand these core elements:

* **Fee Package**: A container that groups fee rules together and defines when they apply (transaction route, segment, amount range)
* **Fee Rule**: An individual fee configuration within a package that specifies how a fee is calculated
* **Application Rule**: The calculation method used—flat fee, percentage, or maximum between both
* **Reference Amount**: Whether percentage fees are calculated on the original transaction amount or after other fees
* **Priority**: The order in which multiple fees are applied within a package

## Available features

***

<Columns cols={2}>
  <Card title="Manage Fee Packages" icon="box" horizontal href="/en/platform/lerian-console/midaz-console/managing-fee-packages">
    Create, edit, and organize fee configurations for your transactions.
  </Card>

  <Card title="Create a Fee Package" icon="plus" horizontal href="/en/platform/lerian-console/midaz-console/fe-creating-a-package">
    Step-by-step guide to setting up a new fee package.
  </Card>

  <Card title="Edit a Fee Package" icon="pen" horizontal href="/en/platform/lerian-console/midaz-console/fe-editing-a-package">
    Update existing fee configurations and rules.
  </Card>

  <Card title="Delete a Fee Package" icon="trash" horizontal href="/en/platform/lerian-console/midaz-console/fe-deleting-a-package">
    Remove fee packages from your configuration.
  </Card>

  <Card title="Run Fee Estimations" icon="calculator" horizontal href="/en/platform/lerian-console/midaz-console/fe-fee-simulation">
    Test fee calculations before applying them to real transactions.
  </Card>
</Columns>

## How fees are calculated

***

When a transaction is processed, the Fees Engine:

1. **Matches the transaction** to applicable fee packages based on route, segment, and ledger
2. **Validates the amount** falls within the package's minimum and maximum range
3. **Checks for waivers** to see if the source account is exempt
4. **Applies fee rules** in priority order
5. **Calculates each fee** using the specified application rule and reference amount
6. **Credits fee accounts** with the calculated amounts

## Fee calculation types

***

The Fees Engine supports three calculation methods:

<AccordionGroup>
  <Accordion title="Flat fee">
    A fixed amount charged regardless of transaction value.

    **Example**: \$2.50 per transaction
  </Accordion>

  <Accordion title="Percentage">
    A percentage of the transaction amount.

    **Example**: 1.5% of $100 = $1.50 fee
  </Accordion>

  <Accordion title="Maximum between types">
    Applies whichever is higher between a flat amount and a percentage.

    **Example**: Max of \$1.00 or 2%

    * On $30: max($1.00, $0.60) = $1.00
    * On $100: max($1.00, $2.00) = $2.00
  </Accordion>
</AccordionGroup>

## Integration with Midaz Core

***

The Fees Engine works with your existing Midaz infrastructure:

* **Ledgers**: Scope fee packages to specific ledgers
* **Segments**: Apply different fee structures to customer segments
* **Transaction Routes**: Define which fees apply to which transaction flows
* **Accounts**: Designate accounts to receive fee credits and specify waived accounts

## Next steps

***

<CardGroup cols={2}>
  <Card title="Create your first Fee Package" icon="rocket" href="/en/platform/lerian-console/midaz-console/fe-creating-a-package">
    Get started by setting up fee rules for your transactions.
  </Card>

  <Card title="Test with Fee Estimation" icon="flask" href="/en/platform/lerian-console/midaz-console/fe-fee-simulation">
    Validate your fee calculations before going live.
  </Card>
</CardGroup>
