# ActivatePurchasePriceRule

## Permission Scope

purchasePricing

## Overview

ActivatePurchasePriceRule re-enables a supplier purchase price rule so it can participate in future price resolution again.

## Business Rules

- Target rule must exist
- Activating an already active rule returns success without changing state
- Reactivated rules still require valid reference data and a non-conflicting precedence context

## Process Flow

```mermaid
flowchart TD
    A[Receive activate request] --> B{Rule exists?}
    B -->|No| C[Return PRICE_RULE_NOT_FOUND]
    B -->|Yes| D{Already active?}
    D -->|Yes| E[Return success with no-op]
    D -->|No| F{Rule still valid for activation?}
    F -->|No| G[Return validation error]
    F -->|Yes| H[Set status to ACTIVE]
    H --> I[Return activated rule]
```

## External Dependencies

- None

## Error Scenarios

- **PRICE_RULE_NOT_FOUND**: Target price rule does not exist
- **DUPLICATE_RULE_PRECEDENCE**: Another rule already owns the same precedence context
- **INVALID_RULE_CONFIGURATION**: Rule references or dates are no longer valid for activation

## Test Cases

- activates an inactive price rule
- returns success when the rule is already active
- returns error when rule does not exist
- returns error when activation would conflict with another active rule
- returns error when rule configuration is invalid at activation time
- returns error when the referenced item no longer exists
- returns error when the referenced item is inactive
- returns error when the referenced currency no longer exists
- returns error when the referenced unit no longer exists
