# ListAccounts

## Overview

ListAccounts retrieves a list of GL accounts within a Chart of Accounts, with optional filters for type, classification, account group, tags, status, and currency restriction. Results are sorted by account code by default.

## Business Rules

- chartOfAccountsId is required — accounts are always scoped to a CoA
- Optional filters:
  - `accountType` — filter by ASSET, LIABILITY, EQUITY, REVENUE, or EXPENSE
  - `accountClassification` — filter by REGULAR, RECEIVABLE, PAYABLE, BANK_CASH, FIXED_ASSET, RETAINED_EARNINGS, or NON_POSTING
  - `accountGroupId` — filter by account group membership
  - `tags` — filter by one or more tag labels (accounts matching any of the provided tags)
  - `status` — filter by DRAFT, ACTIVE, or INACTIVE
  - `currencyRestriction` — filter by currency code
- All filters can be combined; when multiple filters are provided, results must match all criteria (AND logic)
- Returns full account records (same shape as GetAccount output)
- Results are sorted by account code ascending by default
- Returns an empty list if no accounts match the filters

## Process Flow

```mermaid
flowchart TD
    A[Receive input with chartOfAccountsId] --> B[Build query with CoA scope]
    B --> C{Filters provided?}
    C -->|Yes| D[Apply filters to query]
    C -->|No| E[Return all accounts in CoA]
    D --> E
    E --> F[Sort by account code ascending]
    F --> G[Return account list]
```

## External Dependencies

- None

## Error Scenarios

- **EMPTY_RESULT**: No accounts match the given criteria — returns empty list

## Test Cases

- returns all accounts in a CoA when no filters applied
- returns accounts filtered by account type
- returns accounts filtered by classification
- returns accounts filtered by account group
- returns accounts filtered by tags (matches accounts having any of the provided tags)
- returns accounts filtered by status
- returns accounts filtered by currency restriction
- returns accounts filtered by multiple criteria combined
- returns accounts sorted by code ascending
- returns empty list when no accounts match
