# CreateBankAccount

## Permission Scope

bankAccount

## Overview

createBankAccount creates an ACTIVE company bank account and validates all configured GL accounts.

## Business Rules

- Company and currency must exist
- Cash and optional clearing accounts must exist, be ACTIVE, and belong to the company
- Clearing accounts are optional

## Process Flow

```mermaid
flowchart LR
    A[Receive bank account] --> B[Validate company currency and accounts]
    B --> C[Create ACTIVE BankAccount]
```

## External Dependencies

- organization::GetCompany
- primitives::GetCurrency
- coa-management::GetAccount

## Error Scenarios

- **CASH_COMPANY_NOT_FOUND**: Company does not exist
- **CASH_CURRENCY_NOT_FOUND**: Currency does not exist
- **CASH_ACCOUNT_NOT_FOUND**: GL account does not exist
- **CASH_ACCOUNT_INVALID**: GL account is inactive or company-incompatible

## Test Cases

- creates an ACTIVE bank account
