laravel-fiscal-colombia
Colombian tax and fiscal tools for Laravel and MoonShine.
- Validates NIT with verification digit according to the official DIAN algorithm.
- Document types according to Resolution 000042 of 2020 (CC, NIT, CE, TI, PEP, PPT, NUIP…).
- Configurable withholdings: retefuente, reteiva, and reteica.
- MoonShine fields ready for use in the admin panel (optional).
Dual use: works as a pure Laravel package or as a plugin with UI fields for MoonShine v4.
Requirements
| Dependency | Minimum Version |
|---|---|
| PHP | 8.2+ |
| Laravel | 10 / 11 / 12 |
| MoonShine (optional) | ^4.14 |
Installation
composer require jamesmosq/laravel-fiscal-colombiacomposer require jamesmosq/laravel-fiscal-colombia
The FiscalColombiaServiceProvider is automatically registered via Laravel auto-discovery.
Publish configuration
php artisan vendor:publish --tag=fiscal-colombia-configphp artisan vendor:publish --tag=fiscal-colombia-config
This creates config/fiscal-colombia.php in your application with the withholding rates. You can adjust them according to your economic activity or each tax reform.
Usage — Pure Laravel
NitValidator
Pure PHP class, no framework dependencies. Can be used in any PHP 8.2+ project.
use JamesMosqueraiscalColombia heb hem he he hem, N;// Calculate the verification digitNitValidator::calcularDv('800197268'); // → 4// Validate complete NIT (accepts with dots, hyphen, spaces, or continuous digits)NitValidator::esValido('800197268-4'); // → trueNitValidator::esValido('800.197.268-4'); // → trueNitValidator::esValido('8001972684'); // → true (last digit = DV)NitValidator::esValido('800197268-9'); // → false (incorrect DV)// Format with dots and hyphen: 800.197.268-4NitValidator::formatear('800197268', 4);use JamesMosqueraiscalColombia heb hem he he hem, N;// Calculate the verification digitNitValidator::calcularDv('800197268'); // → 4// Validate complete NIT (accepts with dots, hyphen, spaces, or continuous digits)NitValidator::esValido('800197268-4'); // → trueNitValidator::esValido('800.197.268-4'); // → trueNitValidator::esValido('8001972684'); // → true (last digit = DV)NitValidator::esValido('800197268-9'); // → false (incorrect DV)// Format with dots and hyphen: 800.197.268-4NitValidator::formatear('800197268', 4);
Reference NITs verified with DIAN:
| Entity | NIT | DV |
|---|---|---|
| DIAN | 800.197.268 | 4 |
| EPM | 890.904.996 | 1 |
| Univ. Nacional | 899.999.063 | 3 |
NitRule — Form validation
use JamesMosqueraiscalColombia heb hem he he hem,;$request->validate(['nit' => ['required', new NitRule],]);use JamesMosqueraiscalColombia heb hem he he hem,;$request->validate(['nit' => ['required', new NitRule],]);
Accepts all formats: 800197268-4, 800.197.268-4, 8001972684.
TipoDocumento — DIAN Enum
Document types according to DIAN Resolution 000042 of 2020.
use JamesMosqueraiscalColombia heb hem, ,=Types;TipoDocumento::CC->label(); // → "Cédula de Ciudadanía"TipoDocumento::NIT->codigoDian(); // → 31TipoDocumento::NIT->requiereDv(); // → trueTipoDocumento::CC->requiereDv(); // → false// Array for HTML selectsTipoDocumento::opciones();// [['value' => 'CC', 'label' => 'Cédula de Ciudadanía'], ...]use JamesMosqueraiscalColombia heb hem, ,=Types;TipoDocumento::CC->label(); // → "Cédula de Ciudadanía"TipoDocumento::NIT->codigoDian(); // → 31TipoDocumento::NIT->requiereDv(); // → trueTipoDocumento::CC->requiereDv(); // → false// Array for HTML selectsTipoDocumento::opciones();// [['value' => 'CC', 'label' => 'Cédula de Ciudadanía'], ...]
| Enum | Abbreviation | DIAN Code |
|---|---|---|
TipoDocumento::CC |
CC | 13 |
TipoDocumento::NIT |
NIT | 31 |
TipoDocumento::CE |
CE | 22 |
TipoDocumento::RC |
RC | 11 |
TipoDocumento::TI |
TI | 12 |
TipoDocumento::PEP |
PEP | 41 |
TipoDocumento::PPT |
PPT | 42 |
TipoDocumento::PAS |
PAS | 47 |
TipoDocumento::NUIP |
NUIP | 91 |
RegimenTributario — Enum
use JamesMosqueraiscalColombia heb hem he he hem,;RegimenTributario::RESPONSABLE_IVA->label(); // → "Responsable de IVA"RegimenTributario::RESPONSABLE_IVA->aplicaReteiva(); // → trueRegimenTributario::NO_RESPONSABLE_IVA->aplicaReteiva(); // → falseRegimenTributario::opciones(); // array for selectsuse JamesMosqueraiscalColombia heb hem he he hem,;RegimenTributario::RESPONSABLE_IVA->label(); // → "Responsable de IVA"RegimenTributario::RESPONSABLE_IVA->aplicaReteiva(); // → trueRegimenTributario::NO_RESPONSABLE_IVA->aplicaReteiva(); // → falseRegimenTributario::opciones(); // array for selects
| Enum | Label |
|---|---|
RegimenTributario::RESPONSABLE_IVA |
Responsable de IVA |
RegimenTributario::NO_RESPONSABLE_IVA |
No Responsable de IVA |
RegimenTributario::GRAN_CONTRIBUYENTE |
Gran Contribuyente |
RegimenTributario::REGIMEN_SIMPLE |
Régimen Simple de Tributación |
TipoPersona — Enum
use JamesMosqueraiscalColombia heb hem,;TipoPersona::JURIDICA->label(); // → "Persona Jurídica"TipoPersona::NATURAL->documentosPermitidos(); // → [CC, CE, RC, TI, PEP, PPT, PAS, NUIP]TipoPersona::JURIDICA->documentosPermitidos(); // → [NIT]use JamesMosqueraiscalColombia heb hem,;TipoPersona::JURIDICA->label(); // → "Persona Jurídica"TipoPersona::NATURAL->documentosPermitidos(); // → [CC, CE, RC, TI, PEP, PPT, PAS, NUIP]TipoPersona::JURIDICA->documentosPermitidos(); // → [NIT]
Withholdings
Rates are read from config/fiscal-colombia.php, allowing you to adjust them without modifying the package.
use JamesMosqueraiscalColombia heb hem he he hem,;$resultado = Retenciones::calcular(valorBase: 1_000_000,concepto: 'honorarios',calcularReteiva: true,actividadIca: 'servicios');// [// 'retefuente' => 110_000, // 11%// 'reteiva' => 150_000, // 15% of VAT// 'reteica' => 966, // 0.966‰// 'total_retenciones' => 260_966,// 'valor_neto' => 739_034,// ]// Just retefuenteRetenciones::retefuente(1_000_000, 'honorarios'); // → 110_000use JamesMosqueraiscalColombia heb hem he he hem,;$resultado = Retenciones::calcular(valorBase: 1_000_000,concepto: 'honorarios',calcularReteiva: true,actividadIca: 'servicios');// [// 'retefuente' => 110_000, // 11%// 'reteiva' => 150_000, // 15% of VAT// 'reteica' => 966, // 0.966‰// 'total_retenciones' => 260_966,// 'valor_neto' => 739_034,// ]// Just retefuenteRetenciones::retefuente(1_000_000, 'honorarios'); // → 110_000
Default concepts available:
| Concept | Rate |
|---|---|
honorarios |
11 % |
servicios |
4 % |
compras |
2.5 % |
arrendamiento |
4 % |
rendimientos |
7 % |
Usage — With MoonShine v4
NitField
Text field with automatic real-time verification digit calculation (Alpine.js).
use JamesMosquera heb hem,;NitField::make('NIT', 'nit')->required(),use JamesMosquera heb hem,;NitField::make('NIT', 'nit')->required(),
The field shows the calculated DV while the user types.
TipoDocumentoField
Pre-loaded select with all document types from Resolution 000042/2020.
use JamesMosquera heb hem,;TipoDocumentoField::make('Document type', 'tipo_documento')->required(),use JamesMosquera heb hem,;TipoDocumentoField::make('Document type', 'tipo_documento')->required(),
Options are automatically loaded from the TipoDocumento enum. You can pass a subset with ->options([...]).
Updating rates
Rates change annually by decree of the Ministry of Finance. After publishing the config, edit config/fiscal-colombia.php:
'retefuente' => ['honorarios' => 11.0, // update according to current decree],'retefuente' => ['honorarios' => 11.0, // update according to current decree],
Tests
cd packages/laravel-fiscal-colombia./vendor/bin/phpunitcd packages/laravel-fiscal-colombia./vendor/bin/phpunit
20 tests, 27 assertions — all DIAN algorithms verified against real NITs.
License
MIT — see LICENSE.
Developed by James Mosquera Rentería · Medellín, Colombia Based on Colombian regulations: E.T., DIAN Resolution 000042/2020