# GetGoodsReceipt

## Overview

GetGoodsReceipt retrieves a goods receipt with its receipt lines, receipt date, and posting status.

## Business Rules

- Lookup key is goods-receipt id
- Returns receipts in any status so draft, cancelled, and posted receipts remain reviewable
- Response includes receipt lines with their optional purchase-order-line references; related purchase orders are derived from line references rather than a header-level foreign key. PO-unlinked lines have null `purchaseOrderLineId`
- Returns null when the goods receipt does not exist

## Process Flow

```mermaid
flowchart TD
    A[Receive goodsReceiptId] --> B[Select GoodsReceipt and receipt lines by id]
    B --> C{Receipt found?}
    C -->|Yes| D[Return goods receipt with lines]
    C -->|No| E[Return null]
```

## External Dependencies

- None

## Error Scenarios

- **GOODS_RECEIPT_NOT_FOUND**: Referenced goods receipt does not exist

## Test Cases

- returns goods receipt when found
- returns receipt lines with the receipt
- returns null when goods receipt does not exist
