Commit 732f4a1b168552160fe6fcb88ad8f8f8073f957a
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Obtener sucursal y numero de pedido See merge request modulos-npm/foca-crear-nota-pedido!53
Showing
3 changed files
Show diff stats
package.json
| ... | ... | @@ -22,7 +22,13 @@ |
| 22 | 22 | "peerDependencies": { |
| 23 | 23 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", |
| 24 | 24 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", |
| 25 | + "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", | |
| 25 | 26 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", |
| 27 | + "foca-modal-cotizacion": "git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git", | |
| 28 | + "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", | |
| 29 | + "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", | |
| 30 | + "foca-modal-moneda": "git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git", | |
| 31 | + "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", | |
| 26 | 32 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", |
| 27 | 33 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", |
| 28 | 34 | "foca-seguimiento": "git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git" |
| ... | ... | @@ -46,7 +52,7 @@ |
| 46 | 52 | "foca-seguimiento": "git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git", |
| 47 | 53 | "font-awesome": "^4.7.0", |
| 48 | 54 | "gulp": "^3.9.1", |
| 49 | - "gulp-angular-templatecache": "^2.2.2", | |
| 55 | + "gulp-angular-templatecache": "^2.2.3", | |
| 50 | 56 | "gulp-clean": "^0.4.0", |
| 51 | 57 | "gulp-concat": "^2.6.1", |
| 52 | 58 | "gulp-connect": "^5.6.1", |
src/js/controller.js
| ... | ... | @@ -56,9 +56,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 56 | 56 | $scope.showCabecera = true; |
| 57 | 57 | |
| 58 | 58 | $scope.now = new Date(); |
| 59 | - $scope.puntoVenta = Math.round(Math.random() * 10000); | |
| 60 | - $scope.comprobante = Math.round(Math.random() * 1000000); | |
| 61 | - | |
| 59 | + $scope.puntoVenta = '0000'; | |
| 60 | + $scope.comprobante = '00000000'; | |
| 62 | 61 | $scope.articulosTabla = []; |
| 63 | 62 | $scope.idLista = undefined; |
| 64 | 63 | //La pantalla solo se usa para cargar pedidos |
| ... | ... | @@ -69,6 +68,17 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 69 | 68 | $scope.precioCondiciones = res.data; |
| 70 | 69 | } |
| 71 | 70 | ); |
| 71 | + | |
| 72 | + crearNotaPedidoService.getNumeroNotaPedido().then( | |
| 73 | + function(res) { | |
| 74 | + $scope.puntoVenta = rellenar(res.data.sucursal, 4); | |
| 75 | + $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); | |
| 76 | + }, | |
| 77 | + function(err) { | |
| 78 | + focaModalService.alert('La terminal no esta configurada correctamente'); | |
| 79 | + console.info(err); | |
| 80 | + } | |
| 81 | + ); | |
| 72 | 82 | //La pantalla solo se usa para cargar pedidos |
| 73 | 83 | // if (notaPedidoTemp !== undefined) { |
| 74 | 84 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
| ... | ... | @@ -166,6 +176,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 166 | 176 | data.data.id, $scope.notaPedido.cotizacion.COTIZACION); |
| 167 | 177 | focaSeguimientoService.guardarPosicion('crear nota pedido', ''); |
| 168 | 178 | var plazos = $scope.plazosPagos; |
| 179 | + | |
| 169 | 180 | for(var j = 0; j < plazos.length; j++) { |
| 170 | 181 | var json = { |
| 171 | 182 | idPedido: data.data.id, |
| ... | ... | @@ -193,6 +204,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 193 | 204 | $scope.notaPedido.bomba = null; |
| 194 | 205 | $scope.notaPedido.kilometros = null; |
| 195 | 206 | $scope.articulosTabla = []; |
| 207 | + }, | |
| 208 | + function(error) { | |
| 209 | + focaModalService.alert('Hubo un error al crear la nota de pedido'); | |
| 210 | + console.info(error); | |
| 196 | 211 | } |
| 197 | 212 | ); |
| 198 | 213 | }; |
| ... | ... | @@ -580,6 +595,15 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 580 | 595 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
| 581 | 596 | } |
| 582 | 597 | } |
| 598 | + | |
| 599 | + function rellenar(relleno, longitud) { | |
| 600 | + relleno = '' + relleno; | |
| 601 | + while (relleno.length < longitud) { | |
| 602 | + relleno = '0' + relleno; | |
| 603 | + } | |
| 604 | + | |
| 605 | + return relleno; | |
| 606 | + } | |
| 583 | 607 | } |
| 584 | 608 | ] |
| 585 | 609 | ) |
src/js/service.js
| ... | ... | @@ -51,6 +51,9 @@ angular.module('focaCrearNotaPedido') |
| 51 | 51 | }, |
| 52 | 52 | crearEstadoParaNotaPedido: function(estado) { |
| 53 | 53 | return $http.post(route + '/estado', {estado: estado}); |
| 54 | + }, | |
| 55 | + getNumeroNotaPedido: function() { | |
| 56 | + return $http.get(route + '/nota-pedido/numero-siguiente'); | |
| 54 | 57 | } |
| 55 | 58 | }; |
| 56 | 59 | }]); |