# ActivateSalesPriceRule

## Overview

ActivateSalesPriceRule moves a draft SalesPriceRule into ACTIVE status so it can participate in downstream commercial processing.

## Business Rules

- Only DRAFT SalesPriceRule records may be activated.
- Unit price must be positive.
- Effective end date cannot precede start date.
- Minimum quantity cannot be negative.

## Process Flow

```mermaid
flowchart TD
    A[Receive activate request] --> B[Load SalesPriceRule]
    B --> C{Status is DRAFT?}
    C -->|No| D[Return INVALID_SALESPRICERULE_STATUS]
    C -->|Yes| E[Validate activation prerequisites]
    E --> F[Set status to ACTIVE]
    F --> G[Return activated SalesPriceRule]
```

## External Dependencies

- [item-management::GetItem](../../../item-management/docs/queries/GetItem.md) - Validate the referenced sellable item.
- [primitives::GetCurrency](../../../primitives/docs/queries/GetCurrency.md) - Validate currency assignment.
- [primitives::GetUnit](../../../primitives/docs/queries/GetUnit.md) - Validate sales UoM assignment.
- [getSalesPriceList](../queries/GetSalesPriceList.md) - Validate parent price-list scope.

## Error Scenarios

- **SALESPRICERULE_NOT_FOUND**: Referenced SalesPriceRule does not exist.
- **INVALID_SALESPRICERULE_STATUS**: Only DRAFT SalesPriceRule records may be activated.
- **PRICE_LIST_NOT_FOUND**: Parent sales price list does not exist.
- **INVALID_UNIT_PRICE**: Unit price must be greater than zero.
- **INVALID_EFFECTIVE_RANGE**: Effective end date precedes start date.

## Test Cases

- activates a draft SalesPriceRule
- throws when SalesPriceRule is not in DRAFT status
- throws when SalesPriceRule does not exist
- throws when the parent price list does not exist
- throws on invalid unit price
- throws on invalid effective date range
