Commit f00ea060ad04bd61e7b16448ddf85599b5a3b0a1

Authored by Eric Fernandez
1 parent 9ee548483b
Exists in master

git push origin master

1 module.exports = function(comprobante, afipTablas, entities) { 1 module.exports = function(comprobante, afipTablas, entities, item) {
2 2
3 return { 3 return {
4 TIP: afipTablas(comprobante.identificaxComprobante.tipo).letraComprobante, // [char](1) NOT NULL, LETRA DEL COMPROBANTE (A,B,C,M) 4 TIP: afipTablas(comprobante.identificaxComprobante.tipo).letraComprobante, // [char](1) NOT NULL, LETRA DEL COMPROBANTE (A,B,C,M)
5 TCO: afipTablas(comprobante.identificaxComprobante.tipo).tipoComprobante, // [char](2) NOT NULL, TIPO DE COMPROBANTE (FT,NC,ND) 5 TCO: afipTablas(comprobante.identificaxComprobante.tipo).tipoComprobante, // [char](2) NOT NULL, TIPO DE COMPROBANTE (FT,NC,ND)
6 SUC: parseInt(comprobante.identificaxComprobante.puntoVenta), // [int] NOT NULL, PUNTO DE VENTA DE LA FACTURA 6 SUC: parseInt(comprobante.identificaxComprobante.puntoVenta), // [int] NOT NULL, PUNTO DE VENTA DE LA FACTURA
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 PRO: entities.proveedor.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 PRO: 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 ORD: parseInt(comprobante.itemsFactura.numeroLinea), // [int] NOT NULL, ORDEN DEL ITEM, EMPIEZA EN 1 Y SUMA DE A 1 POR CADA REGISTRO DE MOVIMIENTO 9 ORD: parseInt(item.numeroLinea), // [int] NOT NULL, ORDEN DEL ITEM, EMPIEZA EN 1 Y SUMA DE A 1 POR CADA REGISTRO DE MOVIMIENTO
10 COD: null, // [int] NOT NULL, SECTOR DEBO DEL PRODUCTO 10 COD: item.CodSec, // [int] NOT NULL, SECTOR DEBO DEL PRODUCTO
11 ART: null, // [int] NOT NULL, ARTICULO DEBO DEL PRODUCTO ESTOS 2 SE OBTIENEN A PARTIR DEL CODIGO DE BARRAS: SELECT CodSec AS SECTOR,CodArt AS ARTICULO FROM CODBAR WHERE CODBAR='03239210540' 11 ART: item.CodArt, // [int] NOT NULL, ARTICULO DEBO DEL PRODUCTO ESTOS 2 SE OBTIENEN A PARTIR DEL CODIGO DE BARRAS: SELECT CodSec AS SECTOR,CodArt AS ARTICULO FROM CODBAR WHERE CODBAR='03239210540'
12 RUB: null, // [int] NOT NULL, CODIGO DE RUBRO SE OBTIENE DE LA TABLA ARTICULOS SELECT DET_LAR,CODRUB FROM ARTICULOS WHERE CODSEC=SECTOR AND CODART=ARTICULO (DATOS OBTENIDOS EN NOTA ANTERIOR 12 RUB: item.CodRub, // [int] NOT NULL, CODIGO DE RUBRO SE OBTIENE DE LA TABLA ARTICULOS SELECT DET_LAR,CODRUB FROM ARTICULOS WHERE CODSEC=SECTOR AND CODART=ARTICULO (DATOS OBTENIDOS EN NOTA ANTERIOR
13 TIO: null, // [varchar](60) NOT NULL DESCRIPCION DEL PRODUCTO DEL PUNTO ANTERIOR DET_LAR 13 TIO: item.DET_LAR, // [varchar](60) NOT NULL DESCRIPCION DEL PRODUCTO DEL PUNTO ANTERIOR DET_LAR
14 LI0: comprobante.itemsFactura.descripcion, // [varchar](60) NOT NULL, DESCRIPCION ENVIADA POR EL PROVEEDOR 14 LI0: item.descripcion, // [varchar](60) NOT NULL, DESCRIPCION ENVIADA POR EL PROVEEDOR
15 CAN: comprobante.itemsFactura.cantidad, // [money] NOT NULL, CANTIDAD DEL ITEM 15 CAN: item.cantidad, // [money] NOT NULL, CANTIDAD DEL ITEM
16 PUN: comprobante.itemsFactura.precioUnitario, // [decimal](20, 8) NOT NULL PRECIO UNITARIO DEL PRODUCTO ITEM 16 PUN: item.precioUnitario, // [decimal](20, 8) NOT NULL PRECIO UNITARIO DEL PRODUCTO ITEM
17 IMI: comprobante.detalleImpuestosItemFactura.importeImpuesto, // [money] NOT NULL, IMPORTE IMPUESTOS INTERNOS DEL ITEM 17 IMI: item.impuestoInterno ? item.impuestoInterno.importeImpuesto : 0, // [money] NOT NULL, IMPORTE IMPUESTOS INTERNOS DEL ITEM
18 IVA: comprobante.itemsFactura.importeIVA, // [money] NOT NULL, IMPORTE IVA DEL ITEM 18 IVA: item.importeIVA, // [money] NOT NULL, IMPORTE IVA DEL ITEM
19 PUT: comprobante.itemsFactura.precioUnitario, // [money] NOT NULL, IGUAL AL PUN 19 PUT: item.precioUnitario, // [money] NOT NULL, IGUAL AL PUN
20 LEG: 0, // [int] NOT NULL, FIJO 0 20 LEG: 0, // [int] NOT NULL, FIJO 0
21 CMF: 0, // [int] NOT NULL, FIJO 0 21 CMF: 0, // [int] NOT NULL, FIJO 0
22 TUR: 0, // [int] NOT NULL, FIJO 0 22 TUR: 0, // [int] NOT NULL, FIJO 0
23 PLA: 0, // [int] NOT NULL, FIJO 0 23 PLA: 0, // [int] NOT NULL, FIJO 0
24 LUG: 0, // [int] NOT NULL, FIJO 0 24 LUG: 0, // [int] NOT NULL, FIJO 0
25 ESC: 0, // [bit] NOT NULL, FIJO 0 25 ESC: 0, // [bit] NOT NULL, FIJO 0
26 TAN: 0, // [int] NOT NULL, FIJO 0 26 TAN: 0, // [int] NOT NULL, FIJO 0
27 CCO: 0, // [bigint] NOT NULL, FIJO 0 27 CCO: 0, // [bigint] NOT NULL, FIJO 0
28 E_HD: '', // [varchar](8) NOT NULL, FIJO '' VACIO NO NULO 28 E_HD: '', // [varchar](8) NOT NULL, FIJO '' VACIO NO NULO
29 C_HD: '', // [varchar](1) NOT NULL, FIJO '' VACIO NO NULO 29 C_HD: '', // [varchar](1) NOT NULL, FIJO '' VACIO NO NULO
30 DTO: comprobante.detalleDescuentosItemFactura.importeDescuento, // [money] NOT NULL, IMPORTE DESCUENTO DE LA FACTURA 30 DTO: comprobante.detalleDescuentosItemFactura.importeDescuento, // [money] NOT NULL, IMPORTE DESCUENTO DE LA FACTURA
31 PTA: 0, // [int] NOT NULL, FIJO 0 31 PTA: 0, // [int] NOT NULL, FIJO 0
32 SUBM: 0, // [int] NOT NULL, FIJO 0 32 SUBM: 0, // [int] NOT NULL, FIJO 0
33 E_HD2: '', // [varchar](12) NOT NULL, FIJO '' VACIO NO NULO 33 E_HD2: '', // [varchar](12) NOT NULL, FIJO '' VACIO NO NULO
34 C_HD2: '', // [varchar](1) NOT NULL, FIJO '' VACIO NO NULO 34 C_HD2: '', // [varchar](1) NOT NULL, FIJO '' VACIO NO NULO
35 COMISION: 0, // [money] NOT NULL, FIJO 0 35 COMISION: 0, // [money] NOT NULL, FIJO 0
36 LIQ_VTA: '', // [varchar](20) NOT NULL, FIJO '' VACIO NO NULO 36 LIQ_VTA: '', // [varchar](20) NOT NULL, FIJO '' VACIO NO NULO
37 COSTO_PMOV: comprobante.itemsFactura.precioUnitario, // [money] NOT NULL, IGUAL AL PUN 37 COSTO_PMOV: comprobante.itemsFactura.precioUnitario, // [money] NOT NULL, IGUAL AL PUN
38 SAL_ITEM: 0, // [money] NOT NULL, fijo 0 es el que se llenara al mostrar en la tablet o telefono para que llene operador 38 SAL_ITEM: 0, // [money] NOT NULL, fijo 0 es el que se llenara al mostrar en la tablet o telefono para que llene operador
39 TASIVA: comprobante.itemsFactura.alicuotaIVAAplicable, // [money] NOT NULL, TASA DE IVA DEL ITEM = 21.00 / 10.50 / ETC. 39 TASIVA: comprobante.itemsFactura.alicuotaIVAAplicable, // [money] NOT NULL, TASA DE IVA DEL ITEM = 21.00 / 10.50 / ETC.
40 }; 40 };
41 } 41 }
42 42
1 module.exports = function(comprobante, entities) { 1 module.exports = function(comprobante, entities) {
2 2
3 var afipTablas = require('../afip/index'); 3 var afipTablas = require('../afip/index');
4 4
5 return { 5 var objReturn = {
6 cabecera: require('./cabeceraDebo')(comprobante, afipTablas, entities), 6 cabecera: require('./cabeceraDebo')(comprobante, afipTablas, entities),
7 cuerpo: require('./cuerpoDebo')(comprobante, afipTablas) 7 cuerpo: []
8 }; 8 }
9
10 comprobante.itemsFactura.forEach((item, index) => {
11
12 objReturn.cuerpo.push(require('./cuerpoDebo')(comprobante, afipTablas, entities, item));
13 });
14
15 return objReturn;
9 } 16 }
10 17
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 var entities = {}; 13 var entities = {};
14 14
15 var tipoCuit = planex.identificaxEmisor.cuit.slice(0, 2); 15 var tipoCuit = planex.identificaxEmisor.cuit.slice(0, 2);
16 var digitoVerificador = planex.identificaxEmisor.cuit[planex.identificaxEmisor.cuit.length - 1]; 16 var digitoVerificador = planex.identificaxEmisor.cuit[planex.identificaxEmisor.cuit.length - 1];
17 17
18 var cuitToDebo = tipoCuit + '-' + planex.identificaxEmisor.cuit.slice(2, 10) + '-' + digitoVerificador; 18 var cuitToDebo = tipoCuit + '-' + planex.identificaxEmisor.cuit.slice(2, 10) + '-' + digitoVerificador;
19 19
20 var promiseProveedores = wsServer.getEntidad('7790968003283', 'PROVEED', {CUIT: cuitToDebo}); 20 var promiseProveedores = wsServer.getEntidad('7790968003283', 'PROVEED', {CUIT: cuitToDebo});
21 var promiseEmp = wsServer.getEntidad('7790968003283', 'APAREMP'); 21 var promiseEmp = wsServer.getEntidad('7790968003283', 'APAREMP');
22 22
23 Promise.all([promiseProveedores, promiseEmp]).then(function(data) { 23 var promesasArticulo = [];
24 24
25 entities.proveedores = data[0]; 25 planex.itemsFactura.forEach(item => {
26 entities.empresa = data[1];
27 26
28 var debo = require('./debo/index')(planex, entities); 27 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 = \'' +
29 item.codigoUPCEAN13 + '\'';
30
31 promesasArticulo.push(wsServer.getEntidad('7790968003283', null, {}, queryString));
29 }); 32 });
30 33
31 console.log(planex); 34 Promise.all(promesasArticulo).then(function(values) {
35
36 planex.itemsFactura.forEach((item, index) => {
37 item.CodArt = values[index].CodArt;
38 item.CodSec = values[index].CodSec;
39 item.CodRub = values[index].CodRub;
40 item.DET_LAR = values[index].DET_LAR;
41 });
42
43 Promise.all([promiseProveedores, promiseEmp]).then(function(data) {
44
45 entities.proveedores = data[0];
46 entities.empresa = data[1];
47
48 var debo = require('./debo/index')(planex, entities);
49
50 console.log(debo);
51 });
52 });
32 } 53 }
33 54
34 console.log('listen websocket port ' + config.port); 55 console.log('listen websocket port ' + config.port);
35 console.log('Ejecutar programa como administrador...'); 56 console.log('Ejecutar programa como administrador...');
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 = require('./detalleImpuestosItemFactura')(sector, returnFloatByDecimals); // 120
67 } 67 }
68 }); 68 });
69 69
70 objReturn.itemsFactura.array.forEach(item => {
71
72 var detalleDescuentos = planex.detalleImpuestosItemFactura.filter(function(descuento) {
73 return descuento.numeroLinea == item.numeroLinea;
74 })[0];
75
76 switch (detalleDescuentos.descripcionImpuesto) {
77 case 'c05':
78 item.percepcionIVA = detalleDescuentos;
79 break;
80 case 'c06':
81 item.percepcionIIBB = detalleDescuentos;
82 break;
83 case 'c07':
84 item.impuestoInterno = detalleDescuentos;
85 break;
86 case 'c08':
87 item.impuestoAbasto = detalleDescuentos;
88 break;
89 case 'ITC':
90 item.impuestoTransferenciaCombustibles = detalleDescuentos;
91 break;
92 case 'c10':
93 item.percepcionImpuestosMunicipales = detalleDescuentos;
94 break;
95 default:
96 break;
97 }
98 });
99
70 return objReturn; 100 return objReturn;
71 } 101 }
72 102
webSocketServer/index.js
1 module.exports = function() { 1 module.exports = function() {
2 2
3 const webSocketServer = require('ws').Server; 3 const webSocketServer = require('ws').Server;
4 var clients = []; 4 var clients = [];
5 var idsSolicitud = [];
6 5
7 const objWs = {}; 6 const objWs = {};
8 7
9 objWs.wsServer = new webSocketServer({ 8 objWs.wsServer = new webSocketServer({
10 port: config.port 9 port: config.port
11 }); 10 });
12 11
13 objWs.wsServer.on('connection', function connection(ws) { 12 objWs.wsServer.on('connection', function connection(ws) {
14 13
15 console.log('open socket server'); 14 console.log('open socket server');
16 15
17 ws.on('message', function incoming(message) { 16 ws.on('message', function incoming(message) {
18 17
19 message = JSON.parse(message.toString('utf8')); 18 message = JSON.parse(message.toString('utf8'));
20 19
21 switch (message.action) { 20 switch (message.action) {
22 case 'gln': 21 case 'gln':
23 clients.push({ws: ws, gln: message.gln}); 22 clients.push({ws: ws, gln: message.gln});
24 break; 23 break;
25 default: 24 default:
26 // console.log(message.action); 25 // console.log(message.action);
27 } 26 }
28 }); 27 });
29 }); 28 });
30 29
31 objWs.getEntidad = function(gln, tableName, where) { 30 objWs.getEntidad = function(gln, tableName, where, queryString) {
32 31
33 return new Promise(function(resolve, reject) { 32 return new Promise(function(resolve, reject) {
34 33
35 var client = clients.filter(function(client) { 34 var client = clients.filter(function(client) {
36 return client.gln == gln 35 return client.gln == gln
37 })[0]; 36 })[0];
38 37
38 if (!client) {
39 reject('No se encuentra el webSocket client');
40 }
41
39 var idSolicitud = Math.round(Math.random() * 1000); 42 var idSolicitud = Math.round(Math.random() * 1000);
40 43
41 var enviar = { 44 var enviar = {
42 action: 'getEntity', 45 action: 'getEntity',
43 tableName: tableName,
44 where: where || {},
45 idSolicitud: idSolicitud 46 idSolicitud: idSolicitud
46 } 47 };
47 48
48 idsSolicitud.push(idSolicitud); 49 if (queryString) {
50
51 enviar.queryString = queryString;
52 } else {
53 enviar.tableName = tableName;
54 enviar.where = where || {};
55 }
49 56
50 client.ws.send(JSON.stringify(enviar)); 57 client.ws.send(JSON.stringify(enviar));
51 58
52 client.ws.on('message', function(message) { 59 client.ws.on('message', function(message) {
53 60
54 message = JSON.parse(message); 61 message = JSON.parse(message);
55 62
56 if (idSolicitud == message.idSolicitud) { 63 if (idSolicitud == message.idSolicitud) {
57 64
58 resolve(message.data); 65 resolve(message.data);
59 } 66 }
60 67
61 }); 68 });
62 }); 69 });
63 } 70 }
64 71