> ## Documentation Index
> Fetch the complete documentation index at: https://help.agatabo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Bank Accounts Overview

> Manage bank accounts, track cash balances, reconcile transactions, and understand ledger integration

## What are Bank Accounts?

**Bank accounts** in Agatabo represent the physical bank accounts where your organization keeps its money. Each bank account tracks its cash balance through the general ledger system, with all transactions (deposits, withdrawals, loan disbursements, expenses) automatically updating the balance.

## Why Track Bank Accounts?

<Note>
  **Key benefits:**

  * Know exactly how much cash you have in each account
  * Track which transactions came from which account
  * Reconcile Agatabo records with bank statements
  * Separate operational funds from reserve funds
  * Monitor cash flow across multiple accounts
  * Maintain accurate financial statements
  * Prevent overdrafts and negative balances
</Note>

## How Bank Accounts Work

<Steps>
  <Step title="Add bank accounts">
    Create records for each physical bank account (first account is automatically default)
  </Step>

  <Step title="Link to ledger">
    System automatically creates CASH ledger account for each bank account
  </Step>

  <Step title="Record transactions">
    When recording deposits, loans, or expenses, specify which bank account is involved
  </Step>

  <Step title="Automatic balance updates">
    Database triggers update balances instantly when transactions are posted
  </Step>

  <Step title="Reconcile monthly">
    Compare Agatabo balances with bank statements to catch discrepancies
  </Step>
</Steps>

## Bank Account Types

Agatabo supports two types of bank accounts:

| Type        | Purpose                  | Typical Use                                            | Constraints                      |
| ----------- | ------------------------ | ------------------------------------------------------ | -------------------------------- |
| **SAVINGS** | Savings account          | Long-term reserves, dividend funds, emergency funds    | Optional                         |
| **CURRENT** | Current/checking account | Daily operations, loan disbursements, expense payments | At least one required and active |

<Note>
  **Important**: Your organization must have at least one active CURRENT account. You cannot deactivate all CURRENT accounts.
</Note>

## Bank Account Information

Each bank account has:

### Core Fields

**Name**:

* Descriptive name (e.g., "BK Operations Account", "Equity Reserve Account")
* Must be unique within your organization
* Used to identify the account in dropdowns and reports

**Type**:

* SAVINGS or CURRENT
* Determines the account's purpose
* Cannot be changed after creation

**Balance**:

* Current cash balance (automatically calculated from ledger)
* Updated in real-time via database triggers
* Always reflects posted transactions

**Status (isActive)**:

* Active: Account can be used for new transactions
* Inactive: Account is hidden from dropdowns (cannot be used)
* Historical transactions remain visible

**Default (isDefault)**:

* Marks this as the primary bank account
* Used automatically when no specific account is selected
* Only one default account per organization
* First account created is automatically set as default

### Calculated Fields

**Available Balance**:

* Formula: `Balance - Total Reserved Amounts`
* Shows cash available after accounting for reserves
* Use this for operational decisions

**Total Reserved**:

* Sum of all reserve allocation balances
* Cannot be spent on regular operations
* Restricted funds

## Ledger Integration

### How Bank Accounts Work in the Ledger

Each bank account is backed by a **CASH ledger account**:

**Ledger Account Properties**:

* Role: `CASH` (asset account, normal debit balance)
* Scope Key: `cash:{bankAccountId}` (links ledger account to specific bank)
* Balance: Maintained by database triggers

**When transactions occur**:

1. Journal entry is created (e.g., loan disbursement)
2. Entry includes CASH ledger line with bankAccountId scope
3. Database trigger updates ledger balance automatically
4. Bank account balance reflects change instantly

**Example**:

```
Loan disbursement of 500,000 RWF from "BK Operations":

Journal Entry:
Dr LOAN_RECEIVABLE    500,000  (asset increases)
   Cr CASH            500,000  (asset decreases, scope: cash:{bankAccountId})

Bank Account Balance:
Before: 2,000,000 RWF
After:  1,500,000 RWF
```

## Default Account Selection

The system uses this priority when selecting which bank account to use:

**Priority**:

1. Explicitly specified account (if provided in transaction)
2. Default account (marked with isDefault = true)
3. First active CURRENT account (if no default set)

**When creating transactions**:

* Loan disbursements: Uses selected or default account
* Expense payments: Uses selected or default account
* Deposits: Uses selected or default account

## Account Constraints and Validations

### Creation Rules

**First Account**:

* Automatically set as default
* Cannot delete until another account is created

**Name Uniqueness**:

* Each account name must be unique within organization
* Case-sensitive validation

### Deletion Rules

You **cannot delete** a bank account if:

❌ It is the default account (set another as default first)
❌ It is the only account (must maintain at least one)
❌ It has transaction history (journal entries reference it)
❌ Balance is not exactly zero (must be 0.00)

**To delete an account**:

1. Ensure balance is exactly zero
2. If it's default, set another account as default
3. Ensure no transactions reference this account
4. Click delete

### Modification Rules

**Cannot deactivate** if:

* It's the only active CURRENT account
* Would leave organization with no active CURRENT accounts

**Can change**:

* Name (must remain unique)
* Active/inactive status (subject to constraints)
* Default status (sets isDefault on target, unsets on current default)

## Balance Adjustments

### Opening Balance Adjustments

When you first set up Agatabo, you may need to adjust opening balances to match your actual bank balances.

**Endpoint**: `PATCH /bank-accounts/:id/adjust-balance`

**How it works**:

* Creates or adjusts CASH\_OPENING journal entry
* Balances against OPENING\_EQUITY ledger account
* One-time operation per account

**Validations**:

* Cannot adjust if account is inactive
* Cannot adjust after accounting period is closed
* Cannot create negative opening equity (total adjustments cannot exceed existing equity)

**Example**:

```
Your BK account actually has 5,000,000 RWF, but Agatabo shows 0.

Adjust opening balance to 5,000,000:
Dr CASH (BK Operations)    5,000,000
   Cr OPENING_EQUITY       5,000,000

Result: BK Operations now shows 5,000,000 RWF balance
```

## Bank Account Operations

<CardGroup cols={2}>
  <Card title="Adding Bank Accounts" icon="plus" href="/tontines/bank-accounts/adding-bank-accounts">
    Register your organization's bank accounts
  </Card>

  <Card title="Recording Transactions" icon="file-invoice-dollar" href="/tontines/bank-accounts/recording-transactions">
    Record deposits, withdrawals, and expenses
  </Card>

  <Card title="Reconciliation" icon="check-double" href="/tontines/bank-accounts/reconciliation">
    Match Agatabo records with bank statements
  </Card>

  <Card title="Bank Transfers" icon="arrow-right-left" href="/tontines/bank-accounts/bank-transfers">
    Move money between accounts via manual entries
  </Card>
</CardGroup>

## Transaction Types That Affect Bank Accounts

### Cash Inflows (Increase Balance)

**Savings Deposits**:

* Member contributes to savings
* Credits CASH, debits SAVINGS (liability)

**Loan Repayments**:

* Member pays loan installment
* Credits CASH, debits LOAN\_RECEIVABLE

**Entry Fees**:

* New member pays entry fee
* Credits CASH, debits ENTRY\_FEE\_INCOME

**Reserve Releases**:

* Organization releases reserve funds
* Credits CASH, debits RESERVE\_ALLOCATION

### Cash Outflows (Decrease Balance)

**Loan Disbursements**:

* Organization lends to member
* Debits LOAN\_RECEIVABLE, credits CASH

**Expense Payments**:

* Organization pays expense
* Debits EXPENSE, credits CASH

**Bank Charges**:

* Bank deducts fees
* Debits BANK\_CHARGE\_EXPENSE, credits CASH

**Dividend Distributions**:

* Organization pays dividends
* Debits RETAINED\_EARNINGS, credits CASH

**Reserve Top-ups**:

* Organization sets aside reserves
* Debits RESERVE\_ALLOCATION, credits CASH

**Savings Withdrawals**:

* Member withdraws savings
* Debits SAVINGS, credits CASH

## Reconciliation

### What is Reconciliation?

Reconciliation ensures Agatabo's recorded balance matches your actual bank statement balance.

**Why reconcile**:

* Catch data entry errors
* Identify missing transactions
* Detect unauthorized transactions
* Ensure financial statement accuracy

**When to reconcile**:

* Monthly (recommended)
* After closing accounting period
* Before generating financial reports
* When balance seems incorrect

[Learn more about reconciliation →](/tontines/bank-accounts/reconciliation)

## Common Scenarios

### Scenario 1: Starting with Existing Balances

```
Your organization has:
- BK Current Account: 10,000,000 RWF
- Equity Savings Account: 5,000,000 RWF

Steps:
1. Add "BK Current Account" (CURRENT type) - auto-default
2. Adjust opening balance: 10,000,000 RWF
3. Add "Equity Savings Account" (SAVINGS type)
4. Adjust opening balance: 5,000,000 RWF

Result: Total cash = 15,000,000 RWF
```

### Scenario 2: Multiple Accounts for Different Purposes

```
Organization structure:
- "Operations Account" (CURRENT, default) - daily transactions
- "Loan Disbursement Account" (CURRENT) - dedicated for loans
- "Reserve Fund Account" (SAVINGS) - emergency reserves
- "Dividend Account" (SAVINGS) - dividend payouts

Usage:
- Deposits → Operations Account (default)
- Loan disbursements → Loan Disbursement Account (select manually)
- Reserve allocations → Reserve Fund Account
- Dividend distributions → Dividend Account
```

### Scenario 3: Inactivating an Old Account

```
Organization has:
- "Old BK Account" (CURRENT, default) - closing this
- "New Equity Account" (CURRENT) - switching to this

Steps:
1. Transfer all funds out of Old BK Account (via manual journal or expenses)
2. Verify balance is exactly 0.00 RWF
3. Set "New Equity Account" as default
4. Mark "Old BK Account" as inactive
5. Historical transactions still visible in reports

Cannot delete Old BK Account because it has transaction history
```

## Best Practices

<Note>
  **Bank account management tips:**

  * Create separate accounts for different purposes (operations, reserves, loans)
  * Set meaningful, descriptive names
  * Always specify bank account when recording transactions (don't rely on default)
  * Reconcile monthly with bank statements
  * Keep at least two CURRENT accounts (redundancy)
  * Use SAVINGS accounts for restricted funds (reserves, dividends)
  * Adjust opening balances BEFORE recording transactions
  * Never manually edit ledger balances (use opening balance adjustment)
  * Review available balance before large disbursements
  * Document purpose when transferring between accounts
</Note>

## Permissions Required

| Action                 | Permission       | Scope |
| ---------------------- | ---------------- | ----- |
| View bank accounts     | `accounts:read`  | ANY   |
| Create bank account    | `accounts:write` | ANY   |
| Update bank account    | `accounts:write` | ANY   |
| Delete bank account    | `accounts:write` | ANY   |
| Set default account    | `accounts:write` | ANY   |
| Adjust opening balance | `accounts:write` | ANY   |
| View transactions      | `ledger:read`    | ANY   |
| Reconcile accounts     | `ledger:read`    | ANY   |

## Related Topics

<CardGroup cols={2}>
  <Card title="General Ledger Overview" icon="book" href="/tontines/general-ledger/overview">
    Understand accounting behind bank accounts
  </Card>

  <Card title="Understanding Double-Entry" icon="scale-balanced" href="/tontines/general-ledger/understanding-double-entry">
    Learn how transactions affect balances
  </Card>

  <Card title="Recording Transactions" icon="file-invoice" href="/tontines/bank-accounts/recording-transactions">
    How to record bank transactions
  </Card>
</CardGroup>
