- Instalaciones:
yarn add --dev jest babel-jest @babel/preset-env @babel/preset-react
yarn add --dev @testing-library/react @types/jest jest-environment-jsdom
- Opcional: Si usamos Fetch API en el proyecto:
| <?php | |
| $xml = simplexml_load_file('test.xml'); | |
| $ns = $xml->getNamespaces(true); | |
| $xml->registerXPathNamespace('c', $ns['cfdi']); | |
| $xml->registerXPathNamespace('t', $ns['tfd']); | |
| //EMPIEZO A LEER LA INFORMACION DEL CFDI E IMPRIMIRLA | |
| foreach ($xml->xpath('//cfdi:Comprobante') as $cfdiComprobante){ | |
| echo $cfdiComprobante['version']; |
| function number_format(amount, decimals) { | |
| amount += ''; // por si pasan un numero en vez de un string | |
| amount = parseFloat(amount.replace(/[^0-9\.]/g, '')); // elimino cualquier cosa que no sea numero o punto | |
| decimals = decimals || 0; // por si la variable no fue fue pasada | |
| // si no es un numero o es igual a cero retorno el mismo cero | |
| if (isNaN(amount) || amount === 0) | |
| return parseFloat(0).toFixed(decimals); |