Commit ea90545e08a85191df970197ef86ee0c5bbe4a39
1 parent
6710c93dc0
Exists in
master
fix feedback planex
Showing
5 changed files
with
13 additions
and
11 deletions
Show diff stats
recadv/datosArticulos.js
1 | module.exports = function(cuerpo, index, parseToFijo) { | 1 | module.exports = function(cuerpo, index, parseToFijo) { |
2 | 2 | ||
3 | return '110;' + | 3 | return '110;' + |
4 | index + ';' + | 4 | (index + 1) + ';' + |
5 | cuerpo.codigoBarras + ';' + | 5 | cuerpo.codigoBarras + ';' + |
6 | cuerpo.COD + '-' + cuerpo.ART + ';;' + | 6 | cuerpo.COD + '-' + cuerpo.ART + ';;' + |
7 | cuerpo.TIO + ';' + | 7 | cuerpo.TIO + ';' + |
8 | parseToFijo(cuerpo.PUN, 4, 15) + ';' + | 8 | parseToFijo(cuerpo.PUN, 4, 15) + ';' + |
9 | moment().format('YYYYMMDD') + ';;'; | 9 | moment().format('YYYYMMDD') + ';;'; |
10 | } | 10 | } |
11 | 11 |
recadv/datosCantidadArticulos.js
1 | module.exports = function(cuerpo, index) { | 1 | module.exports = function(cuerpo, index, decimalToFijo) { |
2 | 2 | ||
3 | cuerpo.estado == 'rechazado' ? cuerpo.CAN = 0 : false; | 3 | cuerpo.estado == 'rechazado' ? cuerpo.CAN = 0 : false; |
4 | 4 | ||
5 | var cantidadRecibida = cuerpo.recibido ? cuerpo.recibido : cuerpo.CAN; | 5 | var cantidadRecibida = cuerpo.recibido ? cuerpo.recibido : cuerpo.CAN; |
6 | 6 | ||
7 | return '111;' + | 7 | return '111;' + |
8 | index + ';' + | 8 | (index + 1) + ';' + |
9 | 45 + ';' + | 9 | 45 + ';' + |
10 | cantidadRecibida + ';'; | 10 | decimalToFijo(cantidadRecibida, 5, 15) + ';'; |
11 | } | 11 | } |
12 | 12 |
recadv/datosIndentificacionMensaje.js
1 | module.exports = function(comprobante) { | 1 | module.exports = function(comprobante) { |
2 | 2 | ||
3 | return '000;RECADV;' + | 3 | return '000;RECADV;' + |
4 | comprobante.identificaxEmisor.glnEmisor + ';' + | ||
5 | comprobante.identificaxReceptorFactura.glnReceptor + ';' + | 4 | comprobante.identificaxReceptorFactura.glnReceptor + ';' + |
5 | comprobante.identificaxEmisor.glnEmisor + ';' + | ||
6 | comprobante.identificaxMensaje.idMensaje; | 6 | comprobante.identificaxMensaje.idMensaje; |
7 | } | 7 | } |
recadv/datosProveedor.js
1 | module.exports = function(comprobante) { | 1 | module.exports = function(comprobante) { |
2 | 2 | ||
3 | return '040;' + comprobante.identificaxEmisor.glnEmisor + ';' + | 3 | return '040;' + comprobante.identificaxEmisor.glnEmisor + ';' + |
4 | comprobante.identificaxEmisor.glnEmisor + ';;;;;;;;;;;;' | 4 | comprobante.identificaxEmisor.cuit + ';;;;;;;;;;;;' |
5 | } | 5 | } |
6 | 6 |
recadv/todos.js
1 | module.exports = function(planex, cuerpos, fileString, idTransaccion) { | 1 | module.exports = function(planex, cuerpos, fileString, idTransaccion) { |
2 | 2 | ||
3 | var result = require('./datosIndentificacionMensaje')(planex) + '\r\n'; | 3 | var result = require('./datosIndentificacionMensaje')(planex) + '\r\n'; |
4 | 4 | ||
5 | result += require('./datosCabecera')(planex, idTransaccion) + '\r\n'; | 5 | result += require('./datosCabecera')(planex, idTransaccion) + '\r\n'; |
6 | 6 | ||
7 | fileString = fileString.split(/\r?\n/); | 7 | fileString = fileString.split(/\r?\n/); |
8 | 8 | ||
9 | fileString.forEach(bloque => { | 9 | fileString.forEach(bloque => { |
10 | 10 | ||
11 | if (bloque.slice(0, 3) == '020') { | 11 | if (bloque.slice(0, 3) == '020') { |
12 | result += bloque + '\r\n'; | 12 | result += bloque + '\r\n'; |
13 | } | 13 | } |
14 | 14 | ||
15 | }); | 15 | }); |
16 | 16 | ||
17 | result += require('./datosComprador')(planex); | 17 | result += require('./datosComprador')(planex) + '\r\n'; |
18 | result += require('./datosProveedor')(planex); | 18 | result += require('./datosProveedor')(planex) + '\r\n'; |
19 | 19 | ||
20 | cuerpos.forEach((cuerpo, index) => { | 20 | cuerpos.forEach((cuerpo, index) => { |
21 | result += require('./datosArticulos')(cuerpo, index, decimalToFijo) + '\r\n'; | 21 | result += require('./datosArticulos')(cuerpo, index, decimalToFijo) + '\r\n'; |
22 | }); | 22 | }); |
23 | 23 | ||
24 | cuerpos.forEach((cuerpo, index) => { | 24 | cuerpos.forEach((cuerpo, index) => { |
25 | result += require('./datosCantidadArticulos')(cuerpo, index) + '\r\n'; | 25 | result += require('./datosCantidadArticulos')(cuerpo, index, decimalToFijo) + '\r\n'; |
26 | }); | 26 | }); |
27 | 27 | ||
28 | result += require('./totalControl')(cuerpos.length); | 28 | result += require('./totalControl')(cuerpos.length); |
29 | 29 | ||
30 | return result; | 30 | return result; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | function decimalToFijo(decimal, cantidadDecimales, fijo) { | 33 | function decimalToFijo(decimal, cantidadDecimales, fijo) { |
34 | 34 | ||
35 | decimal = decimal.toString().split('.'); | 35 | decimal = decimal.toString().split('.'); |
36 | 36 | ||
37 | decimal[1] = rellenar(decimal[1] || '0', cantidadDecimales, false); | 37 | decimal[1] = rellenar(decimal[1] || '0', cantidadDecimales, false); |
38 | 38 | ||
39 | decimal = rellenar(decimal[0] + decimal[1], fijo, true); | 39 | decimal = rellenar(decimal[0] + decimal[1], fijo, true); |
40 | 40 | ||
41 | function rellenar(aRellenar, cantidad, left) { | 41 | function rellenar(aRellenar, cantidad, left) { |
42 | 42 | ||
43 | for (let i = 0; i <= cantidad - aRellenar.length; i++) { | 43 | for (let i = 0; i <= cantidad; i++) { |
44 | |||
45 | if (aRellenar.length >= cantidad) break; | ||
46 | |||
44 | left ? aRellenar = '0' + aRellenar : aRellenar = aRellenar + '0'; | 47 | left ? aRellenar = '0' + aRellenar : aRellenar = aRellenar + '0'; |
45 | } | 48 | } |
46 | 49 | ||
47 | return aRellenar; | 50 | return aRellenar; |
48 | } | 51 | } |
49 | 52 | ||
50 | return decimal; | 53 | return decimal; |
51 | } | 54 | } |
52 |