# cancelIncomingPayment

## Overview

Cancels a **DRAFT** incoming payment, transitioning the `IncomingPayment` from DRAFT to CANCELLED. Cancellation discards an unposted payment and its draft settlement allocations without ever touching the general ledger. Only DRAFT payments can be cancelled — a POSTED payment must be reversed with [reverseIncomingPayment](./reverseIncomingPayment.md) so its journal entry is properly backed out and its settled items re-opened. `id` is the IncomingPayment id.

## Modules Commands Used

- [account-receivable] cancelIncomingPayment

## Exception Handling

| Error Code | Description |
| --- | --- |
| ACCOUNT_RECEIVABLE_INCOMING_PAYMENT_NOT_FOUND | No incoming payment exists for the given ID. |
| ACCOUNT_RECEIVABLE_INCOMING_PAYMENT_INVALID_STATUS | The payment is not in DRAFT status; only DRAFT payments can be cancelled. |
