# ActivateChartOfAccounts

## Overview

activateChartOfAccounts transitions a Chart of Accounts from DRAFT to ACTIVE status. Activation makes the CoA the authoritative account structure for its company, enabling accounts within it to receive journal postings from downstream modules. Only one CoA per company can be ACTIVE at a time.

## Business Rules

- Target CoA must exist
- Target CoA must be in DRAFT status
- Activating an already ACTIVE or ARCHIVED CoA fails with an invalid state transition error
- Only one CoA per company can be in ACTIVE status; activating a second CoA for the same company fails with a uniqueness constraint error

## Process Flow

```mermaid
flowchart TD
    A[Receive activate request] --> B{CoA exists?}
    B -->|No| C[Return error: not found]
    B -->|Yes| D{Status is DRAFT?}
    D -->|No| E[Return error: invalid state transition]
    D -->|Yes| F{Another ACTIVE CoA for same company?}
    F -->|Yes| G[Return error: duplicate active CoA]
    F -->|No| H[Update status to ACTIVE]
    H --> I[Return activated CoA]
```

## External Dependencies

- None

## Error Scenarios

- **CHART_OF_ACCOUNTS_NOT_FOUND**: Specified CoA ID does not exist
- **INVALID_STATE_TRANSITION**: Entity is not in the required status for the requested state transition
- **DUPLICATE_ACTIVE_CHART_OF_ACCOUNTS**: Another ACTIVE CoA already exists for the same company

## Test Cases

- returns error when CoA does not exist
- returns error when CoA is already ACTIVE
- returns error when CoA is ARCHIVED
- returns error when another ACTIVE CoA exists for the same company
- activates a DRAFT CoA
