From ded337bfb5466447aa46fbec7cc4bbc38f09135c Mon Sep 17 00:00:00 2001 From: Eric Fernandez Date: Thu, 8 Aug 2019 17:34:31 -0300 Subject: [PATCH] refaktor --- db/index.js | 1 + debo/cabeceraDebo.js | 3 ++- knexfile.js | 47 ------------------------------------- migrations/20190626112130_v0.0.1.js | 37 ----------------------------- rutas/comprobantes.js | 4 ++-- 5 files changed, 5 insertions(+), 87 deletions(-) delete mode 100644 knexfile.js delete mode 100644 migrations/20190626112130_v0.0.1.js diff --git a/db/index.js b/db/index.js index 4fbe4cd..e490926 100644 --- a/db/index.js +++ b/db/index.js @@ -12,6 +12,7 @@ module.exports = function(comprobante, nameFile) { .then(saveDebo); function saveDebo(id) { + comprobante.cabecera.idTransaccion = id; var promesas = [knex('PMAEFACT_TEMP').insert(comprobante.cabecera)]; diff --git a/debo/cabeceraDebo.js b/debo/cabeceraDebo.js index f6e486c..7ca9e99 100644 --- a/debo/cabeceraDebo.js +++ b/debo/cabeceraDebo.js @@ -87,6 +87,7 @@ module.exports = function(comprobante, afipTablas, entities) { CABA_PER: 0, // [money] NOT NULL, IMPORTE PERCEPCION CABA PERMUN: comprobante.importesTotales.importeImpuestosMunicipales, // [money] NOT NULL, IMPORTE PERCEPCIONES MUNICIPALES IMI2: 0, // [money] NOT NULL, FIJO 0 - GLN: comprobante.identificaxSucursalReceptorFactura.glnSucursal + GLN: comprobante.identificaxSucursalReceptorFactura.glnSucursal, + origen: 'planex' }; } diff --git a/knexfile.js b/knexfile.js deleted file mode 100644 index f5f2fcb..0000000 --- a/knexfile.js +++ /dev/null @@ -1,47 +0,0 @@ -// Update with your config settings. - -module.exports = { - - development: { - client: 'mssql', - connection: { - host: '10.231.45.211', - user: 'sa', - password: 'xxzza', - database: 'UNITYOIL_28082017' - } - }, - - staging: { - client: 'postgresql', - connection: { - database: 'my_db', - user: 'username', - password: 'password' - }, - pool: { - min: 2, - max: 10 - }, - migrations: { - tableName: 'knex_migrations' - } - }, - - production: { - client: 'postgresql', - connection: { - database: 'my_db', - user: 'username', - password: 'password' - }, - pool: { - min: 2, - max: 10 - }, - migrations: { - tableName: 'knex_migrations' - } - } - -}; diff --git a/migrations/20190626112130_v0.0.1.js b/migrations/20190626112130_v0.0.1.js deleted file mode 100644 index 0cc6634..0000000 --- a/migrations/20190626112130_v0.0.1.js +++ /dev/null @@ -1,37 +0,0 @@ - -exports.up = function(knex, Promise) { - return Promise.all([ - knex.schema - .createTable('planex_transacciones', function(table) { - - table.increments(); - table.string('archivoRecibido', 1024); - table.string('archivoEnviado', 1024); - // 0: insertado, 1 enviado - table.integer('estado'); - table.string('apies'); - table.string('GLN'); - }) - .table('PMAEFACT_TEMP', function(table) { - - table.string('GLN'); - table.bigInteger('idTransaccion'); - }) - .table('PMOVFACT_TEMP', function(table) { - - table.string('GLN'); - table.bigInteger('codigoBarras'); - }) - ]); -}; - -exports.down = function(knex, Promise) { - return Promise.all([ - knex.schema - .dropTable('planex_transacciones') - .table('PMAEFACT_TEMP', function(table) { - - table.dropColumns('GLN', 'idTransaccion'); - }) - ]); -}; diff --git a/rutas/comprobantes.js b/rutas/comprobantes.js index d099f22..56471d8 100644 --- a/rutas/comprobantes.js +++ b/rutas/comprobantes.js @@ -27,7 +27,7 @@ router.get('/comprobantes/:gln*?', function(req, res) { var cuerpos = data[1].filter((cuerpo) => { let idCuerpo = cuerpo.TIP + cuerpo.TCO + cuerpo.SUC + cuerpo.NCO; - return idCuerpo == idCabecera + return idCuerpo == idCabecera; }); result.push({ @@ -103,7 +103,7 @@ router.post('/comprobante', function(req, res) { PVE: req.body.cabecera.SUC, NCO: req.body.cabecera.NCO, ORD: cuerpo.ORD, - CAN: cuerpo.recibido || cuerpo.CAN, + CAN: cuerpo.cantidadRecibida, PUN: cuerpo.PUN, COD: req.body.cabecera.COD, DTO: cuerpo.DTO, -- 1.9.1