# ListBusinessPartners

## Overview

Returns the business partner directory with customer and supplier relationships, one row per partner.

## Business Rules

- Accepts optional search, role (ALL, CUSTOMER, SUPPLIER), offset, and limit
- Defaults to ALL, offset 0, and limit 25; limit must be an integer from 1 to 100 and offset a non-negative integer
- Searches the trimmed partner name case-insensitively; percent, underscore, and backslash are literal characters
- Filters by account existence before counting and pagination; inactive accounts still qualify
- Returns each partner once even with multiple customer and supplier accounts
- Returns id, name, type, status, isCustomer, and isSupplier, with total matching partners before pagination
- Sorts by partner name then ID for deterministic pagination
- Authentication is enforced by the calling resolver

## Process Flow

```mermaid
flowchart TD
    A[Validate pagination] --> B[Filter partners by name and account relationships]
    B --> C[Count distinct matching partners]
    C --> D[Group by partner and apply order and pagination]
    D --> E[Return items and total]
```

## External Dependencies

- None

## Error Scenarios

- **INVALID_PAGINATION**: offset must be a non-negative integer and limit an integer from 1 to 100

## Test Cases

- returns one directory row with both relationships and total
- applies customer and supplier filters before counting and pagination
- treats search wildcard characters literally
- returns an empty page while retaining the matching total
- uses defaults and deterministic ordering without filtering inactive accounts
- rejects invalid pagination before querying
