# CancelPurchaseChangeOrder

## Permission Scope

purchaseOrder

## Overview

CancelPurchaseChangeOrder moves a `DRAFT` change order to `CANCELLED` status, abandoning the proposed changes without affecting the target purchase order.

## Business Rules

- Target change order must exist
- Only change orders in `DRAFT` status can be cancelled
- Cancellation does not modify the target purchase order

## Process Flow

```mermaid
flowchart TD
    A[Receive cancel request] --> B{Change order exists?}
    B -->|No| C[Return CO_NOT_FOUND]
    B -->|Yes| D{Status is DRAFT?}
    D -->|No| E[Return CO_NOT_DRAFT]
    D -->|Yes| F["Set status to CANCELLED"]
    F --> G[Return cancelled change order]
```

## External Dependencies

- None

## Error Scenarios

- **CO_NOT_FOUND**: Target change order does not exist
- **CO_NOT_DRAFT**: Change order is not in `DRAFT` status

## Test Cases

- cancels a valid draft change order
- does not modify the target purchase order on cancellation
- returns error when change order does not exist
- returns error when change order is not in DRAFT status
