# CancelGoodsReceipt

## Overview

CancelGoodsReceipt abandons a draft goods receipt before it affects purchase-order fulfillment or inventory execution.

## Business Rules

- Target goods receipt must exist
- Only receipts in `DRAFT` status can be cancelled
- Cancelling a draft receipt does not change purchase-order received quantity
- Posted receipts cannot be cancelled; they require a future compensating correction workflow

## Process Flow

```mermaid
flowchart TD
    A[Receive cancel request] --> B{Goods receipt exists?}
    B -->|No| C[Return GOODS_RECEIPT_NOT_FOUND]
    B -->|Yes| D{Status is DRAFT?}
    D -->|No| E[Return GOODS_RECEIPT_NOT_DRAFT]
    D -->|Yes| F[Set status to CANCELLED]
    F --> G[Return cancelled receipt]
```

## External Dependencies

- None

## Error Scenarios

- **GOODS_RECEIPT_NOT_FOUND**: Target goods receipt does not exist
- **GOODS_RECEIPT_NOT_DRAFT**: Goods receipt is not in `DRAFT` status

## Test Cases

- cancels a draft goods receipt
- returns error when goods receipt does not exist
- returns error when goods receipt is already posted
