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

# Creating a Fee Package

> Build a new Fee Package in the Midaz Module to define how fees are calculated and applied to Transactions.

To create a new Fee Package in Midaz Module:

<Steps>
  <Step>
    Go to the **Fee Packages** page and click the **New Package** button.
  </Step>

  <Step>
    The **New Fee Package** form will open with multiple sections to configure.

    <Steps>
      <Step title="Fill in the **Basic Information** section">
        * **Fee Group Label** (required) - A descriptive name for this fee package
        * **Description** (required) - Explanation of when and why this package applies
        * **Ledger** (required) - Select the ledger this package applies to
        * **Transaction Route** (optional) - Associate with a specific transaction route
        * **Segment** (optional) - Link to a specific segment for targeted application
      </Step>

      <Step title="Configure the **Amount Range** section">
        * **Minimum Amount** (required) - Lowest transaction amount for fee application
        * **Maximum Amount** (required) - Highest transaction amount for fee application

        <Note>
          Transactions outside this range will not have fees applied from this package.
        </Note>
      </Step>

      <Step>
        Click the **Next** button.
      </Step>

      <Step title="Add the first Fee Rule">
        Select one of the options in the **Add Fee** section:

        * `Flat Fee` - Fixed amount regardless of transaction value.
        * `Percentage` - Percentage of the transaction amount.
        * `Max Between Types` - Higher value between flat and percentage.
      </Step>

      <Step title="Add Fee information">
        * **Priority** (required) - Order of fee application (1 = first)
        * **Calculation Value** (required) - The fee amount or percentage rate.
        * **Fee Name** (required) - Name identifying this specific fee.
        * **Fee Settings** - Specify the values for the fee:
          * **Reference Amount** (required) - Base for percentage calculations:
            * `Original Amount` - Calculate on original transaction value
            * `After Fees Amount` - Calculate after other fees are applied
          * **Credit Account ID** (required) - Account alias that receives the fee amount
          * **Route From** (optional) - Source account filter for this fee
          * **Route To** (optional) - Destination account filter for this fee
          * **Deductible from transaction?** - Toggle if this fee should be deducted from the transaction
      </Step>

      <Step>
        Click the **Next** button.
      </Step>

      <Step>
        (Optional) Configure **Account Waivers** section:

        * Add account aliases that should be exempt from fees in this package
        * Click **Add** to add each waived account
      </Step>

      <Step>
        Click the **Next** button.
      </Step>

      <Step title="Review your package">
        Review the information and confirm that everything is correct.
      </Step>

      <Step>
        Click the **Create Package** button.
      </Step>
    </Steps>
  </Step>

  <Step>
    If successful, you'll see a confirmation message and be redirected to the Fee Packages list.
  </Step>
</Steps>

## Quick examples

***

<AccordionGroup>
  <Accordion title="Flat Fee">
    **Use case**: \$2.00 fee on all transactions between \$10 and \$500

    | Field             | Value                              |
    | ----------------- | ---------------------------------- |
    | Fee Group Label   | `Standard Transfer Fee`            |
    | Description       | `Fixed fee for standard transfers` |
    | Minimum Amount    | `10.00`                            |
    | Maximum Amount    | `500.00`                           |
    | Fee Label         | `Transfer Fee`                     |
    | Application Rule  | `Flat Fee`                         |
    | Calculation Value | `2.00`                             |
    | Priority          | `1`                                |
    | Credit Account    | `@fees/transfers`                  |
  </Accordion>

  <Accordion title="Percentage Fee">
    **Use case**: 1.5% fee on transactions over \$100

    | Field             | Value                                          |
    | ----------------- | ---------------------------------------------- |
    | Fee Group Label   | `Percentage Transaction Fee`                   |
    | Description       | `Percentage-based fee for larger transactions` |
    | Minimum Amount    | `100.00`                                       |
    | Maximum Amount    | `999999.99`                                    |
    | Fee Label         | `Processing Fee`                               |
    | Application Rule  | `Percentage`                                   |
    | Calculation Value | `1.5`                                          |
    | Reference Amount  | `Original Amount`                              |
    | Priority          | `1`                                            |
    | Credit Account    | `@fees/processing`                             |
  </Accordion>

  <Accordion title="Combined Fee">
    **Use case**: Minimum \$1.00 or 2% (whichever is higher)

    | Field            | Value                            |
    | ---------------- | -------------------------------- |
    | Fee Group Label  | `Minimum Guarantee Fee`          |
    | Description      | `Ensures minimum fee collection` |
    | Minimum Amount   | `0.01`                           |
    | Maximum Amount   | `999999.99`                      |
    | Fee Label        | `Guarantee Fee`                  |
    | Application Rule | `Max Between Types`              |
    | Flat Value       | `1.00`                           |
    | Percentage Value | `2.0`                            |
    | Reference Amount | `Original Amount`                |
    | Priority         | `1`                              |
    | Credit Account   | `@fees/guarantee`                |
  </Accordion>
</AccordionGroup>

## Important notes

***

<AccordionGroup>
  <Accordion title="Fee priority ordering">
    When a package contains multiple fees, they are applied in priority order (lowest number first). This matters when using `After Fees Amount` as a reference, since earlier fees affect the calculation base for later fees.

    **Example**:

    * Fee A (Priority 1): 1% on original amount
    * Fee B (Priority 2): 0.5% on after fees amount

    On a \$100 transaction:

    * Fee A = \$1.00 (1% of \$100)
    * Fee B = \$0.495 (0.5% of \$99)
  </Accordion>

  <Accordion title="Amount range considerations">
    * Ranges should not overlap between packages for the same transaction route
    * Use `0.01` as minimum for packages that should apply to all transactions
    * Use a high maximum (e.g., `999999999.99`) for no upper limit
    * Transactions exactly at min or max values are included in the range
  </Accordion>

  <Accordion title="Waived accounts behavior">
    * Waived accounts bypass all fees in the package, not just specific fees
    * Use account aliases (not IDs) when adding waived accounts
    * Waivers apply when the waived account is the **source** of the transaction
  </Accordion>
</AccordionGroup>
