Commit f3e957d099395608d8e2a393beef369a5915cb6d

Authored by Eric Fernandez
1 parent c4e2ac131c
Exists in master

planex parse

1 const webSocketServer = require('ws').Server; 1 const webSocketServer = require('ws').Server;
2 const fs = require('fs'); 2 const fs = require('fs');
3 const config = require('./config/config.json'); 3 const config = require('./config/config.json');
4 4
5 const planex = require('./planex/index')();
6
7 console.log(planex);
8
5 fs.watch(__dirname, function (event, file) { 9 fs.watch(__dirname, function (event, file) {
6 console.log(event); 10 console.log(event);
7 console.log(file); 11 console.log(file);
8 }); 12 });
9 13
10 const wsServer = new webSocketServer({ 14 const wsServer = new webSocketServer({
11 port: config.port 15 port: config.port
12 }); 16 });
13 17
14 wsServer.on('connection', function connection(ws) { 18 wsServer.on('connection', function connection(ws) {
15 console.log('open socket server') 19 console.log('open socket server')
16 20
17 ws.on('message', function incoming(message) { 21 ws.on('message', function incoming(message) {
18 console.log('recibe ho: %s', message); 22 console.log('recibe ho: %s', message);
19 if (message == 'isAlive?') { 23 if (message == 'isAlive?') {
20 24
21 setTimeout(function () { 25 setTimeout(function () {
22 ws.send('YES IS ALIVE'); 26 ws.send('YES IS ALIVE');
23 }, 10000); 27 }, 10000);
24 } 28 }
25 }); 29 });
26 }); 30 });
27 31
28 console.log('listen websocket port ' + config.port); 32 console.log('listen websocket port ' + config.port);
29 33
planex/comprobantesReferencia.js
File was created 1 module.exports = function(comprobante) {
2
3 comprobante = '020;RE;0009;00093491;;'
4
5 var comprobanteArr = comprobante.split(';');
6
7 return {
8 tipoDocumentoReferencia: comprobanteArr[1],
9 puntoVentaReferencia: comprobanteArr[2],
10 numeroDocumentoReferencia: comprobanteArr[3],
11 fechaComprobanteReferencia: comprobanteArr[4],
12 cuitEmisorComprobanteAsociado: comprobanteArr[5]
13 }
14 }
planex/identificacionComprobante.js
File was created 1 module.exports = function(comprobante) {
2
3 var comprobante = '010;01;00081929;00081929;0002;20120927;20120927;;;14 DIAS;;;32012114736927;20140716;;;;;;;;;;;20120927';
4
5 var comprobanteArr = comprobante.split(';');
6
7 return {
8 tipo: comprobanteArr[1],
9 numero: comprobanteArr[2],
10 numeroRegistrado: comprobanteArr[3],
11 puntoVenta: comprobanteArr[4],
12 fechaComprobante: comprobanteArr[5],
13 fechaVencimiento: comprobanteArr[6],
14 fechaSegundoVencimiento: comprobanteArr[7],
15 fechaProximoVencimiento: comprobanteArr[8],
16 condicionPago: comprobanteArr[9],
17 caeOCaea: comprobanteArr[10],
18 fechaVencimientoCaeOCaea: comprobanteArr[11],
19 cai: comprobanteArr[12],
20 fechaVencimientoCai: comprobanteArr[14],
21 motivo: comprobanteArr[15],
22 fechaServicioDesde: comprobanteArr[16],
23 fechaServicioHasta: comprobanteArr[17],
24 codigoControladorFiscal: comprobanteArr[17],
25 codigoOperacion: comprobanteArr[18],
26 cantidadHojas: comprobanteArr[19],
27 datosCodigoBarraParaCobranza: comprobanteArr[20],
28 datosOtroCodigoBarras: comprobanteArr[21],
29 datosCodigoParaPagoElectronico: comprobanteArr[22],
30 fechaAnulacion: comprobanteArr[23],
31 fechaEntrega: comprobanteArr[24],
32 numeroVisualizador: comprobanteArr[25]
33 };
34
35 }
planex/identificacionEmisor.js
File was created 1 module.exports = function(comprobante) {
2
3 comprobante = '030;EMPRESA EMISORA S.A.;7790522012340;01;902-108324-2;19690727;;Maximo M 885;;;;;;;Lanus Oeste;Buenos Aires;1824;;;30123654736;;;;;;'
4
5 comprobanteArr = comprobante.split(';');
6
7 return {
8 razonSocial: comprobanteArr[1],
9 glnEmisor: comprobanteArr[2],
10 ivaEmisor: comprobanteArr[3],
11 numeroIngresosBrutos: comprobanteArr[4],
12 inicioActividades: comprobanteArr[5],
13 contacto: comprobanteArr[6],
14 direccion: comprobanteArr[7],
15 numero: comprobanteArr[8],
16 piso: comprobanteArr[9],
17 departamento: comprobanteArr[10],
18 sector: comprobanteArr[11],
19 torre: comprobanteArr[12],
20 manzana: comprobanteArr[13],
21 localidad: comprobante[14],
22 provincia: comprobanteArr[15],
23 codigoPostal: comprobanteArr[16],
24 email: comprobanteArr[17],
25 telefono: comprobanteArr[18],
26 cuit: comprobanteArr[19],
27 codigoAgenciaResponsableListaCodigos: comprobanteArr[20],
28 numeroEstablecimientoEmisor: comprobanteArr[21],
29 numeroAgentePercepcionProvincialDelEmisor: comprobanteArr[22],
30 numeroAgentePercepcionMunicipalDelEmisor: comprobanteArr[23],
31 numeroFax: comprobanteArr[24],
32 codigoVendedor: comprobanteArr[25]
33 };
34
35 }
36
planex/identificacionMensaje.js
File was created 1 module.exports = function(comprobante) {
2
3 return '';
4
5 }
File was created 1 module.exports = function(comprobante) {
2
3 return {
4 identificacionComprobante: require('./identificacionComprobante')(comprobante),
5 identificacionMensaje: require('./identificacionMensaje')(comprobante),
6 comprobantesReferencia: require('./comprobantesReferencia')(comprobante),
7 identificacionEmisor: require('./identificacionEmisor')(comprobante),
8 }
9 }
10