Skip to content

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:

  1. Create, view, update, and manage currencies in the system
  2. Associate account types with specific currencies
  3. When creating accounts, the currency is automatically determined by the account type

Database Changes

The following database changes were implemented:

  1. Created a new currencies table to store currency information
  2. Added a currency_id foreign key to the account_types table
  3. Removed the currency column from the accounts table as it's now determined by the account type

API Endpoints

Currency Management

  • GET /currencies - List all currencies with optional filtering
  • POST /currencies - Create a new currency
  • GET /currencies/{currency_id} - Get details of a specific currency
  • PUT /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

  1. Run the database migrations to update the schema:

    python run_migrations.py
    

  2. This will:

  3. Create the new currencies table
  4. Add the currency_id column to account_types
  5. Remove the currency column from accounts
  6. Insert default currencies (RWF, USD, EUR, GBP)
  7. Add the required permissions

Usage Examples

Creating a new currency

POST /currencies
{
  "code": "KES",
  "name": "Kenyan Shilling",
  "symbol": "KSh",
  "is_active": true
}

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:

POST /accounts
{
  "customer_id": "uuid-of-customer",
  "type_id": "uuid-of-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