# UpdateSalesCreditNote

## Overview

UpdateSalesCreditNote revises draft credit-note content before issue. It supports correction of quantities, amounts, references, and reason codes while the document remains draft.

## Business Rules

- Only DRAFT credit notes may be updated directly.
- Updated correction lines must still reference valid issued invoice lines.

## Process Flow

```mermaid
flowchart TD
    A[Receive update request] --> B[Load credit note]
    B --> C{Status is DRAFT?}
    C -->|No| D[Return CREDIT_NOTE_NOT_EDITABLE]
    C -->|Yes| E[Validate updated correction content]
    E --> F[Persist updates]
    F --> G[Return updated credit note]
```

## External Dependencies

- [getSalesCreditNote](../queries/GetSalesCreditNote.md) - Load current credit-note state before applying changes.

## Error Scenarios

- **SALES_CREDIT_NOTE_NOT_FOUND**: Referenced sales credit note does not exist.
- **CREDIT_NOTE_NOT_EDITABLE**: Only DRAFT credit notes may be updated.
- **INVALID_CREDIT_NOTE_LINE**: Updated correction content is invalid.

## Test Cases

- updates draft credit-note lines
- returns error when updating an issued credit note
- returns error when correction content is invalid
