# DeleteProduct

## Permission Scope

product

## Overview

deleteProduct permanently removes a product from the system. Only products in DRAFT status can be deleted, as ACTIVE and ARCHIVED products may have generated variants and associated Items that must be preserved for traceability and audit purposes.

## Business Rules

- Target product must exist
- Target product must be in DRAFT status
- ACTIVE and ARCHIVED products cannot be deleted
- Deleting a product removes all associated attribute value assignments (ProductAttributeAssignments)
- Deleting a product removes all associated category assignments (ProductCategoryAssignments)

## Process Flow

```mermaid
flowchart TD
    A[Receive delete request] --> B{Product exists?}
    B -->|No| C[Return error: PRODUCT_NOT_FOUND]
    B -->|Yes| D{Status is DRAFT?}
    D -->|No| E[Return error: DELETE_NOT_ALLOWED]
    D -->|Yes| F[Remove attribute value assignments]
    F --> G[Remove category assignments]
    G --> H[Delete product record]
    H --> I[Return success]
```

## External Dependencies

- None

## Error Scenarios

- **PRODUCT_NOT_FOUND**: Specified product ID does not exist
- **DELETE_NOT_ALLOWED**: Product is not in DRAFT status and cannot be deleted

## Test Cases

- returns error when product not found
- returns error when not DRAFT
- deletes DRAFT product and associated records
