Commit 6ee3d8210af0746159af66b95b003132748b5a1e
1 parent
8a0a50e7af
Exists in
master
and in
1 other branch
parametros nota de pedido
Showing
1 changed file
with
13 additions
and
34 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -50,37 +50,18 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 50 | 50 | if (APP === 'distribuidor') { |
| 51 | 51 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; |
| 52 | 52 | } |
| 53 | - //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | |
| 54 | - //Trabajo con el proveedor YPF, por eso uso siempre la primera | |
| 55 | 53 | |
| 56 | - var promiseMoneda = crearNotaPedidoService.getCotizacionByIdMoneda(1); | |
| 57 | - var promiseProveedor = crearNotaPedidoService.getProveedorById(98); | |
| 58 | - | |
| 59 | - //TODO refactor después de demo | |
| 60 | - Promise.all([promiseMoneda, promiseProveedor]).then(function(res) { | |
| 61 | - | |
| 62 | - var monedaPorDefecto = res[0].data[0]; | |
| 63 | - | |
| 64 | - $scope.notaPedido.cotizacion = Object.assign( | |
| 65 | - {moneda: monedaPorDefecto}, | |
| 66 | - monedaPorDefecto.cotizaciones[0] | |
| 67 | - ); | |
| 68 | - $scope.inicial.cotizacion = $scope.notaPedido.cotizacion; | |
| 69 | - | |
| 70 | - var proveedorPorDefecto = res[1].data[0]; | |
| 71 | - | |
| 72 | - $scope.notaPedido.proveedor = proveedorPorDefecto; | |
| 73 | - $scope.inicial.proveedor = $scope.notaPedido.proveedor; | |
| 74 | - | |
| 75 | - $scope.notaPedido.flete = false; | |
| 76 | - $scope.notaPedido.fob = false; | |
| 77 | - $scope.notaPedido.bomba = false; | |
| 78 | - | |
| 79 | - $scope.inicial.flete = false; | |
| 80 | - $scope.inicial.fob = false; | |
| 81 | - $scope.inicial.bomba = false; | |
| 82 | - | |
| 83 | - $timeout(function() { getLSNotaPedido();} ); | |
| 54 | + crearNotaPedidoService.getParametros().then(function(res) { | |
| 55 | + var parametros = JSON.parse(res.data[0].jsonText); | |
| 56 | + if ($localStorage.notaPedido) { | |
| 57 | + $timeout(function() { getLSNotaPedido();} ); | |
| 58 | + } else { | |
| 59 | + for (property in parametros) { | |
| 60 | + $scope.notaPedido[property] = parametros[property]; | |
| 61 | + $scope.inicial[property] = parametros[property]; | |
| 62 | + } | |
| 63 | + setearNotaPedido($scope.notaPedido); | |
| 64 | + } | |
| 84 | 65 | }); |
| 85 | 66 | |
| 86 | 67 | init(); |
| ... | ... | @@ -100,9 +81,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 100 | 81 | cotizacion: {}, |
| 101 | 82 | articulosNotaPedido: [], |
| 102 | 83 | notaPedidoPlazo: [], |
| 103 | - notaPedidoPuntoDescarga: { | |
| 104 | - puntoDescarga: {} | |
| 105 | - } | |
| 84 | + notaPedidoPuntoDescarga: [] | |
| 106 | 85 | }; |
| 107 | 86 | $scope.idLista = undefined; |
| 108 | 87 | |
| ... | ... | @@ -956,7 +935,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 956 | 935 | notaPedido.numeroNotaPedido, 8 |
| 957 | 936 | ); |
| 958 | 937 | |
| 959 | - if (notaPedido.notaPedidoPuntoDescarga) { | |
| 938 | + if (notaPedido.notaPedidoPuntoDescarga.length) { | |
| 960 | 939 | var puntos = []; |
| 961 | 940 | notaPedido.notaPedidoPuntoDescarga.forEach(function(notaPedidoPuntoDescarga) { |
| 962 | 941 | puntos.push(notaPedidoPuntoDescarga); |