Commit 0d14fbc5921fc4641427cee4877a1740cd7c659b
Exists in
master
Merge branch 'master' into 'develop'
Master(mpuebla) See merge request !80
Showing
2 changed files
Show diff stats
spec/controllerSpec.js
| ... | ... | @@ -439,68 +439,6 @@ describe('controladores módulo crear cobranza', function() { |
| 439 | 439 | expect(scope.cobroDeuda).toEqual(true); |
| 440 | 440 | }); |
| 441 | 441 | |
| 442 | - it('seleccionarCobranza levanta modal y setea datos', function(done) { | |
| 443 | - | |
| 444 | - //arrange | |
| 445 | - var scope = { | |
| 446 | - $broadcast: function() { }, | |
| 447 | - $watch: function() { } | |
| 448 | - }; | |
| 449 | - var uibModal = { | |
| 450 | - open: function() { } | |
| 451 | - }; | |
| 452 | - | |
| 453 | - $controller('cobranzaController', { | |
| 454 | - $scope: scope, | |
| 455 | - $timeout: $timeout, | |
| 456 | - $uibModal: uibModal, | |
| 457 | - $location: {}, | |
| 458 | - focaCrearCobranzaService: { | |
| 459 | - getCotizacionByIdMoneda: function() { | |
| 460 | - return { | |
| 461 | - then: function() { } | |
| 462 | - }; | |
| 463 | - }, | |
| 464 | - getBotonera: function() { }, | |
| 465 | - getNumeroRecibo: function() { | |
| 466 | - return { | |
| 467 | - then: function() { } | |
| 468 | - }; | |
| 469 | - } | |
| 470 | - }, | |
| 471 | - focaModalService: {}, | |
| 472 | - $filter: $filter, | |
| 473 | - focaSeguimientoService: {}, | |
| 474 | - focaBotoneraLateralService: {}, | |
| 475 | - APP: {}, | |
| 476 | - focaLoginService: {}, | |
| 477 | - $localStorage: true | |
| 478 | - }); | |
| 479 | - var respuesta = { | |
| 480 | - facturas: 1, | |
| 481 | - cobros: 2, | |
| 482 | - cliente: { }, | |
| 483 | - moneda: { | |
| 484 | - cotizaciones: [] | |
| 485 | - } | |
| 486 | - }; | |
| 487 | - var promesa = { result: Promise.resolve(respuesta) }; | |
| 488 | - | |
| 489 | - //act | |
| 490 | - spyOn(uibModal, 'open').and.returnValue(promesa); | |
| 491 | - spyOn(scope, '$broadcast'); | |
| 492 | - scope.seleccionarCobranza(); | |
| 493 | - | |
| 494 | - //assert | |
| 495 | - promesa.result.then(function() { | |
| 496 | - expect(uibModal.open).toHaveBeenCalled(); | |
| 497 | - expect(scope.$broadcast).toHaveBeenCalledWith('cleanCabecera'); | |
| 498 | - expect(scope.cobranza.facturas).toEqual(respuesta.facturas); | |
| 499 | - expect(scope.cobranza.cobros).toEqual(respuesta.cobros); | |
| 500 | - done(); | |
| 501 | - }); | |
| 502 | - }); | |
| 503 | - | |
| 504 | 442 | it('seleccionarCliente levanta modal y setea datos', function(done) { |
| 505 | 443 | |
| 506 | 444 | //arrange |
| ... | ... | @@ -950,61 +888,6 @@ describe('controladores módulo crear cobranza', function() { |
| 950 | 888 | }); |
| 951 | 889 | }); |
| 952 | 890 | |
| 953 | - it('seleccionarCobrador levanta modal', function(done) { | |
| 954 | - | |
| 955 | - //arrange | |
| 956 | - var scope = { | |
| 957 | - $broadcast: function() { }, | |
| 958 | - $watch: function() { } | |
| 959 | - }; | |
| 960 | - var focaModalService = { | |
| 961 | - modal: function() { } | |
| 962 | - }; | |
| 963 | - | |
| 964 | - $controller('cobranzaController', { | |
| 965 | - $scope: scope, | |
| 966 | - $timeout: $timeout, | |
| 967 | - $uibModal: {}, | |
| 968 | - $location: {}, | |
| 969 | - focaCrearCobranzaService: { | |
| 970 | - getCotizacionByIdMoneda: function() { | |
| 971 | - return { | |
| 972 | - then: function() { } | |
| 973 | - }; | |
| 974 | - }, | |
| 975 | - getBotonera: function() { }, | |
| 976 | - getNumeroRecibo: function() { | |
| 977 | - return { | |
| 978 | - then: function() { } | |
| 979 | - }; | |
| 980 | - } | |
| 981 | - }, | |
| 982 | - focaModalService: focaModalService, | |
| 983 | - $filter: $filter, | |
| 984 | - focaSeguimientoService: {}, | |
| 985 | - focaBotoneraLateralService: {}, | |
| 986 | - APP: {}, | |
| 987 | - focaLoginService: {}, | |
| 988 | - $localStorage: true | |
| 989 | - }); | |
| 990 | - | |
| 991 | - var respuesta = 1; | |
| 992 | - var promesa = Promise.resolve(respuesta); | |
| 993 | - | |
| 994 | - //act | |
| 995 | - spyOn(focaModalService, 'modal').and.returnValue(promesa); | |
| 996 | - spyOn(scope, '$broadcast'); | |
| 997 | - scope.seleccionarCobrador({ }); | |
| 998 | - | |
| 999 | - //assert | |
| 1000 | - promesa.then(function() { | |
| 1001 | - expect(focaModalService.modal).toHaveBeenCalled(); | |
| 1002 | - expect(scope.$broadcast).toHaveBeenCalled(); | |
| 1003 | - scope.cobranza.cobrador = respuesta; | |
| 1004 | - done(); | |
| 1005 | - }); | |
| 1006 | - }); | |
| 1007 | - | |
| 1008 | 891 | it('getTotalDeuda devuelve correcto', function() { |
| 1009 | 892 | |
| 1010 | 893 | //arrange |
src/js/controller.js
| 1 | -angular.module('focaCrearCobranza') .controller('cobranzaController', | |
| 1 | +angular.module('focaCrearCobranza').controller('cobranzaController', | |
| 2 | 2 | [ |
| 3 | 3 | '$scope', '$timeout', '$uibModal', '$location', |
| 4 | 4 | 'focaCrearCobranzaService', 'focaModalService', '$filter', 'focaSeguimientoService', |
| 5 | 5 | 'focaBotoneraLateralService', 'APP', 'focaLoginService', '$localStorage', |
| 6 | - function($scope, $timeout, $uibModal, $location, focaCrearCobranzaService, | |
| 6 | + function ($scope, $timeout, $uibModal, $location, focaCrearCobranzaService, | |
| 7 | 7 | focaModalService, $filter, focaSeguimientoService, focaBotoneraLateralService, |
| 8 | - APP, loginService, $localStorage) | |
| 9 | - { | |
| 8 | + APP, loginService, $localStorage) { | |
| 10 | 9 | config(); |
| 11 | 10 | |
| 12 | 11 | function config() { |
| ... | ... | @@ -23,17 +22,17 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 23 | 22 | }; |
| 24 | 23 | |
| 25 | 24 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
| 26 | - focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { | |
| 25 | + focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function (res) { | |
| 27 | 26 | var moneda = res.data[0]; |
| 28 | 27 | moneda.cotizacion = moneda.cotizaciones[0]; |
| 29 | 28 | $scope.cobranza.moneda = $scope.inicial.moneda = moneda; |
| 30 | - $filter('filter')( $scope.botonera, { | |
| 29 | + $filter('filter')($scope.botonera, { | |
| 31 | 30 | label: 'Moneda' |
| 32 | 31 | })[0].checked = true; |
| 33 | - $timeout(function() { getLSCobranza();} ); | |
| 32 | + $timeout(function () { getLSCobranza(); }); | |
| 34 | 33 | }); |
| 35 | 34 | |
| 36 | - $timeout(function() { | |
| 35 | + $timeout(function () { | |
| 37 | 36 | focaBotoneraLateralService.showSalir(false); |
| 38 | 37 | focaBotoneraLateralService.showPausar(true); |
| 39 | 38 | focaBotoneraLateralService.showGuardar(true, $scope.crearCobranza); |
| ... | ... | @@ -60,7 +59,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 60 | 59 | |
| 61 | 60 | if (APP === 'cobranza') { |
| 62 | 61 | focaCrearCobranzaService.getCobradorById($scope.idCobrador).then( |
| 63 | - function(res) { | |
| 62 | + function (res) { | |
| 64 | 63 | var cobrador = res.data; |
| 65 | 64 | |
| 66 | 65 | $scope.$broadcast('addCabecera', { |
| ... | ... | @@ -78,7 +77,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 78 | 77 | $scope.inicial = angular.copy($scope.cobranza); |
| 79 | 78 | |
| 80 | 79 | focaCrearCobranzaService.getNumeroRecibo().then( |
| 81 | - function(res) { | |
| 80 | + function (res) { | |
| 82 | 81 | $scope.puntoVenta = $filter('rellenarDigitos')( |
| 83 | 82 | res.data.sucursal, 4 |
| 84 | 83 | ); |
| ... | ... | @@ -87,7 +86,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 87 | 86 | res.data.numeroRecibo, 8 |
| 88 | 87 | ); |
| 89 | 88 | }, |
| 90 | - function(err) { | |
| 89 | + function (err) { | |
| 91 | 90 | focaModalService.alert( |
| 92 | 91 | 'La terminal no esta configurada correctamente' |
| 93 | 92 | ); |
| ... | ... | @@ -96,14 +95,14 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 96 | 95 | ); |
| 97 | 96 | } |
| 98 | 97 | |
| 99 | - $scope.$watch('cobranza', function(newValue) { | |
| 98 | + $scope.$watch('cobranza', function (newValue) { | |
| 100 | 99 | focaBotoneraLateralService.setPausarData({ |
| 101 | 100 | label: 'cobranza', |
| 102 | 101 | val: newValue |
| 103 | 102 | }); |
| 104 | 103 | }, true); |
| 105 | 104 | |
| 106 | - $scope.crearCobranza = function() { | |
| 105 | + $scope.crearCobranza = function () { | |
| 107 | 106 | if (!$scope.cobranza.cliente.COD) { |
| 108 | 107 | focaModalService.alert('Ingrese Cliente'); |
| 109 | 108 | return; |
| ... | ... | @@ -130,7 +129,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 130 | 129 | $scope.editando = false; |
| 131 | 130 | focaBotoneraLateralService.startGuardar(); |
| 132 | 131 | $scope.saveLoading = true; |
| 133 | - for(var i = 0; i < $scope.cobranza.facturas.length; i++) { | |
| 132 | + for (var i = 0; i < $scope.cobranza.facturas.length; i++) { | |
| 134 | 133 | var cuerpoFactura = { |
| 135 | 134 | CYV: 'V', |
| 136 | 135 | TIP: 'C', |
| ... | ... | @@ -144,7 +143,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 144 | 143 | FEC: new Date($scope.cobranza.FEC) |
| 145 | 144 | .toISOString().slice(0, 19).replace('T', ' '), |
| 146 | 145 | IMP: Math.abs($scope.cobranza.facturas[i].IMP || |
| 147 | - $scope.cobranza.facturas[i].IPA), | |
| 146 | + $scope.cobranza.facturas[i].IPA), | |
| 148 | 147 | RES: 0,//caja de tesorería |
| 149 | 148 | SUBM: 0, |
| 150 | 149 | NCU: $scope.cobranza.facturas[i].NCU |
| ... | ... | @@ -162,7 +161,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 162 | 161 | LOP: 'P', |
| 163 | 162 | TIL: $scope.cobranza.cobros[j].TIL, |
| 164 | 163 | COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : $scope.cobranza.cobros[j].COM, |
| 165 | - FEC: !$scope.cobranza.cobros[j].fechaPresentacion ? | |
| 164 | + FEC: !$scope.cobranza.cobros[j].fechaPresentacion ? | |
| 166 | 165 | new Date($scope.cobranza.cobros[j].FEC) |
| 167 | 166 | .toISOString().slice(0, 19).replace('T', ' ') : |
| 168 | 167 | new Date($scope.cobranza.cobros[j].fechaPresentacion) |
| ... | ... | @@ -201,7 +200,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 201 | 200 | ORI: 've', |
| 202 | 201 | FER: '', |
| 203 | 202 | BIMP: 0, |
| 204 | - COMP: 'C ' +'RC ' + $scope.puntoVenta + '-' + $scope.comprobante, | |
| 203 | + COMP: 'C ' + 'RC ' + $scope.puntoVenta + '-' + $scope.comprobante, | |
| 205 | 204 | VAL_E: '',//Cuando egresa por ingresos y egresos en el numero de egreso |
| 206 | 205 | VAL_I: '',//Cuando Ingresa por ingresos y egresos en el numero ingreso |
| 207 | 206 | REC_CAJ: 'D', |
| ... | ... | @@ -222,7 +221,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 222 | 221 | }; |
| 223 | 222 | cheques.push(cheque); |
| 224 | 223 | } |
| 225 | - if ($scope.cobranza.cobros[j].imgs) imgs = $scope.cobranza.cobros[j].imgs; | |
| 224 | + if ($scope.cobranza.cobros[j].imgs) imgs = $scope.cobranza.cobros[j].imgs; | |
| 226 | 225 | |
| 227 | 226 | } |
| 228 | 227 | |
| ... | ... | @@ -286,44 +285,44 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 286 | 285 | //COPIO cobranzaMail Y A cobranza LE ELIMINO EL VALOR NCU DE LOS CUERPOS |
| 287 | 286 | var cobranzaMail = angular.copy(cobranza); |
| 288 | 287 | |
| 289 | - cobranza.cuerpo = cobranza.cuerpo.map(function(c) { | |
| 288 | + cobranza.cuerpo = cobranza.cuerpo.map(function (c) { | |
| 290 | 289 | if (c.NCU) delete c.NCU; |
| 291 | 290 | return c; |
| 292 | 291 | }); |
| 293 | 292 | focaCrearCobranzaService |
| 294 | 293 | .guardarCobranza(cobranza) |
| 295 | 294 | .then( |
| 296 | - function(result) { | |
| 297 | - focaBotoneraLateralService.endGuardar(true); | |
| 298 | - $scope.saveLoading = false; | |
| 299 | - | |
| 300 | - enviarMail(cobranzaMail); | |
| 301 | - | |
| 302 | - focaSeguimientoService.guardarPosicion( | |
| 303 | - 'Cobranza', | |
| 304 | - result.data, | |
| 305 | - '' | |
| 306 | - ); | |
| 307 | - | |
| 308 | - config(); | |
| 309 | - }, function(error) { | |
| 310 | - focaModalService.alert('Hubo un problema al cargar la cobranza'); | |
| 311 | - focaBotoneraLateralService.endGuardar(); | |
| 312 | - $scope.saveLoading = false; | |
| 313 | - console.info(error); | |
| 314 | - } | |
| 315 | - ); | |
| 295 | + function (result) { | |
| 296 | + focaBotoneraLateralService.endGuardar(true); | |
| 297 | + $scope.saveLoading = false; | |
| 298 | + | |
| 299 | + enviarMail(cobranzaMail); | |
| 300 | + | |
| 301 | + focaSeguimientoService.guardarPosicion( | |
| 302 | + 'Cobranza', | |
| 303 | + result.data, | |
| 304 | + '' | |
| 305 | + ); | |
| 306 | + | |
| 307 | + config(); | |
| 308 | + }, function (error) { | |
| 309 | + focaModalService.alert('Hubo un problema al cargar la cobranza'); | |
| 310 | + focaBotoneraLateralService.endGuardar(); | |
| 311 | + $scope.saveLoading = false; | |
| 312 | + console.info(error); | |
| 313 | + } | |
| 314 | + ); | |
| 316 | 315 | }; |
| 317 | 316 | |
| 318 | - $scope.seleccionarCobros = function() { | |
| 317 | + $scope.seleccionarCobros = function () { | |
| 319 | 318 | $scope.cobroDeuda = false; |
| 320 | 319 | }; |
| 321 | 320 | |
| 322 | - $scope.seleccionarComprobantes = function() { | |
| 321 | + $scope.seleccionarComprobantes = function () { | |
| 323 | 322 | $scope.cobroDeuda = true; |
| 324 | 323 | }; |
| 325 | 324 | |
| 326 | - $scope.seleccionarCobranza = function() { | |
| 325 | + $scope.seleccionarCobranza = function () { | |
| 327 | 326 | var modalInstance = $uibModal.open( |
| 328 | 327 | { |
| 329 | 328 | ariaLabelledBy: 'Busqueda de Cobranzas', |
| ... | ... | @@ -332,13 +331,13 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 332 | 331 | size: 'lg' |
| 333 | 332 | } |
| 334 | 333 | ); |
| 335 | - modalInstance.result.then(function(cobranza) { | |
| 334 | + modalInstance.result.then(function (cobranza) { | |
| 336 | 335 | cobranza.moneda.cotizacion = cobranza.moneda.cotizaciones[0]; |
| 337 | 336 | setearCobranza(cobranza); |
| 338 | 337 | }); |
| 339 | 338 | }; |
| 340 | 339 | |
| 341 | - $scope.seleccionarResumenDeCuenta = function() { | |
| 340 | + $scope.seleccionarResumenDeCuenta = function () { | |
| 342 | 341 | if (!$scope.cobranza.cliente.COD) { |
| 343 | 342 | focaModalService.alert('Seleccione primero un cliente'); |
| 344 | 343 | return; |
| ... | ... | @@ -349,114 +348,81 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 349 | 348 | templateUrl: 'modal-resumen-cuenta.html', |
| 350 | 349 | controller: 'focaModalResumenCuentaController', |
| 351 | 350 | resolve: { |
| 352 | - cliente: function() { return $scope.cobranza.cliente; }, | |
| 353 | - idMoneda: function() { return $scope.cobranza.moneda.ID; } | |
| 351 | + cliente: function () { return $scope.cobranza.cliente; }, | |
| 352 | + idMoneda: function () { return $scope.cobranza.moneda.ID; } | |
| 354 | 353 | }, |
| 355 | 354 | size: 'lg' |
| 356 | 355 | } |
| 357 | 356 | ); |
| 358 | 357 | modalInstance.result.then( |
| 359 | - function(cliente) { | |
| 358 | + function (cliente) { | |
| 360 | 359 | $scope.abrirModalDomicilios(cliente); |
| 361 | 360 | $scope.cliente = cliente; |
| 362 | - }, function() {} | |
| 361 | + }, function () { } | |
| 363 | 362 | ); |
| 364 | 363 | }; |
| 365 | 364 | |
| 366 | - $scope.seleccionarCliente = function() { | |
| 365 | + $scope.seleccionarCliente = function () { | |
| 367 | 366 | if ($scope.cobranza.id === undefined) { |
| 368 | - $scope.seleccionarCobrador(function() { | |
| 369 | - var modalInstance = $uibModal.open( | |
| 370 | - { | |
| 371 | - ariaLabelledBy: 'Busqueda de Cliente', | |
| 372 | - templateUrl: 'foca-busqueda-cliente-modal.html', | |
| 373 | - controller: 'focaBusquedaClienteModalController', | |
| 374 | - resolve: { | |
| 375 | - vendedor: function() { return null; }, | |
| 376 | - cobrador: function() { return $scope.cobranza.cobrador; } | |
| 377 | - }, | |
| 378 | - size: 'lg' | |
| 379 | - } | |
| 380 | - ); | |
| 381 | - modalInstance.result.then( | |
| 382 | - function(cliente) { | |
| 383 | - | |
| 384 | - var clienteMayus = { | |
| 385 | - COD: cliente.cod, | |
| 386 | - NOM: cliente.nom, | |
| 387 | - CUIT: cliente.cuit, | |
| 388 | - MAIL: cliente.mail, | |
| 389 | - DOM: cliente.DOM, | |
| 390 | - LOC: cliente.LOC, | |
| 391 | - PCI: cliente.PCI | |
| 392 | - }; | |
| 393 | - console.log(clienteMayus); | |
| 394 | - $scope.$broadcast('addCabecera', { | |
| 395 | - label: 'Cliente:', | |
| 396 | - valor: $filter('rellenarDigitos')(clienteMayus.COD, 5) + ' - ' + | |
| 397 | - clienteMayus.NOM | |
| 398 | - }); | |
| 399 | - | |
| 400 | - $filter('filter')($scope.botonera, | |
| 401 | - { label: 'Cliente'})[0].checked = true; | |
| 402 | - | |
| 403 | - $scope.cobranza.cliente = clienteMayus; | |
| 404 | - $scope.cobranza.facturas = []; | |
| 405 | - }, function() { | |
| 406 | - if (APP !== 'cobranza') $scope.seleccionarCliente(); | |
| 407 | - } | |
| 408 | - ); | |
| 409 | - }); | |
| 410 | - } else { | |
| 411 | - focaModalService.alert('Esta cobranza no se puede editar'); | |
| 412 | - return; | |
| 413 | - } | |
| 414 | - }; | |
| 367 | + var modalInstance = $uibModal.open( | |
| 368 | + { | |
| 369 | + ariaLabelledBy: 'Busqueda de Cliente', | |
| 370 | + templateUrl: 'foca-busqueda-cliente-modal.html', | |
| 371 | + controller: 'focaBusquedaClienteModalController', | |
| 372 | + resolve: { | |
| 373 | + vendedor: function () { return null; }, | |
| 374 | + cobrador: function () { return null; } | |
| 375 | + }, | |
| 376 | + size: 'lg' | |
| 377 | + } | |
| 378 | + ); | |
| 379 | + modalInstance.result.then( | |
| 380 | + function (cliente) { | |
| 381 | + //ELIMINO CLIENTE | |
| 382 | + $scope.$broadcast('removeCabecera', 'Cliente:'); | |
| 383 | + $scope.cobranza.cliente = {}; | |
| 384 | + | |
| 385 | + var clienteMayus = { | |
| 386 | + COD: cliente.cod, | |
| 387 | + NOM: cliente.nom, | |
| 388 | + CUIT: cliente.cuit, | |
| 389 | + MAIL: cliente.mail, | |
| 390 | + DOM: cliente.DOM, | |
| 391 | + LOC: cliente.LOC, | |
| 392 | + PCI: cliente.PCI, | |
| 393 | + idCobrador: cliente.idCobrador, | |
| 394 | + cobrador: cliente.cobrador | |
| 395 | + }; | |
| 396 | + $scope.$broadcast('addCabecera', { | |
| 397 | + label: 'Cobrador:', | |
| 398 | + valor: $filter('rellenarDigitos')(clienteMayus.cobrador.NUM, 3) + | |
| 399 | + ' - ' + clienteMayus.cobrador.NOM | |
| 400 | + }); | |
| 401 | + $scope.cobranza.cobrador = clienteMayus.cobrador; | |
| 415 | 402 | |
| 416 | - $scope.seleccionarCobrador = function(callback) { | |
| 403 | + $scope.$broadcast('addCabecera', { | |
| 404 | + label: 'Cliente:', | |
| 405 | + valor: $filter('rellenarDigitos')(clienteMayus.COD, 5) + ' - ' + | |
| 406 | + clienteMayus.NOM | |
| 407 | + }); | |
| 417 | 408 | |
| 418 | - if (APP === 'cobranza') { | |
| 419 | - callback(); | |
| 420 | - return; | |
| 421 | - } | |
| 409 | + $filter('filter')($scope.botonera, | |
| 410 | + { label: 'Cliente' })[0].checked = true; | |
| 422 | 411 | |
| 423 | - var parametrosModal = { | |
| 424 | - query: '/cobrador', | |
| 425 | - columnas: [ | |
| 426 | - { | |
| 427 | - propiedad: 'NUM', | |
| 428 | - nombre: 'Codigo', | |
| 429 | - filtro: { | |
| 430 | - nombre: 'rellenarDigitos', | |
| 431 | - parametro: 3 | |
| 432 | - } | |
| 433 | - }, | |
| 434 | - { | |
| 435 | - propiedad: 'NOM', | |
| 436 | - nombre: 'Nombre' | |
| 412 | + $scope.cobranza.cliente = clienteMayus; | |
| 413 | + $scope.cobranza.facturas = []; | |
| 414 | + focaCrearCobranzaService | |
| 415 | + .getCobradorById($scope.cobranza.cliente.idCobrador); | |
| 416 | + }, function () { | |
| 437 | 417 | } |
| 438 | - ], | |
| 439 | - titulo:'Búsqueda de cobradores' | |
| 440 | - }; | |
| 441 | - focaModalService.modal(parametrosModal).then( | |
| 442 | - function(cobrador) { | |
| 443 | - $scope.$broadcast('addCabecera', { | |
| 444 | - label: 'Cobrador:', | |
| 445 | - valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + | |
| 446 | - cobrador.NOM | |
| 447 | - }); | |
| 448 | - $scope.cobranza.cobrador = cobrador; | |
| 449 | - | |
| 450 | - //ELIMINO CLIENTE | |
| 451 | - $scope.$broadcast('removeCabecera', 'Cliente:'); | |
| 452 | - $scope.cobranza.cliente = {}; | |
| 453 | - | |
| 454 | - callback(); | |
| 455 | - }, function() {} | |
| 456 | - ); | |
| 418 | + ); | |
| 419 | + } else { | |
| 420 | + focaModalService.alert('Esta cobranza no se puede editar'); | |
| 421 | + return; | |
| 422 | + } | |
| 457 | 423 | }; |
| 458 | 424 | |
| 459 | - $scope.seleccionarFactura = function() { | |
| 425 | + $scope.seleccionarFactura = function () { | |
| 460 | 426 | if ($scope.cobranza.id === undefined) { |
| 461 | 427 | if (!$scope.cobranza.cliente.COD) { |
| 462 | 428 | focaModalService.alert('Seleccione primero un cliente'); |
| ... | ... | @@ -469,7 +435,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 469 | 435 | controller: 'focaModalFacturaController', |
| 470 | 436 | size: 'lg', |
| 471 | 437 | resolve: { |
| 472 | - parametrosFactura: function() { | |
| 438 | + parametrosFactura: function () { | |
| 473 | 439 | return { |
| 474 | 440 | cliente: $scope.cobranza.cliente, |
| 475 | 441 | simbolo: $scope.cobranza.moneda.SIMBOLO, |
| ... | ... | @@ -481,19 +447,20 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 481 | 447 | } |
| 482 | 448 | ); |
| 483 | 449 | modalInstance.result.then( |
| 484 | - function(facturas) { | |
| 450 | + function (facturas) { | |
| 485 | 451 | var facturasResult = []; |
| 486 | 452 | //AGREGO A FACTURASRESULT LAS FACTURAS QUE NO HAN SIDO SELECCIONADAS |
| 487 | - facturas.forEach(function(factura) { | |
| 488 | - var existe = $scope.cobranza.facturas.filter(function(e) { | |
| 453 | + facturas.forEach(function (factura) { | |
| 454 | + var existe = $scope.cobranza.facturas.filter(function (e) { | |
| 489 | 455 | return angular.equals(factura, e); |
| 490 | 456 | }); |
| 491 | 457 | |
| 492 | 458 | if (!existe.length) facturasResult.push(factura); |
| 493 | 459 | }); |
| 494 | 460 | |
| 495 | - $scope.cobranza.facturas = $scope.cobranza.facturas.concat(facturasResult); | |
| 496 | - }, function() { } | |
| 461 | + $scope.cobranza.facturas = | |
| 462 | + $scope.cobranza.facturas.concat(facturasResult); | |
| 463 | + }, function () { } | |
| 497 | 464 | ); |
| 498 | 465 | } else { |
| 499 | 466 | focaModalService.alert('Esta cobranza no se puede editar'); |
| ... | ... | @@ -502,14 +469,14 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 502 | 469 | |
| 503 | 470 | }; |
| 504 | 471 | |
| 505 | - $scope.seleccionarCheque = function(cheque) { | |
| 472 | + $scope.seleccionarCheque = function (cheque) { | |
| 506 | 473 | if ($scope.cobranza.id === undefined) { |
| 507 | 474 | var parametros; |
| 508 | 475 | |
| 509 | 476 | if (!cheque) { |
| 510 | 477 | parametros = { |
| 511 | 478 | importe: getSugerido(), |
| 512 | - esNuevo : true | |
| 479 | + esNuevo: true | |
| 513 | 480 | }; |
| 514 | 481 | } else { |
| 515 | 482 | parametros = cheque; |
| ... | ... | @@ -523,14 +490,14 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 523 | 490 | controller: 'focaModalChequeController', |
| 524 | 491 | size: 'lg', |
| 525 | 492 | resolve: { |
| 526 | - cheque: function() { | |
| 493 | + cheque: function () { | |
| 527 | 494 | return parametros; |
| 528 | 495 | } |
| 529 | 496 | } |
| 530 | 497 | } |
| 531 | 498 | ); |
| 532 | 499 | modalInstance.result.then( |
| 533 | - function(cheque) { | |
| 500 | + function (cheque) { | |
| 534 | 501 | var cobro = { |
| 535 | 502 | COM: 'ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco, |
| 536 | 503 | numero: cheque.numero, |
| ... | ... | @@ -547,7 +514,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 547 | 514 | TIL: 'EF' |
| 548 | 515 | }; |
| 549 | 516 | pushearCobro(cobro, cheque.$$hashKey); |
| 550 | - }, function() { | |
| 517 | + }, function () { | |
| 551 | 518 | |
| 552 | 519 | } |
| 553 | 520 | ); |
| ... | ... | @@ -558,15 +525,15 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 558 | 525 | |
| 559 | 526 | }; |
| 560 | 527 | |
| 561 | - $scope.seleccionarEfectivo = function() { | |
| 528 | + $scope.seleccionarEfectivo = function () { | |
| 562 | 529 | if ($scope.cobranza.id === undefined) { |
| 563 | 530 | var importe = 0; |
| 564 | - $scope.cobranza.cobros.filter(function(a) { | |
| 531 | + $scope.cobranza.cobros.filter(function (a) { | |
| 565 | 532 | if (a.COM === 'Efectivo') { |
| 566 | 533 | importe = a.IMP; |
| 567 | 534 | } |
| 568 | 535 | }); |
| 569 | - | |
| 536 | + | |
| 570 | 537 | var modalInstance = $uibModal.open( |
| 571 | 538 | { |
| 572 | 539 | ariaLabelledBy: 'Carga de cheques', |
| ... | ... | @@ -574,29 +541,29 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 574 | 541 | controller: 'focaModalEfectivoController', |
| 575 | 542 | size: 'sm', |
| 576 | 543 | resolve: { |
| 577 | - sugerido: function() { | |
| 544 | + sugerido: function () { | |
| 578 | 545 | return parseFloat(getSugerido()) + parseFloat(importe); |
| 579 | 546 | } |
| 580 | 547 | } |
| 581 | 548 | } |
| 582 | 549 | ); |
| 583 | 550 | modalInstance.result.then( |
| 584 | - function(efectivo) { | |
| 585 | - | |
| 551 | + function (efectivo) { | |
| 552 | + | |
| 586 | 553 | var cobro = { |
| 587 | 554 | COM: 'Efectivo', |
| 588 | 555 | FEC: new Date(), |
| 589 | 556 | IMP: efectivo, |
| 590 | 557 | TIL: 'EF' |
| 591 | 558 | }; |
| 592 | - | |
| 593 | - $scope.cobranza.cobros = $scope.cobranza.cobros.filter(function(a) { | |
| 559 | + | |
| 560 | + $scope.cobranza.cobros = $scope.cobranza.cobros.filter(function (a) { | |
| 594 | 561 | return a.COM !== 'Efectivo'; |
| 595 | 562 | }); |
| 596 | - | |
| 563 | + | |
| 597 | 564 | $scope.cobranza.cobros.push(cobro); |
| 598 | - }, function() { | |
| 599 | - | |
| 565 | + }, function () { | |
| 566 | + | |
| 600 | 567 | } |
| 601 | 568 | ); |
| 602 | 569 | } else { |
| ... | ... | @@ -605,10 +572,10 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 605 | 572 | } |
| 606 | 573 | }; |
| 607 | 574 | |
| 608 | - $scope.seleccionarDetalles = function(detalle) { | |
| 575 | + $scope.seleccionarDetalles = function (detalle) { | |
| 609 | 576 | if ($scope.cobranza.id === undefined) { |
| 610 | 577 | var parametro = {}; |
| 611 | - | |
| 578 | + | |
| 612 | 579 | if (!detalle) { |
| 613 | 580 | parametro = { |
| 614 | 581 | importe: getSugerido(), |
| ... | ... | @@ -617,9 +584,9 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 617 | 584 | } else { |
| 618 | 585 | parametro = detalle; |
| 619 | 586 | parametro.importe = detalle.IMP; |
| 620 | - parametro.files= detalle.imgs; | |
| 587 | + parametro.files = detalle.imgs; | |
| 621 | 588 | } |
| 622 | - | |
| 589 | + | |
| 623 | 590 | var modalInstance = $uibModal.open( |
| 624 | 591 | { |
| 625 | 592 | ariaLabelledBy: 'Carga de detalles', |
| ... | ... | @@ -627,15 +594,15 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 627 | 594 | controller: 'focaModalDetallesController', |
| 628 | 595 | size: 'lg', |
| 629 | 596 | resolve: { |
| 630 | - parametros: function() { | |
| 597 | + parametros: function () { | |
| 631 | 598 | return parametro; |
| 632 | 599 | } |
| 633 | 600 | } |
| 634 | 601 | } |
| 635 | 602 | ); |
| 636 | 603 | modalInstance.result.then( |
| 637 | - function(detalles) { | |
| 638 | - | |
| 604 | + function (detalles) { | |
| 605 | + | |
| 639 | 606 | var cobro = { |
| 640 | 607 | COM: 'de(COBRO POR DETALLES)', |
| 641 | 608 | FEC: new Date(), |
| ... | ... | @@ -645,7 +612,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 645 | 612 | observacion: detalles.observacion |
| 646 | 613 | }; |
| 647 | 614 | pushearCobro(cobro, detalles.$$hashKey); |
| 648 | - }, function() {} | |
| 615 | + }, function () { } | |
| 649 | 616 | ); |
| 650 | 617 | } else { |
| 651 | 618 | focaModalService.alert('Esta cobranza no se puede editar'); |
| ... | ... | @@ -653,7 +620,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 653 | 620 | } |
| 654 | 621 | }; |
| 655 | 622 | |
| 656 | - $scope.seleccionarMoneda = function() { | |
| 623 | + $scope.seleccionarMoneda = function () { | |
| 657 | 624 | if ($scope.cobranza.id === undefined) { |
| 658 | 625 | var parametrosModal = { |
| 659 | 626 | titulo: 'Búsqueda de monedas', |
| ... | ... | @@ -671,9 +638,9 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 671 | 638 | size: 'md' |
| 672 | 639 | }; |
| 673 | 640 | focaModalService.modal(parametrosModal).then( |
| 674 | - function(moneda) { | |
| 641 | + function (moneda) { | |
| 675 | 642 | $scope.seleccionarCotizacion(moneda); |
| 676 | - }, function() { | |
| 643 | + }, function () { | |
| 677 | 644 | |
| 678 | 645 | } |
| 679 | 646 | ); |
| ... | ... | @@ -684,18 +651,18 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 684 | 651 | |
| 685 | 652 | }; |
| 686 | 653 | |
| 687 | - $scope.seleccionarCotizacion = function(moneda) { | |
| 654 | + $scope.seleccionarCotizacion = function (moneda) { | |
| 688 | 655 | var modalInstance = $uibModal.open( |
| 689 | 656 | { |
| 690 | 657 | ariaLabelledBy: 'Busqueda de Cotización', |
| 691 | 658 | templateUrl: 'modal-cotizacion.html', |
| 692 | 659 | controller: 'focaModalCotizacionController', |
| 693 | 660 | size: 'lg', |
| 694 | - resolve: {idMoneda: function() {return moneda.ID;}} | |
| 661 | + resolve: { idMoneda: function () { return moneda.ID; } } | |
| 695 | 662 | } |
| 696 | 663 | ); |
| 697 | 664 | modalInstance.result.then( |
| 698 | - function(cotizacion) { | |
| 665 | + function (cotizacion) { | |
| 699 | 666 | $scope.cobranza.moneda = moneda; |
| 700 | 667 | $scope.cobranza.moneda.cotizacion = cotizacion; |
| 701 | 668 | if (moneda.DETALLE === 'PESOS ARGENTINOS') { |
| ... | ... | @@ -717,17 +684,17 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 717 | 684 | }); |
| 718 | 685 | } |
| 719 | 686 | |
| 720 | - $filter('filter')( $scope.botonera, { | |
| 687 | + $filter('filter')($scope.botonera, { | |
| 721 | 688 | label: 'Moneda' |
| 722 | 689 | })[0].checked = true; |
| 723 | 690 | |
| 724 | - }, function() { | |
| 691 | + }, function () { | |
| 725 | 692 | |
| 726 | 693 | } |
| 727 | 694 | ); |
| 728 | 695 | }; |
| 729 | 696 | |
| 730 | - $scope.getTotalDeuda = function() { | |
| 697 | + $scope.getTotalDeuda = function () { | |
| 731 | 698 | var total = 0; |
| 732 | 699 | for (var i = 0; i < $scope.cobranza.facturas.length; i++) { |
| 733 | 700 | total += $scope.cobranza.facturas[i].IMP || $scope.cobranza.facturas[i].IPA; |
| ... | ... | @@ -735,7 +702,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 735 | 702 | return parseFloat(total.toFixed(2)); |
| 736 | 703 | }; |
| 737 | 704 | |
| 738 | - $scope.getTotalCobrado = function() { | |
| 705 | + $scope.getTotalCobrado = function () { | |
| 739 | 706 | var total = 0; |
| 740 | 707 | for (var i = 0; i < $scope.cobranza.cobros.length; i++) { |
| 741 | 708 | total += $scope.cobranza.cobros[i].IMP; |
| ... | ... | @@ -743,37 +710,37 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 743 | 710 | return parseFloat(total.toFixed(2)); |
| 744 | 711 | }; |
| 745 | 712 | |
| 746 | - $scope.getSubTotal = function() { | |
| 713 | + $scope.getSubTotal = function () { | |
| 747 | 714 | if ($scope.articuloACargar) { |
| 748 | 715 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 749 | 716 | } |
| 750 | 717 | }; |
| 751 | 718 | //Recibe aviso si el teclado está en uso |
| 752 | 719 | // $rootScope.$on('usarTeclado', function(event, data) { |
| 753 | - // if(data) { | |
| 754 | - // $scope.mostrarTeclado = true; | |
| 755 | - // return; | |
| 756 | - // } | |
| 757 | - // $scope.mostrarTeclado = false; | |
| 720 | + // if(data) { | |
| 721 | + // $scope.mostrarTeclado = true; | |
| 722 | + // return; | |
| 723 | + // } | |
| 724 | + // $scope.mostrarTeclado = false; | |
| 758 | 725 | // }) |
| 759 | - $scope.selectFocus = function($event) { | |
| 726 | + $scope.selectFocus = function ($event) { | |
| 760 | 727 | //Si el teclado esta en uso no selecciona el valor |
| 761 | 728 | // if($scope.mostrarTeclado) { |
| 762 | - // return; | |
| 729 | + // return; | |
| 763 | 730 | // } |
| 764 | 731 | $event.target.select(); |
| 765 | 732 | }; |
| 766 | 733 | |
| 767 | - $scope.salir = function() { | |
| 734 | + $scope.salir = function () { | |
| 768 | 735 | $location.path('/'); |
| 769 | 736 | }; |
| 770 | 737 | |
| 771 | - $scope.parsearATexto = function(articulo) { | |
| 738 | + $scope.parsearATexto = function (articulo) { | |
| 772 | 739 | articulo.cantidad = parseFloat(articulo.cantidad); |
| 773 | 740 | articulo.precio = parseFloat(articulo.precio); |
| 774 | 741 | }; |
| 775 | 742 | |
| 776 | - $scope.quitarFactura = function(key) { | |
| 743 | + $scope.quitarFactura = function (key) { | |
| 777 | 744 | if ($scope.cobranza.id === undefined) { |
| 778 | 745 | $scope.cobranza.facturas.splice(key, 1); |
| 779 | 746 | } else { |
| ... | ... | @@ -782,7 +749,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 782 | 749 | } |
| 783 | 750 | }; |
| 784 | 751 | |
| 785 | - $scope.quitarCobro = function(key) { | |
| 752 | + $scope.quitarCobro = function (key) { | |
| 786 | 753 | if ($scope.cobranza.id === undefined) { |
| 787 | 754 | $scope.cobranza.cobros.splice(key, 1); |
| 788 | 755 | } else { |
| ... | ... | @@ -791,35 +758,35 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 791 | 758 | } |
| 792 | 759 | }; |
| 793 | 760 | |
| 794 | - $scope.editarCobro = function(cobro) { | |
| 795 | - if(cobro.COM === 'Efectivo') { | |
| 761 | + $scope.editarCobro = function (cobro) { | |
| 762 | + if (cobro.COM === 'Efectivo') { | |
| 796 | 763 | $scope.seleccionarEfectivo(); |
| 797 | - } else if(cobro.COM.substring(0, 2) === 'de') { | |
| 764 | + } else if (cobro.COM.substring(0, 2) === 'de') { | |
| 798 | 765 | $scope.seleccionarDetalles(cobro); |
| 799 | - } else if(cobro.COM.substring(0, 2) === 'ch') { | |
| 766 | + } else if (cobro.COM.substring(0, 2) === 'ch') { | |
| 800 | 767 | $scope.seleccionarCheque(cobro); |
| 801 | 768 | } |
| 802 | 769 | }; |
| 803 | 770 | |
| 804 | - $scope.$watch('cobranza.facturas', function() { | |
| 771 | + $scope.$watch('cobranza.facturas', function () { | |
| 805 | 772 | if ($scope.cobranza.facturas.length) { |
| 806 | - $filter('filter')( $scope.botonera, { | |
| 773 | + $filter('filter')($scope.botonera, { | |
| 807 | 774 | label: 'Comprobantes' |
| 808 | 775 | })[0].checked = true; |
| 809 | 776 | } else { |
| 810 | - $filter('filter')( $scope.botonera, { | |
| 777 | + $filter('filter')($scope.botonera, { | |
| 811 | 778 | label: 'Comprobantes' |
| 812 | 779 | })[0].checked = false; |
| 813 | 780 | } |
| 814 | 781 | }, true); |
| 815 | 782 | |
| 816 | - $scope.$watch('cobranza.cobros', function() { | |
| 783 | + $scope.$watch('cobranza.cobros', function () { | |
| 817 | 784 | if ($scope.cobranza.cobros.length) { |
| 818 | - $filter('filter')( $scope.botonera, { | |
| 785 | + $filter('filter')($scope.botonera, { | |
| 819 | 786 | label: 'Cobros' |
| 820 | 787 | })[0].checked = true; |
| 821 | 788 | } else { |
| 822 | - $filter('filter')( $scope.botonera, { | |
| 789 | + $filter('filter')($scope.botonera, { | |
| 823 | 790 | label: 'Cobros' |
| 824 | 791 | })[0].checked = false; |
| 825 | 792 | } |
| ... | ... | @@ -828,8 +795,8 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 828 | 795 | function pushearCobro(cobro, hashKey) { |
| 829 | 796 | var existe; |
| 830 | 797 | |
| 831 | - $scope.cobranza.cobros.forEach(function(c, idx) { | |
| 832 | - if(c.$$hashKey === hashKey) { | |
| 798 | + $scope.cobranza.cobros.forEach(function (c, idx) { | |
| 799 | + if (c.$$hashKey === hashKey) { | |
| 833 | 800 | $scope.cobranza.cobros[idx] = cobro; |
| 834 | 801 | existe = true; |
| 835 | 802 | } |
| ... | ... | @@ -849,7 +816,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 849 | 816 | if (confirmacion) { |
| 850 | 817 | focaModalService.confirm( |
| 851 | 818 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
| 852 | - ).then(function(data) { | |
| 819 | + ).then(function (data) { | |
| 853 | 820 | if (data) { |
| 854 | 821 | $location.path('/'); |
| 855 | 822 | } |
| ... | ... | @@ -870,7 +837,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 870 | 837 | cobranza.cliente.NOM |
| 871 | 838 | }); |
| 872 | 839 | |
| 873 | - $filter('filter')( $scope.botonera, { | |
| 840 | + $filter('filter')($scope.botonera, { | |
| 874 | 841 | label: 'Cliente' |
| 875 | 842 | })[0].checked = true; |
| 876 | 843 | } |
| ... | ... | @@ -886,7 +853,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 886 | 853 | |
| 887 | 854 | // TODO: Setear moneda |
| 888 | 855 | if (cobranza.moneda) { |
| 889 | - $filter('filter')( $scope.botonera, { | |
| 856 | + $filter('filter')($scope.botonera, { | |
| 890 | 857 | label: 'Moneda' |
| 891 | 858 | })[0].checked = true; |
| 892 | 859 | } |