Overview
Credit Notes (Notas de Crédito) are used to correct or cancel previously issued invoices or boletas. They reduce the total amount owed by the client.Service Layer Only: Credit notes are currently implemented in the
DocumentService class but do not yet have REST API endpoints exposed. To use this functionality, you’ll need to interact directly with the service layer in your Laravel application. REST API endpoints are planned for a future release.Prerequisites
- An existing invoice or boleta to correct
- Configured company and branch
- Valid reason code for the credit note
Reason Codes
SUNAT defines specific codes for credit note reasons:| Code | Description | Use Case |
|---|---|---|
01 | Cancellation of operation | Full cancellation |
02 | Cancellation due to error in RUC | Wrong client RUC |
03 | Correction due to error in description | Wrong product description |
04 | Global discount | Volume discount |
05 | Discount per item | Item-level discount |
06 | Total return | Full product return |
07 | Partial return | Partial product return |
08 | Bonus | Promotional bonus |
09 | Price decrease | Price adjustment |
10 | Other concept | Other valid reasons |
11 | Transfer adjustments | |
12 | Expenses incurred for free sales | |
13 | Free bonuses |
Creating a Credit Note
Full Cancellation
Success Response
Required Fields
Company ID issuing the credit note
Branch ID (must belong to company)
Credit note series (max 4 characters)
- Invoices: “FC01”, “FC02”, etc.
- Boletas: “BC01”, “BC02”, etc.
Issue date (YYYY-MM-DD)
Affected document type:
01: Invoice (Factura)03: Boleta07: Credit Note08: Debit Note
Complete number of affected document (e.g., “F001-00000123”)
Reason code (01-13, see table above)
Reason description (max 250 characters)
Currency:
PEN or USDDetails Array
The details array should match or be a subset of the original document:Product/service code (should match original)
Item description
Unit of measure
Quantity to credit (must be ≤ original quantity)
Unit value (should match original)
Tax affectation (should match original)
Sending to SUNAT
Credit notes are sent the same way as invoices:Success Response
Advanced Features
Credit with Payment Terms
If the original was on credit, you can specify payment terms:Related Documents
Link the credit note to related guides or other documents:Custom Legends
The API automatically generates the standard amount legend (code 1000) if not provided.
Downloading Documents
Download XML
Download CDR
Download PDF
Querying Credit Notes
Query Parameters
company_id: Filter by companybranch_id: Filter by branchestado_sunat: Filter by statusfecha_desde: Start datefecha_hasta: End dateper_page: Items per page
Implementation Details
Fromapp/Services/DocumentService.php:880-998, the credit note creation:
- Validates company/branch relationship
- Creates or retrieves client
- Generates automatic correlative for series
- Processes details and calculates totals
- Validates tax affectation types
- Generates automatic legends
- Stores with status
PENDIENTE
Automatic Calculations
The API automatically calculates:- Line item totals (quantity × unit value)
- IGV per item
- Subtotals by tax type (gravadas, exoneradas, inafectas)
- Total IGV
- Total amount
Common Errors
| Error | Cause | Solution |
|---|---|---|
| Referenced document not found | num_doc_afectado doesn’t exist | Verify document number exists |
| Client mismatch | Different client than original | Use same client as original document |
| Invalid reason code | Wrong cod_motivo | Use valid code from 01-13 |
| Amount exceeds original | Credit exceeds original amount | Verify quantities and unit values |
| Document not accepted | Original not accepted by SUNAT | Original must be ACEPTADO first |
Best Practices
- Always reference the complete document number including series (e.g., “F001-00000123”)
- Use descriptive reason descriptions for audit trails
- Match client data exactly from the original document
- Verify original document is accepted before creating credit note
- Keep item codes consistent with original document for tracking
- Document business reason in
des_motivofield clearly
Special Cases
Correcting RUC Error
For code02 (error in RUC):
Global Discount
For code04 (global discount):
Validation Rules
- Serie is required and max 4 characters
tipo_doc_afectadomust be: 01, 03, 07, or 08cod_motivomust be: 01-13- Client document type must be: 0, 1, 4, or 6
- Details array must have at least 1 item
- All monetary values must be ≥ 0
Next Steps
Debit Notes
Learn how to create debit notes for amount increases
PDF Generation
Customize credit note PDF templates
