Commit 17de1e938ff26ef8f7dcfba5cf4049cf69f5f441
Exists in
master
Merge branch 'master' into 'master'
Master(efernandez) See merge request !55
Showing
8 changed files
Show diff stats
gulpfile.js
| 1 | const templateCache = require('gulp-angular-templatecache'); | 1 | const templateCache = require('gulp-angular-templatecache'); |
| 2 | const clean = require('gulp-clean'); | 2 | const clean = require('gulp-clean'); |
| 3 | const concat = require('gulp-concat'); | 3 | const concat = require('gulp-concat'); |
| 4 | const htmlmin = require('gulp-htmlmin'); | 4 | const htmlmin = require('gulp-htmlmin'); |
| 5 | const rename = require('gulp-rename'); | 5 | const rename = require('gulp-rename'); |
| 6 | const uglify = require('gulp-uglify'); | 6 | const uglify = require('gulp-uglify'); |
| 7 | const gulp = require('gulp'); | 7 | const gulp = require('gulp'); |
| 8 | const pump = require('pump'); | 8 | const pump = require('pump'); |
| 9 | const jshint = require('gulp-jshint'); | 9 | const jshint = require('gulp-jshint'); |
| 10 | const replace = require('gulp-replace'); | 10 | const replace = require('gulp-replace'); |
| 11 | const connect = require('gulp-connect'); | 11 | const connect = require('gulp-connect'); |
| 12 | 12 | ||
| 13 | var paths = { | 13 | var paths = { |
| 14 | srcJS: 'src/js/*.js', | 14 | srcJS: 'src/js/*.js', |
| 15 | srcViews: 'src/views/*.html', | 15 | srcViews: 'src/views/*.html', |
| 16 | specs: 'spec/*.js', | ||
| 16 | tmp: 'tmp', | 17 | tmp: 'tmp', |
| 17 | dist: 'dist/' | 18 | dist: 'dist/' |
| 18 | }; | 19 | }; |
| 19 | 20 | ||
| 20 | gulp.task('templates', ['clean'], function() { | 21 | gulp.task('templates', ['clean'], function() { |
| 21 | return pump( | 22 | return pump( |
| 22 | [ | 23 | [ |
| 23 | gulp.src(paths.srcViews), | 24 | gulp.src(paths.srcViews), |
| 24 | htmlmin(), | 25 | htmlmin(), |
| 25 | templateCache('views.js', { | 26 | templateCache('views.js', { |
| 26 | module: 'focaCrearCobranza', | 27 | module: 'focaCrearCobranza', |
| 27 | root: '' | 28 | root: '' |
| 28 | }), | 29 | }), |
| 29 | gulp.dest(paths.tmp) | 30 | gulp.dest(paths.tmp) |
| 30 | ] | 31 | ] |
| 31 | ); | 32 | ); |
| 32 | }); | 33 | }); |
| 33 | 34 | ||
| 34 | gulp.task('uglify', ['templates'], function() { | 35 | gulp.task('uglify', ['templates'], function() { |
| 35 | return pump( | 36 | return pump( |
| 36 | [ | 37 | [ |
| 37 | gulp.src([ | 38 | gulp.src([ |
| 38 | paths.srcJS, | 39 | paths.srcJS, |
| 39 | 'tmp/views.js' | 40 | 'tmp/views.js' |
| 40 | ]), | 41 | ]), |
| 41 | concat('foca-crear-cobranza.js'), | 42 | concat('foca-crear-cobranza.js'), |
| 42 | replace('src/views/', ''), | 43 | replace('src/views/', ''), |
| 43 | gulp.dest(paths.tmp), | 44 | gulp.dest(paths.tmp), |
| 44 | rename('foca-crear-cobranza.min.js'), | 45 | rename('foca-crear-cobranza.min.js'), |
| 45 | uglify(), | 46 | uglify(), |
| 46 | gulp.dest(paths.dist) | 47 | gulp.dest(paths.dist) |
| 47 | 48 | ||
| 48 | ] | 49 | ] |
| 49 | ); | 50 | ); |
| 50 | }); | 51 | }); |
| 51 | 52 | ||
| 52 | gulp.task('clean', function() { | 53 | gulp.task('clean', function() { |
| 53 | return gulp.src(['tmp', 'dist'], {read: false}) | 54 | return gulp.src(['tmp', 'dist'], {read: false}) |
| 54 | .pipe(clean()); | 55 | .pipe(clean()); |
| 55 | }); | 56 | }); |
| 56 | 57 | ||
| 57 | gulp.task('pre-commit', function() { | 58 | gulp.task('pre-commit', function() { |
| 58 | return pump( | 59 | return pump( |
| 59 | [ | 60 | [ |
| 60 | gulp.src(paths.srcJS), | 61 | gulp.src([paths.srcJS, paths.specs]), |
| 61 | jshint('.jshintrc'), | 62 | jshint('.jshintrc'), |
| 62 | jshint.reporter('default'), | 63 | jshint.reporter('default'), |
| 63 | jshint.reporter('fail') | 64 | jshint.reporter('fail') |
| 64 | ] | 65 | ] |
| 65 | ); | 66 | ); |
| 66 | 67 | ||
| 67 | gulp.start('uglify'); | 68 | gulp.start('uglify'); |
| 68 | }); | 69 | }); |
| 69 | 70 | ||
| 70 | gulp.task('webserver', function() { | 71 | gulp.task('webserver', function() { |
| 71 | pump [ | 72 | pump [ |
| 72 | connect.server({port: 3300, host: '0.0.0.0'}) | 73 | connect.server({port: 3300, host: '0.0.0.0'}) |
| 73 | ] | 74 | ] |
| 74 | }); | 75 | }); |
| 75 | 76 | ||
| 76 | gulp.task('clean-post-install', function() { | 77 | gulp.task('clean-post-install', function() { |
| 77 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 78 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
| 78 | 'index.html'], {read: false}) | 79 | 'index.html'], {read: false}) |
| 79 | .pipe(clean()); | 80 | .pipe(clean()); |
| 80 | }); | 81 | }); |
| 81 | 82 | ||
| 82 | gulp.task('default', ['webserver']); | 83 | gulp.task('default', ['webserver']); |
| 83 | 84 | ||
| 84 | gulp.task('watch', function() { | 85 | gulp.task('watch', function() { |
| 85 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | 86 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); |
| 86 | }); | 87 | }); |
| 87 | 88 |
package.json
| 1 | { | 1 | { |
| 2 | "name": "foca-crear-cobranza", | 2 | "name": "foca-crear-cobranza", |
| 3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
| 4 | "description": "sistema de cobranzas a partir de facturas", | 4 | "description": "sistema de cobranzas a partir de facturas", |
| 5 | "main": "index.js", | 5 | "main": "index.js", |
| 6 | "scripts": { | 6 | "scripts": { |
| 7 | "test": "echo \"Error: no test specified\" && exit 1", | 7 | "test": "test.html", |
| 8 | "compile": "gulp uglify", | 8 | "compile": "gulp uglify", |
| 9 | "gulp-pre-commit": "gulp pre-commit", | 9 | "gulp-pre-commit": "gulp pre-commit", |
| 10 | "postinstall": "npm run compile && gulp clean-post-install", | 10 | "postinstall": "npm run compile && gulp clean-post-install", |
| 11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-factura.git git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git git+http://git.focasoftware.com/npm/foca-directivas.git" | 11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-factura.git git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git git+http://git.focasoftware.com/npm/foca-directivas.git" |
| 12 | }, | 12 | }, |
| 13 | "pre-commit": [ | 13 | "pre-commit": [ |
| 14 | "gulp-pre-commit" | 14 | "gulp-pre-commit" |
| 15 | ], | 15 | ], |
| 16 | "repository": { | 16 | "repository": { |
| 17 | "type": "git", | 17 | "type": "git", |
| 18 | "url": "http://git.focasoftware.com/npm/foca-crear-cobranza.git" | 18 | "url": "http://git.focasoftware.com/npm/foca-crear-cobranza.git" |
| 19 | }, | 19 | }, |
| 20 | "author": "Foca Software", | 20 | "author": "Foca Software", |
| 21 | "license": "ISC", | 21 | "license": "ISC", |
| 22 | "devDependencies": { | 22 | "devDependencies": { |
| 23 | "angular": "^1.7.5", | 23 | "angular": "^1.7.5", |
| 24 | "angular-ladda": "^0.4.3", | 24 | "angular-ladda": "^0.4.3", |
| 25 | "angular-mocks": "^1.7.7", | ||
| 25 | "angular-route": "^1.7.5", | 26 | "angular-route": "^1.7.5", |
| 26 | "bootstrap": "^4.1.3", | 27 | "bootstrap": "^4.1.3", |
| 27 | "foca-botonera-facturador": "git+http://git.focasoftware.com/npm/foca-botonera-facturador.git", | 28 | "foca-botonera-facturador": "git+http://git.focasoftware.com/npm/foca-botonera-facturador.git", |
| 28 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", | 29 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", |
| 29 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 30 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
| 30 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", | 31 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", |
| 31 | "foca-modal-factura": "git+http://git.focasoftware.com/npm/foca-modal-factura.git", | 32 | "foca-modal-factura": "git+http://git.focasoftware.com/npm/foca-modal-factura.git", |
| 32 | "font-awesome": "^4.7.0", | 33 | "font-awesome": "^4.7.0", |
| 33 | "gulp": "^3.9.1", | 34 | "gulp": "^3.9.1", |
| 34 | "gulp-angular-templatecache": "^2.2.5", | 35 | "gulp-angular-templatecache": "^2.2.5", |
| 35 | "gulp-clean": "^0.4.0", | 36 | "gulp-clean": "^0.4.0", |
| 36 | "gulp-concat": "^2.6.1", | 37 | "gulp-concat": "^2.6.1", |
| 37 | "gulp-connect": "^5.6.1", | 38 | "gulp-connect": "^5.6.1", |
| 38 | "gulp-htmlmin": "^5.0.1", | 39 | "gulp-htmlmin": "^5.0.1", |
| 39 | "gulp-jshint": "^2.1.0", | 40 | "gulp-jshint": "^2.1.0", |
| 40 | "gulp-rename": "^1.4.0", | 41 | "gulp-rename": "^1.4.0", |
| 41 | "gulp-replace": "^1.0.0", | 42 | "gulp-replace": "^1.0.0", |
| 42 | "gulp-sequence": "^1.0.0", | 43 | "gulp-sequence": "^1.0.0", |
| 43 | "gulp-uglify": "^3.0.1", | 44 | "gulp-uglify": "^3.0.1", |
| 44 | "gulp-uglify-es": "^1.0.4", | 45 | "gulp-uglify-es": "^1.0.4", |
| 45 | "jasmine-core": "^3.3.0", | 46 | "jasmine-core": "^3.3.0", |
| 46 | "jquery": "^3.3.1", | 47 | "jquery": "^3.3.1", |
| 47 | "jshint": "^2.9.6", | 48 | "jshint": "^2.9.6", |
| 48 | "ladda": "1.0.6", | 49 | "ladda": "1.0.6", |
| 49 | "pre-commit": "^1.2.2", | 50 | "pre-commit": "^1.2.2", |
| 50 | "pump": "^3.0.0", | 51 | "pump": "^3.0.0", |
| 51 | "ui-bootstrap4": "^3.0.5" | 52 | "ui-bootstrap4": "^3.0.5" |
| 52 | } | 53 | } |
| 53 | } | 54 | } |
| 54 | 55 |
spec/controllerSpec.js
spec/routeSpec.js
| File was created | 1 | describe('rutas del módulo crear cobranza', function() { | |
| 2 | |||
| 3 | var route; | ||
| 4 | |||
| 5 | beforeEach(function() { | ||
| 6 | |||
| 7 | module('focaCrearCobranza'); | ||
| 8 | inject(function($route) { | ||
| 9 | route = $route; | ||
| 10 | }); | ||
| 11 | }); | ||
| 12 | |||
| 13 | it('route /cobranza/crear lleva a ctrl y template correcto', function() { | ||
| 14 | |||
| 15 | //assert | ||
| 16 | expect(route.routes['/cobranza/crear'].controller).toBe('cobranzaController'); | ||
| 17 | expect(route.routes['/cobranza/crear'].templateUrl).toBe('src/views/cobranza.html'); | ||
| 18 | }); | ||
| 19 | }); | ||
| 20 |
spec/serviceSpec.js
| File was created | 1 | describe('Servicios módulo crear cobranza', function() { | |
| 2 | |||
| 3 | beforeEach(function() { | ||
| 4 | |||
| 5 | module('focaCrearCobranza'); | ||
| 6 | |||
| 7 | inject(module(function($provide) { | ||
| 8 | $provide.value('API_ENDPOINT', { | ||
| 9 | URL: 'localhost' | ||
| 10 | }); | ||
| 11 | })); | ||
| 12 | }); | ||
| 13 | |||
| 14 | describe('servicio focaCrearCobranzaService', function() { | ||
| 15 | |||
| 16 | var servicio; | ||
| 17 | var httpBackend; | ||
| 18 | |||
| 19 | beforeEach(function() { | ||
| 20 | inject(function($httpBackend, _focaCrearCobranzaService_) { | ||
| 21 | httpBackend = $httpBackend; | ||
| 22 | servicio = _focaCrearCobranzaService_; | ||
| 23 | }); | ||
| 24 | }); | ||
| 25 | |||
| 26 | it('existe el servicio focaCrearCobranzaService', function() { | ||
| 27 | |||
| 28 | //assert | ||
| 29 | expect(typeof servicio).toEqual('object'); | ||
| 30 | }); | ||
| 31 | |||
| 32 | it('getNumeroRecibo llama a ruta correcta', function() { | ||
| 33 | |||
| 34 | //arrange | ||
| 35 | var responseFake = 'responseFake'; | ||
| 36 | var result; | ||
| 37 | |||
| 38 | httpBackend.expectGET('localhost/recibo/numero-siguiente').respond(responseFake); | ||
| 39 | |||
| 40 | //act | ||
| 41 | servicio.getNumeroRecibo().then(function(data) { | ||
| 42 | result = data.data; | ||
| 43 | }); | ||
| 44 | httpBackend.flush(); | ||
| 45 | |||
| 46 | //assert | ||
| 47 | expect(result).toEqual(responseFake); | ||
| 48 | }); | ||
| 49 | |||
| 50 | it('getCotizacionByIdMoneda llama a ruta correcta', function() { | ||
| 51 | |||
| 52 | //arrange | ||
| 53 | var responseFake = 'responseFake'; | ||
| 54 | var result; | ||
| 55 | var paramFake = 1; | ||
| 56 | |||
| 57 | httpBackend.expectGET('localhost/moneda/' + paramFake).respond(responseFake); | ||
| 58 | |||
| 59 | //act | ||
| 60 | servicio.getCotizacionByIdMoneda(paramFake).then(function(data) { | ||
| 61 | result = data.data; | ||
| 62 | }); | ||
| 63 | httpBackend.flush(); | ||
| 64 | |||
| 65 | //assert | ||
| 66 | expect(result).toEqual(responseFake); | ||
| 67 | }); | ||
| 68 | |||
| 69 | it('guardarCobranza llama a ruta correcta', function() { | ||
| 70 | |||
| 71 | //arrange | ||
| 72 | var responseFake = 'responseFake'; | ||
| 73 | var result; | ||
| 74 | var paramFake = 1; | ||
| 75 | |||
| 76 | httpBackend.expectPOST('localhost/recibo/guardar', paramFake).respond(responseFake); | ||
| 77 | |||
| 78 | //act | ||
| 79 | servicio.guardarCobranza(paramFake).then(function(data) { | ||
| 80 | result = data.data; | ||
| 81 | }); | ||
| 82 | httpBackend.flush(); | ||
| 83 | |||
| 84 | //assert | ||
| 85 | expect(result).toEqual(responseFake); | ||
| 86 | }); | ||
| 87 | |||
| 88 | it('getCobradorById llama a ruta correcta', function() { | ||
| 89 | |||
| 90 | //arrange | ||
| 91 | var responseFake = 'responseFake'; | ||
| 92 | var result; | ||
| 93 | var paramFake = 1; | ||
| 94 | |||
| 95 | httpBackend.expectGET('localhost/vendedor-cobrador/' + paramFake).respond(responseFake); | ||
| 96 | |||
| 97 | //act | ||
| 98 | servicio.getCobradorById(paramFake).then(function(data) { | ||
| 99 | result = data.data; | ||
| 100 | }); | ||
| 101 | httpBackend.flush(); | ||
| 102 | |||
| 103 | //assert | ||
| 104 | expect(result).toEqual(responseFake); | ||
| 105 | }); | ||
| 106 | |||
| 107 | it('enviarComprobantePorMail llama a ruta correcta', function() { | ||
| 108 | |||
| 109 | //arrange | ||
| 110 | var responseFake = 'responseFake'; | ||
| 111 | var result; | ||
| 112 | var paramFake = 1; | ||
| 113 | |||
| 114 | httpBackend.expectPOST('localhost/mail/comprobante', | ||
| 115 | {receiver: paramFake}).respond(responseFake); | ||
| 116 | |||
| 117 | //act | ||
| 118 | servicio.enviarComprobantePorMail(paramFake).then(function(data) { | ||
| 119 | result = data.data; | ||
| 120 | }); | ||
| 121 | httpBackend.flush(); | ||
| 122 | |||
| 123 | //assert | ||
| 124 | expect(result).toEqual(responseFake); | ||
| 125 | }); | ||
| 126 | |||
| 127 | it('actualizarEmail llama a ruta correcta', function() { | ||
| 128 | |||
| 129 | //arrange | ||
| 130 | var responseFake = 'responseFake'; | ||
| 131 | var result; | ||
| 132 | var paramFake = 1; | ||
| 133 | |||
| 134 | httpBackend.expectPOST('localhost/cliente/update/email', | ||
| 135 | {mail: paramFake}).respond(responseFake); | ||
| 136 | |||
| 137 | //act | ||
| 138 | servicio.actualizarEmail(paramFake).then(function(data) { | ||
| 139 | result = data.data; | ||
| 140 | }); | ||
| 141 | httpBackend.flush(); | ||
| 142 | |||
| 143 | //assert | ||
| 144 | expect(result).toEqual(responseFake); | ||
| 145 | }); | ||
| 146 | }); | ||
| 147 | |||
| 148 | }); |
src/js/app.js
| 1 | angular.module('focaCrearCobranza', []); | 1 | angular.module('focaCrearCobranza', ['ngRoute']); |
| 2 | 2 |
src/js/controller.js
| 1 | angular.module('focaCrearCobranza') .controller('cobranzaController', | 1 | angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 2 | [ | 2 | [ |
| 3 | '$scope', '$timeout', '$uibModal', '$location', | 3 | '$scope', '$timeout', '$uibModal', '$location', |
| 4 | 'focaCrearCobranzaService', 'focaModalService', '$filter', 'focaSeguimientoService', | 4 | 'focaCrearCobranzaService', 'focaModalService', '$filter', 'focaSeguimientoService', |
| 5 | 'focaBotoneraLateralService', 'APP', 'focaLoginService', | 5 | 'focaBotoneraLateralService', 'APP', 'focaLoginService', |
| 6 | function($scope, $timeout, $uibModal, $location, focaCrearCobranzaService, | 6 | function($scope, $timeout, $uibModal, $location, focaCrearCobranzaService, |
| 7 | focaModalService, $filter, focaSeguimientoService, focaBotoneraLateralService, | 7 | focaModalService, $filter, focaSeguimientoService, focaBotoneraLateralService, |
| 8 | APP, loginService) | 8 | APP, loginService) |
| 9 | { | 9 | { |
| 10 | config(); | 10 | config(); |
| 11 | 11 | ||
| 12 | function config() { | 12 | function config() { |
| 13 | $scope.datepickerAbierto = false; | 13 | $scope.datepickerAbierto = false; |
| 14 | $scope.cobroDeuda = true; | 14 | $scope.cobroDeuda = true; |
| 15 | $scope.show = false; | 15 | $scope.show = false; |
| 16 | $scope.cargando = true; | 16 | $scope.cargando = true; |
| 17 | $scope.fecha = new Date(); | 17 | $scope.fecha = new Date(); |
| 18 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); | 18 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
| 19 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); | 19 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
| 20 | 20 | ||
| 21 | $scope.dateOptions = { | 21 | $scope.dateOptions = { |
| 22 | maxDate: new Date(), | 22 | maxDate: new Date(), |
| 23 | minDate: new Date(2010, 0, 1) | 23 | minDate: new Date(2010, 0, 1) |
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | var monedaPorDefecto; | 26 | var monedaPorDefecto; |
| 27 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 27 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
| 28 | focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { | 28 | focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { |
| 29 | monedaPorDefecto = res.data[0]; | 29 | monedaPorDefecto = res.data[0]; |
| 30 | 30 | ||
| 31 | $scope.cobranza.moneda = monedaPorDefecto; | 31 | $scope.cobranza.moneda = monedaPorDefecto; |
| 32 | $scope.inicial.cobranza.moneda = $scope.cobranza.moneda; | 32 | $scope.inicial.cobranza.moneda = $scope.cobranza.moneda; |
| 33 | 33 | ||
| 34 | $scope.cobranza.cotizacion = monedaPorDefecto.cotizaciones[0]; | 34 | $scope.cobranza.cotizacion = monedaPorDefecto.cotizaciones[0]; |
| 35 | $scope.inicial.cobranza.cotizacion = $scope.cobranza.cotizacion; | 35 | $scope.inicial.cobranza.cotizacion = $scope.cobranza.cotizacion; |
| 36 | }); | 36 | }); |
| 37 | 37 | ||
| 38 | $timeout(function() { | 38 | $timeout(function() { |
| 39 | focaBotoneraLateralService.showSalir(false); | 39 | focaBotoneraLateralService.showSalir(false); |
| 40 | focaBotoneraLateralService.showPausar(true); | 40 | focaBotoneraLateralService.showPausar(true); |
| 41 | focaBotoneraLateralService.showGuardar(true, $scope.crearCobranza); | 41 | focaBotoneraLateralService.showGuardar(true, $scope.crearCobranza); |
| 42 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 42 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
| 43 | }); | 43 | }); |
| 44 | 44 | ||
| 45 | if (APP === 'cobranza') { | 45 | if (APP === 'cobranza') { |
| 46 | $scope.idCobrador = loginService.getLoginData().vendedorCobrador; | 46 | $scope.idCobrador = loginService.getLoginData().vendedorCobrador; |
| 47 | $scope.botonera = focaCrearCobranzaService.getBotonera($scope.idCobrador); | 47 | $scope.botonera = focaCrearCobranzaService.getBotonera($scope.idCobrador); |
| 48 | } else { | 48 | } else { |
| 49 | $scope.botonera = focaCrearCobranzaService.getBotonera(); | 49 | $scope.botonera = focaCrearCobranzaService.getBotonera(); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | init(); | 52 | init(); |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | function init() { | 55 | function init() { |
| 56 | $scope.$broadcast('cleanCabecera'); | 56 | $scope.$broadcast('cleanCabecera'); |
| 57 | 57 | ||
| 58 | $scope.cobranza = {}; | 58 | $scope.cobranza = {}; |
| 59 | $scope.facturaTabla = []; | 59 | $scope.facturaTabla = []; |
| 60 | $scope.cobrosTabla = []; | 60 | $scope.cobrosTabla = []; |
| 61 | 61 | ||
| 62 | if (APP === 'cobranza') { | 62 | if (APP === 'cobranza') { |
| 63 | focaCrearCobranzaService.getCobradorById($scope.idCobrador).then( | 63 | focaCrearCobranzaService.getCobradorById($scope.idCobrador).then( |
| 64 | function(res) { | 64 | function(res) { |
| 65 | var cobrador = res.data; | 65 | var cobrador = res.data; |
| 66 | 66 | ||
| 67 | $scope.$broadcast('addCabecera', { | 67 | $scope.$broadcast('addCabecera', { |
| 68 | label: 'Cobrador:', | 68 | label: 'Cobrador:', |
| 69 | valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + | 69 | valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + |
| 70 | cobrador.NOM | 70 | cobrador.NOM |
| 71 | }); | 71 | }); |
| 72 | 72 | ||
| 73 | $scope.cobranza.cobrador = cobrador; | 73 | $scope.cobranza.cobrador = cobrador; |
| 74 | $scope.inicial.cobranza.cobrador = $scope.cobranza.cobrador; | 74 | $scope.inicial.cobranza.cobrador = $scope.cobranza.cobrador; |
| 75 | } | 75 | } |
| 76 | ); | 76 | ); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | $scope.inicial = { | 79 | $scope.inicial = { |
| 80 | cobranza: angular.copy($scope.cobranza), | 80 | cobranza: angular.copy($scope.cobranza), |
| 81 | facturaTabla: angular.copy($scope.facturaTabla), | 81 | facturaTabla: angular.copy($scope.facturaTabla), |
| 82 | cobrosTabla: angular.copy($scope.cobrosTabla) | 82 | cobrosTabla: angular.copy($scope.cobrosTabla) |
| 83 | }; | 83 | }; |
| 84 | 84 | ||
| 85 | focaCrearCobranzaService.getNumeroRecibo().then( | 85 | focaCrearCobranzaService.getNumeroRecibo().then( |
| 86 | function(res) { | 86 | function(res) { |
| 87 | $scope.puntoVenta = $filter('rellenarDigitos')( | 87 | $scope.puntoVenta = $filter('rellenarDigitos')( |
| 88 | res.data.sucursal, 4 | 88 | res.data.sucursal, 4 |
| 89 | ); | 89 | ); |
| 90 | 90 | ||
| 91 | $scope.comprobante = $filter('rellenarDigitos')( | 91 | $scope.comprobante = $filter('rellenarDigitos')( |
| 92 | res.data.numeroRecibo, 8 | 92 | res.data.numeroRecibo, 8 |
| 93 | ); | 93 | ); |
| 94 | }, | 94 | }, |
| 95 | function(err) { | 95 | function(err) { |
| 96 | focaModalService.alert( | 96 | focaModalService.alert( |
| 97 | 'La terminal no esta configurada correctamente' | 97 | 'La terminal no esta configurada correctamente' |
| 98 | ); | 98 | ); |
| 99 | console.info(err); | 99 | console.info(err); |
| 100 | } | 100 | } |
| 101 | ); | 101 | ); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | $scope.crearCobranza = function() { | 104 | $scope.crearCobranza = function() { |
| 105 | if(!$scope.cobranza.cliente) { | 105 | if(!$scope.cobranza.cliente) { |
| 106 | focaModalService.alert('Ingrese Cliente'); | 106 | focaModalService.alert('Ingrese Cliente'); |
| 107 | return; | 107 | return; |
| 108 | } | 108 | } |
| 109 | if(!$scope.cobranza.cobrador) { | 109 | if(!$scope.cobranza.cobrador) { |
| 110 | focaModalService.alert('Ingrese Cobrador'); | 110 | focaModalService.alert('Ingrese Cobrador'); |
| 111 | return; | 111 | return; |
| 112 | } | 112 | } |
| 113 | if($scope.facturaTabla.length < 1) { | 113 | if($scope.facturaTabla.length < 1) { |
| 114 | focaModalService.alert('Ingrese al menos una factura'); | 114 | focaModalService.alert('Ingrese al menos una factura'); |
| 115 | return; | 115 | return; |
| 116 | } | 116 | } |
| 117 | if($scope.getTotalCobrado() + $scope.getTotalDeuda() !== 0) { | 117 | if($scope.getTotalCobrado() + $scope.getTotalDeuda() !== 0) { |
| 118 | focaModalService.alert('La diferencia debe ser ' + | 118 | focaModalService.alert('La diferencia debe ser ' + |
| 119 | $scope.cobranza.moneda.SIMBOLO + '0,00'); | 119 | $scope.cobranza.moneda.SIMBOLO + '0,00'); |
| 120 | return; | 120 | return; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | var cobranza = {}; | 123 | var cobranza = {}; |
| 124 | var cheques = []; | 124 | var cheques = []; |
| 125 | var cuerpos = []; | 125 | var cuerpos = []; |
| 126 | var imgs = []; | 126 | var imgs = []; |
| 127 | var observacion; | 127 | var observacion; |
| 128 | //TODO: habilitar edición | 128 | //TODO: habilitar edición |
| 129 | $scope.editando = false; | 129 | $scope.editando = false; |
| 130 | focaBotoneraLateralService.startGuardar(); | 130 | focaBotoneraLateralService.startGuardar(); |
| 131 | $scope.saveLoading = true; | 131 | $scope.saveLoading = true; |
| 132 | for(var i = 0; i < $scope.facturaTabla.length; i++) { | 132 | for(var i = 0; i < $scope.facturaTabla.length; i++) { |
| 133 | var cuerpoFactura = { | 133 | var cuerpoFactura = { |
| 134 | CYV: 'V', | 134 | CYV: 'V', |
| 135 | TIP: 'C', | 135 | TIP: 'C', |
| 136 | TCO: 'RC', | 136 | TCO: 'RC', |
| 137 | PVE: $scope.puntoVenta, | 137 | PVE: $scope.puntoVenta, |
| 138 | NCO: $scope.comprobante, | 138 | NCO: $scope.comprobante, |
| 139 | LOP: 'L', | 139 | LOP: 'L', |
| 140 | TIL: $scope.facturaTabla[i].TCO, | 140 | TIL: $scope.facturaTabla[i].TCO, |
| 141 | COM: $scope.facturaTabla[i].numeroFactura + '-' + | 141 | COM: $scope.facturaTabla[i].numeroFactura + '-' + |
| 142 | $filter('rellenarDigitos')($scope.facturaTabla[i].NCU,2), | 142 | $filter('rellenarDigitos')($scope.facturaTabla[i].NCU,2), |
| 143 | FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), | 143 | FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), |
| 144 | IMP: Math.abs($scope.facturaTabla[i].IPA), | 144 | IMP: Math.abs($scope.facturaTabla[i].IPA), |
| 145 | RES: 0,//caja de tesorería | 145 | RES: 0,//caja de tesorería |
| 146 | SUBM: 0, | 146 | SUBM: 0, |
| 147 | NCU: $scope.facturaTabla[i].NCU | 147 | NCU: $scope.facturaTabla[i].NCU |
| 148 | }; | 148 | }; |
| 149 | cuerpos.push(cuerpoFactura); | 149 | cuerpos.push(cuerpoFactura); |
| 150 | 150 | ||
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | for (var j = 0; j < $scope.cobrosTabla.length; j++) { | 153 | for (var j = 0; j < $scope.cobrosTabla.length; j++) { |
| 154 | 154 | ||
| 155 | var efectivo = $scope.cobrosTabla[j].tipo === 'Efectivo'; | 155 | var efectivo = $scope.cobrosTabla[j].tipo === 'Efectivo'; |
| 156 | var cuerpoCobros = { | 156 | var cuerpoCobros = { |
| 157 | CYV: 'V', | 157 | CYV: 'V', |
| 158 | TIP: 'C', | 158 | TIP: 'C', |
| 159 | TCO: 'RC', | 159 | TCO: 'RC', |
| 160 | PVE: $scope.puntoVenta, | 160 | PVE: $scope.puntoVenta, |
| 161 | NCO: $scope.comprobante, | 161 | NCO: $scope.comprobante, |
| 162 | LOP: 'P', | 162 | LOP: 'P', |
| 163 | TIL: $scope.cobrosTabla[j].til, | 163 | TIL: $scope.cobrosTabla[j].til, |
| 164 | COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : $scope.cobrosTabla[j].tipo, | 164 | COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : $scope.cobrosTabla[j].tipo, |
| 165 | FEC: !$scope.cobrosTabla[j].fechaPresentacion ? | 165 | FEC: !$scope.cobrosTabla[j].fechaPresentacion ? |
| 166 | $scope.cobrosTabla[j].fecha | 166 | $scope.cobrosTabla[j].fecha |
| 167 | .toISOString().slice(0, 19).replace('T', ' ') : | 167 | .toISOString().slice(0, 19).replace('T', ' ') : |
| 168 | $scope.cobrosTabla[j].fechaPresentacion | 168 | $scope.cobrosTabla[j].fechaPresentacion |
| 169 | .toISOString().slice(0, 19).replace('T', ' '), | 169 | .toISOString().slice(0, 19).replace('T', ' '), |
| 170 | IMP: Math.abs($scope.cobrosTabla[j].importe), | 170 | IMP: Math.abs($scope.cobrosTabla[j].importe), |
| 171 | RES: 0,//caja de tesorería | 171 | RES: 0,//caja de tesorería |
| 172 | SUBM: 0 | 172 | SUBM: 0 |
| 173 | }; | 173 | }; |
| 174 | cuerpos.push(cuerpoCobros); | 174 | cuerpos.push(cuerpoCobros); |
| 175 | 175 | ||
| 176 | if($scope.cobrosTabla[j].observacion) | 176 | if($scope.cobrosTabla[j].observacion) |
| 177 | observacion = $scope.cobrosTabla[j].observacion; | 177 | observacion = $scope.cobrosTabla[j].observacion; |
| 178 | 178 | ||
| 179 | if($scope.cobrosTabla[j].banco) { | 179 | if($scope.cobrosTabla[j].banco) { |
| 180 | var cheque = { | 180 | var cheque = { |
| 181 | BCO: $scope.cobrosTabla[j].banco.ID, | 181 | BCO: $scope.cobrosTabla[j].banco.ID, |
| 182 | NUM: $scope.comprobante, | 182 | NUM: $scope.comprobante, |
| 183 | FEP: $scope.cobrosTabla[j].fechaPresentacion | 183 | FEP: $scope.cobrosTabla[j].fechaPresentacion |
| 184 | .toISOString().slice(0, 19).replace('T', ' '), | 184 | .toISOString().slice(0, 19).replace('T', ' '), |
| 185 | FEE: $scope.cobrosTabla[j].fechaEmision | 185 | FEE: $scope.cobrosTabla[j].fechaEmision |
| 186 | .toISOString().slice(0, 19).replace('T', ' '), | 186 | .toISOString().slice(0, 19).replace('T', ' '), |
| 187 | LUG: $scope.cobrosTabla[j].localidad.NOMBRE, | 187 | LUG: $scope.cobrosTabla[j].localidad.NOMBRE, |
| 188 | IMP: $scope.cobrosTabla[j].importe, | 188 | IMP: $scope.cobrosTabla[j].importe, |
| 189 | LIB: $scope.cobrosTabla[j].librador, | 189 | LIB: $scope.cobrosTabla[j].librador, |
| 190 | EST: 'C',//'D' depositado, 'E' entregado, 'C' en cartera | 190 | EST: 'C',//'D' depositado, 'E' entregado, 'C' en cartera |
| 191 | PCI: $scope.cobrosTabla[j].provincia.ID, | 191 | PCI: $scope.cobrosTabla[j].provincia.ID, |
| 192 | LPLA: 0, | 192 | LPLA: 0, |
| 193 | PLA: 0, | 193 | PLA: 0, |
| 194 | VEN: $scope.cobranza.cobrador.id,//Id vendedor | 194 | VEN: $scope.cobranza.cobrador.id,//Id vendedor |
| 195 | CCLIE: $scope.cobranza.cliente.COD,//Id cliente | 195 | CCLIE: $scope.cobranza.cliente.COD,//Id cliente |
| 196 | REN: 0, | 196 | REN: 0, |
| 197 | PVEC: $scope.puntoVenta, | 197 | PVEC: $scope.puntoVenta, |
| 198 | NCOC: $scope.comprobante, | 198 | NCOC: $scope.comprobante, |
| 199 | OBSE: $scope.cobrosTabla[j].observaciones, | 199 | OBSE: $scope.cobrosTabla[j].observaciones, |
| 200 | LUV: 0, | 200 | LUV: 0, |
| 201 | ORI: 've', | 201 | ORI: 've', |
| 202 | FER: '', | 202 | FER: '', |
| 203 | BIMP: 0, | 203 | BIMP: 0, |
| 204 | COMP: 'C ' +'RC ' + $scope.puntoVenta + '-' + $scope.comprobante, | 204 | COMP: 'C ' +'RC ' + $scope.puntoVenta + '-' + $scope.comprobante, |
| 205 | VAL_E: '',//Cuando egresa por ingresos y egresos en el numero de egreso | 205 | VAL_E: '',//Cuando egresa por ingresos y egresos en el numero de egreso |
| 206 | VAL_I: '',//Cuando Ingresa por ingresos y egresos en el numero ingreso | 206 | VAL_I: '',//Cuando Ingresa por ingresos y egresos en el numero ingreso |
| 207 | REC_CAJ: 'D', | 207 | REC_CAJ: 'D', |
| 208 | TIPO_C: 0,//?? | 208 | TIPO_C: 0,//?? |
| 209 | SALDO_CAJ: 'S', | 209 | SALDO_CAJ: 'S', |
| 210 | FECHA_INGRESO: $scope.fecha | 210 | FECHA_INGRESO: $scope.fecha |
| 211 | .toISOString().slice(0, 19).replace('T', ' '), | 211 | .toISOString().slice(0, 19).replace('T', ' '), |
| 212 | Vendedor_valor: 0, | 212 | Vendedor_valor: 0, |
| 213 | FAMILIA: 0, | 213 | FAMILIA: 0, |
| 214 | CUIT_LIB: '', | 214 | CUIT_LIB: '', |
| 215 | COD_LUG: $scope.cobrosTabla[j].localidad.ID,//código lugar | 215 | COD_LUG: $scope.cobrosTabla[j].localidad.ID,//código lugar |
| 216 | SEN: '', | 216 | SEN: '', |
| 217 | NRC: 0, | 217 | NRC: 0, |
| 218 | COD_LARGO: '', | 218 | COD_LARGO: '', |
| 219 | VN: 0, | 219 | VN: 0, |
| 220 | ID_LECTOR: 0, | 220 | ID_LECTOR: 0, |
| 221 | NATHB: '' | 221 | NATHB: '' |
| 222 | }; | 222 | }; |
| 223 | cheques.push(cheque); | 223 | cheques.push(cheque); |
| 224 | } | 224 | } |
| 225 | if ($scope.cobrosTabla[j].imgs) imgs = $scope.cobrosTabla[j].imgs; | 225 | if ($scope.cobrosTabla[j].imgs) imgs = $scope.cobrosTabla[j].imgs; |
| 226 | 226 | ||
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | cobranza = { | 229 | cobranza = { |
| 230 | recibo: { | 230 | recibo: { |
| 231 | CYV: 'V', | 231 | CYV: 'V', |
| 232 | TIP: 'C', | 232 | TIP: 'C', |
| 233 | TCO: 'RC', | 233 | TCO: 'RC', |
| 234 | PVE: $scope.puntoVenta, //Sucursar, punto de venta | 234 | PVE: $scope.puntoVenta, //Sucursar, punto de venta |
| 235 | NCO: $scope.comprobante, //Numero de comprobante | 235 | NCO: $scope.comprobante, //Numero de comprobante |
| 236 | FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), | 236 | FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), |
| 237 | CLI: $scope.cobranza.cliente.COD, | 237 | CLI: $scope.cobranza.cliente.COD, |
| 238 | ATO: 0, //número de asiento | 238 | ATO: 0, //número de asiento |
| 239 | CFE: $scope.cobranza.cobrador.NOM, | 239 | CFE: $scope.cobranza.cobrador.NOM, |
| 240 | PLA: '',//Numero de planilla, sin uso | 240 | PLA: '',//Numero de planilla, sin uso |
| 241 | ID_MONEDA: $scope.cobranza.moneda.ID, | 241 | ID_MONEDA: $scope.cobranza.moneda.ID, |
| 242 | COTIZACION: $scope.cobranza.cotizacion.VENDEDOR, | 242 | COTIZACION: $scope.cobranza.cotizacion.VENDEDOR, |
| 243 | idCobrador: $scope.cobranza.cobrador.id | 243 | idCobrador: $scope.cobranza.cobrador.id |
| 244 | }, | 244 | }, |
| 245 | cuerpo: cuerpos, | 245 | cuerpo: cuerpos, |
| 246 | cheques: cheques, | 246 | cheques: cheques, |
| 247 | acobypag: { | 247 | acobypag: { |
| 248 | CYV: 'V', | 248 | CYV: 'V', |
| 249 | COD: $scope.cobranza.cliente.COD, | 249 | COD: $scope.cobranza.cliente.COD, |
| 250 | FEP: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), | 250 | FEP: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), |
| 251 | TIP: 'C', | 251 | TIP: 'C', |
| 252 | TCO: 'RC', | 252 | TCO: 'RC', |
| 253 | SUC: $scope.puntoVenta, | 253 | SUC: $scope.puntoVenta, |
| 254 | NCO: $scope.comprobante, | 254 | NCO: $scope.comprobante, |
| 255 | IPA: $scope.getTotalCobrado(), | 255 | IPA: $scope.getTotalCobrado(), |
| 256 | SAL: '',//?? | 256 | SAL: '',//?? |
| 257 | TCA: 1, | 257 | TCA: 1, |
| 258 | ZONA: 1, | 258 | ZONA: 1, |
| 259 | FPA: 2,//Forma de pago | 259 | FPA: 2,//Forma de pago |
| 260 | REC: 0, | 260 | REC: 0, |
| 261 | REP: 0, | 261 | REP: 0, |
| 262 | FER: null, | 262 | FER: null, |
| 263 | REM: 0, | 263 | REM: 0, |
| 264 | FRE: null,//?? | 264 | FRE: null,//?? |
| 265 | PRO: 'N', | 265 | PRO: 'N', |
| 266 | FEV: $scope.fecha.toISOString().slice(0, 19).replace('T', ' ') | 266 | FEV: $scope.fecha.toISOString().slice(0, 19).replace('T', ' ') |
| 267 | }, | 267 | }, |
| 268 | datosCobrador: { | 268 | datosCobrador: { |
| 269 | COD: $scope.cobranza.cobrador.NUM, | 269 | COD: $scope.cobranza.cobrador.NUM, |
| 270 | PVE: $scope.puntoVenta, | 270 | PVE: $scope.puntoVenta, |
| 271 | NUM: $scope.comprobante, | 271 | NUM: $scope.comprobante, |
| 272 | EST: 'C', | 272 | EST: 'C', |
| 273 | OBS: 'RC: ' + $scope.comprobante + '-' + $scope.fecha.toLocaleDateString(), | 273 | OBS: 'RC: ' + $scope.comprobante + '-' + $scope.fecha.toLocaleDateString(), |
| 274 | DAT1: 'C', | 274 | DAT1: 'C', |
| 275 | CLI: $scope.cobranza.cliente.COD | 275 | CLI: $scope.cobranza.cliente.COD |
| 276 | }, | 276 | }, |
| 277 | cliente: $scope.cobranza.cliente, | 277 | cliente: $scope.cobranza.cliente, |
| 278 | imgs: imgs, | 278 | imgs: imgs, |
| 279 | observacion: observacion | 279 | observacion: observacion |
| 280 | }; | 280 | }; |
| 281 | //COPIO cobranzaMail Y A cobranza LE ELIMINO EL VALOR NCU DE LOS CUERPOS | 281 | //COPIO cobranzaMail Y A cobranza LE ELIMINO EL VALOR NCU DE LOS CUERPOS |
| 282 | var cobranzaMail = angular.copy(cobranza); | 282 | var cobranzaMail = angular.copy(cobranza); |
| 283 | cobranza.cuerpo = cobranza.cuerpo.map(function(c) { | 283 | cobranza.cuerpo = cobranza.cuerpo.map(function(c) { |
| 284 | if (c.NCU) delete c.NCU; | 284 | if (c.NCU) delete c.NCU; |
| 285 | return c; | 285 | return c; |
| 286 | }); | 286 | }); |
| 287 | 287 | ||
| 288 | focaCrearCobranzaService | 288 | focaCrearCobranzaService |
| 289 | .guardarCobranza(cobranza) | 289 | .guardarCobranza(cobranza) |
| 290 | .then( | 290 | .then( |
| 291 | function(result) { | 291 | function(result) { |
| 292 | var cliente = angular.copy($scope.cobranza.cliente); | 292 | var cliente = angular.copy($scope.cobranza.cliente); |
| 293 | focaBotoneraLateralService.endGuardar(true); | 293 | focaBotoneraLateralService.endGuardar(true); |
| 294 | $scope.saveLoading = false; | 294 | $scope.saveLoading = false; |
| 295 | 295 | ||
| 296 | focaModalService | 296 | focaModalService |
| 297 | .prompt('Ingrese los emails separados por coma para enviar comprobante', | 297 | .prompt('Ingrese los emails separados por coma para enviar comprobante', |
| 298 | cliente.MAIL) | 298 | cliente.MAIL) |
| 299 | .then(function(res) { | 299 | .then(function(res) { |
| 300 | return Promise.all([ | 300 | return Promise.all([ |
| 301 | focaCrearCobranzaService | 301 | focaCrearCobranzaService |
| 302 | .enviarComprobantePorMail(res, cobranzaMail), | 302 | .enviarComprobantePorMail(res, cobranzaMail), |
| 303 | focaCrearCobranzaService | 303 | focaCrearCobranzaService |
| 304 | .actualizarEmail(res, cliente.COD) | 304 | .actualizarEmail(res, cliente.COD) |
| 305 | ]); | 305 | ]); |
| 306 | }) | 306 | }) |
| 307 | .then(function() { | 307 | .then(function() { |
| 308 | focaModalService.alert('Mensaje enviado correctamente'); | 308 | focaModalService.alert('Mensaje enviado correctamente'); |
| 309 | }); | 309 | }); |
| 310 | 310 | ||
| 311 | focaSeguimientoService.guardarPosicion( | 311 | focaSeguimientoService.guardarPosicion( |
| 312 | 'Cobranza', | 312 | 'Cobranza', |
| 313 | result.data, | 313 | result.data, |
| 314 | '' | 314 | '' |
| 315 | ); | 315 | ); |
| 316 | 316 | ||
| 317 | init(); | 317 | init(); |
| 318 | }, function(error) { | 318 | }, function(error) { |
| 319 | focaModalService.alert('Hubo un problema al cargar la cobranza'); | 319 | focaModalService.alert('Hubo un problema al cargar la cobranza'); |
| 320 | focaBotoneraLateralService.endGuardar(); | 320 | focaBotoneraLateralService.endGuardar(); |
| 321 | $scope.saveLoading = false; | 321 | $scope.saveLoading = false; |
| 322 | console.info(error); | 322 | console.info(error); |
| 323 | } | 323 | } |
| 324 | ); | 324 | ); |
| 325 | }; | 325 | }; |
| 326 | 326 | ||
| 327 | $scope.seleccionarCobros = function() { | 327 | $scope.seleccionarCobros = function() { |
| 328 | $scope.cobroDeuda = false; | 328 | $scope.cobroDeuda = false; |
| 329 | }; | 329 | }; |
| 330 | 330 | ||
| 331 | $scope.seleccionarComprobantes = function() { | 331 | $scope.seleccionarComprobantes = function() { |
| 332 | $scope.cobroDeuda = true; | 332 | $scope.cobroDeuda = true; |
| 333 | }; | 333 | }; |
| 334 | 334 | ||
| 335 | $scope.seleccionarCobranza = function() { | 335 | $scope.seleccionarCobranza = function() { |
| 336 | 336 | ||
| 337 | var modalInstance = $uibModal.open( | 337 | var modalInstance = $uibModal.open( |
| 338 | { | 338 | { |
| 339 | ariaLabelledBy: 'Busqueda de Cobranzas', | 339 | ariaLabelledBy: 'Busqueda de Cobranzas', |
| 340 | templateUrl: 'foca-modal-cobranza.html', | 340 | templateUrl: 'foca-modal-cobranza.html', |
| 341 | controller: 'focaModalCobranzaController', | 341 | controller: 'focaModalCobranzaController', |
| 342 | size: 'lg' | 342 | size: 'lg' |
| 343 | } | 343 | } |
| 344 | ); | 344 | ); |
| 345 | modalInstance.result.then(function(cobranza) { | 345 | modalInstance.result.then(function(cobranza) { |
| 346 | $scope.editando = true; | 346 | $scope.editando = true; |
| 347 | $scope.facturaTabla = []; | 347 | $scope.facturaTabla = []; |
| 348 | $scope.cobrosTabla = []; | 348 | $scope.cobrosTabla = []; |
| 349 | $scope.$broadcast('cleanCabecera'); | 349 | $scope.$broadcast('cleanCabecera'); |
| 350 | 350 | ||
| 351 | $scope.fecha = new Date(cobranza.fecha); | 351 | $scope.fecha = new Date(cobranza.fecha); |
| 352 | 352 | ||
| 353 | $scope.$broadcast('addCabecera', { | 353 | $scope.$broadcast('addCabecera', { |
| 354 | label: 'Cliente:', | 354 | label: 'Cliente:', |
| 355 | valor: $filter('rellenarDigitos')(cobranza.cliente.COD, 5) + ' - ' + | 355 | valor: $filter('rellenarDigitos')(cobranza.cliente.COD, 5) + ' - ' + |
| 356 | cobranza.cliente.NOM | 356 | cobranza.cliente.NOM |
| 357 | }); | 357 | }); |
| 358 | $scope.$broadcast('addCabecera', { | 358 | $scope.$broadcast('addCabecera', { |
| 359 | label: 'Cobrador:', | 359 | label: 'Cobrador:', |
| 360 | valor: cobranza.cobrador | 360 | valor: cobranza.cobrador |
| 361 | //TODO: hacer la relación y traer el cobrador para poner su código | 361 | //TODO: hacer la relación y traer el cobrador para poner su código |
| 362 | // valor: $filter('rellenarDigitos')(cobranza.cobrador.CodVen, 5) + ' - ' + | 362 | // valor: $filter('rellenarDigitos')(cobranza.cobrador.CodVen, 5) + ' - ' + |
| 363 | // cobranza.cobrador | 363 | // cobranza.cobrador |
| 364 | }); | 364 | }); |
| 365 | 365 | ||
| 366 | $scope.facturaTabla = cobranza.facturas; | 366 | $scope.facturaTabla = cobranza.facturas; |
| 367 | $scope.cobrosTabla = cobranza.cobros; | 367 | $scope.cobrosTabla = cobranza.cobros; |
| 368 | }); | 368 | }); |
| 369 | }; | 369 | }; |
| 370 | 370 | ||
| 371 | $scope.seleccionarCliente = function() { | 371 | $scope.seleccionarCliente = function() { |
| 372 | if(!$scope.cobranza.cobrador) { | 372 | if(!$scope.cobranza.cobrador) { |
| 373 | focaModalService.alert('Ingrese primero cobrador'); | 373 | focaModalService.alert('Ingrese primero cobrador'); |
| 374 | return; | 374 | return; |
| 375 | } | 375 | } |
| 376 | var modalInstance = $uibModal.open( | 376 | var modalInstance = $uibModal.open( |
| 377 | { | 377 | { |
| 378 | ariaLabelledBy: 'Busqueda de Cliente', | 378 | ariaLabelledBy: 'Busqueda de Cliente', |
| 379 | templateUrl: 'foca-busqueda-cliente-modal.html', | 379 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 380 | controller: 'focaBusquedaClienteModalController', | 380 | controller: 'focaBusquedaClienteModalController', |
| 381 | resolve: { | 381 | resolve: { |
| 382 | vendedor: function() { return null; } | 382 | vendedor: function() { return null; } |
| 383 | }, | 383 | }, |
| 384 | size: 'lg' | 384 | size: 'lg' |
| 385 | } | 385 | } |
| 386 | ); | 386 | ); |
| 387 | modalInstance.result.then( | 387 | modalInstance.result.then( |
| 388 | function(cliente) { | 388 | function(cliente) { |
| 389 | var clienteMayus = { | 389 | var clienteMayus = { |
| 390 | COD: cliente.cod, | 390 | COD: cliente.cod, |
| 391 | NOM: cliente.nom, | 391 | NOM: cliente.nom, |
| 392 | CUIT: cliente.cuit | 392 | CUIT: cliente.cuit |
| 393 | }; | 393 | }; |
| 394 | 394 | ||
| 395 | $scope.$broadcast('addCabecera', { | 395 | $scope.$broadcast('addCabecera', { |
| 396 | label: 'Cliente:', | 396 | label: 'Cliente:', |
| 397 | valor: $filter('rellenarDigitos')(clienteMayus.COD, 5) + ' - ' + | 397 | valor: $filter('rellenarDigitos')(clienteMayus.COD, 5) + ' - ' + |
| 398 | clienteMayus.NOM | 398 | clienteMayus.NOM |
| 399 | }); | 399 | }); |
| 400 | $scope.cobranza.cliente = clienteMayus; | 400 | $scope.cobranza.cliente = clienteMayus; |
| 401 | } | 401 | } |
| 402 | ); | 402 | ); |
| 403 | }; | 403 | }; |
| 404 | 404 | ||
| 405 | $scope.seleccionarFactura = function() { | 405 | $scope.seleccionarFactura = function() { |
| 406 | if(!$scope.cobranza.cliente) { | 406 | if(!$scope.cobranza.cliente) { |
| 407 | focaModalService.alert('Seleccione primero un cliente'); | 407 | focaModalService.alert('Seleccione primero un cliente'); |
| 408 | return; | 408 | return; |
| 409 | } | 409 | } |
| 410 | var modalInstance = $uibModal.open( | 410 | var modalInstance = $uibModal.open( |
| 411 | { | 411 | { |
| 412 | ariaLabelledBy: 'Busqueda de Facturas', | 412 | ariaLabelledBy: 'Busqueda de Facturas', |
| 413 | templateUrl: 'foca-modal-factura.html', | 413 | templateUrl: 'foca-modal-factura.html', |
| 414 | controller: 'focaModalFacturaController', | 414 | controller: 'focaModalFacturaController', |
| 415 | size: 'lg', | 415 | size: 'lg', |
| 416 | resolve: { | 416 | resolve: { |
| 417 | parametrosFactura: function() { | 417 | parametrosFactura: function() { |
| 418 | return { | 418 | return { |
| 419 | cliente: $scope.cobranza.cliente, | 419 | cliente: $scope.cobranza.cliente, |
| 420 | simbolo: $scope.cobranza.moneda.SIMBOLO, | 420 | simbolo: $scope.cobranza.moneda.SIMBOLO, |
| 421 | cotizacion: $scope.cobranza.cotizacion.VENDEDOR, | 421 | cotizacion: $scope.cobranza.cotizacion.VENDEDOR, |
| 422 | moneda: $scope.cobranza.moneda.ID | 422 | moneda: $scope.cobranza.moneda.ID |
| 423 | }; | 423 | }; |
| 424 | } | 424 | } |
| 425 | } | 425 | } |
| 426 | } | 426 | } |
| 427 | ); | 427 | ); |
| 428 | modalInstance.result.then( | 428 | modalInstance.result.then( |
| 429 | function(facturas) { | 429 | function(facturas) { |
| 430 | $scope.facturaTabla = $scope.facturaTabla.concat(facturas); | 430 | $scope.facturaTabla = $scope.facturaTabla.concat(facturas); |
| 431 | }, function() { | 431 | }, function() { |
| 432 | 432 | ||
| 433 | } | 433 | } |
| 434 | ); | 434 | ); |
| 435 | }; | 435 | }; |
| 436 | 436 | ||
| 437 | $scope.seleccionarCheque = function() { | 437 | $scope.seleccionarCheque = function() { |
| 438 | var modalInstance = $uibModal.open( | 438 | var modalInstance = $uibModal.open( |
| 439 | { | 439 | { |
| 440 | ariaLabelledBy: 'Carga de cheques', | 440 | ariaLabelledBy: 'Carga de cheques', |
| 441 | templateUrl: 'modal-cheque.html', | 441 | templateUrl: 'modal-cheque.html', |
| 442 | controller: 'focaModalChequeController', | 442 | controller: 'focaModalChequeController', |
| 443 | size: 'lg', | 443 | size: 'lg', |
| 444 | resolve: { | 444 | resolve: { |
| 445 | sugerido: function() { | 445 | sugerido: function() { |
| 446 | var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); | 446 | var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); |
| 447 | return sugerido < 0 ? sugerido : null; | 447 | return sugerido < 0 ? sugerido : null; |
| 448 | } | 448 | } |
| 449 | } | 449 | } |
| 450 | } | 450 | } |
| 451 | ); | 451 | ); |
| 452 | modalInstance.result.then( | 452 | modalInstance.result.then( |
| 453 | function(cheque) { | 453 | function(cheque) { |
| 454 | var cobro = { | 454 | var cobro = { |
| 455 | tipo: 'ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco, | 455 | tipo: 'ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco, |
| 456 | numero: cheque.numero, | 456 | numero: cheque.numero, |
| 457 | banco: cheque.banco, | 457 | banco: cheque.banco, |
| 458 | fecha: cheque.fechaEmision.toLocaleDateString() + '-' + | 458 | fecha: cheque.fechaEmision.toLocaleDateString() + '-' + |
| 459 | cheque.fechaPresentacion.toLocaleDateString(), | 459 | cheque.fechaPresentacion.toLocaleDateString(), |
| 460 | fechaPresentacion: cheque.fechaPresentacion, | 460 | fechaPresentacion: cheque.fechaPresentacion, |
| 461 | fechaEmision: cheque.fechaEmision, | 461 | fechaEmision: cheque.fechaEmision, |
| 462 | importe: cheque.importe * $scope.cobranza.cotizacion.VENDEDOR, | 462 | importe: cheque.importe * $scope.cobranza.cotizacion.VENDEDOR, |
| 463 | localidad: cheque.localidad, | 463 | localidad: cheque.localidad, |
| 464 | librador: cheque.librador, | 464 | librador: cheque.librador, |
| 465 | provincia: cheque.provincia, | 465 | provincia: cheque.provincia, |
| 466 | observaciones: cheque.observaciones, | 466 | observaciones: cheque.observaciones, |
| 467 | til: 'EF' | 467 | til: 'EF' |
| 468 | }; | 468 | }; |
| 469 | $scope.cobrosTabla.push(cobro); | 469 | $scope.cobrosTabla.push(cobro); |
| 470 | }, function() { | 470 | }, function() { |
| 471 | 471 | ||
| 472 | } | 472 | } |
| 473 | ); | 473 | ); |
| 474 | }; | 474 | }; |
| 475 | 475 | ||
| 476 | $scope.seleccionarEfectivo = function() { | 476 | $scope.seleccionarEfectivo = function() { |
| 477 | var modalInstance = $uibModal.open( | 477 | var modalInstance = $uibModal.open( |
| 478 | { | 478 | { |
| 479 | ariaLabelledBy: 'Carga de cheques', | 479 | ariaLabelledBy: 'Carga de cheques', |
| 480 | templateUrl: 'modal-efectivo.html', | 480 | templateUrl: 'modal-efectivo.html', |
| 481 | controller: 'focaModalEfectivoController', | 481 | controller: 'focaModalEfectivoController', |
| 482 | size: 'sm', | 482 | size: 'sm', |
| 483 | resolve: { | 483 | resolve: { |
| 484 | sugerido: function() { | 484 | sugerido: function() { |
| 485 | var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); | 485 | var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); |
| 486 | return sugerido < 0 ? sugerido : null; | 486 | return sugerido < 0 ? sugerido : null; |
| 487 | } | 487 | } |
| 488 | } | 488 | } |
| 489 | } | 489 | } |
| 490 | ); | 490 | ); |
| 491 | modalInstance.result.then( | 491 | modalInstance.result.then( |
| 492 | function(efectivo) { | 492 | function(efectivo) { |
| 493 | var cobro = { | 493 | var cobro = { |
| 494 | tipo: 'Efectivo', | 494 | tipo: 'Efectivo', |
| 495 | fecha: new Date(), | 495 | fecha: new Date(), |
| 496 | importe: efectivo * $scope.cobranza.cotizacion.VENDEDOR, | 496 | importe: efectivo * $scope.cobranza.cotizacion.VENDEDOR, |
| 497 | til: 'EF' | 497 | til: 'EF' |
| 498 | }; | 498 | }; |
| 499 | $scope.cobrosTabla = $scope.cobrosTabla.filter(function(a) { | 499 | $scope.cobrosTabla = $scope.cobrosTabla.filter(function(a) { |
| 500 | return a.tipo !== 'Efectivo'; | 500 | return a.tipo !== 'Efectivo'; |
| 501 | }); | 501 | }); |
| 502 | $scope.cobrosTabla.push(cobro); | 502 | $scope.cobrosTabla.push(cobro); |
| 503 | }, function() { | 503 | }, function() { |
| 504 | 504 | ||
| 505 | } | 505 | } |
| 506 | ); | 506 | ); |
| 507 | }; | 507 | }; |
| 508 | 508 | ||
| 509 | $scope.seleccionarDetalles = function() { | 509 | $scope.seleccionarDetalles = function() { |
| 510 | var modalInstance = $uibModal.open( | 510 | var modalInstance = $uibModal.open( |
| 511 | { | 511 | { |
| 512 | ariaLabelledBy: 'Carga de detalles', | 512 | ariaLabelledBy: 'Carga de detalles', |
| 513 | templateUrl: 'modal-detalles.html', | 513 | templateUrl: 'modal-detalles.html', |
| 514 | controller: 'focaModalDetallesController', | 514 | controller: 'focaModalDetallesController', |
| 515 | size: 'lg', | 515 | size: 'lg', |
| 516 | resolve: { | 516 | resolve: { |
| 517 | sugerido: function() { | 517 | sugerido: function() { |
| 518 | var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); | 518 | var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); |
| 519 | return sugerido < 0 ? sugerido : null; | 519 | return sugerido < 0 ? sugerido : null; |
| 520 | } | 520 | } |
| 521 | } | 521 | } |
| 522 | } | 522 | } |
| 523 | ); | 523 | ); |
| 524 | modalInstance.result.then( | 524 | modalInstance.result.then( |
| 525 | function(detalles) { | 525 | function(detalles) { |
| 526 | var cobro = { | 526 | var cobro = { |
| 527 | tipo: 'de(COBRO POR DETALLES)', | 527 | tipo: 'de(COBRO POR DETALLES)', |
| 528 | fecha: new Date(), | 528 | fecha: new Date(), |
| 529 | importe: detalles.monto * $scope.cobranza.cotizacion.VENDEDOR, | 529 | importe: detalles.monto * $scope.cobranza.cotizacion.VENDEDOR, |
| 530 | imgs: detalles.imgs, | 530 | imgs: detalles.imgs, |
| 531 | til: 'DE', | 531 | til: 'DE', |
| 532 | observacion: detalles.observacion | 532 | observacion: detalles.observacion |
| 533 | }; | 533 | }; |
| 534 | var existe = false; | 534 | var existe = false; |
| 535 | 535 | ||
| 536 | $scope.cobrosTabla.forEach(function(c, idx) { | 536 | $scope.cobrosTabla.forEach(function(c, idx) { |
| 537 | if (c.til === 'DE') { | 537 | if (c.til === 'DE') { |
| 538 | $scope.cobrosTabla[idx] = cobro; | 538 | $scope.cobrosTabla[idx] = cobro; |
| 539 | existe = true; | 539 | existe = true; |
| 540 | } | 540 | } |
| 541 | }); | 541 | }); |
| 542 | if (!existe) { | 542 | if (!existe) { |
| 543 | $scope.cobrosTabla.push(cobro); | 543 | $scope.cobrosTabla.push(cobro); |
| 544 | } | 544 | } |
| 545 | }, function() {} | 545 | }, function() {} |
| 546 | ); | 546 | ); |
| 547 | }; | 547 | }; |
| 548 | 548 | ||
| 549 | $scope.seleccionarMoneda = function() { | 549 | $scope.seleccionarMoneda = function() { |
| 550 | var parametrosModal = { | 550 | var parametrosModal = { |
| 551 | titulo: 'Búsqueda de monedas', | 551 | titulo: 'Búsqueda de monedas', |
| 552 | query: '/moneda', | 552 | query: '/moneda', |
| 553 | columnas: [ | 553 | columnas: [ |
| 554 | { | 554 | { |
| 555 | propiedad: 'DETALLE', | 555 | propiedad: 'DETALLE', |
| 556 | nombre: 'Nombre' | 556 | nombre: 'Nombre' |
| 557 | }, | 557 | }, |
| 558 | { | 558 | { |
| 559 | propiedad: 'SIMBOLO', | 559 | propiedad: 'SIMBOLO', |
| 560 | nombre: 'Símbolo' | 560 | nombre: 'Símbolo' |
| 561 | } | 561 | } |
| 562 | ], | 562 | ], |
| 563 | size: 'md' | 563 | size: 'md' |
| 564 | }; | 564 | }; |
| 565 | focaModalService.modal(parametrosModal).then( | 565 | focaModalService.modal(parametrosModal).then( |
| 566 | function(moneda) { | 566 | function(moneda) { |
| 567 | $scope.seleccionarCotizacion(moneda); | 567 | $scope.seleccionarCotizacion(moneda); |
| 568 | }, function() { | 568 | }, function() { |
| 569 | 569 | ||
| 570 | } | 570 | } |
| 571 | ); | 571 | ); |
| 572 | }; | 572 | }; |
| 573 | 573 | ||
| 574 | $scope.seleccionarCotizacion = function(moneda) { | 574 | $scope.seleccionarCotizacion = function(moneda) { |
| 575 | var modalInstance = $uibModal.open( | 575 | var modalInstance = $uibModal.open( |
| 576 | { | 576 | { |
| 577 | ariaLabelledBy: 'Busqueda de Cotización', | 577 | ariaLabelledBy: 'Busqueda de Cotización', |
| 578 | templateUrl: 'modal-cotizacion.html', | 578 | templateUrl: 'modal-cotizacion.html', |
| 579 | controller: 'focaModalCotizacionController', | 579 | controller: 'focaModalCotizacionController', |
| 580 | size: 'lg', | 580 | size: 'lg', |
| 581 | resolve: {idMoneda: function() {return moneda.ID;}} | 581 | resolve: {idMoneda: function() {return moneda.ID;}} |
| 582 | } | 582 | } |
| 583 | ); | 583 | ); |
| 584 | modalInstance.result.then( | 584 | modalInstance.result.then( |
| 585 | function(cotizacion) { | 585 | function(cotizacion) { |
| 586 | $scope.cobranza.moneda = moneda; | 586 | $scope.cobranza.moneda = moneda; |
| 587 | $scope.cobranza.cotizacion = cotizacion; | 587 | $scope.cobranza.cotizacion = cotizacion; |
| 588 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { | 588 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { |
| 589 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 589 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
| 590 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 590 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
| 591 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 591 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
| 592 | }else { | 592 | }else { |
| 593 | $scope.$broadcast('addCabecera', { | 593 | $scope.$broadcast('addCabecera', { |
| 594 | label: 'Moneda:', | 594 | label: 'Moneda:', |
| 595 | valor: moneda.DETALLE | 595 | valor: moneda.DETALLE |
| 596 | }); | 596 | }); |
| 597 | $scope.$broadcast('addCabecera', { | 597 | $scope.$broadcast('addCabecera', { |
| 598 | label: 'Fecha cotizacion:', | 598 | label: 'Fecha cotizacion:', |
| 599 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 599 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 600 | }); | 600 | }); |
| 601 | $scope.$broadcast('addCabecera', { | 601 | $scope.$broadcast('addCabecera', { |
| 602 | label: 'Cotizacion:', | 602 | label: 'Cotizacion:', |
| 603 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 603 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
| 604 | }); | 604 | }); |
| 605 | } | 605 | } |
| 606 | }, function() { | 606 | }, function() { |
| 607 | 607 | ||
| 608 | } | 608 | } |
| 609 | ); | 609 | ); |
| 610 | }; | 610 | }; |
| 611 | 611 | ||
| 612 | $scope.seleccionarCobrador = function() { | 612 | $scope.seleccionarCobrador = function() { |
| 613 | var parametrosModal = { | 613 | var parametrosModal = { |
| 614 | query: '/cobrador', | 614 | query: '/cobrador', |
| 615 | columnas: [ | 615 | columnas: [ |
| 616 | { | 616 | { |
| 617 | propiedad: 'NUM', | 617 | propiedad: 'NUM', |
| 618 | nombre: 'Codigo', | 618 | nombre: 'Codigo', |
| 619 | filtro: { | 619 | filtro: { |
| 620 | nombre: 'rellenarDigitos', | 620 | nombre: 'rellenarDigitos', |
| 621 | parametro: 3 | 621 | parametro: 3 |
| 622 | } | 622 | } |
| 623 | }, | 623 | }, |
| 624 | { | 624 | { |
| 625 | propiedad: 'NOM', | 625 | propiedad: 'NOM', |
| 626 | nombre: 'Nombre' | 626 | nombre: 'Nombre' |
| 627 | } | 627 | } |
| 628 | ], | 628 | ], |
| 629 | titulo:'Búsqueda de cobradores' | 629 | titulo:'Búsqueda de cobradores' |
| 630 | }; | 630 | }; |
| 631 | focaModalService.modal(parametrosModal).then( | 631 | focaModalService.modal(parametrosModal).then( |
| 632 | function(cobrador) { | 632 | function(cobrador) { |
| 633 | $scope.$broadcast('addCabecera', { | 633 | $scope.$broadcast('addCabecera', { |
| 634 | label: 'Cobrador:', | 634 | label: 'Cobrador:', |
| 635 | valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + | 635 | valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + |
| 636 | cobrador.NOM | 636 | cobrador.NOM |
| 637 | }); | 637 | }); |
| 638 | $scope.cobranza.cobrador = cobrador; | 638 | $scope.cobranza.cobrador = cobrador; |
| 639 | }, function() { | 639 | }, function() { |
| 640 | 640 | ||
| 641 | } | 641 | } |
| 642 | ); | 642 | ); |
| 643 | }; | 643 | }; |
| 644 | 644 | ||
| 645 | $scope.getTotalDeuda = function() { | 645 | $scope.getTotalDeuda = function() { |
| 646 | var total = 0; | 646 | var total = 0; |
| 647 | for (var i = 0; i < $scope.facturaTabla.length; i++) { | 647 | for (var i = 0; i < $scope.facturaTabla.length; i++) { |
| 648 | total += $scope.facturaTabla[i].IPA; | 648 | total += $scope.facturaTabla[i].IPA; |
| 649 | } | 649 | } |
| 650 | return parseFloat(total.toFixed(2)); | 650 | return parseFloat(total.toFixed(2)); |
| 651 | }; | 651 | }; |
| 652 | 652 | ||
| 653 | $scope.getTotalCobrado = function() { | 653 | $scope.getTotalCobrado = function() { |
| 654 | var total = 0; | 654 | var total = 0; |
| 655 | for (var i = 0; i < $scope.cobrosTabla.length; i++) { | 655 | for (var i = 0; i < $scope.cobrosTabla.length; i++) { |
| 656 | total += $scope.cobrosTabla[i].importe; | 656 | total += $scope.cobrosTabla[i].importe; |
| 657 | } | 657 | } |
| 658 | return parseFloat(total.toFixed(2)); | 658 | return parseFloat(total.toFixed(2)); |
| 659 | }; | 659 | }; |
| 660 | 660 | ||
| 661 | $scope.getSubTotal = function() { | 661 | $scope.getSubTotal = function() { |
| 662 | if ($scope.articuloACargar) { | 662 | if ($scope.articuloACargar) { |
| 663 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 663 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 664 | } | 664 | } |
| 665 | }; | 665 | }; |
| 666 | //Recibe aviso si el teclado está en uso | 666 | //Recibe aviso si el teclado está en uso |
| 667 | // $rootScope.$on('usarTeclado', function(event, data) { | 667 | // $rootScope.$on('usarTeclado', function(event, data) { |
| 668 | // if(data) { | 668 | // if(data) { |
| 669 | // $scope.mostrarTeclado = true; | 669 | // $scope.mostrarTeclado = true; |
| 670 | // return; | 670 | // return; |
| 671 | // } | 671 | // } |
| 672 | // $scope.mostrarTeclado = false; | 672 | // $scope.mostrarTeclado = false; |
| 673 | // }) | 673 | // }) |
| 674 | $scope.selectFocus = function($event) { | 674 | $scope.selectFocus = function($event) { |
| 675 | //Si el teclado esta en uso no selecciona el valor | 675 | //Si el teclado esta en uso no selecciona el valor |
| 676 | // if($scope.mostrarTeclado) { | 676 | // if($scope.mostrarTeclado) { |
| 677 | // return; | 677 | // return; |
| 678 | // } | 678 | // } |
| 679 | $event.target.select(); | 679 | $event.target.select(); |
| 680 | }; | 680 | }; |
| 681 | 681 | ||
| 682 | $scope.salir = function() { | 682 | $scope.salir = function() { |
| 683 | $location.path('/'); | 683 | $location.path('/'); |
| 684 | }; | 684 | }; |
| 685 | 685 | ||
| 686 | $scope.parsearATexto = function(articulo) { | 686 | $scope.parsearATexto = function(articulo) { |
| 687 | articulo.cantidad = parseFloat(articulo.cantidad); | 687 | articulo.cantidad = parseFloat(articulo.cantidad); |
| 688 | articulo.precio = parseFloat(articulo.precio); | 688 | articulo.precio = parseFloat(articulo.precio); |
| 689 | }; | 689 | }; |
| 690 | 690 | ||
| 691 | $scope.quitarFactura = function(key) { | 691 | $scope.quitarFactura = function(key) { |
| 692 | $scope.facturaTabla.splice(key, 1); | 692 | $scope.facturaTabla.splice(key, 1); |
| 693 | }; | 693 | }; |
| 694 | 694 | ||
| 695 | $scope.quitarCobro = function(key) { | 695 | $scope.quitarCobro = function(key) { |
| 696 | $scope.cobrosTabla.splice(key, 1); | 696 | $scope.cobrosTabla.splice(key, 1); |
| 697 | }; | 697 | }; |
| 698 | 698 | ||
| 699 | function salir() { | 699 | function salir() { |
| 700 | var confirmacion = false; | 700 | var confirmacion = false; |
| 701 | 701 | ||
| 702 | angular.forEach($scope.inicial, function(valor, key) { | 702 | angular.forEach($scope.inicial, function(valor, key) { |
| 703 | if (!angular.equals($scope[key], $scope.inicial[key])) { | 703 | if (!angular.equals($scope[key], $scope.inicial[key])) { |
| 704 | confirmacion = true; | 704 | confirmacion = true; |
| 705 | } | 705 | } |
| 706 | }); | 706 | }); |
| 707 | 707 | ||
| 708 | if (confirmacion) { | 708 | if (confirmacion) { |
| 709 | focaModalService.confirm( | 709 | focaModalService.confirm( |
| 710 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 710 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
| 711 | ).then(function(data) { | 711 | ).then(function(data) { |
| 712 | if (data) { | 712 | if (data) { |
| 713 | $location.path('/'); | 713 | $location.path('/'); |
| 714 | } | 714 | } |
| 715 | }); | 715 | }); |
| 716 | } else { | 716 | } else { |
| 717 | $location.path('/'); | 717 | $location.path('/'); |
| 718 | } | 718 | } |
| 719 | } | 719 | } |
| 720 | } | 720 | } |
| 721 | ]); | 721 | ]); |
| 722 | 722 |
test.html
| File was created | 1 | <html> | |
| 2 | <head> | ||
| 3 | <link rel="stylesheet" type="text/css" href="node_modules/jasmine-core/lib/jasmine-core/jasmine.css"> | ||
| 4 | <meta charset="UTF-8" /> | ||
| 5 | </head> | ||
| 6 | <body> | ||
| 7 | <script type="text/javascript" src="node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script> | ||
| 8 | <script type="text/javascript" src="node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script> | ||
| 9 | <script type="text/javascript" src="node_modules/jasmine-core/lib/jasmine-core/boot.js"></script> | ||
| 10 | <script type="text/javascript" src="node_modules/angular/angular.min.js"></script> | ||
| 11 | <script type="text/javascript" src="node_modules/angular-route/angular-route.min.js"></script> | ||
| 12 | <script type="text/javascript" src="node_modules/angular-mocks/angular-mocks.js"></script> | ||
| 13 | <script type="text/javascript" src="src/js/app.js"></script> | ||
| 14 | <script type="text/javascript" src="src/js/controller.js"></script> | ||
| 15 | <script type="text/javascript" src="src/js/service.js"></script> | ||
| 16 | <script type="text/javascript" src="src/js/route.js"></script> | ||
| 17 | <script type="text/javascript" src="spec/controllerSpec.js"></script> | ||
| 18 | <script type="text/javascript" src="spec/serviceSpec.js"></script> | ||
| 19 | <script type="text/javascript" src="spec/routeSpec.js"></script> | ||
| 20 | </body> | ||
| 21 | </html> | ||
| 22 |