# UpdatePartner

## Permission Scope

partner

## Overview

updatePartner modifies the mutable fields of an existing business partner. Only name and preferred currency can be updated. Partner type is fixed by the existing record and is not part of the update input. This command supports incremental enrichment of partner data throughout the partner lifecycle.

## Business Rules

- Partner must exist in the system
- Name, if provided, must be non-empty
- Preferred currency, if provided, must reference an existing Currency in the primitives module
- Partner type is not part of the update input

## Process Flow

```mermaid
flowchart TD
    A[Receive update request] --> B{Partner exists?}
    B -->|No| C[Return error: partner not found]
    B -->|Yes| D{Name provided?}
    D -->|Yes| E{Name non-empty?}
    E -->|No| F[Return error: invalid name]
    E -->|Yes| G{Currency provided?}
    D -->|No| G
    G -->|Yes| H{Currency exists?}
    H -->|No| I[Return error: currency not found]
    H -->|Yes| J[Update partner record]
    G -->|No| J
    J --> K[Return updated partner]
```

## External Dependencies

- [primitives::Currency](../../../primitives/docs/models/Currency.md) - Validates that the referenced preferred currency exists (when provided)

## Error Scenarios

- **PARTNER_NOT_FOUND**: Specified partner ID does not exist
- **CURRENCY_NOT_FOUND**: Referenced currency does not exist
- **INVALID_NAME**: Name is empty, whitespace-only, or not provided

## Test Cases

- updates partner name
- updates preferred currency
- returns error when partner not found
- returns error when name is empty
- returns error when currency not found
