# RejectStockAdjustment

## Permission Scope

inventoryApproval

## Overview

rejectStockAdjustment transitions a stock adjustment from SUBMITTED to REJECTED status. This indicates that a reviewer has declined the adjustment. An optional rejection reason can be provided. The submitter can then update the adjustment (which transitions it back to DRAFT) and resubmit. No inventory or ledger changes occur.

## Business Rules

- Stock adjustment must exist
- Stock adjustment must be in SUBMITTED status
- Rejection reason is optional
- Transitions status from SUBMITTED to REJECTED
- No inventory or ledger changes occur

## Process Flow

```mermaid
flowchart TD
    A[Reject stock adjustment request] --> B{Adjustment exists?}
    B -->|No| C[Return error: STOCK_ADJUSTMENT_NOT_FOUND]
    B -->|Yes| D{Status is SUBMITTED?}
    D -->|No| E[Return error: INVALID_STATUS]
    D -->|Yes| F[Transition to REJECTED]
    F --> G{Rejection reason provided?}
    G -->|Yes| H[Store rejection reason]
    G -->|No| I[Skip]
    H --> J[Return updated stock adjustment]
    I --> J
```

## External Dependencies

- [inventory::StockAdjustment](../model/StockAdjustment.md) - Validates existence and current status, updates status to REJECTED

## Error Scenarios

- **STOCK_ADJUSTMENT_NOT_FOUND**: Referenced stock adjustment does not exist
- **INVALID_STATUS**: Target entity is not in a valid status for this operation

## Test Cases

- returns error when stock adjustment does not exist
- returns error when stock adjustment is not in SUBMITTED status
- transitions stock adjustment from SUBMITTED to REJECTED
- succeeds without rejection reason
