Commit ca2329118e9232120968307e45207b6ee6033b12
1 parent
94d630a24e
Exists in
master
and in
2 other branches
puntos descarga
Showing
3 changed files
with
36 additions
and
7 deletions
Show diff stats
src/js/businessService.js
| ... | ... | @@ -36,6 +36,19 @@ angular.module('focaCrearRemito') |
| 36 | 36 | result += plazos[i].dias + ' '; |
| 37 | 37 | } |
| 38 | 38 | return result.trim(); |
| 39 | + }, | |
| 40 | + addPuntosDescarga: function(idRemito, puntosDescarga) { | |
| 41 | + | |
| 42 | + var puntos = []; | |
| 43 | + | |
| 44 | + puntosDescarga.forEach(function(punto) { | |
| 45 | + puntos.push({ | |
| 46 | + idPuntoDescarga: punto.id, | |
| 47 | + idRemito: idRemito, | |
| 48 | + }); | |
| 49 | + }); | |
| 50 | + | |
| 51 | + return crearRemitoService.crearPuntosDescarga(puntos); | |
| 39 | 52 | } |
| 40 | 53 | }; |
| 41 | 54 | }]); |
src/js/controller.js
| ... | ... | @@ -65,7 +65,8 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 65 | 65 | domicilio: {dom: ''}, |
| 66 | 66 | moneda: {}, |
| 67 | 67 | cotizacion: $scope.cotizacionPorDefecto || {}, |
| 68 | - articulosRemito: [] | |
| 68 | + articulosRemito: [], | |
| 69 | + remitoPuntoDescarga: [] | |
| 69 | 70 | }; |
| 70 | 71 | |
| 71 | 72 | $scope.notaPedido = { |
| ... | ... | @@ -218,6 +219,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 218 | 219 | $scope.remito = notaPedido; |
| 219 | 220 | $scope.remito.id = 0; |
| 220 | 221 | $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; |
| 222 | + $scope.remito.remitoPuntoDescarga = notaPedido.notaPedidoPuntoDescarga; | |
| 221 | 223 | |
| 222 | 224 | notaPedido.articulosNotaPedido.forEach(function (articulo) { |
| 223 | 225 | articulo.id = 0; |
| ... | ... | @@ -347,6 +349,11 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 347 | 349 | $scope.remito.id = data.data.id; |
| 348 | 350 | $scope.remito.numeroRemito = data.data.numero; |
| 349 | 351 | |
| 352 | + if ($scope.remito.remitoPuntoDescarga) { | |
| 353 | + remitoBusinessService.addPuntosDescarga(data.data.id, | |
| 354 | + $scope.remito.remitoPuntoDescarga); | |
| 355 | + } | |
| 356 | + | |
| 350 | 357 | remitoBusinessService.addArticulos($scope.remito.articulosRemito, |
| 351 | 358 | $scope.remito.id, $scope.remito.cotizacion.VENDEDOR); |
| 352 | 359 | |
| ... | ... | @@ -458,7 +465,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 458 | 465 | idDomicilio: $scope.remito.domicilio.id, |
| 459 | 466 | idCliente: $scope.remito.cliente.COD, |
| 460 | 467 | articulos: $scope.remito.articulosRemito, |
| 461 | - puntosDescarga: $scope.remito.domicilio.puntosDescarga, | |
| 468 | + puntosDescarga: $scope.remito.remitoPuntoDescarga, | |
| 462 | 469 | domicilio: $scope.remito.domicilio |
| 463 | 470 | } |
| 464 | 471 | } |
| ... | ... | @@ -466,12 +473,12 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 466 | 473 | ); |
| 467 | 474 | modalInstance.result.then( |
| 468 | 475 | function(puntosDescarga) { |
| 469 | - $scope.remito.domicilio.puntosDescarga = puntosDescarga; | |
| 476 | + $scope.remito.remitoPuntoDescarga = puntosDescarga; | |
| 470 | 477 | |
| 471 | 478 | $scope.$broadcast('addCabecera', { |
| 472 | 479 | label: 'Puntos de descarga:', |
| 473 | 480 | valor: getCabeceraPuntoDescarga( |
| 474 | - $scope.remito.domicilio.puntosDescarga ) | |
| 481 | + $scope.remito.remitoPuntoDescarga) | |
| 475 | 482 | }); |
| 476 | 483 | }, function() { |
| 477 | 484 | $scope.abrirModalDomicilios($scope.cliente); |
| ... | ... | @@ -1146,11 +1153,16 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 1146 | 1153 | $scope.puntoVenta = rellenar(remito.sucursal, 4); |
| 1147 | 1154 | $scope.comprobante = rellenar(remito.numeroRemito, 8); |
| 1148 | 1155 | $scope.remito = remito; |
| 1149 | - if ($scope.remito.puntosDescarga) { | |
| 1150 | - var puntosDescarga = $scope.remito.puntosDescarga; | |
| 1156 | + if ($scope.remito.remitoPuntoDescarga.length) { | |
| 1157 | + var puntoDescarga = []; | |
| 1158 | + | |
| 1159 | + $scope.remito.remitoPuntoDescarga.forEach(function(remitoPuntoDescarga) { | |
| 1160 | + puntoDescarga.push(remitoPuntoDescarga.puntoDescarga); | |
| 1161 | + }); | |
| 1162 | + | |
| 1151 | 1163 | cabeceras.push({ |
| 1152 | 1164 | label: 'Puntos de descarga: ', |
| 1153 | - valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntosDescarga)) | |
| 1165 | + valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntoDescarga)) | |
| 1154 | 1166 | }); |
| 1155 | 1167 | } |
| 1156 | 1168 |
src/js/service.js
| ... | ... | @@ -78,6 +78,10 @@ angular.module('focaCrearRemito') |
| 78 | 78 | getParametros: function() { |
| 79 | 79 | return $http.get(API_ENDPOINT.URL + '/parametros/remito'); |
| 80 | 80 | }, |
| 81 | + crearPuntosDescarga: function(puntosDescarga) { | |
| 82 | + return $http.post(route + '/puntos-descarga/remito', | |
| 83 | + {puntosDescarga: puntosDescarga}); | |
| 84 | + }, | |
| 81 | 85 | getBotonera: function() { |
| 82 | 86 | return [ |
| 83 | 87 | { |