# PurchasePriceList

## Description

PurchasePriceList groups the supplier-specific purchasing conditions that buyers can reuse across many orders. It defines the commercial container for one supplier in one company, while the actual unit prices, validity windows, and quantity breaks live on child purchase price rules.

Separating the list from the rules lets procurement retire an entire negotiated contract or reactivate it later without rewriting historical purchase-order snapshots.

## Domain Model Definitions

### Model type

Stateful

#### State Transitions

```mermaid
stateDiagram-v2
    [*] --> Active: createPurchasePriceList
    Active --> Inactive: deactivatePurchasePriceList
    Inactive --> Active: activatePurchasePriceList
    Active --> Active: updatePurchasePriceList
    Inactive --> Inactive: updatePurchasePriceList
```

| Operation | From | To | Command |
|-----------|------|----|---------|
| deactivate | ACTIVE | INACTIVE | [deactivatePurchasePriceList](../commands/DeactivatePurchasePriceList.md) |
| activate | INACTIVE | ACTIVE | [activatePurchasePriceList](../commands/ActivatePurchasePriceList.md) |

### Command Definitions

- [createPurchasePriceList](../commands/CreatePurchasePriceList.md) - Create a new active supplier price list container
- [updatePurchasePriceList](../commands/UpdatePurchasePriceList.md) - Update descriptive or prioritization fields of an existing price list
- [activatePurchasePriceList](../commands/ActivatePurchasePriceList.md) - Re-enable a retired supplier contract for new price resolution
- [deactivatePurchasePriceList](../commands/DeactivatePurchasePriceList.md) - Prevent a price list from participating in future rule resolution

### Query Definitions

- [getPurchasePriceList](../queries/GetPurchasePriceList.md) - Retrieve a price list with its embedded rules
- [calculatePurchasePrice](../queries/CalculatePurchasePrice.md) - Resolve the best matching active purchase price rule for a draft order line

### Models

- PurchasePriceList

### Invariants

- Every price list belongs to exactly one company and one supplier
- Only active price lists can participate in automatic purchase price resolution
- Deactivating a price list does not change purchase orders that already snapshotted one of its rules
- Price-list priority must be deterministic within one supplier and company so rule resolution can break ties consistently

### Relationships

- **Belongs To BusinessPartner**: Each list targets one supplier [BusinessPartner](../../../business-partner/docs/models/BusinessPartner.md)
- **Has Many PurchasePriceRules**: A price list contains one or more [PurchasePriceRule](./PurchasePriceRule.md) records
- **Referenced By PurchaseOrder**: Draft [PurchaseOrder](./PurchaseOrder.md) lines may default from rules owned by the list before snapshotting the final agreed price
