# DeactivatePurchasePriceRule

## Permission Scope

purchasePricing

## Overview

DeactivatePurchasePriceRule retires one supplier purchase pricing condition from future rule resolution while preserving all historical purchase orders that already used it.

## Business Rules

- Target rule must exist
- Deactivating an already inactive rule returns success without changing state
- Deactivated rules are ignored by automatic price calculation for new draft orders
- Historical purchase orders keep their ordered prices and matched rule references

## Process Flow

```mermaid
flowchart TD
    A[Receive deactivate request] --> B{Rule exists?}
    B -->|No| C[Return PRICE_RULE_NOT_FOUND]
    B -->|Yes| D{Already inactive?}
    D -->|Yes| E[Return success with no-op]
    D -->|No| F[Set status to INACTIVE]
    F --> G[Return deactivated rule]
```

## External Dependencies

- None

## Error Scenarios

- **PRICE_RULE_NOT_FOUND**: Target price rule does not exist

## Test Cases

- deactivates an active price rule
- returns success when the rule is already inactive
- returns error when rule does not exist
