# Currency

## Description

Currency defines a monetary unit available for use across the ERP system. Each currency contains the ISO 4217 code, display symbol, name, and decimal precision. The primitives module owns the currency catalog; base/functional currency assignment is per company and owned by the organization module.

Examples: USD (US Dollar), EUR (Euro), JPY (Japanese Yen).

## Domain Model Definitions

### Model type

Stateful

#### State Transitions

```mermaid
stateDiagram-v2
    [*] --> Active: create
    Active --> Inactive: deactivate
    Inactive --> Active: activate
    note right of Active: Currency assigned as base currency by any company cannot be deactivated
```

| Operation | From | To | Command |
|-----------|------|----|---------|
| deactivate | ACTIVE | INACTIVE | [deactivateCurrency](../commands/DeactivateCurrency.md) |
| activate | INACTIVE | ACTIVE | [activateCurrency](../commands/ActivateCurrency.md) |

### Command Definitions

- [createCurrency](../commands/CreateCurrency.md)
- [activateCurrency](../commands/ActivateCurrency.md)
- [deactivateCurrency](../commands/DeactivateCurrency.md)
- [setBaseCurrency](../commands/SetBaseCurrency.md)

### Query Definitions

- [convertAmount](../queries/ConvertAmount.md)

### Models

- Currency

### Invariants

- ISO 4217 code must be unique across all currencies
- A currency assigned as base currency by any company (via the organization module) cannot be deactivated

### Relationships

- **Referenced By Exchange Rates**: Currency is referenced as source or target in ExchangeRate records
- **Referenced By Transactions**: Currency is used in sales, purchase, and accounting transactions
