Commit a3d93798a6087b8f4e11b53a1070d57e07af405b
Exists in
master
Merge branch 'master' into 'master'
Master See merge request modulos-npm/foca-crear-remito!11
Showing
1 changed file
Show diff stats
src/js/controller.js
... | ... | @@ -160,7 +160,11 @@ angular.module('focaCrearRemito') .controller('remitoController', |
160 | 160 | cabeceras.push(cabeceraBomba); |
161 | 161 | } |
162 | 162 | $scope.articulosTabla = notaPedido.articulosNotaPedido; |
163 | - $scope.idLista = notaPedido.precioCondicion[0].idListaPrecio; | |
163 | + if(notaPedido.precioCondicion.length > 0) { | |
164 | + $scope.idLista = notaPedido.precioCondicion[0].idListaPrecio; | |
165 | + } else { | |
166 | + $scope.idLista = -1; | |
167 | + } | |
164 | 168 | $scope.remito = notaPedido; |
165 | 169 | $scope.remito.vendedor = notaPedido.vendedor[0]; |
166 | 170 | $scope.remito.cliente = notaPedido.cliente[0]; |
... | ... | @@ -185,8 +189,87 @@ angular.module('focaCrearRemito') .controller('remitoController', |
185 | 189 | } |
186 | 190 | ); |
187 | 191 | modalInstance.result.then( |
188 | - function() { | |
189 | - // TODO: Implementar carga remito | |
192 | + function(remito) { | |
193 | + //añado cabeceras | |
194 | + removeCabecera('Moneda:'); | |
195 | + removeCabecera('Fecha cotizacion:'); | |
196 | + removeCabecera('Cotizacion:'); | |
197 | + var cabeceras = [ | |
198 | + { | |
199 | + label: 'Moneda', | |
200 | + valor: remito.cotizacion[0].moneda[0].DETALLE | |
201 | + }, | |
202 | + { | |
203 | + label: 'Fecha cotizacion', | |
204 | + valor: $filter('date')(remito.cotizacion[0].FECHA, | |
205 | + 'dd/MM/yyyy') | |
206 | + }, | |
207 | + { | |
208 | + label: 'Cotizacion', | |
209 | + valor: remito.cotizacion[0].VENDEDOR | |
210 | + }, | |
211 | + { | |
212 | + label: 'Cliente:', | |
213 | + valor: remito.cliente[0].NOM | |
214 | + }, | |
215 | + { | |
216 | + label: 'Vendedor:', | |
217 | + valor: remito.vendedor[0].NomVen | |
218 | + }, | |
219 | + { | |
220 | + label: 'Proveedor:', | |
221 | + valor: remito.proveedor[0].NOM | |
222 | + }, | |
223 | + { | |
224 | + label: 'Flete:', | |
225 | + valor: remito.flete === 1 ? 'Si' : 'No' | |
226 | + }, | |
227 | + { | |
228 | + label: 'FOB:', | |
229 | + valor: remito.fob === 1 ? 'Si' : 'No' | |
230 | + }, | |
231 | + { | |
232 | + label: 'Precio condicion:', | |
233 | + valor: valorPrecioCondicion() | |
234 | + } | |
235 | + ]; | |
236 | + //TO DO CUANDO MOSTRAR PLAZOS | |
237 | + function valorPrecioCondicion() { | |
238 | + if(remito.idPrecioCondicion > 0) { | |
239 | + return remito.precioCondicion[0].nombre; | |
240 | + } else { | |
241 | + return 'Ingreso Manual'; | |
242 | + } | |
243 | + | |
244 | + } | |
245 | + | |
246 | + if(remito.flete === 1) { | |
247 | + var cabeceraBomba = { | |
248 | + label: 'Bomba', | |
249 | + valor: remito.bomba === 1 ? 'Si' : 'No' | |
250 | + }; | |
251 | + if(remito.kilometros) { | |
252 | + var cabeceraKilometros = { | |
253 | + label: 'Kilometros', | |
254 | + valor: remito.kilometros | |
255 | + }; | |
256 | + cabeceras.push(cabeceraKilometros); | |
257 | + } | |
258 | + cabeceras.push(cabeceraBomba); | |
259 | + } | |
260 | + $scope.articulosTabla = remito.articulosRemito; | |
261 | + if(remito.precioCondicion.length > 0) { | |
262 | + $scope.idLista = remito.precioCondicion[0].idListaPrecio; | |
263 | + } else { | |
264 | + $scope.idLista = -1; | |
265 | + } | |
266 | + $scope.remito = remito; | |
267 | + $scope.remito.vendedor = remito.vendedor[0]; | |
268 | + $scope.remito.cliente = remito.cliente[0]; | |
269 | + $scope.remito.proveedor = remito.proveedor[0]; | |
270 | + $scope.remito.moneda = remito.cotizacion[0].moneda[0]; | |
271 | + $scope.remito.cotizacion = remito.cotizacion[0]; | |
272 | + addArrayCabecera(cabeceras); | |
190 | 273 | }, function() { |
191 | 274 | // funcion ejecutada cuando se cancela el modal |
192 | 275 | } |
... | ... | @@ -293,6 +376,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
293 | 376 | idProveedor: $scope.remito.idProveedor, |
294 | 377 | idDomicilio: 0,//TODO |
295 | 378 | idCotizacion: $scope.remito.idCotizacion, |
379 | + idPrecioCondicion: $scope.remito.idPrecioCondicion, | |
296 | 380 | flete: $scope.remito.flete, |
297 | 381 | fob: $scope.remito.fob, |
298 | 382 | bomba: $scope.remito.bomba, |
... | ... | @@ -498,6 +582,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
498 | 582 | var cabecera = ''; |
499 | 583 | var plazosConcat = ''; |
500 | 584 | if(!Array.isArray(precioCondicion)) { |
585 | + $scope.remito.idPrecioCondicion = precioCondicion.id; | |
501 | 586 | $scope.plazosPagos = precioCondicion.plazoPago; |
502 | 587 | $scope.idLista = precioCondicion.idListaPrecio; |
503 | 588 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
... | ... | @@ -505,6 +590,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
505 | 590 | } |
506 | 591 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
507 | 592 | } else { //Cuando se ingresan los plazos manualmente |
593 | + $scope.remito.idPrecioCondicion = 0; | |
508 | 594 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
509 | 595 | $scope.plazosPagos = precioCondicion; |
510 | 596 | for(var j = 0; j < precioCondicion.length; j++) { |