Skip to content

Voiding & Cancellation

A document that has been authorized by the DGI cannot be deleted. It can only be voided (anulado) — Alanube records the void event and forwards it to the DGI.

Time limits

The DGI's regime allows voiding within a window of the issue date. As of writing, the practical limit communicated by Alanube is 182 hours (~7.5 days). After that, the void will be rejected and you must issue a credit note instead.

Endpoints

Document Method Endpoint
Invoice DELETE /pan/v1/invoices/{document_id}
Credit note DELETE /pan/v1/credit-notes/{document_id}

The body must include a reason between 15 and 1000 characters. Shorter reasons are rejected.

Mutations

Mutation File
void_invoice(invoice_id, reason) invoice_mutations.py
void_credit(credit_id, reason) credit_mutations.py

What happens on success

  • legal_status stays at DGI_AUTHORIZED (the document is still legally recognized as having existed).
  • invoice_status (or credit_status) flips to VOID.
  • Alanube emits a separate "event" document representing the void, which the DGI cross-references.

What happens on failure

Failure mode Cause Resolution
400 "reason too short" Reason < 15 chars Provide a real reason.
400 "outside void window" Past the time limit Issue a credit note instead.
404 from Alanube Wrong document_id or wrong tenant Check pac_company_id.
Network/5xx Transient Retried twice (tenacity).

Cancellation vs voiding vs canceling

Three terms with three meanings:

Term What it is DB column
Void DGI-recognized cancellation via PAC. Permanent. invoice_status = VOID
Internal cancel Soft state change in Cifras. No PAC call. Used for proformas or pre-DGI invoices. invoice_status = CANCELED
Credit-canceled The invoice's balance has been fully neutralized by credit notes. invoice_status = CANCELED or PARTIALLY_CANCELED

If the document was never sent to PAC (PROFORM mode), there's nothing to void — just mark it canceled internally.

Legacy cancel endpoint

PacService.cancel_invoice calls a different, older endpoint:

POST /api/v1/InvoiceEvents/CreateCancellation

This predates the unified DELETE flow. New code should use void_invoice / void_credit_note. The legacy method is kept for backwards compatibility with old data flows that haven't been migrated.