Skip to content

Commit

Permalink
feat: add plataformas tecnologicas complement (#47)
Browse files Browse the repository at this point in the history
* build: ⬆️ upgrade dependencie cfdi to pdf

* refactor: ♻️ added Cuenta Predial

* build: ➖ deleted recursive dependencies

* refactor: ♻️ fixed bad condition

* style: 🎨 lint fix

* refactor: ♻️ better condition

* build: 🌱 added retenciones complements

added plataformas tecnologicas

* build: 🌱 added plataformas tecnologicas nodes and tables

* style: 🎨 format code

* build: 🌱 table of subnodes of plataformas tecnologicas

and show a table with its attributtes

* refactor: ♻️ added dividing border

* refactor: ♻️ deleted return

* refactor: ♻️ return null

* build: ⬆️ upgrade pdfmake

* build: ⬆️ upgrade dependencies

* build: ⬆️ upgrade nodecfdi eslint-config

---------

Co-authored-by: Isaac Cruz <[email protected]>
  • Loading branch information
CombatantFawn and Isaac Cruz authored Aug 27, 2024
1 parent 832492e commit 32b71dc
Show file tree
Hide file tree
Showing 5 changed files with 544 additions and 3 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@
"@jsprismarine/typedoc-material-theme": "^1.0.4",
"@nodecfdi/cfdi-core": "^0.5.0",
"@nodecfdi/cfdi-expresiones": "^3.0.2",
"@nodecfdi/eslint-config": "^1.10.1",
"@nodecfdi/eslint-config": "^1.10.4",
"@nodecfdi/prettier-config": "^1.1.1",
"@nodecfdi/tsconfig": "^1.6.0",
"@types/node": "^20.16.1",
"@types/node": "^22.5.0",
"@types/pdfmake": "^0.2.9",
"@vitest/coverage-istanbul": "^2.0.5",
"conventional-changelog-cli": "^5.0.0",
Expand All @@ -93,7 +93,7 @@
"husky": "^9.1.5",
"is-in-ci": "^1.0.0",
"np": "^10.0.7",
"pdfmake": "^0.2.10",
"pdfmake": "^0.2.12",
"prettier": "^3.3.3",
"tshy": "^3.0.2",
"typedoc": "^0.26.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
import { type XmlNodeInterface } from '@nodecfdi/cfdi-core/types';
import { type ContentTable, type TableCell } from 'pdfmake/interfaces.js';
import { formatCurrency } from '#src/utils/currency';

const impuestosTrasladadosPlataformasComplementTable = (
servicio: XmlNodeInterface,
primaryColor: string,
bgGrayColor: string,
): ContentTable | null => {
const impuestosTableBody: TableCell[][] = [];

const impuestosTrasladadosDelServicio = servicio.searchNode(
'plataformasTecnologicas:ImpuestosTrasladadosdelServicio',
);
const contribucionGubernamental = servicio.searchNode(
'plataformasTecnologicas:ContribucionGubernamental',
);
const comisionDelServicio = servicio.searchNode('plataformasTecnologicas:ComisionDelServicio');

if (impuestosTrasladadosDelServicio) {
impuestosTableBody.push([
{
table: {
widths: ['auto', 'auto', 'auto', 'auto', 'auto', 'auto', 'auto', 'auto', 'auto', '*'],
body: [
[
{
text: 'Impuestos Trasladados del Servicio',
colSpan: 10,
alignment: 'left',
color: primaryColor,
},
{},
{},
{},
{},
{},
{},
{},
{},
{},
],
[
{
text: 'Impuesto base:',
color: primaryColor,
},
{
text: formatCurrency(impuestosTrasladadosDelServicio.getAttribute('Base')),
alignment: 'left',
},
{
text: 'Impuesto',
color: primaryColor,
},
{
text: impuestosTrasladadosDelServicio.getAttribute('Impuesto'),
alignment: 'left',
},
{
text: 'Tipo factor:',
color: primaryColor,
},
{
text: impuestosTrasladadosDelServicio.getAttribute('TipoFactor'),
alignment: 'left',
},
{
text: 'Tasa o cuota:',
color: primaryColor,
},
{
text: impuestosTrasladadosDelServicio.getAttribute('TasaCuota'),
alignment: 'left',
},
{
text: 'Importe',
color: primaryColor,
},
{
text: formatCurrency(impuestosTrasladadosDelServicio.getAttribute('Importe')),
alignment: 'left',
},
],
],
},
layout: 'conceptosLayout',
colSpan: 10,
fillColor: bgGrayColor,
},
]);
}

if (comisionDelServicio !== undefined || contribucionGubernamental !== undefined) {
impuestosTableBody.push([
{
table: {
widths: ['auto', 'auto', 'auto', 'auto', 'auto', 'auto', '*', 'auto', 'auto', 'auto'],
body: [
[
{
text: comisionDelServicio === undefined ? '' : 'Comisión del Servicio',
colSpan: 6,
alignment: 'left',
color: primaryColor,
},
{},
{},
{},
{},
{},
{
text: contribucionGubernamental === undefined ? '' : 'Contribución Gubernamental',
colSpan: 4,
alignment: 'right',
color: primaryColor,
},
{},
{},
{},
],
[
{
text: comisionDelServicio === undefined ? '' : 'Base:',
color: primaryColor,
alignment: 'right',
},
{
text:
comisionDelServicio === undefined
? ''
: formatCurrency(comisionDelServicio.getAttribute('Base')) || '---',
alignment: 'left',
},
{
text: comisionDelServicio === undefined ? '' : 'Porcentaje:',
color: primaryColor,
alignment: 'right',
},
{
text:
comisionDelServicio === undefined
? ''
: comisionDelServicio.getAttribute('Porcentaje') || '---',
alignment: 'left',
},
{
text: comisionDelServicio === undefined ? '' : 'Importe:',
color: primaryColor,
alignment: 'right',
},
{
text:
comisionDelServicio === undefined
? ''
: formatCurrency(comisionDelServicio.getAttribute('Importe')),
alignment: 'left',
},
{
text: contribucionGubernamental === undefined ? '' : 'Estado:',
color: primaryColor,
alignment: 'right',
},
{
text:
contribucionGubernamental === undefined
? ''
: contribucionGubernamental.getAttribute('EntidadDondePagaLaContribucion'),
alignment: 'left',
},
{
text: contribucionGubernamental === undefined ? '' : 'Importe:',
color: primaryColor,
alignment: 'right',
},
{
text:
contribucionGubernamental === undefined
? ''
: formatCurrency(contribucionGubernamental.getAttribute('ImpContrib')),
alignment: 'left',
},
],
],
},
layout: 'conceptosLayout',
colSpan: 10,
fillColor: bgGrayColor,
},
]);
}

if (
impuestosTrasladadosDelServicio !== undefined ||
contribucionGubernamental !== undefined ||
comisionDelServicio !== undefined
) {
impuestosTableBody.push([
{
text: '',
color: primaryColor,
colSpan: 10,
border: [false, true, false, false],
},
'',
'',
'',
'',
'',
'',
'',
'',
'',
]);
}

if (impuestosTableBody.length === 0) {
return null;
}

return {
table: {
widths: ['*', '*', '*', '*', '*', '*', '*', '*', '*', '*'],
body: impuestosTableBody,
},
layout: 'conceptosLayout',
};
};

export default impuestosTrasladadosPlataformasComplementTable;
Loading

0 comments on commit 32b71dc

Please sign in to comment.