# DeactivateItem

## Permission Scope

item

## Overview

deactivateItem transitions an item from ACTIVE to INACTIVE status, removing it from availability for new transactions while preserving it for historical reference and audit trails. This supports scenarios such as discontinuing a product line or seasonal item removal.

## Business Rules

- Target item must exist in the system
- Target item must be in ACTIVE status
- Deactivated items remain in the system for reporting and audit purposes
- Deactivation prevents the item from being used in new transactions
- Existing transactions referencing this item are not affected

## Process Flow

```mermaid
flowchart TD
    A[Receive deactivate request] --> B{Item exists?}
    B -->|No| C[Return error: not found]
    B -->|Yes| D{Status is ACTIVE?}
    D -->|No| E[Return error: invalid state transition]
    D -->|Yes| F[Update status to INACTIVE]
    F --> G[Return deactivated item]
```

## External Dependencies

- None

## Error Scenarios

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

## Test Cases

- returns error when item does not exist
- returns error when item is not ACTIVE
- returns error when item is already INACTIVE
- deactivates an ACTIVE item
