From c28f89332a45b08e672914ec5a41c431ff4fd271 Mon Sep 17 00:00:00 2001 From: Luigi Date: Wed, 17 Apr 2019 10:07:41 -0300 Subject: [PATCH] Arreglo --- src/js/controller.js | 127 +++++++++++++++++++++++++-------------------------- 1 file changed, 63 insertions(+), 64 deletions(-) diff --git a/src/js/controller.js b/src/js/controller.js index 5221339..f774cee 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -155,76 +155,75 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', focaModalService.alert('Debe cargar al menos un articulo'); return; } - focaBotoneraLateralService.startGuardar(); - $scope.saveLoading = true; - var notaPedido = { - id: $scope.notaPedido.id, - fechaCarga: new Date($scope.notaPedido.fechaCarga) - .toISOString().slice(0, 19).replace('T', ' '), - idVendedor: $scope.notaPedido.vendedor.id, - idCliente: $scope.notaPedido.cliente.COD, - nombreCliente: $scope.notaPedido.cliente.NOM, - cuitCliente: $scope.notaPedido.cliente.CUIT, - idProveedor: $scope.notaPedido.proveedor.COD, - idDomicilio: $scope.notaPedido.domicilio.id, - idCotizacion: $scope.notaPedido.cotizacion.ID, - idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, - cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, - flete: $scope.notaPedido.flete, - fob: $scope.notaPedido.fob, - bomba: $scope.notaPedido.bomba, - kilometros: $scope.notaPedido.kilometros, - domicilioStamp: $scope.notaPedido.domicilioStamp, - observaciones: $scope.notaPedido.observaciones, - estado: 0, - total: $scope.getTotal() - }; - crearNotaPedidoService.crearNotaPedido(notaPedido).then( - function(data) { - // Al guardar los datos de la nota de pedido logueamos la - // actividad para su seguimiento. - //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? - focaSeguimientoService.guardarPosicion( - 'Nota de pedido', - data.data.id, - '' - ); - notaPedidoBusinessService.addArticulos( - $scope.notaPedido.articulosNotaPedido, - data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); - - if ($scope.notaPedido.notaPedidoPuntoDescarga) { - notaPedidoBusinessService.addPuntosDescarga(data.data.id, - $scope.notaPedido.notaPedidoPuntoDescarga); - } + focaBotoneraLateralService.startGuardar(); + $scope.saveLoading = true; + var notaPedido = { + id: $scope.notaPedido.id, + fechaCarga: new Date($scope.notaPedido.fechaCarga) + .toISOString().slice(0, 19).replace('T', ' '), + idVendedor: $scope.notaPedido.vendedor.id, + idCliente: $scope.notaPedido.cliente.COD, + nombreCliente: $scope.notaPedido.cliente.NOM, + cuitCliente: $scope.notaPedido.cliente.CUIT, + idProveedor: $scope.notaPedido.proveedor.COD, + idDomicilio: $scope.notaPedido.domicilio.id, + idCotizacion: $scope.notaPedido.cotizacion.ID, + idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, + cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, + flete: $scope.notaPedido.flete, + fob: $scope.notaPedido.fob, + bomba: $scope.notaPedido.bomba, + kilometros: $scope.notaPedido.kilometros, + domicilioStamp: $scope.notaPedido.domicilioStamp, + observaciones: $scope.notaPedido.observaciones, + estado: 0, + total: $scope.getTotal() + }; + crearNotaPedidoService.crearNotaPedido(notaPedido).then( + function(data) { + // Al guardar los datos de la nota de pedido logueamos la + // actividad para su seguimiento. + //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? + focaSeguimientoService.guardarPosicion( + 'Nota de pedido', + data.data.id, + '' + ); + notaPedidoBusinessService.addArticulos( + $scope.notaPedido.articulosNotaPedido, + data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); - var plazos = $scope.notaPedido.notaPedidoPlazo; - var plazosACrear = []; - plazos.forEach(function(plazo) { - plazosACrear.push({ - idNotaPedido: data.data.id, - dias: plazo.dias - }); + if ($scope.notaPedido.notaPedidoPuntoDescarga) { + notaPedidoBusinessService.addPuntosDescarga(data.data.id, + $scope.notaPedido.notaPedidoPuntoDescarga); + } + + var plazos = $scope.notaPedido.notaPedidoPlazo; + var plazosACrear = []; + plazos.forEach(function(plazo) { + plazosACrear.push({ + idNotaPedido: data.data.id, + dias: plazo.dias }); + }); - if (plazosACrear.length) { - crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); - } + if (plazosACrear.length) { + crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); + } - notaPedidoBusinessService.addEstado(data.data.id, - $scope.notaPedido.vendedor.id); + notaPedidoBusinessService.addEstado(data.data.id, + $scope.notaPedido.vendedor.id); - focaBotoneraLateralService.endGuardar(true); - $scope.saveLoading = false; + focaBotoneraLateralService.endGuardar(true); + $scope.saveLoading = false; - init(); - }, function(error) { - focaModalService.alert('Hubo un error al crear la nota de pedido'); - focaBotoneraLateralService.endGuardar(); - $scope.saveLoading = false; - console.info(error); - } - ); + init(); + }, function(error) { + focaModalService.alert('Hubo un error al crear la nota de pedido'); + focaBotoneraLateralService.endGuardar(); + $scope.saveLoading = false; + console.info(error); + }); } }; -- 1.9.1