UNPKG

@disruptive-learning/cfdi-to-pdf

Version:

Librería para crear un pdf basado en un XML CFDI o Retenciones

67 lines (66 loc) 2.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const catalogs_source_1 = require("#src/catalogs/catalogs_source"); const currency_1 = require("#src/utils/currency"); const genericCfdiDetailsInfoContent = (comprobante, catalogs, primaryColor) => { const detailsInfo = []; const total = comprobante.getAttribute('Total'); const moneda = comprobante.getAttribute('Moneda'); detailsInfo.push([ { text: ['Importe con letra: ', (0, currency_1.toCurrency)(total === '' ? 0 : Number(total), moneda)], alignment: 'center', colSpan: 4, style: ['tableSubtitleHeader'], }, '', '', '', ]); const comprobanteInfo = [ { text: [ { text: 'Método de Pago: ', color: primaryColor }, { text: (0, catalogs_source_1.getKeyValueOfCatalog)('cfdi40MetodosPago', comprobante.getAttribute('MetodoPago'), catalogs), }, ], alignment: 'center', }, { text: [ { text: 'Forma de Pago: ', color: primaryColor }, { text: (0, catalogs_source_1.getKeyValueOfCatalog)('cfdi40FormasPago', comprobante.getAttribute('FormaPago'), catalogs), }, ], alignment: 'center', }, ]; if (moneda === 'MXN') { comprobanteInfo.push({ text: [{ text: 'Moneda: ', color: primaryColor }, { text: moneda }], colSpan: 2, alignment: 'center', }, ''); } else { comprobanteInfo.push({ text: [{ text: 'Moneda: ', color: primaryColor }, { text: moneda }], alignment: 'center' }, { text: [ { text: 'Tipo cambio: ', color: primaryColor }, { text: comprobante.getAttribute('TipoCambio') }, ], alignment: 'center', }); } detailsInfo.push(comprobanteInfo); return { table: { widths: ['38%', '38%', '12%', '12%'], body: detailsInfo, dontBreakRows: true, }, layout: 'tableLayout', }; }; exports.default = genericCfdiDetailsInfoContent;