# ListPurchaseReceiptQuantitiesForMatching

## Overview

ListPurchaseReceiptQuantitiesForMatching returns posted purchase goods-receipt quantities aggregated by purchase-order line. It is the inventory-owned boundary query used by payable matching logic when the caller only needs received quantity totals, not receipt-line allocation evidence.

## Business Rules

- Only InventoryExecution rows with `executionType=GOODS_RECEIPT` and `status=POSTED` are included
- Only InventoryExecutionLine rows with `direction=IN` are included
- The InventoryExecution must have `sourceDocumentType=PURCHASE_ORDER`
- The InventoryExecutionLine `sourceLineId` must match one of the requested purchase-order line IDs
- Results are grouped by purchase-order line ID

## Process Flow

```mermaid
flowchart TD
    A[Receive purchase order line IDs] --> B{Any line IDs?}
    B -->|No| C[Return empty quantities]
    B -->|Yes| D[Join InventoryExecutionLine to InventoryExecution]
    D --> E[Filter posted purchase goods receipt IN lines]
    E --> F[Group received quantity by purchase order line]
    F --> G[Return receipt quantity totals]
```

## External Dependencies

- None

## Error Scenarios

None. No matching receipt evidence returns an empty list.

## Test Cases

- lists posted purchase goods receipt quantities by purchase order line
- returns empty quantities without querying when no purchase order lines are provided
