1. Go to this page and download the library: Download djasoft/sunat-comprobantes 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/ */
djasoft / sunat-comprobantes example snippets
use Djasoft\Sunat\Calculator;
$calc = new Calculator;
// buildDetail recibe el precio unitario CON IGV, que es el que ve el cliente
// y el que sueles tener guardado. Él calcula el valor sin IGV.
$data = ['details' => [
$calc->buildDetail('SKU-001', 'NIU', 'Teclado mecánico', 2, 118.00),
$calc->buildDetail('SKU-002', 'NIU', 'Libro', 1, 50.00, Calculator::EXONERADO),
]];
$calc->calculate($data);
$data['mtoOperGravadas']; // 200.00
$data['mtoOperExoneradas']; // 50.00
$data['mtoIGV']; // 36.00
$data['valorVenta']; // 250.00
$data['subTotal']; // 286.00
$data['mtoImpVenta']; // 286.00 (redondeado al décimo inferior)
$data['redondeo']; // 0.00
$data['legends'][0]['value']; // "DOSCIENTOS OCHENTA Y SEIS CON 00/100 SOLES"
use BaconQrCode\Renderer\{ImageRenderer, RendererStyle\RendererStyle};
use BaconQrCode\Renderer\Image\SvgImageBackEnd;
use BaconQrCode\Writer;
$svg = (new Writer(new ImageRenderer(new RendererStyle(220, 1), new SvgImageBackEnd)))
->writeString($contenido, 'UTF-8');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.