# RejectPurchaseChangeOrder

## Permission Scope

purchaseOrder

## Overview

RejectPurchaseChangeOrder moves a `SUBMITTED` change order to `REJECTED` status with a rejection reason, returning it to `DRAFT` for revision by the requester.

## Business Rules

- Target change order must exist
- Only change orders in `SUBMITTED` status can be rejected
- A `rejectionReason` must be provided
- Rejected change orders return to `DRAFT` status for further revision

## Process Flow

```mermaid
flowchart TD
    A[Receive reject request] --> B{Change order exists?}
    B -->|No| C[Return CO_NOT_FOUND]
    B -->|Yes| D{Status is SUBMITTED?}
    D -->|No| E[Return CO_NOT_SUBMITTED]
    D -->|Yes| F[Record rejectionReason]
    F --> G["Set status to REJECTED, then back to DRAFT"]
    G --> H[Return rejected change order]
```

## External Dependencies

- None

## Error Scenarios

- **CO_NOT_FOUND**: Target change order does not exist
- **CO_NOT_SUBMITTED**: Change order is not in `SUBMITTED` status

## Test Cases

- rejects a valid submitted change order with a rejection reason
- returns the change order to DRAFT status after rejection
- returns error when change order does not exist
- returns error when change order is not in SUBMITTED status
