Skip to content

Credit Notes

Credit notes (Notas de Crédito) are reverse-charge documents issued against an existing invoice. They reduce or fully cancel the receiver's obligation.

Differences from invoices

The submission flow mirrors Invoice Submission. The differences:

Aspect Invoice Credit Note
Endpoint POST /pan/v1/invoices POST /pan/v1/credit-notes
Required reference None invoice_cufe and invoice_date of the original invoice
CUFE column invoice_number credit_number
Document type code 01 02
Service InvoicePacService CreditPacService
Factory PacInvoiceFactory PacCreditNoteFactory
Mutations create_invoice, generate_invoice, ... create_credit, void_credit, convert_credit_to_dgi

Referenced documents

The factory builds a DocumentosFiscalesReferenciados block:

PacCreditNoteFactory._create_referenced_documents(invoice_cufe, invoice_date)

This points the credit at the original invoice. Without it, Alanube rejects the submission. The original invoice must already be DGI_AUTHORIZED — you can't credit a document that doesn't legally exist.

Status flow

The legal status machine is identical to invoices (Document Lifecycle). Business statuses differ:

Status Meaning
UNAPPLIED Default. Not yet applied to any invoice.
APPLIED Applied against an invoice (reduces invoice balance).
CANCELED Soft-canceled internally.
VOID Voided through PAC.

Mutations

credit_mutations.py

Mutation What it does
create_credit(credit) Create + submit a credit note (or save as proforma if mode is PROFORM).
void_credit(credit_id, reason) Void in PAC via DELETE /credit-notes/{id}. See Voiding.
convert_credit_to_dgi(credit_id) Promote a PROFORM credit to a DGI credit by submitting it now.

PDF attachment

Three paths, same as invoices:

  1. Webhook (preferred) — PacWebhookService._handle_credit_pac_authorized.
  2. Polling — currently invoice-focused; check pac_status_poll_task for credit support.
  3. Manual — attach_pac_pdf(source_id, source_type=CREDIT_NOTE).

See PDF Attachment for the shared logic.