# UpdateStorageLocation

## Permission Scope

location

## Overview

updateStorageLocation modifies the mutable fields of a storage location: name, storageCondition, and capacity. `siteId` and `code` are fixed by the existing record and are not part of the mutable update payload.

## Business Rules

- Storage location must exist
- Name must remain unique within the site if changed
- siteId and code are not part of the mutable update payload

## Process Flow

```mermaid
flowchart TD
    A[Receive update request] --> B{Location exists?}
    B -->|No| C[Return error: STORAGE_LOCATION_NOT_FOUND]
    B -->|Yes| D{Name changed?}
    D -->|Yes| E{New name unique in site?}
    E -->|No| F[Return error: DUPLICATE_LOCATION_NAME]
    E -->|Yes| G[Update location record]
    D -->|No| G
    G --> H[Return updated location]
```

## External Dependencies

- None

## Error Scenarios

- **STORAGE_LOCATION_NOT_FOUND**: Referenced storage location does not exist
- **DUPLICATE_LOCATION_NAME**: A location with the same name or code already exists in the site

## Test Cases

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