# UpdateWarehouse

## Permission Scope

location

## Overview

updateWarehouse modifies the mutable fields of an existing warehouse, including name, storageCondition, and capacity. `siteId` is fixed by the existing record and is not part of the update input.

## Business Rules

- Warehouse must exist
- Name must remain unique within the same site if changed
- siteId is not part of the update input

## Process Flow

```mermaid
flowchart TD
    A[Receive update request] --> B{Warehouse exists?}
    B -->|No| C[Return error: WAREHOUSE_NOT_FOUND]
    B -->|Yes| D{Name changed?}
    D -->|Yes| E{New name unique within site?}
    E -->|No| F[Return error: DUPLICATE_WAREHOUSE_NAME]
    E -->|Yes| G[Update warehouse record]
    D -->|No| G
    G --> H[Return updated warehouse]
```

## External Dependencies

- None

## Error Scenarios

- **WAREHOUSE_NOT_FOUND**: Referenced warehouse does not exist
- **DUPLICATE_WAREHOUSE_NAME**: A warehouse with the new name already exists at the same site

## Test Cases

- returns error when warehouse not found
- returns error when new name conflicts
- updates warehouse name
- updates storage condition
- updates capacity
