| 1 |
|
defmodule WalletLimitsFees do |
| 2 |
|
@moduledoc """ |
| 3 |
|
Public interface for the WalletLimitsFees application. |
| 4 |
|
|
| 5 |
|
## Responsibilities |
| 6 |
|
- Policy evaluation for transfer limits (transaction, daily, monthly). |
| 7 |
|
- Fee calculation based on tier, currency, and transfer type. |
| 8 |
|
- Rule decision capture for audit traceability. |
| 9 |
|
|
| 10 |
|
## Delegated to sub-modules |
| 11 |
|
- `WalletLimitsFees.Commands.UpsertLimitPolicy` — create or update a limit policy. |
| 12 |
|
- `WalletLimitsFees.Commands.UpsertFeePolicy` — create or update a fee policy. |
| 13 |
|
- `WalletLimitsFees.Queries.EvaluateTransferLimits` — evaluate limits for a transfer. |
| 14 |
|
- `WalletLimitsFees.Queries.CalculateFee` — calculate applicable fee. |
| 15 |
|
|
| 16 |
|
## Forbidden |
| 17 |
|
- Direct transfer state management (that is `wallet_transfers`). |
| 18 |
|
- Ledger writes (that is `wallet_ledger`). |
| 19 |
|
- Auth logic (that is `wallet_auth`). |
| 20 |
|
""" |
| 21 |
|
|
| 22 |
|
alias WalletLimitsFees.Commands.{UpsertLimitPolicy, UpsertFeePolicy} |
| 23 |
|
alias WalletLimitsFees.Queries.{EvaluateTransferLimits, CalculateFee} |
| 24 |
|
|
| 25 |
|
@doc "Create or update a limit policy." |
| 26 |
:-( |
defdelegate upsert_limit_policy(params), to: UpsertLimitPolicy, as: :execute |
| 27 |
|
|
| 28 |
|
@doc "Create or update a fee policy." |
| 29 |
:-( |
defdelegate upsert_fee_policy(params), to: UpsertFeePolicy, as: :execute |
| 30 |
|
|
| 31 |
|
@doc "Evaluate whether a transfer amount is within configured limits." |
| 32 |
:-( |
defdelegate evaluate_limits(tier, currency, amount, context \\ %{}), |
| 33 |
|
to: EvaluateTransferLimits, |
| 34 |
|
as: :execute |
| 35 |
|
|
| 36 |
|
@doc "Calculate the applicable fee for a transfer." |
| 37 |
:-( |
defdelegate calculate_fee(tier, currency, transfer_type, amount), |
| 38 |
|
to: CalculateFee, |
| 39 |
|
as: :execute |
| 40 |
|
end |