1. Go to this page and download the library: Download schoolaid/fel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
schoolaid / fel example snippets
use Schoolaid\Fel\Enums\CurrencyEnum;
use Schoolaid\Fel\Enums\DocumentTypeEnum;
use Schoolaid\Fel\Enums\IVAAffiliationTypeEnum;
use Schoolaid\Fel\Models\FelAddenda;
use Schoolaid\Fel\Models\FelAddress;
use Schoolaid\Fel\Models\FelIssuer;
use Schoolaid\Fel\Models\FelItem;
use Schoolaid\Fel\Models\FelItems;
use Schoolaid\Fel\Models\FelPhrase;
use Schoolaid\Fel\Models\FelPhrases;
use Schoolaid\Fel\Models\FelReceiver;
use Schoolaid\Fel\Models\FelTotals;
use Schoolaid\Fel\Models\Invoice;
use Schoolaid\Fel\Actions\FelGenerate;
use Schoolaid\Fel\Actions\FelCertify;
use Schoolaid\Fel\Config\FelConfig;
// Configurar datos básicos
$issuerAddress = new FelAddress(
'Avenida Reforma 15-85 Zona 10, Edificio Torre Internacional Nivel 11',
'01001',
'Guatemala',
'Guatemala',
'GT'
);
$issuer = new FelIssuer(
'[email protected]',
'1',
'12345678', // NIT del emisor
'Empresa, S.A.',
IVAAffiliationTypeEnum::General,
'Mi Empresa',
$issuerAddress
);
$receiverAddress = new FelAddress(
'Avenida Las Américas 7-62 Zona 13',
'01013',
'Guatemala',
'Guatemala',
'GT'
);
$receiver = new FelReceiver(
'87654321', // NIT del receptor (o CF para Consumidor Final)
'[email protected]',
'Cliente Frecuente, S.A.',
$receiverAddress
);
// Frases requeridas para FACT
$phrases = new FelPhrases([
new FelPhrase(1, 1) // Frase 1 y Escenario 1 - Afecta IVA
]);
// Productos/servicios
$items = new FelItems([
new FelItem(
1, // Número de línea
'B', // Bien (B) o Servicio (S)
500.0, // Precio unitario sin IVA
'UND', // Unidad de medida
'Computadora portátil HP Probook 450 G8', // Descripción
500.0, // Precio (sin impuestos)
1, // Cantidad
0.0, // Descuento
[], // Los impuestos se calcularán automáticamente
500.0 // Total de línea
),
new FelItem(
2, // Número de línea
'S', // Bien (B) o Servicio (S)
200.0, // Precio unitario sin IVA
'UND', // Unidad de medida
'Servicio de instalación y configuración', // Descripción
200.0, // Precio (sin impuestos)
1, // Cantidad
0.0, // Descuento
[], // Los impuestos se calcularán automáticamente
200.0 // Total de línea
)
]);
// Totales con IVA
$totals = new FelTotals(
grandTotal: 700.0 // Total incluyendo impuestos (los demás valores se calcularán automáticamente)
);
// Addendas (información adicional)
$addendas = [
new FelAddenda(
'http://www.sat.gob.gt/face2/ComplementoFacturaEspecial/0.1.0',
'ReferenciaInterna',
'Orden #FT-2023-1234'
),
new FelAddenda(
'http://www.sat.gob.gt/face2/ComplementoFacturaEspecial/0.1.0',
'DatosCliente',
'Proyecto: Implementación ERP'
)
];
// Crear la factura (FACT)
$invoice = new Invoice(
DocumentTypeEnum::LOCAL_INVOICE, // FACT - Factura local
now()->format('Y-m-d\TH:i:s'),
CurrencyEnum::QUETZAL,
$issuer,
$receiver,
$phrases,
$items,
$totals,
$addendas
);
// Certificar
$config = FelConfig::fromConfig();
$certify = new FelCertify($invoice, $config);
$response = $certify->execute();
// Procesar respuesta
$uuid = $response->getUuid();
$serie = $response->getSerial();
$numero = $response->getNumber();
$fecha = $response->getCertificationDate();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.