Commit 200e6c8195b7966640305bde95895a65f9797f13
Exists in
master
Merge branch 'master' into 'master'
Master(efernandez) See merge request modulos-npm/foca-crear-nota-pedido!46
Showing
3 changed files
 
Show diff stats
gulpfile.js
| ... | ... | @@ -46,7 +46,7 @@ gulp.task('uglify', ['templates'], function() { | 
| 46 | 46 | replace('"ngRoute","ui.bootstrap","focaModalVendedores","focaBusquedaProductos",'+ | 
| 47 | 47 | '"focaModalProveedor","focaBusquedaCliente","focaModalPrecioCondicion",'+ | 
| 48 | 48 | '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio",'+ | 
| 49 | - '"angular-ladda"', ''), | |
| 49 | + '"angular-ladda","focaModalMoneda","focaModalCotizacion"', ''), | |
| 50 | 50 | gulp.dest(paths.dist) | 
| 51 | 51 | ] | 
| 52 | 52 | ); | 
src/js/controller.js
| ... | ... | @@ -25,38 +25,32 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 
| 25 | 25 | maxDate: new Date(), | 
| 26 | 26 | minDate: new Date(2010, 0, 1) | 
| 27 | 27 | }; | 
| 28 | - $scope.crearObjetoNotaPedido = function() { | |
| 29 | - $scope.notaPedido = { | |
| 30 | - vendedor: {}, | |
| 31 | - cliente: {}, | |
| 32 | - proveedor: {}, | |
| 33 | - domicilio: {dom: ''}, | |
| 34 | - moneda: {}, | |
| 35 | - cotizacion: {} | |
| 36 | - }; | |
| 37 | - }; | |
| 38 | 28 | |
| 39 | - //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | |
| 40 | - $scope.obtenerMonedaPorDefecto = function() { | |
| 41 | - crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | |
| 42 | - monedaPorDefecto = { | |
| 43 | - id: res.data[0].ID, | |
| 44 | - detalle: res.data[0].DETALLE, | |
| 45 | - simbolo: res.data[0].SIMBOLO, | |
| 46 | - cotizaciones: res.data[0].cotizaciones | |
| 47 | - }; | |
| 48 | - addCabecera('Moneda:', monedaPorDefecto.detalle); | |
| 49 | - addCabecera('Fecha cotizacion:', | |
| 50 | - new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | |
| 51 | - addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); | |
| 52 | - $scope.notaPedido.moneda = monedaPorDefecto; | |
| 53 | - $scope.notaPedido.cotizacion.id = monedaPorDefecto.cotizaciones[0].ID; | |
| 54 | - }); | |
| 29 | + $scope.notaPedido = { | |
| 30 | + vendedor: {}, | |
| 31 | + cliente: {}, | |
| 32 | + proveedor: {}, | |
| 33 | + domicilio: {dom: ''}, | |
| 34 | + moneda: {}, | |
| 35 | + cotizacion: {} | |
| 55 | 36 | }; | 
| 56 | - | |
| 57 | 37 | var monedaPorDefecto; | 
| 58 | - $scope.crearObjetoNotaPedido(); | |
| 59 | - $scope.obtenerMonedaPorDefecto(); | |
| 38 | + //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | |
| 39 | + crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | |
| 40 | + monedaPorDefecto = { | |
| 41 | + id: res.data[0].ID, | |
| 42 | + detalle: res.data[0].DETALLE, | |
| 43 | + simbolo: res.data[0].SIMBOLO, | |
| 44 | + cotizaciones: res.data[0].cotizaciones | |
| 45 | + }; | |
| 46 | + addCabecera('Moneda:', monedaPorDefecto.detalle); | |
| 47 | + addCabecera('Fecha cotizacion:', | |
| 48 | + new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | |
| 49 | + addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); | |
| 50 | + $scope.notaPedido.moneda = monedaPorDefecto; | |
| 51 | + $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; | |
| 52 | + }); | |
| 53 | + | |
| 60 | 54 | $scope.cabecera = []; | 
| 61 | 55 | $scope.showCabecera = true; | 
| 62 | 56 | |
| ... | ... | @@ -127,7 +121,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 
| 127 | 121 | } else if(!$scope.notaPedido.moneda.id) { | 
| 128 | 122 | focaModalService.alert('Ingrese Moneda'); | 
| 129 | 123 | return; | 
| 130 | - } else if(!$scope.notaPedido.cotizacion.id) { | |
| 124 | + } else if(!$scope.notaPedido.cotizacion.ID) { | |
| 131 | 125 | focaModalService.alert('Ingrese Cotización'); | 
| 132 | 126 | return; | 
| 133 | 127 | } else if(!$scope.plazosPagos) { | 
| ... | ... | @@ -140,7 +134,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 
| 140 | 134 | focaModalService.aler('Ingrese Domicilio'); | 
| 141 | 135 | return; | 
| 142 | 136 | } else if($scope.articulosTabla.length === 0) { | 
| 143 | - focaModalService.alert('Debe cargar almenos un articulo'); | |
| 137 | + focaModalService.alert('Debe cargar al menos un articulo'); | |
| 144 | 138 | return; | 
| 145 | 139 | } | 
| 146 | 140 | var date = new Date(); | 
| ... | ... | @@ -152,10 +146,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 
| 152 | 146 | idCliente: $scope.notaPedido.cliente.id, | 
| 153 | 147 | idProveedor: $scope.notaPedido.proveedor.codigo, | 
| 154 | 148 | idDomicilio: $scope.notaPedido.domicilio.id, | 
| 155 | - idCotizacion: $scope.notaPedido.cotizacion.id, | |
| 156 | - flete: parseInt($scope.notaPedido.flete), | |
| 157 | - fob: parseInt($scope.notaPedido.fob), | |
| 158 | - bomba: parseInt($scope.notaPedido.bomba), | |
| 149 | + idCotizacion: $scope.notaPedido.cotizacion.ID, | |
| 150 | + flete: $scope.notaPedido.flete, | |
| 151 | + fob: $scope.notaPedido.fob, | |
| 152 | + bomba: $scope.notaPedido.bomba, | |
| 159 | 153 | kilometros: $scope.notaPedido.kilometros, | 
| 160 | 154 | total: $scope.getTotal() | 
| 161 | 155 | }; | 
| ... | ... | @@ -179,9 +173,21 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 
| 179 | 173 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); | 
| 180 | 174 | } | 
| 181 | 175 | focaModalService.alert('Nota pedido creada'); | 
| 182 | - $scope.obtenerMonedaPorDefecto(); | |
| 183 | - $scope.crearObjetoNotaPedido(); | |
| 184 | 176 | $scope.cabecera = []; | 
| 177 | + addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); | |
| 178 | + addCabecera( | |
| 179 | + 'Fecha cotizacion:', | |
| 180 | + $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') | |
| 181 | + ); | |
| 182 | + addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.cotizacion); | |
| 183 | + $scope.notaPedido.vendedor = {}; | |
| 184 | + $scope.notaPedido.cliente = {}; | |
| 185 | + $scope.notaPedido.proveedor = {}; | |
| 186 | + $scope.notaPedido.domicilio = {}; | |
| 187 | + $scope.notaPedido.flete = null; | |
| 188 | + $scope.notaPedido.fob = null; | |
| 189 | + $scope.notaPedido.bomba = null; | |
| 190 | + $scope.notaPedido.kilometros = null; | |
| 185 | 191 | $scope.articulosTabla = []; | 
| 186 | 192 | } | 
| 187 | 193 | ); | 
| ... | ... | @@ -198,7 +204,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 
| 198 | 204 | ariaLabelledBy: 'Busqueda de Productos', | 
| 199 | 205 | templateUrl: 'modal-busqueda-productos.html', | 
| 200 | 206 | controller: 'modalBusquedaProductosCtrl', | 
| 201 | - resolve: { idLista: function() { return $scope.idLista; } }, | |
| 207 | + resolve: { | |
| 208 | + idLista: function() { return $scope.idLista; }, | |
| 209 | + cotizacion: $scope.notaPedido.cotizacion.COTIZACION | |
| 210 | + }, | |
| 202 | 211 | size: 'lg' | 
| 203 | 212 | } | 
| 204 | 213 | ); | 
| ... | ... | @@ -393,8 +402,11 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 
| 393 | 402 | parametrosFlete: | 
| 394 | 403 | function() { | 
| 395 | 404 | return { | 
| 396 | - flete: $scope.notaPedido.flete, | |
| 397 | - bomba: $scope.notaPedido.bomba, | |
| 405 | + flete: $scope.notaPedido.flete ? '1' : | |
| 406 | + ($scope.notaPedido.fob ? 'FOB' : | |
| 407 | + ($scope.notaPedido.flete === undefined ? null : '0')), | |
| 408 | + bomba: $scope.notaPedido.bomba ? '1' : | |
| 409 | + ($scope.notaPedido.bomba === undefined ? null : '0'), | |
| 398 | 410 | kilometros: $scope.notaPedido.kilometros | 
| 399 | 411 | }; | 
| 400 | 412 | } | 
| ... | ... | @@ -408,13 +420,17 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 
| 408 | 420 | $scope.notaPedido.bomba = datos.bomba; | 
| 409 | 421 | $scope.notaPedido.kilometros = datos.kilometros; | 
| 410 | 422 | |
| 411 | - addCabecera('Flete:', datos.flete); | |
| 412 | - if(datos.flete === '1') { | |
| 413 | - addCabecera('Bomba:', datos.bomba); | |
| 414 | - addCabecera('Kilometros:', datos.kilometros); | |
| 423 | + addCabecera('Flete:', datos.flete ? 'Si' : | |
| 424 | + ($scope.notaPedido.fob ? 'FOB' : 'No')); | |
| 425 | + if(datos.flete) { | |
| 426 | + addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | |
| 427 | + addCabecera('Kilometros:', datos.kilometros ? 'Si' : 'No'); | |
| 415 | 428 | } else { | 
| 416 | 429 | removeCabecera('Bomba:'); | 
| 417 | 430 | removeCabecera('Kilometros:'); | 
| 431 | + $scope.notaPedido.fob = false; | |
| 432 | + $scope.notaPedido.bomba = false; | |
| 433 | + $scope.notaPedido.kilometros = null; | |
| 418 | 434 | } | 
| 419 | 435 | }, function() { | 
| 420 | 436 | |
| ... | ... | @@ -433,7 +449,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 
| 433 | 449 | ); | 
| 434 | 450 | modalInstance.result.then( | 
| 435 | 451 | function(moneda) { | 
| 436 | - | |
| 437 | 452 | $scope.abrirModalCotizacion(moneda); | 
| 438 | 453 | }, function() { | 
| 439 | 454 | |
| ... | ... | @@ -453,14 +468,23 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 
| 453 | 468 | ); | 
| 454 | 469 | modalInstance.result.then( | 
| 455 | 470 | function(cotizacion) { | 
| 471 | + var articulosTablaTemp = $scope.articulosTabla; | |
| 472 | + for(var i = 0; i < articulosTablaTemp.length; i++) { | |
| 473 | + articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | |
| 474 | + $scope.notaPedido.cotizacion.COTIZACION; | |
| 475 | + articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | |
| 476 | + cotizacion.COTIZACION; | |
| 477 | + } | |
| 478 | + $scope.articulosTabla = articulosTablaTemp; | |
| 456 | 479 | $scope.notaPedido.moneda = { | 
| 457 | 480 | id: moneda.ID, | 
| 458 | 481 | detalle: moneda.DETALLE, | 
| 459 | 482 | simbolo: moneda.SIMBOLO | 
| 460 | 483 | }; | 
| 461 | 484 | $scope.notaPedido.cotizacion = { | 
| 462 | - id: cotizacion.ID, | |
| 463 | - cotizacion: cotizacion.COTIZACION | |
| 485 | + ID: cotizacion.ID, | |
| 486 | + COTIZACION: cotizacion.COTIZACION, | |
| 487 | + FECHA: cotizacion.fecha | |
| 464 | 488 | }; | 
| 465 | 489 | addCabecera('Moneda:', moneda.DETALLE); | 
| 466 | 490 | addCabecera( | 
src/views/nota-pedido.html
| ... | ... | @@ -162,7 +162,7 @@ | 
| 162 | 162 | class="selectable" | 
| 163 | 163 | ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" | 
| 164 | 164 | ng-hide="articulo.editPrecio" | 
| 165 | - ng-bind="articulo.precio"> | |
| 165 | + ng-bind="articulo.precio | currency: '$'"> | |
| 166 | 166 | </i> | 
| 167 | 167 | </td> | 
| 168 | 168 | <td | 
| ... | ... | @@ -254,7 +254,7 @@ | 
| 254 | 254 | </tr> | 
| 255 | 255 | <tr class="d-flex"> | 
| 256 | 256 | <td colspan="4" class="no-border-top"> | 
| 257 | - <strong>Cantidad Items:</strong> | |
| 257 | + <strong>Items:</strong> | |
| 258 | 258 | <a ng-bind="articulosTabla.length"></a> | 
| 259 | 259 | </td> | 
| 260 | 260 | <td class="text-right ml-auto table-celda-total no-border-top"> |