Commit 585772b1bb4246884ab20e48780ac5fd71db599c
1 parent
f00ea060ad
Exists in
master
avances
Showing
3 changed files
with
32 additions
and
26 deletions
Show diff stats
debo/cabeceraDebo.js
1 | module.exports = function(comprobante, afipTablas, entities) { | 1 | module.exports = function(comprobante, afipTablas, entities) { |
2 | 2 | ||
3 | return { | 3 | return { |
4 | TIP: afipTablas(comprobante.identificaxComprobante.tipo).letraComprobante, // [char](1) NOT NULL, LETRA DEL COMPROBANTE (A,B,C,M,E) | 4 | TIP: afipTablas(comprobante.identificaxComprobante.tipo).letraComprobante, // [char](1) NOT NULL, LETRA DEL COMPROBANTE (A,B,C,M,E) |
5 | TCO: afipTablas(comprobante.identificaxComprobante.tipo).tipoComprobante, // [char](2) NOT NULL, TIPO DE COMPROBANTE (FT,NC,ND,RE,CI,LP) | 5 | TCO: afipTablas(comprobante.identificaxComprobante.tipo).tipoComprobante, // [char](2) NOT NULL, TIPO DE COMPROBANTE (FT,NC,ND,RE,CI,LP) |
6 | SUC: parseInt(comprobante.identificaxComprobante.puntoVenta), // [int] NOT NULL, PUNTO DE VENTA | 6 | SUC: parseInt(comprobante.identificaxComprobante.puntoVenta), // [int] NOT NULL, PUNTO DE VENTA |
7 | NCO: parseInt(comprobante.identificaxComprobante.numero), // [bigint] NOT NULL, NUMERO DE COMPROBANTE | 7 | NCO: parseInt(comprobante.identificaxComprobante.numero), // [bigint] NOT NULL, NUMERO DE COMPROBANTE |
8 | COD: entities.proveedores.COD, // [int] NOT NULL, CODIGO DEL PROVEEDOR NECESITAS RELACION -- BUSCAR SI ENVIAN EL CUIT DEL PROVEEDOR SELECT COD FROM PROVEED WHERE CUIT= '30-54775125-2' | 8 | COD: entities.proveedores.COD, // [int] NOT NULL, CODIGO DEL PROVEEDOR NECESITAS RELACION -- BUSCAR SI ENVIAN EL CUIT DEL PROVEEDOR SELECT COD FROM PROVEED WHERE CUIT= '30-54775125-2' |
9 | FEC: comprobante.identificaxComprobante.fechaComprobante, // [smalldatetime] NULL, FECHA DEL COMPROBANTE | 9 | FEC: comprobante.identificaxComprobante.fechaComprobante, // [smalldatetime] NULL, FECHA DEL COMPROBANTE |
10 | NOM: entities.proveedores.NOM, // [varchar](40) NOT NULL, NOMBRE DEL PROVEEDOR TABLA PROVEED CAMPO NOM | 10 | NOM: entities.proveedores.NOM, // [varchar](40) NOT NULL, NOMBRE DEL PROVEEDOR TABLA PROVEED CAMPO NOM |
11 | TIV: entities.proveedores.IVA, // [tinyint] NOT NULL, TIPO DE IVA CAMPO IVA TABLA PROVEED | 11 | TIV: entities.proveedores.IVA, // [tinyint] NOT NULL, TIPO DE IVA CAMPO IVA TABLA PROVEED |
12 | CUI: entities.proveedores.CUIT, // [char](13) NOT NULL, CUIT DEL PROVEEDOR CAMPO CUIT DEL PROVEEDOR O EL QUE VIENE EN LA COMUNICACION | 12 | CUI: entities.proveedores.CUIT, // [char](13) NOT NULL, CUIT DEL PROVEEDOR CAMPO CUIT DEL PROVEEDOR O EL QUE VIENE EN LA COMUNICACION |
13 | FPA: entities.proveedores.FPA, // [tinyint] NOT NULL, FORMA DE PAGO CAMPO FPA TABLA PROVEED | 13 | FPA: entities.proveedores.FPA, // [tinyint] NOT NULL, FORMA DE PAGO CAMPO FPA TABLA PROVEED |
14 | TCA: 1, // [money] NOT NULL, FIJO 1 | 14 | TCA: 1, // [money] NOT NULL, FIJO 1 |
15 | DTO: comprobante.descuentosGlobalesFactura.importe, // [money] NOT NULL, DESCUENTO TOTAL SUMATORIA DE LOS DTO POR ITEM | 15 | DTO: comprobante.descuentosGlobalesFactura.importe, // [money] NOT NULL, DESCUENTO TOTAL SUMATORIA DE LOS DTO POR ITEM |
16 | PDT: 0, // [money] NOT NULL, FIJO 0 | 16 | PDT: 0, // [money] NOT NULL, FIJO 0 |
17 | NET: null, // [money] NOT NULL, SUMATORIA DE LOS NETOS POR ITEM QUE TIENEN IVA <> 0 | 17 | NET: comprobante.importesTotales.netoGravado, // [money] NOT NULL, SUMATORIA DE LOS NETOS POR ITEM QUE TIENEN IVA <> 0 |
18 | NEE: null, // [money] NOT NULL, SUMATORIA DE LOS NETOS POR ITEM QUE TIENEN IVA = 0 | 18 | NEE: comprobante.importesTotales.importeOperacionesExentas, // [money] NOT NULL, SUMATORIA DE LOS NETOS POR ITEM QUE TIENEN IVA = 0 |
19 | IRI: comprobante.detallesImportesIVA.importeLiquidado, // [money] NOT NULL, SUMATORIA DE LOS IVA POR ITEM | 19 | IRI: comprobante.detallesImportesIVA.importeLiquidado, // [money] NOT NULL, SUMATORIA DE LOS IVA POR ITEM |
20 | IRS: 0, // [money] NOT NULL, FIJO 0 | 20 | IRS: 0, // [money] NOT NULL, FIJO 0 |
21 | IMI: comprobante.importesTotales.importeImpuestosInternos, // [money] NOT NULL, SUMATORIA DE LOS IMPUESTOS INTERNOS POR ITEM | 21 | IMI: comprobante.importesTotales.importeImpuestosInternos, // [money] NOT NULL, SUMATORIA DE LOS IMPUESTOS INTERNOS POR ITEM |
22 | RGA: null, // [money] NOT NULL, IMPORTE RETENCION DE GANANCIAS | 22 | RGA: 0, // [money] NOT NULL, IMPORTE RETENCION DE GANANCIAS |
23 | RIB: null, // [money] NOT NULL, IMPORTE RETENCION DE INGRESOS BRUTOS | 23 | RIB: 0, // [money] NOT NULL, IMPORTE RETENCION DE INGRESOS BRUTOS |
24 | PIV: null, // [money] NOT NULL, IMPORTE PERCEPCION DE IVA | 24 | PIV: null, // [money] NOT NULL, IMPORTE PERCEPCION DE IVA, SECTOR 90 C05 |
25 | CNG: comprobante.importesTotales.totalConceptosNoNetoGravado, // [money] NULL, IMPORTE DE CONCEPTOS NO GRAVADOS | 25 | CNG: comprobante.importesTotales.totalConceptosNoNetoGravado, // [money] NULL, IMPORTE DE CONCEPTOS NO GRAVADOS |
26 | TOT: null, // [money] NOT NULL, IMPORTE TOTAL DE LA FACTURA | 26 | TOT: comprobante.importesTotales.totalOperacion, // [money] NOT NULL, IMPORTE TOTAL DE LA FACTURA |
27 | ZON: entities.empresa.ZON, // [int] NOT NULL, NUMERO DE LA EMPRESA SELECT ZON FROM APAREMP | 27 | ZON: entities.empresa.ZON, // [int] NOT NULL, NUMERO DE LA EMPRESA SELECT ZON FROM APAREMP |
28 | FEV: comprobante.identificaxComprobante.fechaComprobante, // [datetime] NULL, FECHA DE VENCIMIENTO | 28 | FEV: comprobante.identificaxComprobante.fechaVencimiento, // [datetime] NULL, FECHA DE VENCIMIENTO |
29 | OCP: null, // [char](10) NOT NULL, SI VIENE LA ORDEN DE COMPRA FORMATO "0000000000" (DOS PRIMERO PARA PVE Y 8 ULTIMOS EL NUMERO DE LA OC) | 29 | OCP: comprobante.comprobantesReferencia[0].numeroDocumentoReferencia, // [char](10) NOT NULL, SI VIENE LA ORDEN DE COMPRA FORMATO "0000000000" (DOS PRIMERO PARA PVE Y 8 ULTIMOS EL NUMERO DE LA OC) |
30 | OPE: 0, // [int] NOT NULL, FIJO 0 | 30 | OPE: 0, // [int] NOT NULL, FIJO 0 |
31 | REC: 0, // [bigint] NOT NULL, FIJO 0 | 31 | REC: 0, // [bigint] NOT NULL, FIJO 0 |
32 | FEP: null, // [datetime] NULL, ITEM FECHA FACTURA | 32 | FEP: comprobante.identificaxComprobante.fechaComprobante, // [datetime] NULL, ITEM FECHA FACTURA |
33 | NPE: 0, // [bigint] NOT NULL, NOTA DE PEDIDO FIJO 0 | 33 | NPE: 0, // [bigint] NOT NULL, NOTA DE PEDIDO FIJO 0 |
34 | CPA: 0, // [int] NOT NULL, FIJO 0 | 34 | CPA: 0, // [int] NOT NULL, FIJO 0 |
35 | ENV: 0, // [int] NOT NULL, FIJO 0 | 35 | ENV: 0, // [int] NOT NULL, FIJO 0 |
36 | REM: 0, // [bigint] NOT NULL, FIJO 0 | 36 | REM: 0, // [bigint] NOT NULL, FIJO 0 |
37 | PRO: ' ', // [char](1) NOT NULL, FIJO ' ' VACIO NO NULO | 37 | PRO: ' ', // [char](1) NOT NULL, FIJO ' ' VACIO NO NULO |
38 | ANU: ' ', // [char](1) NOT NULL, FIJO ' ' VACIO NO NULO | 38 | ANU: ' ', // [char](1) NOT NULL, FIJO ' ' VACIO NO NULO |
39 | TUR: 0, // [int] NOT NULL, FIJO 0 | 39 | TUR: 0, // [int] NOT NULL, FIJO 0 |
40 | PLA: 0, // [int] NOT NULL, FIJO 0 | 40 | PLA: 0, // [int] NOT NULL, FIJO 0 |
41 | LUG: 0, // [int] NOT NULL, FIJO 0 | 41 | LUG: 0, // [int] NOT NULL, FIJO 0 |
42 | ATO: 0, // [numeric](18, 0) NOT NULL, FIJO 0 | 42 | ATO: 0, // [numeric](18, 0) NOT NULL, FIJO 0 |
43 | CCO: 0, // [bigint] NOT NULL, FIJO 0 | 43 | CCO: 0, // [bigint] NOT NULL, FIJO 0 |
44 | IMA: 0, // [int] NOT NULL, FIJO 0 | 44 | IMA: 0, // [int] NOT NULL, FIJO 0 |
45 | CCA1: 0, // [int] NOT NULL, FIJO 0 | 45 | CCA1: 0, // [int] NOT NULL, FIJO 0 |
46 | CCA2: 0, // [int] NOT NULL, FIJO 0 | 46 | CCA2: 0, // [int] NOT NULL, FIJO 0 |
47 | CCA3: 0, // [int] NOT NULL, FIJO 0 | 47 | CCA3: 0, // [int] NOT NULL, FIJO 0 |
48 | CCA4: 0, // [int] NOT NULL, FIJO 0 | 48 | CCA4: 0, // [int] NOT NULL, FIJO 0 |
49 | CCA5: 0, // [int] NOT NULL, FIJO 0 | 49 | CCA5: 0, // [int] NOT NULL, FIJO 0 |
50 | CCA6: 0, // [int] NOT NULL, FIJO 0 | 50 | CCA6: 0, // [int] NOT NULL, FIJO 0 |
51 | CCA7: 0, // [int] NOT NULL, FIJO 0 | 51 | CCA7: 0, // [int] NOT NULL, FIJO 0 |
52 | CCA8: 0, // [int] NOT NULL, FIJO 0 | 52 | CCA8: 0, // [int] NOT NULL, FIJO 0 |
53 | CCA0: 0, // [int] NOT NULL, FIJO 0 | 53 | CCA0: 0, // [int] NOT NULL, FIJO 0 |
54 | OBS: comprobante.importesTotales.observaciones, // [varchar](60) NOT NULL, SI VIENEN OBSERVACIONES PONER AQUI SINO VACIO NO NULO | 54 | OBS: comprobante.importesTotales.observaciones, // [varchar](60) NOT NULL, SI VIENEN OBSERVACIONES PONER AQUI SINO VACIO NO NULO |
55 | RIV: null, // [money] NOT NULL, IMPORTE RETENCION DE IVA | 55 | RIV: 0, // [money] NOT NULL, IMPORTE RETENCION DE IVA |
56 | FECCAI: comprobante.identificaxComprobante.fechaVencimientoCai, // [smalldatetime] NOT NULL, FECHA DEL CAI | 56 | FECCAI: comprobante.identificaxComprobante.fechaVencimientoCai, // [smalldatetime] NOT NULL, FECHA DEL CAI |
57 | CAI: comprobante.identificaxComprobante.cai, // [char](16) NOT NULL, NUMERO DE CAI | 57 | CAI: comprobante.identificaxComprobante.cai, // [char](16) NOT NULL, NUMERO DE CAI |
58 | CHO: 0, // [int] NOT NULL, FIJO 0 | 58 | CHO: 0, // [int] NOT NULL, FIJO 0 |
59 | CTR: '', // [char](1) NOT NULL, VACIO NO NULO | 59 | CTR: '', // [char](1) NOT NULL, VACIO NO NULO |
60 | PER: null, // [money] NOT NULL, IMPORTE DE PERCEPCIONES | 60 | PER: comprobante.importesTotales.importeIB, // [money] NOT NULL, IMPORTE DE PERCEPCIONES |
61 | CCA9: 0, // [int] NOT NULL, FIJO 0 | 61 | CCA9: 0, // [int] NOT NULL, FIJO 0 |
62 | FECVEN: comprobante.identificaxComprobante.fechaVencimiento, // [smalldatetime] NOT NULL, FECHA DE VENCIMIENTO DE LA FACTURA | 62 | FECVEN: comprobante.identificaxComprobante.fechaVencimiento, // [smalldatetime] NOT NULL, FECHA DE VENCIMIENTO DE LA FACTURA |
63 | CNG2: null, // [money] NOT NULL, IMPORTE DE CONCEPTOS NO GRAVADOS 2 | 63 | CNG2: 0, // [money] NOT NULL, IMPORTE DE CONCEPTOS NO GRAVADOS 2 |
64 | E_HD: '', // [varchar](8) NOT NULL, VACIO NO NULO | 64 | E_HD: '', // [varchar](8) NOT NULL, VACIO NO NULO |
65 | C_HD: '', // [varchar](1) NOT NULL, VACIO NO NULO | 65 | C_HD: '', // [varchar](1) NOT NULL, VACIO NO NULO |
66 | RSS: null, // [money] NOT NULL, IMPORTE RETENCIONS SUSS | 66 | RSS: 0, // [money] NOT NULL, IMPORTE RETENCIONS SUSS |
67 | E_HD2: '', // [varchar](12) NOT NULL, VACIO NO NULO | 67 | E_HD2: '', // [varchar](12) NOT NULL, VACIO NO NULO |
68 | C_HD2: '', // [varchar](1) NOT NULL, VACIO NO NULO | 68 | C_HD2: '', // [varchar](1) NOT NULL, VACIO NO NULO |
69 | DTO2: null, // [money] NOT NULL, IMPORTE DE OTROS DESCUENTOS | 69 | DTO2: 0, // [money] NOT NULL, IMPORTE DE OTROS DESCUENTOS |
70 | ENLP: 0, // [bit] NOT NULL, FIJO 0 | 70 | ENLP: 0, // [bit] NOT NULL, FIJO 0 |
71 | COD_TRANS: comprobante.identificaxComprobante.numeroRegistrado, // [bigint] NOT NULL, VER DE PONER EL NUMERO DE REFERENCIA QUE PUEDA UNIRNOS A LO QUE VIENE DESDE PLANEX | 71 | COD_TRANS: comprobante.identificaxComprobante.numeroRegistrado, // [bigint] NOT NULL, VER DE PONER EL NUMERO DE REFERENCIA QUE PUEDA UNIRNOS A LO QUE VIENE DESDE PLANEX |
72 | RETMUN: comprobante.importesTotales.importeImpuestosMunicipales, // [money] NOT NULL, IMPORTE DE RETENCIONES MUNICIPALES | 72 | RETMUN: comprobante.importesTotales.importeImpuestosMunicipales, // [money] NOT NULL, IMPORTE DE RETENCIONES MUNICIPALES |
73 | TIPO_OPERACION: 0, // [int] NOT NULL, FIJO 0 | 73 | TIPO_OPERACION: 0, // [int] NOT NULL, FIJO 0 |
74 | IRD: 0, // [money] NOT NULL, FIJO 0 | 74 | IRD: 0, // [money] NOT NULL, FIJO 0 |
75 | AUX1: 0, // [money] NOT NULL, FIJO 0 | 75 | AUX1: 0, // [money] NOT NULL, FIJO 0 |
76 | AUX2: 0, // [money] NOT NULL, FIJO 0 | 76 | AUX2: 0, // [money] NOT NULL, FIJO 0 |
77 | AUX3: 0, // [money] NOT NULL, FIJO 0 | 77 | AUX3: 0, // [money] NOT NULL, FIJO 0 |
78 | AUX4: 0, // [money] NOT NULL, FIJO 0 | 78 | AUX4: 0, // [money] NOT NULL, FIJO 0 |
79 | ARBA: null, // [money] NOT NULL, IMPORTE RETENCION ARBA | 79 | ARBA: 0, // [money] NOT NULL, IMPORTE RETENCION ARBA |
80 | DGR: null, // [money] NOT NULL, IMPORTE RETENCION DGR | 80 | DGR: 0, // [money] NOT NULL, IMPORTE RETENCION DGR |
81 | DTO_PIE: null, // [money] NOT NULL, IMPORTE DE DESCUENTO AL PIE, NO POR ITEM | 81 | DTO_PIE: 0, // [money] NOT NULL, IMPORTE DE DESCUENTO AL PIE, NO POR ITEM |
82 | OPERACIONES_3711: 1, // [int] NOT NULL, FIJO 1 (PORQUE SON BIENES) | 82 | OPERACIONES_3711: 1, // [int] NOT NULL, FIJO 1 (PORQUE SON BIENES) |
83 | ORC: null, // [bigint] NOT NULL, NUMERO DE ORDEN DE COMPRA | 83 | ORC: 'TODO: comprobantesReferencia CUANDO ES PC', // [bigint] NOT NULL, NUMERO DE ORDEN DE COMPRA |
84 | NC_ES_NP: 0, // [bit] NOT NULL, FIJO 0 | 84 | NC_ES_NP: 0, // [bit] NOT NULL, FIJO 0 |
85 | CABA: null, // [money] NOT NULL, IMPORTE RETENCION CABA | 85 | CABA: 0, // [money] NOT NULL, IMPORTE RETENCION CABA |
86 | ARBA_PER: null, // [money] NOT NULL, IMPORTE PERCEPCION ARBA | 86 | ARBA_PER: 0, // [money] NOT NULL, IMPORTE PERCEPCION ARBA |
87 | CABA_PER: null, // [money] NOT NULL, IMPORTE PERCEPCION CABA | 87 | CABA_PER: 0, // [money] NOT NULL, IMPORTE PERCEPCION CABA |
88 | PERMUN: comprobante.importesTotales.importeImpuestosMunicipales, // [money] NOT NULL, IMPORTE PERCEPCIONES MUNICIPALES | 88 | PERMUN: comprobante.importesTotales.importeImpuestosMunicipales, // [money] NOT NULL, IMPORTE PERCEPCIONES MUNICIPALES |
89 | IMI2: 0, // [money] NOT NULL, FIJO 0 | 89 | IMI2: 0, // [money] NOT NULL, FIJO 0 |
90 | }; | 90 | }; |
91 | } | 91 | } |
92 | 92 |
index.js
1 | config = require('./config/config.json'); | 1 | config = require('./config/config.json'); |
2 | 2 | ||
3 | require('./watch/index')(config.dir, onGetFile); | 3 | require('./watch/index')(config.dir, onGetFile); |
4 | 4 | ||
5 | const wsServer = require('./webSocketServer/index')(); | 5 | const wsServer = require('./webSocketServer/index')(); |
6 | 6 | ||
7 | function onGetFile(event, fileString) { | 7 | function onGetFile(event, fileString) { |
8 | 8 | ||
9 | if (!fileString) return; | 9 | if (!fileString) return; |
10 | 10 | ||
11 | var planex = require('./planex/index')(fileString); | 11 | var planex = require('./planex/index')(fileString); |
12 | 12 | ||
13 | console.log(planex); | ||
14 | |||
13 | var entities = {}; | 15 | var entities = {}; |
14 | 16 | ||
15 | var tipoCuit = planex.identificaxEmisor.cuit.slice(0, 2); | 17 | var tipoCuit = planex.identificaxEmisor.cuit.slice(0, 2); |
16 | var digitoVerificador = planex.identificaxEmisor.cuit[planex.identificaxEmisor.cuit.length - 1]; | 18 | var digitoVerificador = planex.identificaxEmisor.cuit[planex.identificaxEmisor.cuit.length - 1]; |
17 | 19 | ||
18 | var cuitToDebo = tipoCuit + '-' + planex.identificaxEmisor.cuit.slice(2, 10) + '-' + digitoVerificador; | 20 | var cuitToDebo = tipoCuit + '-' + planex.identificaxEmisor.cuit.slice(2, 10) + '-' + digitoVerificador; |
19 | 21 | ||
20 | var promiseProveedores = wsServer.getEntidad('7790968003283', 'PROVEED', {CUIT: cuitToDebo}); | 22 | var promiseProveedores = wsServer.getEntidad('7790968003283', 'PROVEED', {CUIT: cuitToDebo}); |
21 | var promiseEmp = wsServer.getEntidad('7790968003283', 'APAREMP'); | 23 | var promiseEmp = wsServer.getEntidad('7790968003283', 'APAREMP'); |
22 | 24 | ||
23 | var promesasArticulo = []; | 25 | var promesasArticulo = []; |
24 | 26 | ||
25 | planex.itemsFactura.forEach(item => { | 27 | planex.itemsFactura.forEach(item => { |
26 | 28 | ||
27 | var queryString = 'select cb.*, art.CodRub, art.DET_LAR from CODBAR cb ' + | 29 | var queryString = 'select cb.*, art.CodRub, art.DET_LAR from CODBAR cb ' + |
28 | 'join ARTICULOS art on cb.CodArt = art.CodArt and cb.CodSec = art.CodSec where cb.CodBar = \'' + | 30 | 'join ARTICULOS art on cb.CodArt = art.CodArt and cb.CodSec = art.CodSec where cb.CodBar = \'' + |
29 | item.codigoUPCEAN13 + '\''; | 31 | item.codigoUPCEAN13 + '\''; |
30 | 32 | ||
31 | promesasArticulo.push(wsServer.getEntidad('7790968003283', null, {}, queryString)); | 33 | promesasArticulo.push(wsServer.getEntidad('7790968003283', null, {}, queryString)); |
32 | }); | 34 | }); |
33 | 35 | ||
34 | Promise.all(promesasArticulo).then(function(values) { | 36 | Promise.all(promesasArticulo).then(function(values) { |
35 | 37 | ||
36 | planex.itemsFactura.forEach((item, index) => { | 38 | planex.itemsFactura.forEach((item, index) => { |
37 | item.CodArt = values[index].CodArt; | 39 | item.CodArt = values[index].CodArt; |
38 | item.CodSec = values[index].CodSec; | 40 | item.CodSec = values[index].CodSec; |
39 | item.CodRub = values[index].CodRub; | 41 | item.CodRub = values[index].CodRub; |
40 | item.DET_LAR = values[index].DET_LAR; | 42 | item.DET_LAR = values[index].DET_LAR; |
41 | }); | 43 | }); |
42 | 44 | ||
43 | Promise.all([promiseProveedores, promiseEmp]).then(function(data) { | 45 | Promise.all([promiseProveedores, promiseEmp]).then(function(data) { |
44 | 46 | ||
45 | entities.proveedores = data[0]; | 47 | entities.proveedores = data[0]; |
46 | entities.empresa = data[1]; | 48 | entities.empresa = data[1]; |
47 | 49 | ||
48 | var debo = require('./debo/index')(planex, entities); | 50 | var debo = require('./debo/index')(planex, entities); |
49 | 51 | ||
50 | console.log(debo); | 52 | console.log(debo); |
51 | }); | 53 | }); |
52 | }); | 54 | }); |
53 | } | 55 | } |
54 | 56 | ||
55 | console.log('listen websocket port ' + config.port); | 57 | console.log('listen websocket port ' + config.port); |
56 | console.log('Ejecutar programa como administrador...'); | 58 | console.log('Ejecutar programa como administrador...'); |
57 | 59 |
planex/index.js
1 | module.exports = function(comprobante) { | 1 | module.exports = function(comprobante) { |
2 | 2 | ||
3 | // split por salto de línea | 3 | // split por salto de línea |
4 | comprobante = comprobante.split(/\r?\n/); | 4 | comprobante = comprobante.split(/\r?\n/); |
5 | 5 | ||
6 | var objReturn = { | 6 | var objReturn = { |
7 | identificaxComprobante: {}, | 7 | identificaxComprobante: {}, |
8 | identificaxMensaje: {}, | 8 | identificaxMensaje: {}, |
9 | comprobantesReferencia: [], | 9 | comprobantesReferencia: [], |
10 | identificaxEmisor: {}, | 10 | identificaxEmisor: {}, |
11 | informaxRepresentanteEmisor: {}, | 11 | informaxRepresentanteEmisor: {}, |
12 | identificaxReceptorFactura: {}, | 12 | identificaxReceptorFactura: {}, |
13 | identificaxSucursalReceptorFactura: {}, | 13 | identificaxSucursalReceptorFactura: {}, |
14 | importesTotales: {}, | 14 | importesTotales: {}, |
15 | detallesImportesIVA: {}, | 15 | detallesImportesIVA: {}, |
16 | detallePercepcionesIIBB: {}, | 16 | detallePercepcionesIIBB: {}, |
17 | descuentosGlobalesFactura: {}, | 17 | descuentosGlobalesFactura: {}, |
18 | detalleOtrosImpuestosComprobante: {}, | 18 | detalleOtrosImpuestosComprobante: {}, |
19 | itemsFactura: [], | 19 | itemsFactura: [], |
20 | detalleDescuentosItemFactura: {}, | 20 | detalleDescuentosItemFactura: [], |
21 | detalleImpuestosItemFactura: {} | 21 | detalleImpuestosItemFactura: [] |
22 | }; | 22 | }; |
23 | 23 | ||
24 | function returnFloatByDecimals(parameter, cantDecimal) { | 24 | function returnFloatByDecimals(parameter, cantDecimal) { |
25 | 25 | ||
26 | if (!parameter) return; | 26 | if (!parameter) return; |
27 | 27 | ||
28 | var beforeSemiColon = parseFloat(parameter.slice(0, parameter.length - cantDecimal)); | 28 | var beforeSemiColon = parseFloat(parameter.slice(0, parameter.length - cantDecimal)); |
29 | 29 | ||
30 | var afterSemicolon = parameter.slice(parameter.length - cantDecimal, parameter.length); | 30 | var afterSemicolon = parameter.slice(parameter.length - cantDecimal, parameter.length); |
31 | 31 | ||
32 | return parseFloat(beforeSemiColon + '.' + afterSemicolon); | 32 | return parseFloat(beforeSemiColon + '.' + afterSemicolon); |
33 | } | 33 | } |
34 | 34 | ||
35 | comprobante.forEach(sector => { | 35 | comprobante.forEach(sector => { |
36 | 36 | ||
37 | if (sector.slice(0, 3) == '010') { | 37 | if (sector.slice(0, 3) == '010') { |
38 | objReturn.identificaxComprobante = require('./identificaxComprobante')(sector)// 010 | 38 | objReturn.identificaxComprobante = require('./identificaxComprobante')(sector)// 010 |
39 | } else if (sector.slice(0, 3) == '012') { | 39 | } else if (sector.slice(0, 3) == '012') { |
40 | objReturn.identificaxMensaje = require('./identificaxMensaje')(sector)// 012 | 40 | objReturn.identificaxMensaje = require('./identificaxMensaje')(sector)// 012 |
41 | } else if (sector.slice(0, 3) == '020') { | 41 | } else if (sector.slice(0, 3) == '020') { |
42 | objReturn.comprobantesReferencia.push(require('./comprobantesReferencia')(sector)) // 020 | 42 | objReturn.comprobantesReferencia.push(require('./comprobantesReferencia')(sector)) // 020 |
43 | } else if (sector.slice(0, 3) == '030') { | 43 | } else if (sector.slice(0, 3) == '030') { |
44 | objReturn.identificaxEmisor = require('./identificaxEmisor')(sector) // 030 | 44 | objReturn.identificaxEmisor = require('./identificaxEmisor')(sector) // 030 |
45 | } else if (sector.slice(0, 3) == '035') { | 45 | } else if (sector.slice(0, 3) == '035') { |
46 | objReturn.informaxRepresentanteEmisor = require('./informaxRepresentanteEmisor')(sector) // 035 | 46 | objReturn.informaxRepresentanteEmisor = require('./informaxRepresentanteEmisor')(sector) // 035 |
47 | } else if (sector.slice(0, 3) == '040') { | 47 | } else if (sector.slice(0, 3) == '040') { |
48 | objReturn.identificaxReceptorFactura = require('./identificaxReceptorFactura')(sector) // 040 | 48 | objReturn.identificaxReceptorFactura = require('./identificaxReceptorFactura')(sector) // 040 |
49 | } else if (sector.slice(0, 3) == '045') { | 49 | } else if (sector.slice(0, 3) == '045') { |
50 | objReturn.identificaxSucursalReceptorFactura = require('./identificaxSucursalReceptorFactura')(sector) // 045 | 50 | objReturn.identificaxSucursalReceptorFactura = require('./identificaxSucursalReceptorFactura')(sector) // 045 |
51 | } else if (sector.slice(0, 3) == '050') { | 51 | } else if (sector.slice(0, 3) == '050') { |
52 | objReturn.importesTotales = require('./importesTotales')(sector, returnFloatByDecimals) // 050 | 52 | objReturn.importesTotales = require('./importesTotales')(sector, returnFloatByDecimals) // 050 |
53 | } else if (sector.slice(0, 3) == '060') { | 53 | } else if (sector.slice(0, 3) == '060') { |
54 | objReturn.detallesImportesIVA = require('./detallesImportesIVA')(sector, returnFloatByDecimals) // 060 | 54 | objReturn.detallesImportesIVA = require('./detallesImportesIVA')(sector, returnFloatByDecimals) // 060 |
55 | } else if (sector.slice(0, 3) == '070') { | 55 | } else if (sector.slice(0, 3) == '070') { |
56 | objReturn.detallePercepcionesIIBB = require('./detallePercepcionesIIBB')(sector, returnFloatByDecimals) // 070 | 56 | objReturn.detallePercepcionesIIBB = require('./detallePercepcionesIIBB')(sector, returnFloatByDecimals) // 070 |
57 | } else if (sector.slice(0, 3) == '080') { | 57 | } else if (sector.slice(0, 3) == '080') { |
58 | objReturn.descuentosGlobalesFactura = require('./descuentosGlobalesFactura')(sector, returnFloatByDecimals) // 080 | 58 | objReturn.descuentosGlobalesFactura = require('./descuentosGlobalesFactura')(sector, returnFloatByDecimals) // 080 |
59 | } else if (sector.slice(0, 3) == '090') { | 59 | } else if (sector.slice(0, 3) == '090') { |
60 | objReturn.detalleOtrosImpuestosComprobante = require('./detalleOtrosImpuestosComprobante')(sector, returnFloatByDecimals) // 090 | 60 | objReturn.detalleOtrosImpuestosComprobante = require('./detalleOtrosImpuestosComprobante')(sector, returnFloatByDecimals) // 090 |
61 | } else if (sector.slice(0, 3) == '100') { | 61 | } else if (sector.slice(0, 3) == '100') { |
62 | objReturn.itemsFactura.push(require('./itemsFactura')(sector, returnFloatByDecimals)); // 100 | 62 | objReturn.itemsFactura.push(require('./itemsFactura')(sector, returnFloatByDecimals)); // 100 |
63 | } else if (sector.slice(0, 3) == '110') { | 63 | } else if (sector.slice(0, 3) == '110') { |
64 | objReturn.detalleDescuentosItemFactura = require('./detalleDescuentosItemFactura')(sector, returnFloatByDecimals); // 110 | 64 | objReturn.detalleDescuentosItemFactura = require('./detalleDescuentosItemFactura')(sector, returnFloatByDecimals); // 110 |
65 | } else if (sector.slice(0, 3) == '120') { | 65 | } else if (sector.slice(0, 3) == '120') { |
66 | objReturn.detalleImpuestosItemFactura = require('./detalleImpuestosItemFactura')(sector, returnFloatByDecimals); // 120 | 66 | objReturn.detalleImpuestosItemFactura.push(require('./detalleImpuestosItemFactura')(sector, returnFloatByDecimals)); // 120 |
67 | } | 67 | } |
68 | }); | 68 | }); |
69 | 69 | ||
70 | objReturn.itemsFactura.array.forEach(item => { | 70 | if (!objReturn.detalleImpuestosItemFactura.length) { |
71 | return objReturn; | ||
72 | } | ||
73 | |||
74 | objReturn.itemsFactura.forEach(item => { | ||
71 | 75 | ||
72 | var detalleDescuentos = planex.detalleImpuestosItemFactura.filter(function(descuento) { | 76 | var detalleDescuentos = objReturn.detalleImpuestosItemFactura.filter(function(descuento) { |
73 | return descuento.numeroLinea == item.numeroLinea; | 77 | return descuento.numeroLinea == item.numeroLinea; |
74 | })[0]; | 78 | })[0]; |
75 | 79 | ||
76 | switch (detalleDescuentos.descripcionImpuesto) { | 80 | switch (detalleDescuentos.descripcionImpuesto) { |
77 | case 'c05': | 81 | case 'c05': |
78 | item.percepcionIVA = detalleDescuentos; | 82 | item.percepcionIVA = detalleDescuentos; |
79 | break; | 83 | break; |
80 | case 'c06': | 84 | case 'c06': |
81 | item.percepcionIIBB = detalleDescuentos; | 85 | item.percepcionIIBB = detalleDescuentos; |
82 | break; | 86 | break; |
83 | case 'c07': | 87 | case 'c07': |
84 | item.impuestoInterno = detalleDescuentos; | 88 | item.impuestoInterno = detalleDescuentos; |
85 | break; | 89 | break; |
86 | case 'c08': | 90 | case 'c08': |
87 | item.impuestoAbasto = detalleDescuentos; | 91 | item.impuestoAbasto = detalleDescuentos; |
88 | break; | 92 | break; |
89 | case 'ITC': | 93 | case 'ITC': |
90 | item.impuestoTransferenciaCombustibles = detalleDescuentos; | 94 | item.impuestoTransferenciaCombustibles = detalleDescuentos; |
91 | break; | 95 | break; |
92 | case 'c10': | 96 | case 'c10': |
93 | item.percepcionImpuestosMunicipales = detalleDescuentos; | 97 | item.percepcionImpuestosMunicipales = detalleDescuentos; |
94 | break; | 98 | break; |
95 | default: | 99 | default: |
96 | break; | 100 | break; |
97 | } | 101 | } |
98 | }); | 102 | }); |
99 | 103 | ||
100 | return objReturn; | 104 | return objReturn; |
101 | } | 105 | } |
102 | 106 |