Commit 399786fc5794960f029393f7924a2e3d68c47483

Authored by Jose Pinto
1 parent aed57b90d8
Exists in master

crea nota de pedido, correccion guardar precios y condiciones

src/js/businessService.js
... ... @@ -23,6 +23,22 @@ angular.module('focaCrearNotaPedido')
23 23 };
24 24 crearNotaPedidoService.crearEstadoParaNotaPedido(estado);
25 25 },
  26 + addPuntosDescarga: function(idNotaPedido, puntosDescarga) {
  27 + var puntos = [];
  28 +
  29 + puntosDescarga.forEach(function(punto) {
  30 + punto.articulosAgregados.forEach(function(articulo) {
  31 + puntos.push({
  32 + idPuntoDescarga: punto.id,
  33 + idNotaPedido: idNotaPedido,
  34 + idProducto: articulo.id,
  35 + cantidad: articulo.cantidad
  36 + });
  37 + });
  38 + });
  39 +
  40 + return crearNotaPedidoService.crearPuntosDescarga(puntos);
  41 + },
26 42 calcularArticulos: function(articulos, cotizacion) {
27 43 for(var i = 0; i < articulos.length; i++) {
28 44 articulos[i].precio = articulos[i].precio / cotizacion;
src/js/controller.js
... ... @@ -147,15 +147,22 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
147 147 );
148 148 notaPedidoBusinessService.addArticulos($scope.articulosTabla,
149 149 data.data.id, $scope.notaPedido.cotizacion.VENDEDOR);
150   - var plazos = $scope.plazosPagos;
151 150  
152   - for(var j = 0; j < plazos.length; j++) {
153   - var json = {
154   - idPedido: data.data.id,
155   - dias: plazos[j].dias
156   - };
157   - crearNotaPedidoService.crearPlazosParaNotaPedido(json);
  151 + if($scope.notaPedido.puntosDescarga) {
  152 + notaPedidoBusinessService.addPuntosDescarga(data.data.id,
  153 + $scope.notaPedido.puntosDescarga);
158 154 }
  155 +
  156 + var plazos = $scope.plazosPagos;
  157 + var plazosACrear = [];
  158 + plazos.forEach(function(plazo) {
  159 + plazosACrear.push({
  160 + idNotaPedido: data.data.id,
  161 + dias: plazo.dias
  162 + });
  163 + });
  164 + crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear);
  165 +
159 166 notaPedidoBusinessService.addEstado(data.data.id,
160 167 $scope.notaPedido.vendedor.CodVen);
161 168  
... ... @@ -256,7 +263,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
256 263 valor: notaPedido.proveedor.NOM
257 264 },
258 265 {
259   - label: 'Precio condicion:',
  266 + label: 'Precios y condiciones:',
260 267 valor: valorPrecioCondicion() + ' ' +
261 268 notaPedidoBusinessService
262 269 .plazoToString(notaPedido.notaPedidoPlazo)
... ... @@ -446,7 +453,10 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
446 453 controller: 'focaModalDomicilioController',
447 454 resolve: {
448 455 idCliente: function() { return cliente.cod; },
449   - esNuevo: function() { return cliente.esNuevo; }
  456 + esNuevo: function() { return cliente.esNuevo; },
  457 + articulos: function() {
  458 + return $scope.articulosTabla;
  459 + }
450 460 },
451 461 size: 'lg',
452 462 }
... ... @@ -464,6 +474,8 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
464 474 domicilio.Localidad + ', ' + domicilio.Provincia;
465 475 $scope.notaPedido.domicilioStamp = domicilioStamp;
466 476  
  477 + $scope.notaPedido.puntosDescarga = domicilio.puntosDescarga;
  478 +
467 479 $scope.$broadcast('addCabecera', {
468 480 label: 'Cliente:',
469 481 valor: cliente.nom
... ... @@ -44,7 +44,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
44 44 return $http.post(route + '/flete', {flete : flete});
45 45 },
46 46 crearPlazosParaNotaPedido: function(plazos) {
47   - return $http.post(route + '/plazo-pago/nota-pedido', plazos);
  47 + return $http.post(route + '/plazo-pago/nota-pedido', {plazos: plazos});
48 48 },
49 49 getCotizacionByIdMoneda: function(id) {
50 50 return $http.get(route + '/moneda/' + id);
... ... @@ -58,6 +58,10 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
58 58 getBotonera: function() {
59 59 return ['Vendedor', 'Cliente', 'Proveedor', 'Moneda',
60 60 'Precios y condiciones', 'Flete', 'Productos'];
  61 + },
  62 + crearPuntosDescarga: function(puntosDescarga) {
  63 + return $http.post(route + '/puntos-descarga/nota-pedido',
  64 + {puntosDescarga: puntosDescarga});
61 65 }
62 66 };
63 67 }]);