Skip to main content

cancelInvoice

Requires at least one of the permissions payments:invoice:cancel or purchase:purchase_invoice:cancel.

Cancels an invoice and reverses what it caused: payment allocations on it are reversed, shipped quantities are restored on the source order, and the order's invoice status is recalculated. Money already settled against the invoice is given back through a credit note (sales invoice) or a debit note (purchase invoice). Call invoiceCancellationPreview first; the cancellation is refused if blockers exist or if the allocations changed since you read them.

Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.

Example:

mutation CancelInvoice($id: ID!, $reverseAllocations: Boolean!) {
cancelInvoice(id: $id, reverseAllocations: $reverseAllocations) {
id
invoiceNumber
supplierCode
supplierDisplayName
supplierName
status
allocations {
id
invoiceNumber
paymentNumber
createdAt
amount
appliedFromAdvance
}
}
}

Variables:

{
"id": "id",
"reverseAllocations": true
}

Response:

{
"data": {
"cancelInvoice": {
"id": "id",
"invoiceNumber": "string",
"supplierCode": "string",
"supplierDisplayName": "string",
"supplierName": "string",
"status": "APPROVED",
"allocations": [
{
"id": "id",
"invoiceNumber": "string",
"paymentNumber": "string",
"createdAt": "2025-01-15T00:00:00Z",
"amount": 0,
"appliedFromAdvance": true
}
]
}
}
}

Cancel an invoice and reverse its payment allocations:

mutation CancelInvoice($id: ID!, $reverseAllocations: Boolean!) {
cancelInvoice(id: $id, reverseAllocations: $reverseAllocations) {
id
invoiceNumber
status
}
}

Variables:

{
"id": "INVOICE_ID",
"reverseAllocations": true
}

Response:

{
"data": {
"cancelInvoice": {
"id": "INVOICE_ID",
"invoiceNumber": "INVOICE_NUMBER",
"status": "CANCELLED"
}
}
}
cancelInvoice(
id: ID!
reverseAllocations: Boolean! = false
): Invoice!

Arguments​

cancelInvoice.id ● ID! non-null scalar​

The ID of the invoice.

cancelInvoice.reverseAllocations ● Boolean! non-null scalar​

Whether to also reverse the payments allocated to the invoice. Defaults to false. Use invoiceCancellationPreview to see the effect first.

Type​

Invoice object​

A sales invoice issued to a customer or a purchase invoice received from a supplier, with its lines, totals, status and settlement.