# ListSitesByCompany

## Overview

ListSitesByCompany retrieves sites belonging to a specific company with paginated results. Returns a paginated list of site records for the given companyId. This supports multi-site operations where facilities for a company need to be displayed or processed.

## Business Rules

- companyId is required
- Returns sites for the specified company regardless of status by default
- Results are paginated using offset/limit (default page size applies)
- An optional `status` filter can restrict results to ACTIVE or INACTIVE sites
- An optional `type` filter can restrict results to a specific site type (e.g., OFFICE, WAREHOUSE, STORE, FACTORY, DISTRIBUTION_CENTER)
- Returns an empty list if the company has no sites
- Results are ordered by site name by default; sortable by name, type, or createdAt
- `hasNextPage` indicates whether more results exist beyond the current page

## Process Flow

```mermaid
flowchart TD
    A[Receive request with companyId] --> B[Query sites where companyId matches]
    B --> C{Status filter provided?}
    C -->|Yes| D[Filter by status]
    C -->|No| E[Continue]
    D --> E
    E --> F{Type filter provided?}
    F -->|Yes| G[Filter by type]
    F -->|No| H[Continue]
    G --> H
    H --> I[Order by name]
    I --> I2[Apply limit+1 / offset pagination]
    I2 --> J[Return paginated site list]
```

## External Dependencies

- None

## Error Scenarios

- None (returns empty list when no sites found)

## Test Cases

- returns sites for a company
- returns empty list when no sites exist
- filters by status when provided
- filters by type when provided
- filters sites by INACTIVE status
- combines status and type filters
- returns sites ordered by name
- returns hasNextPage true when more results exist
- respects limit parameter
