# SalesPriceList

## Description

SalesPriceList groups reusable customer-facing price rules for one company. It provides the administrative boundary for activating, retiring, and auditing a commercial pricing set without forcing price logic into the item master itself.

## Domain Model Definitions

### Model type

Stateful

#### State Transitions

```mermaid
stateDiagram-v2
    [*] --> Draft: createSalesPriceList
    Draft --> Active: activateSalesPriceList
    Active --> Inactive: deactivateSalesPriceList
```

| Operation | From | To | Command |
|-----------|------|----|---------|
| activate | DRAFT | ACTIVE | [activateSalesPriceList](../command/ActivateSalesPriceList.md) |
| deactivate | ACTIVE | INACTIVE | [deactivateSalesPriceList](../command/DeactivateSalesPriceList.md) |

### Command Definitions

- [createSalesPriceList](../command/CreateSalesPriceList.md) - Create a draft price list for one company and commercial context.
- [updateSalesPriceList](../command/UpdateSalesPriceList.md) - Revise list metadata while it remains editable.
- [activateSalesPriceList](../command/ActivateSalesPriceList.md) - Make the list available for price-rule resolution on new orders.
- [deactivateSalesPriceList](../command/DeactivateSalesPriceList.md) - Prevent future orders from using the list while preserving history.

### Query Definitions

- [getSalesPriceList](../query/GetSalesPriceList.md) - Retrieve one price list with its company scope and activation state.
- [listSalesPriceLists](../query/ListSalesPriceLists.md) - List price lists for pricing administration and audit.
- [listSalesPriceRulesByPriceList](../query/ListSalesPriceRulesByPriceList.md) - List the rules maintained under a selected price list.

### Models

- SalesPriceList
- SalesPriceRule

### Invariants

- Every price list belongs to exactly one company.
- Only ACTIVE price lists may participate in new price resolution.
- Deactivating a price list never mutates the snapshotted prices already stored on confirmed sales orders or issued invoices.

### Relationships

- **Owns SalesPriceRule**: A price list groups one or more SalesPriceRule records.
- **References Company (cross-module)**: `companyId` scopes the list to a single legal entity.
- **Referenced By SalesOrderLine**: Order lines may store the matched rule that came from a given list at defaulting time.
