Commit d2fa34eb33ef7e867cf549dd53d3cfd4ef70dcdc
Exists in
master
conflicts
Showing
1 changed file
Show diff stats
src/js/controller.js
| 1 | -angular.module('focaCrearRemito') .controller('remitoController', | |
| 1 | +angular.module('focaCrearRemito').controller('remitoController', | |
| 2 | 2 | [ |
| 3 | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', |
| 4 | - 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', | |
| 4 | + 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', | |
| 5 | 5 | '$localStorage', |
| 6 | - function( | |
| 6 | + function ( | |
| 7 | 7 | $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, |
| 8 | - remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) | |
| 9 | - { | |
| 8 | + remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) { | |
| 10 | 9 | config(); |
| 11 | 10 | |
| 12 | 11 | var cotizacionPArgentino = {}; |
| ... | ... | @@ -28,10 +27,10 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 28 | 27 | }; |
| 29 | 28 | |
| 30 | 29 | |
| 31 | - crearRemitoService.getParametros().then(function(res) { | |
| 30 | + crearRemitoService.getParametros().then(function (res) { | |
| 32 | 31 | var parametros = JSON.parse(res.data[0].jsonText); |
| 33 | 32 | if ($localStorage.remito) { |
| 34 | - $timeout(function() { getLSRemito();} ); | |
| 33 | + $timeout(function () { getLSRemito(); }); | |
| 35 | 34 | } else { |
| 36 | 35 | for (var property in parametros) { |
| 37 | 36 | $scope.remito[property] = parametros[property]; |
| ... | ... | @@ -42,7 +41,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 42 | 41 | }); |
| 43 | 42 | |
| 44 | 43 | //SETEO BOTONERA LATERAL |
| 45 | - $timeout(function() { | |
| 44 | + $timeout(function () { | |
| 46 | 45 | focaBotoneraLateralService.showSalir(false); |
| 47 | 46 | focaBotoneraLateralService.showPausar(true); |
| 48 | 47 | focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); |
| ... | ... | @@ -55,14 +54,14 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 55 | 54 | |
| 56 | 55 | function init() { |
| 57 | 56 | $scope.$broadcast('cleanCabecera'); |
| 58 | - | |
| 57 | + $scope.remitoIsDirty = false; | |
| 59 | 58 | $scope.remito = { |
| 60 | 59 | id: 0, |
| 61 | 60 | estado: 0, |
| 62 | 61 | vendedor: {}, |
| 63 | 62 | cliente: {}, |
| 64 | 63 | proveedor: {}, |
| 65 | - domicilio: {dom: ''}, | |
| 64 | + domicilio: { dom: '' }, | |
| 66 | 65 | moneda: {}, |
| 67 | 66 | cotizacion: $scope.cotizacionPorDefecto || {}, |
| 68 | 67 | articulosRemito: [] |
| ... | ... | @@ -76,11 +75,11 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 76 | 75 | $scope.idLista = undefined; |
| 77 | 76 | |
| 78 | 77 | crearRemitoService.getNumeroRemito().then( |
| 79 | - function(res) { | |
| 78 | + function (res) { | |
| 80 | 79 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
| 81 | 80 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); |
| 82 | 81 | }, |
| 83 | - function(err) { | |
| 82 | + function (err) { | |
| 84 | 83 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 85 | 84 | console.info(err); |
| 86 | 85 | } |
| ... | ... | @@ -89,14 +88,14 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 89 | 88 | $scope.inicial = angular.copy($scope.remito); |
| 90 | 89 | } |
| 91 | 90 | |
| 92 | - $scope.$watch('remito', function(newValue) { | |
| 91 | + $scope.$watch('remito', function (newValue) { | |
| 93 | 92 | focaBotoneraLateralService.setPausarData({ |
| 94 | 93 | label: 'remito', |
| 95 | 94 | val: newValue |
| 96 | 95 | }); |
| 97 | 96 | }, true); |
| 98 | 97 | |
| 99 | - $scope.seleccionarNotaPedido = function() { | |
| 98 | + $scope.seleccionarNotaPedido = function () { | |
| 100 | 99 | if (varlidarRemitoFacturado()) { |
| 101 | 100 | var modalInstance = $uibModal.open( |
| 102 | 101 | { |
| ... | ... | @@ -105,19 +104,20 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 105 | 104 | controller: 'focaModalNotaPedidoController', |
| 106 | 105 | size: 'lg', |
| 107 | 106 | resolve: { |
| 108 | - usadoPor: function() { return 'remito'; }, | |
| 109 | - idVendedor: function() { return null; } | |
| 107 | + usadoPor: function () { return 'remito'; }, | |
| 108 | + idVendedor: function () { return null; } | |
| 110 | 109 | } |
| 111 | 110 | } |
| 112 | 111 | ); |
| 113 | 112 | modalInstance.result.then( |
| 114 | - function(notaPedido) { | |
| 113 | + function (notaPedido) { | |
| 115 | 114 | //añado cabeceras |
| 115 | + $scope.remitoIsDirty = true; | |
| 116 | 116 | $scope.notaPedido.id = notaPedido.id; |
| 117 | 117 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
| 118 | 118 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
| 119 | 119 | var puntosDescarga = []; |
| 120 | - notaPedido.notaPedidoPuntoDescarga.forEach(function(notaPedido) { | |
| 120 | + notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedido) { | |
| 121 | 121 | puntosDescarga.push(notaPedido.puntoDescarga); |
| 122 | 122 | }); |
| 123 | 123 | var cabeceras = [ |
| ... | ... | @@ -152,7 +152,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 152 | 152 | }, |
| 153 | 153 | { |
| 154 | 154 | label: 'Proveedor:', |
| 155 | - valor: $filter('rellenarDigitos') | |
| 155 | + valor: $filter('rellenarDigitos') | |
| 156 | 156 | (notaPedido.proveedor.COD, 5) + ' - ' + |
| 157 | 157 | notaPedido.proveedor.NOM |
| 158 | 158 | }, |
| ... | ... | @@ -223,7 +223,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 223 | 223 | articulo.id = 0; |
| 224 | 224 | articulo.idRemito = 0; |
| 225 | 225 | articulo.precio = |
| 226 | - (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4); | |
| 226 | + (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4); | |
| 227 | 227 | }); |
| 228 | 228 | |
| 229 | 229 | $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; |
| ... | ... | @@ -237,32 +237,41 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 237 | 237 | enableObservaciones(notaPedido.observaciones ? true : false); |
| 238 | 238 | addArrayCabecera(cabeceras); |
| 239 | 239 | |
| 240 | - }, function() { | |
| 240 | + }, function () { | |
| 241 | 241 | // funcion ejecutada cuando se cancela el modal |
| 242 | 242 | } |
| 243 | 243 | ); |
| 244 | 244 | } |
| 245 | 245 | }; |
| 246 | 246 | |
| 247 | - $scope.seleccionarRemito = function() { | |
| 247 | + $scope.seleccionarRemito = function () { | |
| 248 | + if ($scope.remitoIsDirty) { | |
| 249 | + focaModalService.confirm("¿Desea continuar? Se perderan los cambios") | |
| 250 | + .then(function () { | |
| 251 | + $scope.getRemitoModal(); | |
| 252 | + }); | |
| 253 | + } else { | |
| 254 | + $scope.getRemitoModal() | |
| 255 | + } | |
| 256 | + }; | |
| 257 | + $scope.getRemitoModal = function () { | |
| 248 | 258 | var modalInstance = $uibModal.open( |
| 249 | 259 | { |
| 250 | 260 | ariaLabelledBy: 'Busqueda de Remito', |
| 251 | 261 | templateUrl: 'foca-modal-remito.html', |
| 252 | 262 | controller: 'focaModalRemitoController', |
| 253 | 263 | size: 'lg', |
| 254 | - resolve: {usadoPor: function() {return 'remito';}} | |
| 264 | + resolve: { usadoPor: function () { return 'remito'; } } | |
| 255 | 265 | } |
| 256 | 266 | ); |
| 257 | 267 | modalInstance.result.then( |
| 258 | - setearRemito, function() { | |
| 268 | + setearRemito, function () { | |
| 259 | 269 | // funcion ejecutada cuando se cancela el modal |
| 260 | 270 | } |
| 261 | 271 | ); |
| 262 | - }; | |
| 263 | - | |
| 272 | + } | |
| 264 | 273 | //validacion por domicilio y por plazo pago |
| 265 | - $scope.crearRemito = function() { | |
| 274 | + $scope.crearRemito = function () { | |
| 266 | 275 | if (!$scope.remito.vendedor.NUM) { |
| 267 | 276 | focaModalService.alert('Ingrese Vendedor'); |
| 268 | 277 | return; |
| ... | ... | @@ -273,13 +282,13 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 273 | 282 | focaModalService.alert('Ingrese Proveedor'); |
| 274 | 283 | return; |
| 275 | 284 | } else if (!$scope.remito.cotizacion.moneda.id && |
| 276 | - !$scope.remito.cotizacion.moneda.ID){ | |
| 285 | + !$scope.remito.cotizacion.moneda.ID) { | |
| 277 | 286 | focaModalService.alert('Ingrese Moneda'); |
| 278 | 287 | return; |
| 279 | 288 | } else if (!$scope.remito.cotizacion.ID) { |
| 280 | 289 | focaModalService.alert('Ingrese Cotización'); |
| 281 | 290 | return; |
| 282 | - } else if ($scope.remito.flete === undefined || $scope.remito.flete === null){ | |
| 291 | + } else if ($scope.remito.flete === undefined || $scope.remito.flete === null) { | |
| 283 | 292 | focaModalService.alert('Ingrese Flete'); |
| 284 | 293 | return; |
| 285 | 294 | } else if ($scope.articulosFiltro().length === 0) { |
| ... | ... | @@ -288,7 +297,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 288 | 297 | } |
| 289 | 298 | focaBotoneraLateralService.startGuardar(); |
| 290 | 299 | $scope.saveLoading = true; |
| 291 | - var save = { | |
| 300 | + var save = { | |
| 292 | 301 | remito: { |
| 293 | 302 | id: $scope.remito.id, |
| 294 | 303 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), |
| ... | ... | @@ -311,7 +320,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 311 | 320 | numeroRemito: parseInt($scope.comprobante), |
| 312 | 321 | sucursal: parseInt($scope.puntoVenta), |
| 313 | 322 | responsabilidadIvaCliente: $scope.remito.cliente.IVA, |
| 314 | - descuento: 0,//TODO, | |
| 323 | + descuento: 0,//TODO, | |
| 315 | 324 | importeNeto: getImporte('netoUnitario'), |
| 316 | 325 | importeExento: getImporte('exentoUnitario'), |
| 317 | 326 | importeIva: getImporte('ivaUnitario'), |
| ... | ... | @@ -339,7 +348,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 339 | 348 | }; |
| 340 | 349 | |
| 341 | 350 | crearRemitoService.crearRemito(save).then( |
| 342 | - function(data) { | |
| 351 | + function (data) { | |
| 343 | 352 | |
| 344 | 353 | focaBotoneraLateralService.endGuardar(true); |
| 345 | 354 | $scope.saveLoading = false; |
| ... | ... | @@ -350,7 +359,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 350 | 359 | remitoBusinessService.addArticulos($scope.remito.articulosRemito, |
| 351 | 360 | $scope.remito.id, $scope.remito.cotizacion.VENDEDOR); |
| 352 | 361 | |
| 353 | - if(data.status === 500) { | |
| 362 | + if (data.status === 500) { | |
| 354 | 363 | focaModalService.alert(data.data); |
| 355 | 364 | return; |
| 356 | 365 | } |
| ... | ... | @@ -359,7 +368,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 359 | 368 | if ($scope.remito.id === 0) { |
| 360 | 369 | var plazos = $scope.remito.remitoPlazo; |
| 361 | 370 | |
| 362 | - for(var j = 0; j < plazos.length; j++) { | |
| 371 | + for (var j = 0; j < plazos.length; j++) { | |
| 363 | 372 | var json = { |
| 364 | 373 | idRemito: $scope.remito.id, |
| 365 | 374 | dias: plazos[j].dias |
| ... | ... | @@ -378,7 +387,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 378 | 387 | |
| 379 | 388 | config(); |
| 380 | 389 | |
| 381 | - }, function(error) { | |
| 390 | + }, function (error) { | |
| 382 | 391 | focaModalService.alert(error.data || 'Hubo un error al crear el remito'); |
| 383 | 392 | focaBotoneraLateralService.endGuardar(); |
| 384 | 393 | $scope.saveLoading = false; |
| ... | ... | @@ -387,7 +396,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 387 | 396 | ); |
| 388 | 397 | }; |
| 389 | 398 | |
| 390 | - $scope.seleccionarProductos = function() { | |
| 399 | + $scope.seleccionarProductos = function () { | |
| 391 | 400 | if ($scope.idLista === undefined) { |
| 392 | 401 | focaModalService.alert( |
| 393 | 402 | 'Primero seleccione una lista de precio y condicion'); |
| ... | ... | @@ -409,7 +418,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 409 | 418 | } |
| 410 | 419 | ); |
| 411 | 420 | modalInstance.result.then( |
| 412 | - function(producto) { | |
| 421 | + function (producto) { | |
| 413 | 422 | var newArt = |
| 414 | 423 | { |
| 415 | 424 | id: 0, |
| ... | ... | @@ -436,13 +445,13 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 436 | 445 | }; |
| 437 | 446 | $scope.articuloACargar = newArt; |
| 438 | 447 | $scope.cargando = false; |
| 439 | - }, function() { | |
| 448 | + }, function () { | |
| 440 | 449 | // funcion ejecutada cuando se cancela el modal |
| 441 | 450 | } |
| 442 | 451 | ); |
| 443 | 452 | }; |
| 444 | 453 | |
| 445 | - $scope.seleccionarPuntosDeDescarga = function() { | |
| 454 | + $scope.seleccionarPuntosDeDescarga = function () { | |
| 446 | 455 | if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { |
| 447 | 456 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
| 448 | 457 | return; |
| ... | ... | @@ -465,22 +474,22 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 465 | 474 | } |
| 466 | 475 | ); |
| 467 | 476 | modalInstance.result.then( |
| 468 | - function(puntosDescarga) { | |
| 477 | + function (puntosDescarga) { | |
| 469 | 478 | $scope.remito.domicilio.puntosDescarga = puntosDescarga; |
| 470 | 479 | |
| 471 | 480 | $scope.$broadcast('addCabecera', { |
| 472 | 481 | label: 'Puntos de descarga:', |
| 473 | 482 | valor: getCabeceraPuntoDescarga( |
| 474 | - $scope.remito.domicilio.puntosDescarga ) | |
| 483 | + $scope.remito.domicilio.puntosDescarga) | |
| 475 | 484 | }); |
| 476 | - }, function() { | |
| 485 | + }, function () { | |
| 477 | 486 | $scope.abrirModalDomicilios($scope.cliente); |
| 478 | 487 | } |
| 479 | 488 | ); |
| 480 | 489 | } |
| 481 | 490 | }; |
| 482 | 491 | |
| 483 | - $scope.seleccionarVendedor = function(callback, ocultarVendedor) { | |
| 492 | + $scope.seleccionarVendedor = function (callback, ocultarVendedor) { | |
| 484 | 493 | if (ocultarVendedor) { |
| 485 | 494 | callback(); |
| 486 | 495 | return; |
| ... | ... | @@ -507,8 +516,9 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 507 | 516 | size: 'md' |
| 508 | 517 | }; |
| 509 | 518 | focaModalService.modal(parametrosModal).then( |
| 510 | - function(vendedor) { | |
| 511 | - $scope.$broadcast('addCabecera',{ | |
| 519 | + function (vendedor) { | |
| 520 | + $scope.remitoIsDirty = true; | |
| 521 | + $scope.$broadcast('addCabecera', { | |
| 512 | 522 | label: 'Vendedor:', |
| 513 | 523 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
| 514 | 524 | vendedor.NOM |
| ... | ... | @@ -517,16 +527,16 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 517 | 527 | $scope.remito.vendedor = vendedor; |
| 518 | 528 | deleteCliente(); |
| 519 | 529 | callback(); |
| 520 | - }, function() { | |
| 530 | + }, function () { | |
| 521 | 531 | |
| 522 | 532 | } |
| 523 | 533 | ); |
| 524 | 534 | } |
| 525 | 535 | }; |
| 526 | 536 | |
| 527 | - $scope.seleccionarCliente = function(ocultarVendedor) { | |
| 537 | + $scope.seleccionarCliente = function (ocultarVendedor) { | |
| 528 | 538 | |
| 529 | - $scope.seleccionarVendedor(function() { | |
| 539 | + $scope.seleccionarVendedor(function () { | |
| 530 | 540 | if (varlidarRemitoFacturado()) { |
| 531 | 541 | var modalInstance = $uibModal.open( |
| 532 | 542 | { |
| ... | ... | @@ -534,17 +544,17 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 534 | 544 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 535 | 545 | controller: 'focaBusquedaClienteModalController', |
| 536 | 546 | resolve: { |
| 537 | - vendedor: function() { return $scope.remito.vendedor; }, | |
| 538 | - cobrador: function() { return null; } | |
| 547 | + vendedor: function () { return $scope.remito.vendedor; }, | |
| 548 | + cobrador: function () { return null; } | |
| 539 | 549 | }, |
| 540 | 550 | size: 'lg' |
| 541 | 551 | } |
| 542 | 552 | ); |
| 543 | 553 | modalInstance.result.then( |
| 544 | - function(cliente) { | |
| 554 | + function (cliente) { | |
| 545 | 555 | $scope.abrirModalDomicilios(cliente); |
| 546 | 556 | $scope.cliente = cliente; |
| 547 | - }, function() { | |
| 557 | + }, function () { | |
| 548 | 558 | $scope.seleccionarCliente(); |
| 549 | 559 | } |
| 550 | 560 | ); |
| ... | ... | @@ -552,7 +562,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 552 | 562 | }, ocultarVendedor); |
| 553 | 563 | }; |
| 554 | 564 | |
| 555 | - $scope.seleccionarProveedor = function() { | |
| 565 | + $scope.seleccionarProveedor = function () { | |
| 556 | 566 | if (varlidarRemitoFacturado()) { |
| 557 | 567 | var parametrosModal = { |
| 558 | 568 | titulo: 'Búsqueda de Proveedor', |
| ... | ... | @@ -576,17 +586,17 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 576 | 586 | } |
| 577 | 587 | ], |
| 578 | 588 | tipo: 'POST', |
| 579 | - json: {razonCuitCod: ''} | |
| 589 | + json: { razonCuitCod: '' } | |
| 580 | 590 | }; |
| 581 | 591 | focaModalService.modal(parametrosModal).then( |
| 582 | - function(proveedor) { | |
| 592 | + function (proveedor) { | |
| 583 | 593 | $scope.seleccionarFlete(proveedor); |
| 584 | - }, function() { } | |
| 594 | + }, function () { } | |
| 585 | 595 | ); |
| 586 | 596 | } |
| 587 | 597 | }; |
| 588 | 598 | |
| 589 | - $scope.abrirModalDomicilios = function(cliente) { | |
| 599 | + $scope.abrirModalDomicilios = function (cliente) { | |
| 590 | 600 | var modalInstanceDomicilio = $uibModal.open( |
| 591 | 601 | { |
| 592 | 602 | ariaLabelledBy: 'Busqueda de Domicilios', |
| ... | ... | @@ -594,13 +604,13 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 594 | 604 | controller: 'focaModalDomicilioController', |
| 595 | 605 | size: 'lg', |
| 596 | 606 | resolve: { |
| 597 | - idCliente: function() { return cliente.cod; }, | |
| 598 | - esNuevo: function() { return cliente.esNuevo; } | |
| 607 | + idCliente: function () { return cliente.cod; }, | |
| 608 | + esNuevo: function () { return cliente.esNuevo; } | |
| 599 | 609 | } |
| 600 | 610 | } |
| 601 | 611 | ); |
| 602 | 612 | modalInstanceDomicilio.result.then( |
| 603 | - function(domicilio) { | |
| 613 | + function (domicilio) { | |
| 604 | 614 | $scope.remito.domicilio = domicilio; |
| 605 | 615 | console.log(cliente); |
| 606 | 616 | $scope.remito.cliente = { |
| ... | ... | @@ -616,11 +626,11 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 616 | 626 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
| 617 | 627 | domicilio.Localidad + ', ' + domicilio.Provincia; |
| 618 | 628 | $scope.remito.domicilioStamp = domicilioStamp; |
| 619 | - $scope.$broadcast('addCabecera',{ | |
| 629 | + $scope.$broadcast('addCabecera', { | |
| 620 | 630 | label: 'Cliente:', |
| 621 | 631 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom |
| 622 | 632 | }); |
| 623 | - $scope.$broadcast('addCabecera',{ | |
| 633 | + $scope.$broadcast('addCabecera', { | |
| 624 | 634 | label: 'Domicilio:', |
| 625 | 635 | valor: domicilioStamp |
| 626 | 636 | }); |
| ... | ... | @@ -631,35 +641,35 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 631 | 641 | } else { |
| 632 | 642 | crearRemitoService |
| 633 | 643 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
| 634 | - .then(function(res) { | |
| 644 | + .then(function (res) { | |
| 635 | 645 | if (res.data.length) $scope.seleccionarPuntosDeDescarga(); |
| 636 | 646 | }); |
| 637 | 647 | } |
| 638 | 648 | |
| 639 | - $filter('filter')($scope.botonera, { label: 'Cliente'})[0].checked = true; | |
| 640 | - }, function() { | |
| 649 | + $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; | |
| 650 | + }, function () { | |
| 641 | 651 | $scope.seleccionarCliente(true); |
| 642 | 652 | return; |
| 643 | 653 | } |
| 644 | 654 | ); |
| 645 | 655 | }; |
| 646 | 656 | |
| 647 | - $scope.getTotal = function() { | |
| 657 | + $scope.getTotal = function () { | |
| 648 | 658 | var total = 0; |
| 649 | 659 | var arrayTempArticulos = $scope.articulosFiltro(); |
| 650 | - for(var i = 0; i < arrayTempArticulos.length; i++) { | |
| 660 | + for (var i = 0; i < arrayTempArticulos.length; i++) { | |
| 651 | 661 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 652 | 662 | } |
| 653 | 663 | return parseFloat(total.toFixed(2)); |
| 654 | 664 | }; |
| 655 | 665 | |
| 656 | - $scope.getSubTotal = function() { | |
| 666 | + $scope.getSubTotal = function () { | |
| 657 | 667 | if ($scope.articuloACargar) { |
| 658 | 668 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 659 | 669 | } |
| 660 | 670 | }; |
| 661 | 671 | |
| 662 | - $scope.seleccionarPreciosYCondiciones = function() { | |
| 672 | + $scope.seleccionarPreciosYCondiciones = function () { | |
| 663 | 673 | if (!$scope.remito.cliente.COD) { |
| 664 | 674 | focaModalService.alert('Primero seleccione un cliente'); |
| 665 | 675 | return; |
| ... | ... | @@ -667,7 +677,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 667 | 677 | |
| 668 | 678 | if ($scope.remito.articulosRemito.length !== 0) { |
| 669 | 679 | focaModalService.confirm('Se perderan los productos ingresados') |
| 670 | - .then(function(data) { | |
| 680 | + .then(function (data) { | |
| 671 | 681 | if (data && varlidarRemitoFacturado()) { |
| 672 | 682 | abrirModal(); |
| 673 | 683 | } |
| ... | ... | @@ -684,21 +694,21 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 684 | 694 | controller: 'focaModalPrecioCondicionController', |
| 685 | 695 | size: 'lg', |
| 686 | 696 | resolve: { |
| 687 | - idListaPrecio: function() { | |
| 697 | + idListaPrecio: function () { | |
| 688 | 698 | return $scope.remito.cliente.MOD || null; |
| 689 | 699 | } |
| 690 | 700 | } |
| 691 | 701 | } |
| 692 | 702 | ); |
| 693 | 703 | modalInstance.result.then( |
| 694 | - function(precioCondicion) { | |
| 704 | + function (precioCondicion) { | |
| 695 | 705 | var cabecera = ''; |
| 696 | 706 | var plazosConcat = ''; |
| 697 | 707 | if (!Array.isArray(precioCondicion)) { |
| 698 | 708 | $scope.remito.idPrecioCondicion = precioCondicion.id; |
| 699 | 709 | $scope.remito.remitoPlazo = precioCondicion.plazoPago; |
| 700 | 710 | $scope.idLista = precioCondicion.idListaPrecio; |
| 701 | - for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | |
| 711 | + for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | |
| 702 | 712 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
| 703 | 713 | } |
| 704 | 714 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + |
| ... | ... | @@ -708,28 +718,28 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 708 | 718 | //-1, el modal productos busca todos los productos |
| 709 | 719 | $scope.idLista = -1; |
| 710 | 720 | $scope.remito.remitoPlazo = precioCondicion; |
| 711 | - for(var j = 0; j < precioCondicion.length; j++) { | |
| 721 | + for (var j = 0; j < precioCondicion.length; j++) { | |
| 712 | 722 | plazosConcat += precioCondicion[j].dias + ' '; |
| 713 | 723 | } |
| 714 | 724 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
| 715 | 725 | } |
| 716 | 726 | $scope.remito.articulosRemito = []; |
| 717 | - $scope.$broadcast('addCabecera',{ | |
| 727 | + $scope.$broadcast('addCabecera', { | |
| 718 | 728 | label: 'Precios y condiciones:', |
| 719 | 729 | valor: cabecera |
| 720 | 730 | }); |
| 721 | 731 | $scope.remito.precioCondicion = precioCondicion; |
| 722 | 732 | |
| 723 | 733 | $filter('filter')($scope.botonera, |
| 724 | - { label: 'Precios y Condiciones'})[0].checked = true; | |
| 725 | - }, function() { | |
| 734 | + { label: 'Precios y Condiciones' })[0].checked = true; | |
| 735 | + }, function () { | |
| 726 | 736 | |
| 727 | 737 | } |
| 728 | 738 | ); |
| 729 | 739 | } |
| 730 | 740 | }; |
| 731 | 741 | |
| 732 | - $scope.seleccionarFlete = function(proveedor) { | |
| 742 | + $scope.seleccionarFlete = function (proveedor) { | |
| 733 | 743 | if (varlidarRemitoFacturado()) { |
| 734 | 744 | var modalInstance = $uibModal.open( |
| 735 | 745 | { |
| ... | ... | @@ -739,12 +749,12 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 739 | 749 | size: 'lg', |
| 740 | 750 | resolve: { |
| 741 | 751 | parametrosFlete: |
| 742 | - function() { | |
| 752 | + function () { | |
| 743 | 753 | return { |
| 744 | 754 | flete: $scope.remito.flete ? '1' : |
| 745 | 755 | ($scope.remito.fob ? 'FOB' : |
| 746 | - ($scope.remito.flete === undefined ? | |
| 747 | - null : '0')), | |
| 756 | + ($scope.remito.flete === undefined ? | |
| 757 | + null : '0')), | |
| 748 | 758 | bomba: $scope.remito.bomba ? '1' : |
| 749 | 759 | ($scope.remito.bomba === undefined ? |
| 750 | 760 | null : '0'), |
| ... | ... | @@ -755,11 +765,11 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 755 | 765 | } |
| 756 | 766 | ); |
| 757 | 767 | modalInstance.result.then( |
| 758 | - function(datos) { | |
| 759 | - | |
| 768 | + function (datos) { | |
| 769 | + $scope.remitoIsDirty = true; | |
| 760 | 770 | $scope.remito.proveedor = proveedor; |
| 761 | 771 | $scope.remito.idProveedor = proveedor.COD; |
| 762 | - $scope.$broadcast('addCabecera',{ | |
| 772 | + $scope.$broadcast('addCabecera', { | |
| 763 | 773 | label: 'Proveedor:', |
| 764 | 774 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
| 765 | 775 | proveedor.NOM |
| ... | ... | @@ -770,16 +780,16 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 770 | 780 | $scope.remito.bomba = datos.bomba; |
| 771 | 781 | $scope.remito.kilometros = datos.kilometros; |
| 772 | 782 | |
| 773 | - $scope.$broadcast('addCabecera',{ | |
| 783 | + $scope.$broadcast('addCabecera', { | |
| 774 | 784 | label: 'Flete:', |
| 775 | 785 | valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') |
| 776 | 786 | }); |
| 777 | 787 | if (datos.flete) { |
| 778 | - $scope.$broadcast('addCabecera',{ | |
| 788 | + $scope.$broadcast('addCabecera', { | |
| 779 | 789 | label: 'Bomba:', |
| 780 | 790 | valor: datos.bomba ? 'Si' : 'No' |
| 781 | 791 | }); |
| 782 | - $scope.$broadcast('addCabecera',{ | |
| 792 | + $scope.$broadcast('addCabecera', { | |
| 783 | 793 | label: 'Kilometros:', |
| 784 | 794 | valor: datos.kilometros |
| 785 | 795 | }); |
| ... | ... | @@ -791,15 +801,15 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 791 | 801 | } |
| 792 | 802 | |
| 793 | 803 | $filter('filter')($scope.botonera, |
| 794 | - { label: 'Proveedor'})[0].checked = true; | |
| 795 | - }, function() { | |
| 804 | + { label: 'Proveedor' })[0].checked = true; | |
| 805 | + }, function () { | |
| 796 | 806 | $scope.seleccionarTransportista(); |
| 797 | 807 | } |
| 798 | 808 | ); |
| 799 | 809 | } |
| 800 | 810 | }; |
| 801 | 811 | |
| 802 | - $scope.seleccionarMoneda = function() { | |
| 812 | + $scope.seleccionarMoneda = function () { | |
| 803 | 813 | if (varlidarRemitoFacturado()) { |
| 804 | 814 | var parametrosModal = { |
| 805 | 815 | titulo: 'Búsqueda de monedas', |
| ... | ... | @@ -817,7 +827,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 817 | 827 | size: 'md' |
| 818 | 828 | }; |
| 819 | 829 | focaModalService.modal(parametrosModal).then( |
| 820 | - function(moneda) { | |
| 830 | + function (moneda) { | |
| 821 | 831 | |
| 822 | 832 | if (moneda.ID !== 1) { |
| 823 | 833 | $scope.abrirModalCotizacion(moneda); |
| ... | ... | @@ -834,14 +844,14 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 834 | 844 | |
| 835 | 845 | $scope.remito.cotizacion = cotizacionPArgentino; |
| 836 | 846 | }); |
| 837 | - }, function() { | |
| 847 | + }, function () { | |
| 838 | 848 | |
| 839 | 849 | } |
| 840 | 850 | ); |
| 841 | 851 | } |
| 842 | 852 | }; |
| 843 | 853 | |
| 844 | - $scope.seleccionarObservaciones = function() { | |
| 854 | + $scope.seleccionarObservaciones = function () { | |
| 845 | 855 | focaModalService |
| 846 | 856 | .prompt({ |
| 847 | 857 | titulo: 'Observaciones', |
| ... | ... | @@ -849,37 +859,36 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 849 | 859 | textarea: true, |
| 850 | 860 | readonly: true |
| 851 | 861 | }) |
| 852 | - .then(function(observaciones) { | |
| 862 | + .then(function (observaciones) { | |
| 853 | 863 | $scope.remito.observaciones = observaciones; |
| 854 | 864 | }); |
| 855 | 865 | }; |
| 856 | 866 | |
| 857 | - $scope.abrirModalCotizacion = function(moneda) { | |
| 867 | + $scope.abrirModalCotizacion = function (moneda) { | |
| 858 | 868 | var modalInstance = $uibModal.open( |
| 859 | 869 | { |
| 860 | 870 | ariaLabelledBy: 'Busqueda de Cotización', |
| 861 | 871 | templateUrl: 'modal-cotizacion.html', |
| 862 | 872 | controller: 'focaModalCotizacionController', |
| 863 | 873 | size: 'lg', |
| 864 | - resolve: {idMoneda: function() {return moneda.ID;}} | |
| 874 | + resolve: { idMoneda: function () { return moneda.ID; } } | |
| 865 | 875 | } |
| 866 | 876 | ); |
| 867 | 877 | modalInstance.result.then( |
| 868 | - function(cotizacion) { | |
| 869 | - | |
| 878 | + function (cotizacion) { | |
| 870 | 879 | cotizacion.moneda = moneda; |
| 871 | - | |
| 880 | + $scope.remitoIsDirty = true; | |
| 872 | 881 | actualizarCabeceraMoneda(cotizacion); |
| 873 | 882 | $scope.remito.cotizacion = cotizacion; |
| 874 | - }, function() { | |
| 883 | + }, function () { | |
| 875 | 884 | |
| 876 | 885 | } |
| 877 | 886 | ); |
| 878 | 887 | }; |
| 879 | 888 | |
| 880 | - function actualizarCabeceraMoneda (cotizacion) { | |
| 889 | + function actualizarCabeceraMoneda(cotizacion) { | |
| 881 | 890 | |
| 882 | - $scope.remito.articulosRemito.forEach(function(art) { | |
| 891 | + $scope.remito.articulosRemito.forEach(function (art) { | |
| 883 | 892 | art.precio = (art.precio * $scope.remito.cotizacion.VENDEDOR).toFixed(4); |
| 884 | 893 | art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); |
| 885 | 894 | }); |
| ... | ... | @@ -904,13 +913,13 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 904 | 913 | } |
| 905 | 914 | } |
| 906 | 915 | |
| 907 | - $scope.agregarATabla = function(key) { | |
| 916 | + $scope.agregarATabla = function (key) { | |
| 908 | 917 | if (key === 13) { |
| 909 | 918 | if ($scope.articuloACargar.cantidad === undefined || |
| 910 | 919 | $scope.articuloACargar.cantidad === 0 || |
| 911 | - $scope.articuloACargar.cantidad === null ) { | |
| 912 | - focaModalService.alert('El valor debe ser al menos 1'); | |
| 913 | - return; | |
| 920 | + $scope.articuloACargar.cantidad === null) { | |
| 921 | + focaModalService.alert('El valor debe ser al menos 1'); | |
| 922 | + return; | |
| 914 | 923 | } |
| 915 | 924 | delete $scope.articuloACargar.sectorCodigo; |
| 916 | 925 | $scope.remito.articulosRemito.push($scope.articuloACargar); |
| ... | ... | @@ -918,26 +927,26 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 918 | 927 | } |
| 919 | 928 | }; |
| 920 | 929 | |
| 921 | - $scope.quitarArticulo = function(articulo) { | |
| 930 | + $scope.quitarArticulo = function (articulo) { | |
| 922 | 931 | articulo.idRemito = -1; |
| 923 | 932 | }; |
| 924 | 933 | |
| 925 | - $scope.articulosFiltro = function() { | |
| 934 | + $scope.articulosFiltro = function () { | |
| 926 | 935 | |
| 927 | - var result = $scope.remito.articulosRemito.filter(function(articulo) { | |
| 936 | + var result = $scope.remito.articulosRemito.filter(function (articulo) { | |
| 928 | 937 | return articulo.idRemito >= 0; |
| 929 | 938 | }); |
| 930 | 939 | |
| 931 | 940 | // Agrego checked en cabecera si hay datos |
| 932 | 941 | if (result.length) { |
| 933 | - $filter('filter')($scope.botonera, { label: 'Productos'})[0].checked = true; | |
| 942 | + $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = true; | |
| 934 | 943 | } else { |
| 935 | - $filter('filter')($scope.botonera, { label: 'Productos'})[0].checked = false; | |
| 944 | + $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = false; | |
| 936 | 945 | } |
| 937 | 946 | return result; |
| 938 | 947 | }; |
| 939 | 948 | |
| 940 | - $scope.editarArticulo = function(key, articulo, tmpCantidad, tmpPrecio) { | |
| 949 | + $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { | |
| 941 | 950 | if (key === 13) { |
| 942 | 951 | if (!articulo.cantidad || !articulo.precio) { |
| 943 | 952 | focaModalService.alert('Los valores deben ser al menos 1'); |
| ... | ... | @@ -953,13 +962,13 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 953 | 962 | } |
| 954 | 963 | }; |
| 955 | 964 | |
| 956 | - $scope.cancelarEditar = function(articulo) { | |
| 965 | + $scope.cancelarEditar = function (articulo) { | |
| 957 | 966 | $scope.tmpCantidad = articulo.cantidad; |
| 958 | 967 | $scope.tmpPrecio = articulo.precio; |
| 959 | 968 | articulo.editCantidad = articulo.editPrecio = false; |
| 960 | 969 | }; |
| 961 | 970 | |
| 962 | - $scope.cambioEdit = function(articulo, propiedad) { | |
| 971 | + $scope.cambioEdit = function (articulo, propiedad) { | |
| 963 | 972 | if (propiedad === 'cantidad') { |
| 964 | 973 | articulo.editCantidad = true; |
| 965 | 974 | } else if (propiedad === 'precio') { |
| ... | ... | @@ -967,12 +976,12 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 967 | 976 | } |
| 968 | 977 | }; |
| 969 | 978 | |
| 970 | - $scope.resetFilter = function() { | |
| 979 | + $scope.resetFilter = function () { | |
| 971 | 980 | $scope.articuloACargar = {}; |
| 972 | 981 | $scope.cargando = true; |
| 973 | 982 | }; |
| 974 | 983 | //Recibe aviso si el teclado está en uso |
| 975 | - $rootScope.$on('usarTeclado', function(event, data) { | |
| 984 | + $rootScope.$on('usarTeclado', function (event, data) { | |
| 976 | 985 | if (data) { |
| 977 | 986 | $scope.mostrarTeclado = true; |
| 978 | 987 | return; |
| ... | ... | @@ -980,7 +989,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 980 | 989 | $scope.mostrarTeclado = false; |
| 981 | 990 | }); |
| 982 | 991 | |
| 983 | - $scope.selectFocus = function($event) { | |
| 992 | + $scope.selectFocus = function ($event) { | |
| 984 | 993 | // Si el teclado esta en uso no selecciona el valor |
| 985 | 994 | if ($scope.mostrarTeclado) { |
| 986 | 995 | return; |
| ... | ... | @@ -990,7 +999,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 990 | 999 | |
| 991 | 1000 | function addArrayCabecera(array) { |
| 992 | 1001 | for (var i = 0; i < array.length; i++) { |
| 993 | - $scope.$broadcast('addCabecera',{ | |
| 1002 | + $scope.$broadcast('addCabecera', { | |
| 994 | 1003 | label: array[i].label, |
| 995 | 1004 | valor: array[i].valor |
| 996 | 1005 | }); |
| ... | ... | @@ -1024,7 +1033,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 1024 | 1033 | if (confirmacion) { |
| 1025 | 1034 | focaModalService.confirm( |
| 1026 | 1035 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
| 1027 | - ).then(function(data) { | |
| 1036 | + ).then(function (data) { | |
| 1028 | 1037 | if (data) { |
| 1029 | 1038 | $location.path('/'); |
| 1030 | 1039 | } |
| ... | ... | @@ -1035,7 +1044,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 1035 | 1044 | } |
| 1036 | 1045 | |
| 1037 | 1046 | function enableObservaciones(val) { |
| 1038 | - var boton = $scope.botonera.filter(function(botonObs) { | |
| 1047 | + var boton = $scope.botonera.filter(function (botonObs) { | |
| 1039 | 1048 | return botonObs.label === 'Observaciones'; |
| 1040 | 1049 | }); |
| 1041 | 1050 | boton[0].disable = !val; |
| ... | ... | @@ -1056,7 +1065,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 1056 | 1065 | }); |
| 1057 | 1066 | cabeceras.push({ |
| 1058 | 1067 | label: 'Fecha cotizacion:', |
| 1059 | - valor: $filter('date')(remito.cotizacion.FECHA, | |
| 1068 | + valor: $filter('date')(remito.cotizacion.FECHA, | |
| 1060 | 1069 | 'dd/MM/yyyy') |
| 1061 | 1070 | }); |
| 1062 | 1071 | cabeceras.push({ |
| ... | ... | @@ -1153,6 +1162,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 1153 | 1162 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntosDescarga)) |
| 1154 | 1163 | }); |
| 1155 | 1164 | } |
| 1165 | + $scope.remitoIsDirty = false; | |
| 1156 | 1166 | |
| 1157 | 1167 | if ($scope.remito.articulosRemito.length) { |
| 1158 | 1168 | $scope.remito.articulosRemito.forEach(function (articulo) { |
| ... | ... | @@ -1175,7 +1185,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 1175 | 1185 | function deleteCliente() { |
| 1176 | 1186 | delete $scope.remito.domicilioStamp; |
| 1177 | 1187 | delete $scope.remito.puntosDescarga; |
| 1178 | - $scope.remito.domicilio = {dom: ''}; | |
| 1188 | + $scope.remito.domicilio = { dom: '' }; | |
| 1179 | 1189 | $scope.remito.cliente = {}; |
| 1180 | 1190 | $scope.$broadcast('removeCabecera', 'Cliente:'); |
| 1181 | 1191 | $scope.$broadcast('removeCabecera', 'Domicilio:'); |
| ... | ... | @@ -1184,7 +1194,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 1184 | 1194 | |
| 1185 | 1195 | function getCabeceraPuntoDescarga(puntosDescarga) { |
| 1186 | 1196 | var puntosStamp = ''; |
| 1187 | - puntosDescarga.forEach(function(punto, idx, arr) { | |
| 1197 | + puntosDescarga.forEach(function (punto, idx, arr) { | |
| 1188 | 1198 | puntosStamp += punto.descripcion; |
| 1189 | 1199 | if ((idx + 1) !== arr.length) puntosStamp += ', '; |
| 1190 | 1200 | }); |
| ... | ... | @@ -1208,13 +1218,13 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 1208 | 1218 | } |
| 1209 | 1219 | } |
| 1210 | 1220 | ) |
| 1211 | - .then(function(res) { | |
| 1212 | - if (res === false) { | |
| 1213 | - abrirModalMail(id); | |
| 1214 | - focaModalService.alert('Descarga o envíe su remito ' + | |
| 1215 | - 'antes de cerrar esta ventana'); | |
| 1216 | - } | |
| 1217 | - }); | |
| 1221 | + .then(function (res) { | |
| 1222 | + if (res === false) { | |
| 1223 | + abrirModalMail(id); | |
| 1224 | + focaModalService.alert('Descarga o envíe su remito ' + | |
| 1225 | + 'antes de cerrar esta ventana'); | |
| 1226 | + } | |
| 1227 | + }); | |
| 1218 | 1228 | } |
| 1219 | 1229 | //recibo la propiedad por la cual quiero obtener el valor |
| 1220 | 1230 | function getImporte(propiedad) { |