# ListPurchaseOrderLinesForMatching

## Overview

ListPurchaseOrderLinesForMatching returns purchase order line attributes needed for supplier invoice matching. It is the purchase-owned boundary query used by AP matching logic so account-payable does not query the PurchaseOrderLine table or carry its commercial fields directly.

The query returns one row per requested purchase-order line ID, exposing the owning purchase order ID, the ordered item, ordered quantity, unit price, unit of measure, whether the line requires a physical goods receipt, and the current received quantity projection.

## Business Rules

- Returns one row per existing requested purchase-order line ID
- Each row exposes purchaseOrderId, itemId, quantity, unitPrice, unitId, requiresPhysicalReceipt, and receivedQuantity
- Unknown purchase-order line IDs are omitted from the result


Each returned line includes its purchase order's `companyId` and `supplierAccountId`. AP compares both with its invoice identity before using the line for matching or accounting. Other consumers may declare a narrower port, such as inbound shipment's `{ id, unitPrice }` price projection; they need not depend on these extra fields.

## Process Flow

```mermaid
flowchart TD
    A[Receive purchase order line IDs] --> B{Any line IDs?}
    B -->|No| C[Return empty list]
    B -->|Yes| D[Select matching purchase order lines]
    D --> E[Return purchase order line attributes]
```

## External Dependencies

- None

## Error Scenarios

None. Unknown purchase-order line IDs are omitted and an empty input returns an empty list.

## Test Cases

- lists purchase order line attributes for matching
- returns empty list without querying when no purchase order line IDs are provided
