Commit 3b710e85b10c1988f1f58528ec5a869cf282ca15
1 parent
5e1a7f48ec
Exists in
master
and in
2 other branches
boton pausar funcionando
Showing
3 changed files
with
174 additions
and
145 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -2,9 +2,10 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 2 | 2 | [ |
| 3 | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', |
| 4 | 4 | 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', |
| 5 | + '$localStorage', | |
| 5 | 6 | function( |
| 6 | 7 | $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, |
| 7 | - remitoBusinessService, $rootScope, focaBotoneraLateralService) | |
| 8 | + remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) | |
| 8 | 9 | { |
| 9 | 10 | config(); |
| 10 | 11 | |
| ... | ... | @@ -27,11 +28,10 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 27 | 28 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { |
| 28 | 29 | monedaPorDefecto = res.data[0]; |
| 29 | 30 | |
| 30 | - $scope.remito.moneda = monedaPorDefecto; | |
| 31 | - $scope.inicial.remito.moneda = $scope.remito.moneda; | |
| 32 | - | |
| 33 | - $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0]; | |
| 34 | - $scope.inicial.remito.cotizacion = $scope.remito.cotizacion; | |
| 31 | + $scope.remito.cotizacion = Object.assign( | |
| 32 | + {moneda: monedaPorDefecto}, monedaPorDefecto.cotizaciones[0] | |
| 33 | + ); | |
| 34 | + $scope.inicial.cotizacion = $scope.remito.cotizacion; | |
| 35 | 35 | }); |
| 36 | 36 | |
| 37 | 37 | //SETEO BOTONERA LATERAL |
| ... | ... | @@ -43,6 +43,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 43 | 43 | }); |
| 44 | 44 | |
| 45 | 45 | init(); |
| 46 | + $timeout(function() {getLSRemito();}); | |
| 46 | 47 | } |
| 47 | 48 | |
| 48 | 49 | function init() { |
| ... | ... | @@ -56,14 +57,15 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 56 | 57 | proveedor: {}, |
| 57 | 58 | domicilio: {dom: ''}, |
| 58 | 59 | moneda: {}, |
| 59 | - cotizacion: {} | |
| 60 | + cotizacion: {}, | |
| 61 | + articulosRemito: [] | |
| 60 | 62 | }; |
| 61 | 63 | |
| 62 | 64 | $scope.notaPedido = { |
| 63 | 65 | id: 0 |
| 64 | 66 | }; |
| 65 | 67 | |
| 66 | - $scope.articulosTabla = []; | |
| 68 | + $scope.remito.articulosRemito = []; | |
| 67 | 69 | $scope.idLista = undefined; |
| 68 | 70 | |
| 69 | 71 | crearRemitoService.getNumeroRemito().then( |
| ... | ... | @@ -77,14 +79,16 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 77 | 79 | } |
| 78 | 80 | ); |
| 79 | 81 | |
| 80 | - $scope.inicial = { | |
| 81 | - remito: angular.copy($scope.remito), | |
| 82 | - notaPedido: angular.copy($scope.notaPedido), | |
| 83 | - articulosTabla: angular.copy($scope.articulosTabla), | |
| 84 | - idLista: angular.copy($scope.idLista) | |
| 85 | - }; | |
| 82 | + $scope.inicial = angular.copy($scope.remito); | |
| 86 | 83 | } |
| 87 | 84 | |
| 85 | + $scope.$watch('remito', function(newValue, oldValue) { | |
| 86 | + focaBotoneraLateralService.setPausarData({ | |
| 87 | + label: 'remito', | |
| 88 | + val: newValue | |
| 89 | + }); | |
| 90 | + }, true); | |
| 91 | + | |
| 88 | 92 | $scope.seleccionarNotaPedido = function() { |
| 89 | 93 | if(varlidarRemitoFacturado()) { |
| 90 | 94 | var modalInstance = $uibModal.open( |
| ... | ... | @@ -177,12 +181,17 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 177 | 181 | cabeceras.push(cabeceraBomba); |
| 178 | 182 | } |
| 179 | 183 | |
| 184 | + delete notaPedido.id; | |
| 185 | + $scope.remito = notaPedido; | |
| 186 | + $scope.remito.id = 0; | |
| 187 | + $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; | |
| 188 | + | |
| 180 | 189 | for(var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) { |
| 181 | 190 | notaPedido.articulosNotaPedido[i].id = 0; |
| 182 | 191 | } |
| 183 | 192 | |
| 184 | - $scope.articulosTabla = notaPedido.articulosNotaPedido; | |
| 185 | - remitoBusinessService.calcularArticulos($scope.articulosTabla, | |
| 193 | + $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; | |
| 194 | + remitoBusinessService.calcularArticulos($scope.remito.articulosRemito, | |
| 186 | 195 | notaPedido.cotizacion.VENDEDOR); |
| 187 | 196 | |
| 188 | 197 | if(notaPedido.idPrecioCondicion > 0) { |
| ... | ... | @@ -191,11 +200,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 191 | 200 | $scope.idLista = -1; |
| 192 | 201 | } |
| 193 | 202 | |
| 194 | - delete notaPedido.id; | |
| 195 | - $scope.remito = notaPedido; | |
| 196 | - $scope.remito.id = 0; | |
| 197 | - $scope.remito.moneda = notaPedido.cotizacion.moneda; | |
| 198 | - $scope.plazosPagos = notaPedido.notaPedidoPlazo; | |
| 203 | + | |
| 199 | 204 | enableObservaciones(notaPedido.observaciones ? true : false); |
| 200 | 205 | addArrayCabecera(cabeceras); |
| 201 | 206 | |
| ... | ... | @@ -217,93 +222,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 217 | 222 | } |
| 218 | 223 | ); |
| 219 | 224 | modalInstance.result.then( |
| 220 | - function(remito) { | |
| 221 | - //aรฑado cabeceras | |
| 222 | - $scope.$broadcast('removeCabecera', 'Moneda:'); | |
| 223 | - $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | |
| 224 | - $scope.$broadcast('removeCabecera', 'Cotizacion:'); | |
| 225 | - var cabeceras = [ | |
| 226 | - { | |
| 227 | - label: 'Moneda:', | |
| 228 | - valor: remito.cotizacion.moneda.DETALLE | |
| 229 | - }, | |
| 230 | - { | |
| 231 | - label: 'Fecha cotizacion:', | |
| 232 | - valor: $filter('date')(remito.cotizacion.FECHA, | |
| 233 | - 'dd/MM/yyyy') | |
| 234 | - }, | |
| 235 | - { | |
| 236 | - label: 'Cotizacion:', | |
| 237 | - valor: $filter('number')(remito.cotizacion.VENDEDOR, | |
| 238 | - '2') | |
| 239 | - }, | |
| 240 | - { | |
| 241 | - label: 'Cliente:', | |
| 242 | - valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + | |
| 243 | - remito.cliente.NOM | |
| 244 | - }, | |
| 245 | - { | |
| 246 | - label: 'Domicilio:', | |
| 247 | - valor: remito.domicilioStamp | |
| 248 | - }, | |
| 249 | - { | |
| 250 | - label: 'Vendedor:', | |
| 251 | - valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + | |
| 252 | - ' - ' + remito.vendedor.NOM | |
| 253 | - }, | |
| 254 | - { | |
| 255 | - label: 'Proveedor:', | |
| 256 | - valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + | |
| 257 | - ' - ' + remito.proveedor.NOM | |
| 258 | - }, | |
| 259 | - { | |
| 260 | - label: 'Flete:', | |
| 261 | - valor: remito.fob === 1 ? 'FOB' : ( | |
| 262 | - remito.flete === 1 ? 'Si' : 'No') | |
| 263 | - }, | |
| 264 | - { | |
| 265 | - label: 'Precio condicion:', | |
| 266 | - valor: valorPrecioCondicion() + ' ' + | |
| 267 | - remitoBusinessService.plazoToString(remito.remitoPlazo) | |
| 268 | - } | |
| 269 | - ]; | |
| 270 | - function valorPrecioCondicion() { | |
| 271 | - if(remito.idPrecioCondicion > 0) { | |
| 272 | - return remito.precioCondicion.nombre; | |
| 273 | - }else { | |
| 274 | - return 'Ingreso Manual'; | |
| 275 | - } | |
| 276 | - } | |
| 277 | - | |
| 278 | - if(remito.flete === 1) { | |
| 279 | - var cabeceraBomba = { | |
| 280 | - label: 'Bomba', | |
| 281 | - valor: remito.bomba === 1 ? 'Si' : 'No' | |
| 282 | - }; | |
| 283 | - if(remito.kilometros) { | |
| 284 | - var cabeceraKilometros = { | |
| 285 | - label: 'Kilometros', | |
| 286 | - valor: remito.kilometros | |
| 287 | - }; | |
| 288 | - cabeceras.push(cabeceraKilometros); | |
| 289 | - } | |
| 290 | - cabeceras.push(cabeceraBomba); | |
| 291 | - } | |
| 292 | - $scope.articulosTabla = remito.articulosRemito; | |
| 293 | - remitoBusinessService.calcularArticulos($scope.articulosTabla, | |
| 294 | - remito.cotizacion.VENDEDOR); | |
| 295 | - if(remito.idPrecioCondicion > 0) { | |
| 296 | - $scope.idLista = remito.precioCondicion.idListaPrecio; | |
| 297 | - }else { | |
| 298 | - $scope.idLista = -1; | |
| 299 | - } | |
| 300 | - $scope.puntoVenta = rellenar(remito.sucursal, 4); | |
| 301 | - $scope.comprobante = rellenar(remito.numeroRemito, 8); | |
| 302 | - $scope.remito = remito; | |
| 303 | - $scope.remito.moneda = remito.cotizacion.moneda; | |
| 304 | - $scope.plazosPagos = remito.remitoPlazo; | |
| 305 | - addArrayCabecera(cabeceras); | |
| 306 | - }, function() { | |
| 225 | + setearRemito, function() { | |
| 307 | 226 | // funcion ejecutada cuando se cancela el modal |
| 308 | 227 | } |
| 309 | 228 | ); |
| ... | ... | @@ -320,7 +239,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 320 | 239 | }else if(!$scope.remito.proveedor) { |
| 321 | 240 | focaModalService.alert('Ingrese Proveedor'); |
| 322 | 241 | return; |
| 323 | - }else if(!$scope.remito.moneda.id && !$scope.remito.moneda.ID) { | |
| 242 | + }else if(!$scope.remito.cotizacion.moneda.id && !$scope.remito.cotizacion.moneda.ID) { | |
| 324 | 243 | focaModalService.alert('Ingrese Moneda'); |
| 325 | 244 | return; |
| 326 | 245 | }else if(!$scope.remito.cotizacion.ID) { |
| ... | ... | @@ -331,7 +250,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 331 | 250 | { |
| 332 | 251 | focaModalService.alert('Ingrese Flete'); |
| 333 | 252 | return; |
| 334 | - }else if($scope.articulosTabla.length === 0) { | |
| 253 | + }else if($scope.remito.articulosRemito.length === 0) { | |
| 335 | 254 | focaModalService.alert('Debe cargar al menos un articulo'); |
| 336 | 255 | return; |
| 337 | 256 | } |
| ... | ... | @@ -386,7 +305,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 386 | 305 | |
| 387 | 306 | crearRemitoService.crearRemito(save).then( |
| 388 | 307 | function(data) { |
| 389 | - remitoBusinessService.addArticulos($scope.articulosTabla, | |
| 308 | + remitoBusinessService.addArticulos($scope.remito.articulosRemito, | |
| 390 | 309 | data.data.id, $scope.remito.cotizacion.COTIZACION); |
| 391 | 310 | |
| 392 | 311 | focaBotoneraLateralService.endGuardar(true); |
| ... | ... | @@ -394,8 +313,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 394 | 313 | |
| 395 | 314 | //TODO: updatear plazos |
| 396 | 315 | if($scope.remito.id === 0) { |
| 397 | - $scope.remito.id = data.data.id; | |
| 398 | - var plazos = $scope.plazosPagos; | |
| 316 | + var plazos = $scope.remito.remitoPlazo; | |
| 399 | 317 | |
| 400 | 318 | for(var j = 0; j < plazos.length; j++) { |
| 401 | 319 | var json = { |
| ... | ... | @@ -442,7 +360,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 442 | 360 | parametroProducto: { |
| 443 | 361 | idLista: $scope.idLista, |
| 444 | 362 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
| 445 | - simbolo: $scope.remito.moneda.simbolo | |
| 363 | + simbolo: $scope.remito.cotizacion.moneda.simbolo | |
| 446 | 364 | } |
| 447 | 365 | }, |
| 448 | 366 | size: 'lg' |
| ... | ... | @@ -457,7 +375,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 457 | 375 | sector: producto.sector, |
| 458 | 376 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 459 | 377 | descripcion: producto.descripcion, |
| 460 | - item: $scope.articulosTabla.length + 1, | |
| 378 | + item: $scope.remito.articulosRemito.length + 1, | |
| 461 | 379 | nombre: producto.descripcion, |
| 462 | 380 | precio: parseFloat(producto.precio.toFixed(4)), |
| 463 | 381 | costoUnitario: producto.costo, |
| ... | ... | @@ -496,7 +414,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 496 | 414 | filters: { |
| 497 | 415 | idDomicilio: $scope.remito.domicilio.id, |
| 498 | 416 | idCliente: $scope.remito.cliente.COD, |
| 499 | - articulos: $scope.articulosTabla, | |
| 417 | + articulos: $scope.remito.articulosRemito, | |
| 500 | 418 | puntosDescarga: $scope.remito.domicilio.puntosDescarga |
| 501 | 419 | } |
| 502 | 420 | } |
| ... | ... | @@ -553,7 +471,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 553 | 471 | vendedor.NOM |
| 554 | 472 | }); |
| 555 | 473 | $scope.remito.idVendedor = vendedor.id; |
| 556 | - $scope.vendedor = vendedor; | |
| 474 | + $scope.remito.vendedor = vendedor; | |
| 557 | 475 | }, function() { |
| 558 | 476 | |
| 559 | 477 | } |
| ... | ... | @@ -589,7 +507,9 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 589 | 507 | }; |
| 590 | 508 | focaModalService.modal(parametrosModal).then( |
| 591 | 509 | function(proveedor) { |
| 510 | + $scope.remito.proveedor = proveedor; | |
| 592 | 511 | $scope.remito.idProveedor = proveedor.COD; |
| 512 | + | |
| 593 | 513 | $scope.$broadcast('addCabecera',{ |
| 594 | 514 | label: 'Proveedor:', |
| 595 | 515 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
| ... | ... | @@ -603,7 +523,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 603 | 523 | }; |
| 604 | 524 | |
| 605 | 525 | $scope.seleccionarCliente = function() { |
| 606 | - if(!$scope.vendedor) { | |
| 526 | + if(!$scope.remito.vendedor) { | |
| 607 | 527 | focaModalService.alert('Primero seleccione un vendedor'); |
| 608 | 528 | return; |
| 609 | 529 | } |
| ... | ... | @@ -615,7 +535,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 615 | 535 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 616 | 536 | controller: 'focaBusquedaClienteModalController', |
| 617 | 537 | resolve: { |
| 618 | - vendedor: function() { return $scope.vendedor; } | |
| 538 | + vendedor: function() { return $scope.remito.vendedor; } | |
| 619 | 539 | }, |
| 620 | 540 | size: 'lg' |
| 621 | 541 | } |
| ... | ... | @@ -699,7 +619,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 699 | 619 | |
| 700 | 620 | $scope.getTotal = function() { |
| 701 | 621 | var total = 0; |
| 702 | - var arrayTempArticulos = $scope.articulosTabla; | |
| 622 | + var arrayTempArticulos = $scope.remito.articulosRemito; | |
| 703 | 623 | for(var i = 0; i < arrayTempArticulos.length; i++) { |
| 704 | 624 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 705 | 625 | } |
| ... | ... | @@ -728,7 +648,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 728 | 648 | var plazosConcat = ''; |
| 729 | 649 | if(!Array.isArray(precioCondicion)) { |
| 730 | 650 | $scope.remito.idPrecioCondicion = precioCondicion.id; |
| 731 | - $scope.plazosPagos = precioCondicion.plazoPago; | |
| 651 | + $scope.remito.remitoPlazo = precioCondicion.plazoPago; | |
| 732 | 652 | $scope.idLista = precioCondicion.idListaPrecio; |
| 733 | 653 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
| 734 | 654 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
| ... | ... | @@ -739,17 +659,19 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 739 | 659 | $scope.remito.idPrecioCondicion = 0; |
| 740 | 660 | //-1, el modal productos busca todos los productos |
| 741 | 661 | $scope.idLista = -1; |
| 742 | - $scope.plazosPagos = precioCondicion; | |
| 662 | + $scope.remito.remitoPlazo = precioCondicion; | |
| 743 | 663 | for(var j = 0; j < precioCondicion.length; j++) { |
| 744 | 664 | plazosConcat += precioCondicion[j].dias + ' '; |
| 745 | 665 | } |
| 746 | 666 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
| 747 | 667 | } |
| 748 | - $scope.articulosTabla = []; | |
| 668 | + $scope.remito.articulosRemito = []; | |
| 749 | 669 | $scope.$broadcast('addCabecera',{ |
| 750 | 670 | label: 'Precios y condiciones:', |
| 751 | 671 | valor: cabecera |
| 752 | 672 | }); |
| 673 | + | |
| 674 | + $scope.remito.precioCondicion = precioCondicion; | |
| 753 | 675 | }, function() { |
| 754 | 676 | |
| 755 | 677 | } |
| ... | ... | @@ -861,15 +783,15 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 861 | 783 | ); |
| 862 | 784 | modalInstance.result.then( |
| 863 | 785 | function(cotizacion) { |
| 864 | - var articulosTablaTemp = $scope.articulosTabla; | |
| 786 | + var articulosTablaTemp = $scope.remito.articulosRemito; | |
| 865 | 787 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
| 866 | 788 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
| 867 | 789 | $scope.remito.cotizacion.COTIZACION; |
| 868 | 790 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
| 869 | 791 | cotizacion.COTIZACION; |
| 870 | 792 | } |
| 871 | - $scope.articulosTabla = articulosTablaTemp; | |
| 872 | - $scope.remito.moneda = moneda; | |
| 793 | + $scope.remito.articulosRemito = articulosTablaTemp; | |
| 794 | + $scope.remito.cotizacion.moneda = moneda; | |
| 873 | 795 | $scope.remito.cotizacion = cotizacion; |
| 874 | 796 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { |
| 875 | 797 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
| ... | ... | @@ -904,13 +826,13 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 904 | 826 | return; |
| 905 | 827 | } |
| 906 | 828 | delete $scope.articuloACargar.sectorCodigo; |
| 907 | - $scope.articulosTabla.push($scope.articuloACargar); | |
| 829 | + $scope.remito.articulosRemito.push($scope.articuloACargar); | |
| 908 | 830 | $scope.cargando = true; |
| 909 | 831 | } |
| 910 | 832 | }; |
| 911 | 833 | |
| 912 | 834 | $scope.quitarArticulo = function(key) { |
| 913 | - $scope.articulosTabla.splice(key, 1); | |
| 835 | + $scope.remito.articulosRemito.splice(key, 1); | |
| 914 | 836 | }; |
| 915 | 837 | |
| 916 | 838 | $scope.editarArticulo = function(key, articulo) { |
| ... | ... | @@ -948,7 +870,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 948 | 870 | $scope.remito.flete = '0'; |
| 949 | 871 | $scope.remito.bomba = '0'; |
| 950 | 872 | $scope.remito.precioCondicion = ''; |
| 951 | - $scope.articulosTabla = []; | |
| 873 | + $scope.remito.articulosRemito = []; | |
| 952 | 874 | $scope.remito.vendedor.nombre = ''; |
| 953 | 875 | $scope.remito.cliente = {nombre: ''}; |
| 954 | 876 | $scope.remito.domicilio = {dom: ''}; |
| ... | ... | @@ -1006,11 +928,9 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 1006 | 928 | function salir() { |
| 1007 | 929 | var confirmacion = false; |
| 1008 | 930 | |
| 1009 | - angular.forEach($scope.inicial, function(valor, key) { | |
| 1010 | - if (!angular.equals($scope[key], $scope.inicial[key])) { | |
| 1011 | - confirmacion = true; | |
| 1012 | - } | |
| 1013 | - }); | |
| 931 | + if (!angular.equals($scope.remito, $scope.inicial)) { | |
| 932 | + confirmacion = true; | |
| 933 | + } | |
| 1014 | 934 | |
| 1015 | 935 | if (confirmacion) { |
| 1016 | 936 | focaModalService.confirm( |
| ... | ... | @@ -1031,6 +951,114 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 1031 | 951 | }); |
| 1032 | 952 | |
| 1033 | 953 | boton[0].disable = !val; |
| 1034 | - } | |
| 954 | + } | |
| 955 | + | |
| 956 | + function setearRemito(remito) { | |
| 957 | + //aรฑado cabeceras | |
| 958 | + $scope.$broadcast('removeCabecera', 'Moneda:'); | |
| 959 | + $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | |
| 960 | + $scope.$broadcast('removeCabecera', 'Cotizacion:'); | |
| 961 | + | |
| 962 | + var cabeceras = []; | |
| 963 | + | |
| 964 | + if (remito.cotizacion) { | |
| 965 | + cabeceras.push({ | |
| 966 | + label: 'Moneda:', | |
| 967 | + valor: remito.cotizacion.moneda.DETALLE | |
| 968 | + }); | |
| 969 | + cabeceras.push({ | |
| 970 | + label: 'Fecha cotizacion:', | |
| 971 | + valor: $filter('date')(remito.cotizacion.FECHA, | |
| 972 | + 'dd/MM/yyyy') | |
| 973 | + }); | |
| 974 | + cabeceras.push({ | |
| 975 | + label: 'Cotizacion:', | |
| 976 | + valor: $filter('number')(remito.cotizacion.VENDEDOR, | |
| 977 | + '2') | |
| 978 | + }); | |
| 979 | + } | |
| 980 | + if (remito.cliente.COD){ | |
| 981 | + cabeceras.push({ | |
| 982 | + label: 'Cliente:', | |
| 983 | + valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + | |
| 984 | + remito.cliente.NOM | |
| 985 | + }); | |
| 986 | + cabeceras.push({ | |
| 987 | + label: 'Domicilio:', | |
| 988 | + valor: remito.domicilioStamp | |
| 989 | + }); | |
| 990 | + } | |
| 991 | + if (remito.vendedor.NUM) { | |
| 992 | + cabeceras.push({ | |
| 993 | + label: 'Vendedor:', | |
| 994 | + valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + | |
| 995 | + ' - ' + remito.vendedor.NOM | |
| 996 | + }); | |
| 997 | + } | |
| 998 | + if (remito.proveedor.COD) { | |
| 999 | + cabeceras.push({ | |
| 1000 | + label: 'Proveedor:', | |
| 1001 | + valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + | |
| 1002 | + ' - ' + remito.proveedor.NOM | |
| 1003 | + }); | |
| 1004 | + } | |
| 1005 | + if (remito.flete !== undefined) { | |
| 1006 | + cabeceras.push({ | |
| 1007 | + label: 'Flete:', | |
| 1008 | + valor: remito.fob === 1 ? 'FOB' : ( | |
| 1009 | + remito.flete === 1 ? 'Si' : 'No') | |
| 1010 | + }); | |
| 1011 | + } | |
| 1012 | + if (remito.remitoPlazo) { | |
| 1013 | + cabeceras.push({ | |
| 1014 | + label: 'Precio condicion:', | |
| 1015 | + valor: valorPrecioCondicion() + ' ' + | |
| 1016 | + remitoBusinessService.plazoToString(remito.remitoPlazo) | |
| 1017 | + }); | |
| 1018 | + } | |
| 1019 | + | |
| 1020 | + function valorPrecioCondicion() { | |
| 1021 | + if (remito.idPrecioCondicion > 0) { | |
| 1022 | + return remito.precioCondicion.nombre; | |
| 1023 | + } else { | |
| 1024 | + return 'Ingreso Manual'; | |
| 1025 | + } | |
| 1026 | + } | |
| 1027 | + | |
| 1028 | + if (remito.flete === 1) { | |
| 1029 | + var cabeceraBomba = { | |
| 1030 | + label: 'Bomba', | |
| 1031 | + valor: remito.bomba === 1 ? 'Si' : 'No' | |
| 1032 | + }; | |
| 1033 | + if (remito.kilometros) { | |
| 1034 | + var cabeceraKilometros = { | |
| 1035 | + label: 'Kilometros', | |
| 1036 | + valor: remito.kilometros | |
| 1037 | + }; | |
| 1038 | + cabeceras.push(cabeceraKilometros); | |
| 1039 | + } | |
| 1040 | + cabeceras.push(cabeceraBomba); | |
| 1041 | + } | |
| 1042 | + $scope.remito.articulosRemito = remito.articulosRemito; | |
| 1043 | + remitoBusinessService.calcularArticulos($scope.remito.articulosRemito, | |
| 1044 | + remito.cotizacion.VENDEDOR); | |
| 1045 | + if (remito.idPrecioCondicion > 0) { | |
| 1046 | + $scope.idLista = remito.precioCondicion.idListaPrecio; | |
| 1047 | + } else { | |
| 1048 | + $scope.idLista = -1; | |
| 1049 | + } | |
| 1050 | + $scope.puntoVenta = rellenar(remito.sucursal, 4); | |
| 1051 | + $scope.comprobante = rellenar(remito.numeroRemito, 8); | |
| 1052 | + $scope.remito = remito; | |
| 1053 | + addArrayCabecera(cabeceras); | |
| 1054 | + } | |
| 1055 | + | |
| 1056 | + function getLSRemito() { | |
| 1057 | + var remito = JSON.parse($localStorage.remito || null); | |
| 1058 | + if (remito) { | |
| 1059 | + setearRemito(remito); | |
| 1060 | + delete $localStorage.remito; | |
| 1061 | + } | |
| 1062 | + } | |
| 1035 | 1063 | } |
| 1036 | 1064 | ]); |
src/js/service.js
| 1 | 1 | angular.module('focaCrearRemito') |
| 2 | - .service('crearRemitoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | |
| 2 | + .service('crearRemitoService', ['$http', 'API_ENDPOINT', | |
| 3 | + function($http, API_ENDPOINT) { | |
| 3 | 4 | var route = API_ENDPOINT.URL; |
| 4 | 5 | return { |
| 5 | 6 | crearRemito: function(remito) { |
src/views/remito.html
| ... | ... | @@ -47,8 +47,8 @@ |
| 47 | 47 | </thead> |
| 48 | 48 | <tbody class="tabla-articulo-body"> |
| 49 | 49 | <tr |
| 50 | - ng-repeat="(key, articulo) in articulosTabla" | |
| 51 | - ng-show="show || key == (articulosTabla.length - 1)" | |
| 50 | + ng-repeat="(key, articulo) in remito.articulosRemito" | |
| 51 | + ng-show="show || key == (remito.articulosRemito.length - 1)" | |
| 52 | 52 | class="d-flex" |
| 53 | 53 | > |
| 54 | 54 | <td ng-bind="key + 1"></td> |
| ... | ... | @@ -117,7 +117,7 @@ |
| 117 | 117 | <tr ng-show="!cargando" class="d-flex"> |
| 118 | 118 | <td |
| 119 | 119 | class="align-middle" |
| 120 | - ng-bind="articulosTabla.length + 1" | |
| 120 | + ng-bind="remito.articulosRemito.length + 1" | |
| 121 | 121 | ></td> |
| 122 | 122 | <td class="col"> |
| 123 | 123 | <input |
| ... | ... | @@ -182,7 +182,7 @@ |
| 182 | 182 | <tr class="d-flex"> |
| 183 | 183 | <td colspan="4" class="no-border-top"> |
| 184 | 184 | <strong>Items:</strong> |
| 185 | - <a ng-bind="articulosTabla.length"></a> | |
| 185 | + <a ng-bind="remito.articulosRemito.length"></a> | |
| 186 | 186 | </td> |
| 187 | 187 | <td class="text-right ml-auto table-celda-total no-border-top"> |
| 188 | 188 | <h3>Total:</h3> |
| ... | ... | @@ -227,8 +227,8 @@ |
| 227 | 227 | </thead> |
| 228 | 228 | <tbody> |
| 229 | 229 | <tr |
| 230 | - ng-repeat="(key, articulo) in articulosTabla" | |
| 231 | - ng-show="show || key == articulosTabla.length - 1" | |
| 230 | + ng-repeat="(key, articulo) in remito.articulosRemito" | |
| 231 | + ng-show="show || key == remito.articulosRemito.length - 1" | |
| 232 | 232 | > |
| 233 | 233 | <td class="w-100 align-middle d-flex p-0"> |
| 234 | 234 | <div class="align-middle p-1"> |
| ... | ... | @@ -296,7 +296,7 @@ |
| 296 | 296 | <tr ng-show="!cargando" class="d-flex"> |
| 297 | 297 | <td |
| 298 | 298 | class="align-middle p-1" |
| 299 | - ng-bind="articulosTabla.length + 1" | |
| 299 | + ng-bind="remito.articulosRemito.length + 1" | |
| 300 | 300 | ></td> |
| 301 | 301 | <td class="col p-0"> |
| 302 | 302 | <div class="d-flex"> |
| ... | ... | @@ -347,7 +347,7 @@ |
| 347 | 347 | <button |
| 348 | 348 | class="btn btn-outline-light selectable w-100" |
| 349 | 349 | ng-click="show = !show; masMenos()" |
| 350 | - ng-show="articulosTabla.length > 0" | |
| 350 | + ng-show="remito.articulosRemito.length > 0" | |
| 351 | 351 | > |
| 352 | 352 | <i |
| 353 | 353 | class="fa fa-chevron-down" |
| ... | ... | @@ -367,7 +367,7 @@ |
| 367 | 367 | <tr class="d-flex"> |
| 368 | 368 | <td class="align-middle no-border-top" colspan="2"> |
| 369 | 369 | <strong>Cantidad Items:</strong> |
| 370 | - <a ng-bind="articulosTabla.length"></a> | |
| 370 | + <a ng-bind="remito.articulosRemito.length"></a> | |
| 371 | 371 | </td> |
| 372 | 372 | <td class="text-right ml-auto table-celda-total no-border-top"> |
| 373 | 373 | <h3>Total:</h3> |