Commit a464e39d2049bdd532a3e2acffe56829b228da99
1 parent
ea90545e08
Exists in
master
validación by tabla planex_transacción
Showing
3 changed files
with
26 additions
and
30 deletions
Show diff stats
debo/validacion.js
1 | -module.exports = function(debo, wsServer, gln) { | |
1 | +module.exports = function (fileString) { | |
2 | 2 | |
3 | - return new Promise(function(resolve, reject) { | |
3 | + return new Promise(function (resolve, reject) { | |
4 | 4 | |
5 | - wsServer | |
6 | - .getEntidad(gln, 'PMAEFACT_TEMP', { | |
7 | - TIP: debo.cabecera.TIP, | |
8 | - TCO: debo.cabecera.TCO, | |
9 | - SUC: debo.cabecera.SUC, | |
10 | - NCO: debo.cabecera.NCO, | |
11 | - COD: debo.cabecera.COD | |
12 | - }).then(function(values) { | |
5 | + var nameFileDest = fileString.split('\\')[fileString.split('\\').length - 1]; | |
13 | 6 | |
14 | - if (values) { | |
7 | + knex('planex_transacciones') | |
8 | + .where({ archivoRecibido: nameFileDest }) | |
9 | + .then(function (values) { | |
10 | + | |
11 | + if (values.length) { | |
15 | 12 | reject('Ya existe el comprobante', values); |
16 | 13 | } else { |
17 | - resolve(debo); | |
14 | + resolve(); | |
18 | 15 | } |
19 | 16 | }); |
20 | 17 | }); |
index.js
... | ... | @@ -30,31 +30,30 @@ function onGetFile(fileString, nameFile) { |
30 | 30 | |
31 | 31 | if (!fileString) return; |
32 | 32 | |
33 | - var planex = require('./planex/index')(fileString); | |
33 | + require('./debo/validacion')(fileString).then(function() { | |
34 | 34 | |
35 | - // Traigo proveedor, empresa | |
36 | - require('./debo/relaciones')(planex, wsServer).then(function(result) { | |
35 | + var planex = require('./planex/index')(fileString); | |
37 | 36 | |
38 | - var planex = result.planex; | |
37 | + // Traigo proveedor, empresa | |
38 | + require('./debo/relaciones')(planex, wsServer).then(function(result) { | |
39 | 39 | |
40 | - var entities = {}; | |
40 | + var planex = result.planex; | |
41 | 41 | |
42 | - entities.proveedores = result.values[0]; | |
43 | - entities.empresa = result.values[1]; | |
42 | + var entities = {}; | |
44 | 43 | |
45 | - var debo = require('./debo/index')(planex, entities); | |
44 | + entities.proveedores = result.values[0]; | |
45 | + entities.empresa = result.values[1]; | |
46 | 46 | |
47 | - require('./debo/validacion')(debo, wsServer, planex.identificaxSucursalReceptorFactura.glnSucursal) | |
48 | - .then(function(debo) { | |
47 | + var debo = require('./debo/index')(planex, entities); | |
49 | 48 | |
50 | - require('./db/index')(debo, nameFile); | |
51 | - }).catch(function(err) { | |
49 | + require('./db/index')(debo, nameFile); | |
52 | 50 | |
53 | - console.log(err); | |
54 | - }); | |
55 | - | |
56 | - }).catch(function(e) { | |
57 | - console.log(e); | |
51 | + }).catch(function(e) { | |
52 | + console.log(e); | |
53 | + }); | |
54 | + }).catch(function(err) { | |
55 | + | |
56 | + console.log(err); | |
58 | 57 | }); |
59 | 58 | } |
60 | 59 |
rutas/comprobantes.js
... | ... | @@ -53,7 +53,7 @@ router.post('/comprobante', function(req, res) { |
53 | 53 | delete req.body.cabecera.C_HD2; |
54 | 54 | delete req.body.cabecera.E_HD2; |
55 | 55 | |
56 | - //smalldatetime | |
56 | + //smalldatetime TODO: USAR MOMENT JS | |
57 | 57 | req.body.cabecera.FEC = new Date(req.body.cabecera.FEC).toISOString().slice(0, 19).replace('T', ' '); |
58 | 58 | req.body.cabecera.FECCAI = new Date(req.body.cabecera.FECCAI).toISOString().slice(0, 19).replace('T', ' '); |
59 | 59 | req.body.cabecera.FECVEN = new Date(req.body.cabecera.FECVEN).toISOString().slice(0, 19).replace('T', ' '); |