# SendSalesInvoice

## Permission Scope

salesBilling

## Overview

SendSalesInvoice records customer-facing delivery of an issued invoice. The command captures the metadata required by company policy to treat the invoice as sent.

## Business Rules

- Only ISSUED invoices may be marked as sent.
- Required delivery metadata must be present before the status moves to SENT.

## Process Flow

```mermaid
flowchart TD
    A[Receive send request] --> B[Load issued invoice]
    B --> C{Status is ISSUED?}
    C -->|No| D[Return INVALID_INVOICE_STATUS]
    C -->|Yes| E[Validate delivery metadata]
    E --> F[Set status to SENT]
    F --> G[Return sent invoice]
```

## External Dependencies

- None

## Error Scenarios

- **SALES_INVOICE_NOT_FOUND**: Referenced sales invoice does not exist
- **INVALID_INVOICE_STATUS**: Invoice status does not allow this operation
- **DELIVERY_METADATA_REQUIRED**: Required invoice delivery metadata is missing.

## Test Cases

- marks an issued invoice as sent when delivery metadata is present
- throws when invoice is not issued
- throws when delivery metadata is incomplete
