# DeleteProductAttributeValue

## Permission Scope

productCatalog

## Overview

deleteProductAttributeValue deletes a predefined value from an existing attribute. Deletion is blocked if the value is currently in use on any ACTIVE product, preventing the invalidation of existing variant configurations.

## Business Rules

- Target attribute value must exist
- Value deletion is blocked if the value is in use on any ACTIVE product
- Values used only on DRAFT products can be deleted
- Deleting a value also removes any ProductAttributeAssignment records referencing it on DRAFT products

## Process Flow

```mermaid
flowchart TD
    A[Receive delete value request] --> B{Attribute value exists?}
    B -->|No| C[Return error: VALUE_NOT_FOUND]
    B -->|Yes| D{Value in use on ACTIVE product?}
    D -->|Yes| E[Return error: VALUE_IN_USE]
    D -->|No| F[Delete product attribute assignment references on DRAFT products]
    F --> G[Delete attribute value record]
    G --> H[Return success]
```

## External Dependencies

- None

## Error Scenarios

- **VALUE_NOT_FOUND**: Specified attribute value ID does not exist
- **ATTRIBUTE_NOT_FOUND**: Specified attribute ID does not exist
- **VALUE_IN_USE**: Value is in use on one or more ACTIVE products

## Test Cases

- returns error when value not found
- returns error when parent attribute does not exist
- returns error when value is in use on ACTIVE product
- deletes value and cleans up DRAFT product assignments
