PHP code example of lopezsoft / ubl21dian
1. Go to this page and download the library: Download lopezsoft/ubl21dian 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/ */
lopezsoft / ubl21dian example snippets
// Casos de prueba garantizados:
truncateDecimals(33000) → "33000.00" ✅
truncateDecimals(30555.55) → "30555.55" ✅
truncateDecimals(12037.046) → "12037.04" ✅ (trunca, NO redondea a .05)
truncateDecimals(2444.4) → "2444.40" ✅
// ❌ Antes (con bug de precisión flotante)
33000 * 100 / 100 = 33000.0000000001 → CUFE incorrecto
// ✅ Ahora (truncado exacto con strings)
sprintf('%.10f', 33000) = "33000.0000000000"
substr() = "33000.00" → CUFE correcto