Skip to content

Commit

Permalink
refactor: ♻️ better presentation of fields title for cfdi and emisor,…
Browse files Browse the repository at this point in the history
… receptor content
  • Loading branch information
luffynando committed Sep 11, 2024
1 parent 9e9fb09 commit 09864e0
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 45 deletions.
10 changes: 6 additions & 4 deletions src/templates/complements/donat11_complement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const useDonat11Complement = (
{
fillColor: bgGrayColor,
text: [
{ text: 'Version: ', color: primaryColor },
{ text: 'Version: ', color: primaryColor, bold: true },
{
text: donat11.getAttribute('version'),
},
Expand All @@ -34,25 +34,27 @@ const useDonat11Complement = (
{
fillColor: bgGrayColor,
text: [
{ text: 'No. Autorización: ', color: primaryColor },
{ text: 'No. Autorización: ', color: primaryColor, bold: true },
{
text: donat11.getAttribute('noAutorizacion'),
},
],
alignment: 'center',
},
{
fillColor: bgGrayColor,
text: [
{ text: 'Fecha Autorización: ', color: primaryColor },
{ text: 'Fecha Autorización: ', color: primaryColor, bold: true },
{ text: donat11.getAttribute('fechaAutorizacion') },
],
alignment: 'right',
},
],
[
{
fillColor: bgGrayColor,
text: [
{ text: 'Leyenda: ', color: primaryColor },
{ text: 'Leyenda: ', color: primaryColor, bold: true },
{ text: donat11.getAttribute('leyenda') },
],
colSpan: 3,
Expand Down
40 changes: 27 additions & 13 deletions src/templates/sections/generic_cfdi_concepto_impuestos_content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const generateImpuestosContentTable = (
for (const traslado of traslados) {
const baseCells: TableCell[] = [];
baseCells.push(
{ text: 'Traslado', color: primaryColor },
{ text: 'Traslado:', color: primaryColor, bold: true },
{ text: getValueOfCatalog('cfdi40Impuestos', traslado.getAttribute('Impuesto'), catalogs) },
{ text: 'Base', color: primaryColor },
{ text: 'Base:', color: primaryColor, bold: true },
{
text: formatCurrency(traslado.getAttribute('Base')),
alignment: 'right',
Expand All @@ -29,20 +29,27 @@ const generateImpuestosContentTable = (
const factor = traslado.getAttribute('TipoFactor');

if (factor === 'Exento') {
baseCells.push({ text: 'Factor', color: primaryColor }, { text: factor }, '', '');
baseCells.push(
{ text: 'Factor:', color: primaryColor, bold: true },
{ text: factor },
'',
'',
);
} else {
const importe = traslado.getAttribute('Importe');
baseCells.push(
{
text: 'Tasa',
text: 'Tasa:',
color: primaryColor,
bold: true,
},
{
text: traslado.getAttribute('TasaOCuota'),
},
{
text: 'Importe',
text: 'Importe:',
color: primaryColor,
bold: true,
},
{
text: formatCurrency(importe === '' ? '0' : importe),
Expand All @@ -56,11 +63,11 @@ const generateImpuestosContentTable = (
for (const retencion of retenciones) {
const baseCells: TableCell[] = [];
baseCells.push(
{ text: 'Retención', color: primaryColor },
{ text: 'Retención:', color: primaryColor, bold: true },
{
text: getValueOfCatalog('cfdi40Impuestos', retencion.getAttribute('Impuesto'), catalogs),
},
{ text: 'Base', color: primaryColor },
{ text: 'Base:', color: primaryColor, bold: true },
{
text: formatCurrency(retencion.getAttribute('Base')),
alignment: 'right',
Expand All @@ -70,20 +77,27 @@ const generateImpuestosContentTable = (
const factor = retencion.getAttribute('TipoFactor');

if (factor === 'Exento') {
baseCells.push({ text: 'Factor', color: primaryColor }, { text: factor }, '', '');
baseCells.push(
{ text: 'Factor:', color: primaryColor, bold: true },
{ text: factor },
'',
'',
);
} else {
const importe = retencion.getAttribute('Importe');
baseCells.push(
{
text: 'Tasa',
text: 'Tasa:',
color: primaryColor,
bold: true,
},
{
text: retencion.getAttribute('TasaOCuota'),
},
{
text: 'Importe',
text: 'Importe:',
color: primaryColor,
bold: true,
},
{
text: formatCurrency(importe === '' ? '0' : importe),
Expand Down Expand Up @@ -119,7 +133,7 @@ const genericCfdiConceptoImpuestosContent = (
'',
{
text: [
{ text: 'Clave Producto/Servicio: ', color: primaryColor },
{ text: 'Clave Producto/Servicio: ', color: primaryColor, bold: true },
{
text: codigoSat,
},
Expand All @@ -130,7 +144,7 @@ const genericCfdiConceptoImpuestosContent = (
objetoImp === ''
? ''
: [
{ text: 'Objeto Impuesto: ', color: primaryColor },
{ text: 'Objeto Impuesto: ', color: primaryColor, bold: true },
{
text: getValueOfCatalog('cfdi40ObjetosImpuestos', objetoImp, catalogs),
},
Expand All @@ -141,7 +155,7 @@ const genericCfdiConceptoImpuestosContent = (
predial === undefined
? ''
: [
{ text: 'Cuenta Predial: ', color: primaryColor },
{ text: 'Cuenta Predial: ', color: primaryColor, bold: true },
{ text: predial.getAttribute('Numero') },
],
},
Expand Down
13 changes: 8 additions & 5 deletions src/templates/sections/generic_cfdi_details_info_content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const genericCfdiDetailsInfoContent = (
const comprobanteInfo: TableCell[] = [
{
text: [
{ text: 'Método de Pago: ', color: primaryColor },
{ text: 'Método de Pago: ', color: primaryColor, bold: true },
{
text: getKeyValueOfCatalog(
'cfdi40MetodosPago',
Expand All @@ -41,7 +41,7 @@ const genericCfdiDetailsInfoContent = (
},
{
text: [
{ text: 'Forma de Pago: ', color: primaryColor },
{ text: 'Forma de Pago: ', color: primaryColor, bold: true },
{
text: getKeyValueOfCatalog(
'cfdi40FormasPago',
Expand All @@ -57,18 +57,21 @@ const genericCfdiDetailsInfoContent = (
if (moneda === 'MXN') {
comprobanteInfo.push(
{
text: [{ text: 'Moneda: ', color: primaryColor }, { text: moneda }],
text: [{ text: 'Moneda: ', color: primaryColor, bold: true }, { text: moneda }],
colSpan: 2,
alignment: 'center',
},
'',
);
} else {
comprobanteInfo.push(
{ text: [{ text: 'Moneda: ', color: primaryColor }, { text: moneda }], alignment: 'center' },
{
text: [{ text: 'Moneda: ', color: primaryColor, bold: true }, { text: moneda }],
alignment: 'center',
},
{
text: [
{ text: 'Tipo cambio: ', color: primaryColor },
{ text: 'Tipo cambio: ', color: primaryColor, bold: true },
{ text: comprobante.getAttribute('TipoCambio') },
],
alignment: 'center',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const genericCfdiInformacionGlobalContent = (
{
fillColor: bgGrayColor,
text: [
{ text: 'Periodicidad: ', color: primaryColor },
{ text: 'Periodicidad: ', color: primaryColor, bold: true },
{
text: getKeyValueOfCatalog(
'cfdi40Periodicidades',
Expand All @@ -40,7 +40,7 @@ const genericCfdiInformacionGlobalContent = (
{
fillColor: bgGrayColor,
text: [
{ text: 'Meses: ', color: primaryColor },
{ text: 'Meses: ', color: primaryColor, bold: true },
{
text: getKeyValueOfCatalog(
'cfdi40Meses',
Expand All @@ -53,7 +53,7 @@ const genericCfdiInformacionGlobalContent = (
{
fillColor: bgGrayColor,
text: [
{ text: 'Año: ', color: primaryColor },
{ text: 'Año: ', color: primaryColor, bold: true },
{ text: informacionGlobal.getAttribute('Año') },
],
},
Expand Down
2 changes: 2 additions & 0 deletions src/templates/sections/generic_cfdi_relacionados_content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const genericCfdiRelacionadosContent = (
alignment: 'left',
fillColor: bgGrayColor,
color: primaryColor,
bold: true,
},
{
text: '',
Expand All @@ -65,6 +66,7 @@ const genericCfdiRelacionadosContent = (
alignment: 'left',
fillColor: bgGrayColor,
color: primaryColor,
bold: true,
},
],
...relatedInfoAndImport.map((related) => {
Expand Down
8 changes: 4 additions & 4 deletions src/templates/sections/generic_cfdi_totales_content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,28 +170,28 @@ const genericCfdiTotalesContent = (
const tableTotales: TableCell[][] = [
[
{ text: 'Subtotal', alignment: 'right' },
{ text: '$', color: primaryColor, alignment: 'center' },
{ text: '$', color: primaryColor, alignment: 'center', bold: true },
{
text: formatCurrency(comprobante.getAttribute('SubTotal'), 'code'),
alignment: 'right',
},
],
[
{ text: 'Descuento', alignment: 'right' },
{ text: '$', color: primaryColor, alignment: 'center' },
{ text: '$', color: primaryColor, alignment: 'center', bold: true },
{
text: `- ${formatCurrency(comprobante.getAttribute('Descuento'), 'code')}`,
alignment: 'right',
},
],
[
{ text: 'Traslados', alignment: 'right' },
{ text: '$', color: primaryColor, alignment: 'center' },
{ text: '$', color: primaryColor, alignment: 'center', bold: true },
{ text: formatCurrency(totalImpuestosTrasladados, 'code'), alignment: 'right' },
],
[
{ text: 'Retenciones', alignment: 'right' },
{ text: '$', color: primaryColor, alignment: 'center' },
{ text: '$', color: primaryColor, alignment: 'center', bold: true },
{ text: `- ${formatCurrency(totalImpuestosRetenidos, 'code')}`, alignment: 'right' },
],
];
Expand Down
11 changes: 7 additions & 4 deletions src/templates/sections/generic_emisor_content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const genericEmisorContent = (
additionalEmisorData.push([
{
text: [
{ text: 'Regimen Fiscal ', color: primaryColor },
{ text: 'Regimen Fiscal: ', color: primaryColor, bold: true },
{
text: getKeyValueOfCatalog('cfdi40RegimenesFiscales', regimenFiscal, catalogs),
},
Expand All @@ -48,14 +48,17 @@ const genericEmisorContent = (

additionalEmisorData.push([
{
text: [{ text: 'Número de certificado ', color: primaryColor }, { text: numCertificado }],
text: [
{ text: 'Número de certificado: ', color: primaryColor, bold: true },
{ text: numCertificado },
],
},
]);

if (curp && curp !== '') {
additionalEmisorData.push([
{
text: [{ text: 'CURP ', color: primaryColor }, { text: curp }],
text: [{ text: 'CURP: ', color: primaryColor, bold: true }, { text: curp }],
},
]);
}
Expand All @@ -76,7 +79,7 @@ const genericEmisorContent = (
widths: ['*'],
body: [
[{ text: razonSocial, style: ['subHeader'], color: primaryColor }],
[{ text: [{ text: 'RFC ', color: primaryColor }, { text: rfc }] }],
[{ text: [{ text: 'RFC: ', color: primaryColor, bold: true }, { text: rfc }] }],
],
},
layout: 'tableLayout',
Expand Down
Loading

0 comments on commit 09864e0

Please sign in to comment.