# DeactivateProduct

## Permission Scope

product

## Overview

deactivateProduct transitions a product from ACTIVE to ARCHIVED status, preventing new variant generation. Existing Items generated from this product's variants remain unaffected and continue to operate independently in item-management.

## Business Rules

- Target product must exist
- Target product must be in ACTIVE status
- Deactivating does not delete or deactivate existing generated Items
- Deactivated products can be reactivated via reactivateProduct

## Process Flow

```mermaid
flowchart TD
    A[Receive deactivate request] --> B{Product exists?}
    B -->|No| C[Return error: PRODUCT_NOT_FOUND]
    B -->|Yes| D{Status is ACTIVE?}
    D -->|No| E[Return error: INVALID_STATE_TRANSITION]
    D -->|Yes| F[Update status to ARCHIVED]
    F --> G[Return deactivated product]
```

## External Dependencies

- None

## Error Scenarios

- **PRODUCT_NOT_FOUND**: Specified product ID does not exist
- **INVALID_STATE_TRANSITION**: Requested state transition is not allowed from the current status

## Test Cases

- returns error when product not found
- returns error when not in ACTIVE status
- deactivates ACTIVE product to ARCHIVED
