# Banking System

Comprehensive Financial Management

## Overview

The banking system provides comprehensive financial management capabilities including bank accounts, transactions, transfers, reconciliations, and beneficiaries. It integrates with the accounting system to maintain proper financial records.

## Key Features

#### Bank Accounts

- Create and manage bank accounts
- Support for multiple currencies
- Integration with accounting codes
- Account balance tracking

#### Bank Transactions

- Record deposits, withdrawals, transfers
- VAT tracking
- Automatic accounting entry creation
- Transaction reconciliation support

#### Bank Transfers

- Internal transfers between accounts
- External transfers with exchange rates
- Transfer fees and VAT handling
- Beneficiary management

#### Bank Reconciliations

- Statement vs book balance reconciliation
- Reconciliation items management
- Multi-currency support
- Complete audit trail

## API Endpoints

### Bank Accounts

Method | Endpoint | Description
--- | --- | ---
GET | `/api/v1/banking/accounts` | List bank accounts with filtering
POST | `/api/v1/banking/accounts` | Create new bank account
GET | `/api/v1/banking/accounts/{id}` | Get specific bank account

### Bank Transactions

Method | Endpoint | Description
--- | --- | ---
GET | `/api/v1/banking/transactions` | List transactions with filtering
POST | `/api/v1/banking/transactions` | Create new transaction

### Bank Transfers

Method | Endpoint | Description
--- | --- | ---
GET | `/api/v1/banking/transfers` | List transfers with filtering
POST | `/api/v1/banking/transfers` | Create new transfer

## Data Models

### BankAccount

class BankAccount(BaseModel): id: str name: str institution: str account_number: str currency: str account_type: str accounting_code_id: str

### BankTransaction

class BankTransaction(BaseModel): id: str bank_account_id: str date: date amount: Decimal description: str transaction_type: str reference: str reconciled: bool vat_amount: Decimal accounting_entry_id: str

### BankTransfer

class BankTransfer(BaseModel): id: str amount: Decimal transfer_type: str status: str reference: str description: str source_account_id: str destination_account_id: str exchange_rate: Decimal vat_amount: Decimal transfer_fee: Decimal

## Transaction Types

Type | Description
--- | ---
`deposit` | Money received
`withdrawal` | Money withdrawn
`transfer` | Internal transfer
`payment` | Payment made

Type | Description
--- | ---
`receipt` | Payment received
`bank_charge` | Bank fees
`interest` | Interest earned/paid
`reversal` | Transaction reversal

## Usage Examples

### Create Bank Account

account_data = { "name": "Main Checking Account", "institution": "First National Bank", "account_number": "1234567890", "currency": "USD", "account_type": "checking", "accounting_code_id": "bank-account-code-id" } banking_service = BankingService(db) account, result = banking_service.create_bank_account( account_data, branch_id )

### Create Transaction

transaction_data = { "bank_account_id": "account-id", "date": date.today(), "amount": Decimal("1000.00"), "description": "Customer payment", "transaction_type": "deposit", "reference": "INV-001", "vat_amount": Decimal("100.00") } transaction, result = banking_service.create_bank_transaction( transaction_data, branch_id )

### Create Transfer

transfer_data = { "source_account_id": "source-account-id", "destination_account_id": "dest-account-id", "amount": Decimal("500.00"), "transfer_type": "internal", "reference": "TRANSFER-001", "description": "Transfer to savings", "vat_amount": Decimal("0.00"), "transfer_fee": Decimal("5.00") } transfer, result = banking_service.create_bank_transfer( transfer_data, branch_id )

## Integration

Accounting Integration

- Automatic journal entry creation
- Proper debit/credit handling
- Chart of accounts integration
- Audit trail maintenance

User Management

- User-specific beneficiaries
- Branch-based account management
- Role-based access control

VAT Handling

- VAT amount tracking
- VAT rate calculations
- Separate VAT accounting entries