Commit 19fcbdcd82127f98ff90e2224228b5b7c881a3f2

Authored by Eric Fernandez
1 parent c2932337d9
Exists in master

precommit...

Showing 2 changed files with 47 additions and 45 deletions   Show diff stats
src/js/controller.js
... ... @@ -19,7 +19,7 @@ angular.module('focaCrearNotaPedido')
19 19 $scope.precioCondiciones = res.data;
20 20 }
21 21 );
22   - if (notaPedidoTemp != undefined) {
  22 + if (notaPedidoTemp !== undefined) {
23 23 notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga);
24 24 $scope.notaPedido = notaPedidoTemp;
25 25 $scope.notaPedido.flete = ($scope.notaPedido.flete).toString();
... ... @@ -35,26 +35,26 @@ angular.module('focaCrearNotaPedido')
35 35 function(res) {
36 36 $scope.notaPedido.domicilio = res.data;
37 37 }
38   - )
  38 + );
39 39 } else {
40 40 $scope.notaPedido.fechaCarga = new Date();
41   - $scope.notaPedido.domicilio = [{ id: 0 }]
  41 + $scope.notaPedido.domicilio = [{ id: 0 }];
42 42 $scope.notaPedido.bomba = '1';
43 43 $scope.notaPedido.flete = '1';
44 44 idLista = undefined;
45 45 }
46 46 $scope.addNewDom = function() {
47 47 $scope.notaPedido.domicilio.push({ 'id': 0 });
48   - }
  48 + };
49 49 $scope.removeNewChoice = function(choice) {
50 50 if ($scope.notaPedido.domicilio.length > 1) {
51 51 $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex(
52 52 function(c) {
53   - return c.$$hashKey == choice.$$hashKey;
  53 + return c.$$hashKey === choice.$$hashKey;
54 54 }
55   - ), 1)
  55 + ), 1);
56 56 }
57   - }
  57 + };
58 58 $scope.crearNotaPedido = function() {
59 59 var notaPedido = {
60 60 id: 0,
... ... @@ -71,29 +71,30 @@ angular.module('focaCrearNotaPedido')
71 71 costoFinanciacion: $scope.notaPedido.costoFinanciacion,
72 72 flete: $scope.notaPedido.flete,
73 73 costoUnitarioKmFlete: $scope.notaPedido.costoUnitarioKmFlete,
74   - total : $scope.articulosTabla[0].subTotal
75   - }
  74 + total: $scope.articulosTabla[0].subTotal
  75 + };
76 76 crearNotaPedidoService.crearNotaPedido(notaPedido).then(
77   - function(res) {
  77 + function() {
78 78 alert('Nota pedido creada');
79 79 $location.path('/venta-nota-pedido');
80 80 }
81   - )
  81 + );
82 82 var articulosNotaPedido = $scope.articulosTabla;
83 83 for(var i = 0; i< articulosNotaPedido.length;i++) {
84   - crearNotaPedidoService.crearArticulosParaNotaPedido(articulosNotaPedido[i]).then(
85   - function(res) {
86   - return;
87   - }
88   - )
  84 + crearNotaPedidoService
  85 + .crearArticulosParaNotaPedido(articulosNotaPedido[i]).then(
  86 + function() {
  87 + return;
  88 + }
  89 + );
89 90 }
90 91  
91   - }
  92 + };
92 93 $scope.siguienteTab = function() {
93 94 $scope.active = 1;
94   - }
  95 + };
95 96 $scope.seleccionarArticulo = function() {
96   - if (idLista == undefined) {
  97 + if (idLista === undefined) {
97 98 alert('primero seleccione una lista de precio y condicion');
98 99 return;
99 100 }
... ... @@ -102,10 +103,10 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
102 103 ariaLabelledBy: 'Busqueda de Productos',
103 104 templateUrl: 'modal-busqueda-productos.html',
104 105 controller: 'modalBusquedaProductosCtrl',
105   - resolve: { idLista: function() { return idLista } },
  106 + resolve: { idLista: function() { return idLista; } },
106 107 size: 'lg'
107 108 }
108   - )
  109 + );
109 110 modalInstance.result.then(
110 111 function(producto) {
111 112 var newArt =
... ... @@ -117,13 +118,13 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
117 118 precio: producto.precio,
118 119 costoUnitario: producto.costo,
119 120 cantidad: 1
120   - }
  121 + };
121 122 $scope.articulosTabla.unshift(newArt);
122 123 }, function() {
123 124 // funcion ejecutada cuando se cancela el modal
124 125 }
125 126 );
126   - }
  127 + };
127 128 $scope.seleccionarVendedor = function() {
128 129 var modalInstance = $uibModal.open(
129 130 {
... ... @@ -132,7 +133,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
132 133 controller: 'modalVendedoresCtrl',
133 134 size: 'lg'
134 135 }
135   - )
  136 + );
136 137 modalInstance.result.then(
137 138 function(vendedor) {
138 139 $scope.notaPedido.vendedor = vendedor.NomVen;
... ... @@ -140,7 +141,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
140 141  
141 142 }
142 143 );
143   - }
  144 + };
144 145 $scope.seleccionarPetrolera = function() {
145 146 var modalInstance = $uibModal.open(
146 147 {
... ... @@ -149,7 +150,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
149 150 controller: 'modalPetrolerasCtrl',
150 151 size: 'lg'
151 152 }
152   - )
  153 + );
153 154 modalInstance.result.then(
154 155 function(petrolera) {
155 156 $scope.notaPedido.petrolera = petrolera.NOM;
... ... @@ -157,7 +158,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
157 158  
158 159 }
159 160 );
160   - }
  161 + };
161 162 $scope.seleccionarCliente = function() {
162 163 var modalInstance = $uibModal.open(
163 164 {
... ... @@ -166,7 +167,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
166 167 controller: 'focaBusquedaClienteModalController',
167 168 size: 'lg'
168 169 }
169   - )
  170 + );
170 171 modalInstance.result.then(
171 172 function(cliente) {
172 173 $scope.notaPedido.cliente = cliente.nom;
... ... @@ -174,14 +175,14 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
174 175  
175 176 }
176 177 );
177   - }
  178 + };
178 179 $scope.obtenerDomicilios = function(id) {
179 180 crearNotaPedidoService.getDomicilios(id).then(
180 181 function(res) {
181 182 $scope.notaPedido.domicilio = res.data;
182 183 }
183   - )
184   - }
  184 + );
  185 + };
185 186 $scope.getSubTotal = function(item) {
186 187 var subTotal = 0;
187 188 var array = $scope.articulosTabla.filter(
... ... @@ -190,14 +191,14 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
190 191 }
191 192 );
192 193 for (var i = 0; i < array.length; i++) {
193   - subTotal += array[i].precio * array[i].cantidad
  194 + subTotal += array[i].precio * array[i].cantidad;
194 195 }
195 196 return subTotal.toFixed(2);
196   - }
  197 + };
197 198 $scope.cargarArticulos = function() {
198 199 idLista = $scope.notaPedido.precioCondicion;
199 200 $scope.articulosTabla = [];
200   - }
  201 + };
201 202 }
202 203 ]
203 204 )
... ... @@ -212,10 +213,10 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
212 213 $scope.editar = function(notaPedido) {
213 214 crearNotaPedidoService.setNotaPedido(notaPedido);
214 215 $location.path('/venta-nota-pedido/abm/');
215   - }
  216 + };
216 217 $scope.crearPedido = function() {
217 218 crearNotaPedidoService.clearNotaPedido();
218 219 $location.path('/venta-nota-pedido/abm/');
219   - }
  220 + };
220 221 }
221   - ])
  222 + ]);
1 1 angular.module('focaCrearNotaPedido')
2 2 .service('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) {
3 3 var route = API_ENDPOINT.URL;
4   - var notaPedido;
  4 + var notaPedido = undefined;
5 5 return {
6 6 crearNotaPedido: function(notaPedido) {
7 7 return $http.post(route + '/nota-pedido', {notaPedido: notaPedido});
... ... @@ -22,7 +22,8 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
22 22 return $http.get(route+'/articulos/nota-pedido/'+id);
23 23 },
24 24 crearArticulosParaNotaPedido: function(articuloNotaPedido) {
25   - return $http.post(route + '/articulos/nota-pedido', {articuloNotaPedido: articuloNotaPedido});
  25 + return $http.post(route + '/articulos/nota-pedido',
  26 + {articuloNotaPedido: articuloNotaPedido});
26 27 },
27 28 getDomiciliosByIdNotaPedido: function(id) {
28 29 return $http.get(route +'/nota-pedido/'+id+'/domicilios');
... ... @@ -43,17 +44,17 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
43 44 id: 3,
44 45 dom: 'SALTA 796'
45 46 }
46   - ]
  47 + ];
47 48 return domicilio;
48 49 },
49 50 getPrecioCondicion: function() {
50   - return $http.get(route + '/precio-condicion')
  51 + return $http.get(route + '/precio-condicion');
51 52 },
52 53 getPrecioCondicionById: function(id) {
53   - return $http.get(route + '/precio-condicion/' + id)
  54 + return $http.get(route + '/precio-condicion/' + id);
54 55 },
55 56 getPlazoPagoByPrecioCondicion: function(id) {
56   - return $http.get(route + '/plazo-pago/precio-condicion/'+ id)
  57 + return $http.get(route + '/plazo-pago/precio-condicion/'+ id);
57 58 }
58   - }
59   - }])
  59 + };
  60 + }]);