Commit 1798fe5137fd385533177c81743ae1b3f2b4042e
1 parent
cafb195b5c
Exists in
master
producto no encontrado, rechazados
Showing
2 changed files
with
41 additions
and
36 deletions
Show diff stats
debo/relaciones.js
... | ... | @@ -31,13 +31,13 @@ module.exports = function(planex, wsServer) { |
31 | 31 | if (!values[index]) { |
32 | 32 | |
33 | 33 | console.error('No se encontró el articulo Código de barras = ' + item.codigoUPCEAN13); |
34 | - return; | |
34 | + | |
35 | 35 | } |
36 | 36 | |
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; | |
37 | + item.CodArt = values[index] ? values[index].CodArt : 0; | |
38 | + item.CodSec = values[index] ? values[index].CodSec : 0; | |
39 | + item.CodRub = values[index] ? values[index].CodRub : 0; | |
40 | + item.DET_LAR = values[index] ? values[index].DET_LAR : item.descripcion; | |
41 | 41 | |
42 | 42 | delete values[index]; |
43 | 43 | }); |
rutas/comprobantes.js
... | ... | @@ -88,37 +88,41 @@ router.post('/comprobante', function(req, res) { |
88 | 88 | |
89 | 89 | req.body.cuerpo.forEach(cuerpo => { |
90 | 90 | |
91 | - if (cuerpo.estado == 'rechazado') return; | |
92 | - promesas.push(knex('AMOVSTOC').insert({ | |
93 | - SEC: cuerpo.COD, | |
94 | - ART: cuerpo.ART, | |
95 | - FEC: req.body.cabecera.FEC, | |
96 | - CYV: 'C', | |
97 | - TIP: req.body.cabecera.TIP, | |
98 | - TCO: req.body.cabecera.TCO, | |
99 | - PVE: req.body.cabecera.SUC, | |
100 | - NCO: req.body.cabecera.NCO, | |
101 | - ORD: cuerpo.ORD, | |
102 | - CAN: cuerpo.recibido || cuerpo.CAN, | |
103 | - PUN: cuerpo.PUN, | |
104 | - COD: req.body.cabecera.COD, | |
105 | - DTO: cuerpo.DTO, | |
106 | - IMI: cuerpo.IMI, | |
107 | - PLA: 0, | |
108 | - LUG: 0, | |
109 | - ANU: '', | |
110 | - TIM: 'Co', | |
111 | - OPE: -888, // <= TODO: Cuando se haga el login poner codigo operario | |
112 | - IMI2: cuerpo.IMI2, | |
113 | - E_HD: '', | |
114 | - C_HD: '', | |
115 | - JUS: 'PLANEX', | |
116 | - NLC: 0, | |
117 | - IMI3: cuerpo.IMI3, | |
118 | - JJN: '', | |
119 | - JDJ: '', | |
120 | - ID_MOTIVO_NANB: 0 | |
121 | - })); | |
91 | + if (cuerpo.estado = 'rechazado' && !(cuerpo.COD == 0 && cuerpo.ART == 0 && cuerpo.RUB == 0)) { | |
92 | + | |
93 | + promesas.push(knex('AMOVSTOC').insert({ | |
94 | + SEC: cuerpo.COD, | |
95 | + ART: cuerpo.ART, | |
96 | + FEC: req.body.cabecera.FEC, | |
97 | + CYV: 'C', | |
98 | + TIP: req.body.cabecera.TIP, | |
99 | + TCO: req.body.cabecera.TCO, | |
100 | + PVE: req.body.cabecera.SUC, | |
101 | + NCO: req.body.cabecera.NCO, | |
102 | + ORD: cuerpo.ORD, | |
103 | + CAN: cuerpo.recibido || cuerpo.CAN, | |
104 | + PUN: cuerpo.PUN, | |
105 | + COD: req.body.cabecera.COD, | |
106 | + DTO: cuerpo.DTO, | |
107 | + IMI: cuerpo.IMI, | |
108 | + PLA: 0, | |
109 | + LUG: 0, | |
110 | + ANU: '', | |
111 | + TIM: 'Co', | |
112 | + OPE: -888, // <= TODO: Cuando se haga el login poner codigo operario | |
113 | + IMI2: cuerpo.IMI2, | |
114 | + E_HD: '', | |
115 | + C_HD: '', | |
116 | + JUS: 'PLANEX', | |
117 | + NLC: 0, | |
118 | + IMI3: cuerpo.IMI3, | |
119 | + JJN: '', | |
120 | + JDJ: '', | |
121 | + ID_MOTIVO_NANB: 0 | |
122 | + })); | |
123 | + }; | |
124 | + | |
125 | + cuerpo.estado == 'rechazado' ? cuerpo.CAN = 0 : false; | |
122 | 126 | |
123 | 127 | delete cuerpo.gln; |
124 | 128 | delete cuerpo.C_HD2; |
... | ... | @@ -127,6 +131,7 @@ router.post('/comprobante', function(req, res) { |
127 | 131 | delete cuerpo.estado; |
128 | 132 | delete cuerpo.recibido; |
129 | 133 | delete cuerpo.input; |
134 | + delete cuerpo.tempRecibido; | |
130 | 135 | |
131 | 136 | cuerpo.LI0 = cuerpo.LI0.slice(0, 29); |
132 | 137 | cuerpo.TIO = cuerpo.TIO.slice(0, 29); |