# closePurchaseOrder

## Overview

Closes an ORDERED purchase order. Sets `closedAt`, resets incoming inventory to 0.

Accepts an optional `closeReason` (String).

Returns the purchase order `id` and new `status` (`CLOSED`).

## Modules Commands Used

- [purchase] ClosePurchaseOrder

## Exception Handling

| Error Code | Description |
| --- | --- |
| PURCHASE_PURCHASE_ORDER_NOT_FOUND | The specified purchase order does not exist |
| PURCHASE_PURCHASE_ORDER_NOT_CLOSABLE | The purchase order is not in a status that allows closing |
| PURCHASE_OPEN_QUANTITY_REMAINS | Outstanding quantities remain and cannot be closed as-is |
