Currency Management Implementation
This document outlines the implementation of currency management in the UBU Finance backend system.
Overview
The currency management feature allows administrators to:
- Create, view, update, and manage currencies in the system
- Associate account types with specific currencies
- When creating accounts, the currency is automatically determined by the account type
Database Changes
The following database changes were implemented:
- Created a new
currenciestable to store currency information - Added a
currency_idforeign key to theaccount_typestable - Removed the
currencycolumn from theaccountstable as it's now determined by the account type
API Endpoints
Currency Management
GET /currencies- List all currencies with optional filteringPOST /currencies- Create a new currencyGET /currencies/{currency_id}- Get details of a specific currencyPUT /currencies/{currency_id}- Update a currency
Required Permissions
Two new permissions have been added:
- view_currencies - Permission to view currency list and details
- manage_currencies - Permission to create, update, and manage currencies
How to Apply the Changes
-
Run the database migrations to update the schema:
-
This will:
- Create the new
currenciestable - Add the
currency_idcolumn toaccount_types - Remove the
currencycolumn fromaccounts - Insert default currencies (RWF, USD, EUR, GBP)
- Add the required permissions
Usage Examples
Creating a new currency
Creating an account type with currency
POST /accounts/types
{
"type_name": "Premium Savings",
"type_description": "High-interest savings account",
"interest_rate": 3.5,
"minimum_balance": 1000,
"maintenance_fee": 5,
"is_active": true,
"currency_id": "uuid-of-currency"
}
Creating an account
When creating an account, you no longer need to specify the currency as it's determined by the account type:
Security Considerations
The currency management feature is integrated with the existing security system: - Rate limiting and IP whitelisting apply to currency endpoints - Account lockout after failed login attempts is maintained - All security middleware is applied to the new endpoints - Comprehensive monitoring with Prometheus and Grafana includes the new endpoints