Commit 25927158cf8856fb1069a2fc04ca27da28cd95e7
Exists in
master
Merge branch 'master' into 'master'
Master(efernandez) See merge request !36
Showing
4 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 | tmp: 'tmp', | 16 | tmp: 'tmp', |
| 17 | dist: 'dist/' | 17 | dist: 'dist/' |
| 18 | }; | 18 | }; |
| 19 | 19 | ||
| 20 | gulp.task('templates', ['clean'], function() { | 20 | gulp.task('templates', ['clean'], function() { |
| 21 | return pump( | 21 | return pump( |
| 22 | [ | 22 | [ |
| 23 | gulp.src(paths.srcViews), | 23 | gulp.src(paths.srcViews), |
| 24 | htmlmin(), | 24 | htmlmin(), |
| 25 | templateCache('views.js', { | 25 | templateCache('views.js', { |
| 26 | module: 'focaCrearCobranza', | 26 | module: 'focaCrearCobranza', |
| 27 | root: '' | 27 | root: '' |
| 28 | }), | 28 | }), |
| 29 | gulp.dest(paths.tmp) | 29 | gulp.dest(paths.tmp) |
| 30 | ] | 30 | ] |
| 31 | ); | 31 | ); |
| 32 | }); | 32 | }); |
| 33 | 33 | ||
| 34 | gulp.task('uglify', ['templates'], function() { | 34 | gulp.task('uglify', ['templates'], function() { |
| 35 | return pump( | 35 | return pump( |
| 36 | [ | 36 | [ |
| 37 | gulp.src([ | 37 | gulp.src([ |
| 38 | paths.srcJS, | 38 | paths.srcJS, |
| 39 | 'tmp/views.js' | 39 | 'tmp/views.js' |
| 40 | ]), | 40 | ]), |
| 41 | concat('foca-crear-cobranza.js'), | 41 | concat('foca-crear-cobranza.js'), |
| 42 | replace('src/views/', ''), | 42 | replace('src/views/', ''), |
| 43 | gulp.dest(paths.tmp), | 43 | gulp.dest(paths.tmp), |
| 44 | rename('foca-crear-cobranza.min.js'), | 44 | rename('foca-crear-cobranza.min.js'), |
| 45 | uglify(), | 45 | uglify(), |
| 46 | replace('"ngRoute","ui.bootstrap","focaBotoneraLateral",'+ | ||
| 47 | '"focaModal","focaModalFactura","focaBusquedaCliente",'+ | ||
| 48 | '"focaDirectivas","focaModalMoneda","focaModalCotizacion"', ''), | ||
| 49 | gulp.dest(paths.dist) | 46 | gulp.dest(paths.dist) |
| 50 | 47 | ||
| 51 | ] | 48 | ] |
| 52 | ); | 49 | ); |
| 53 | }); | 50 | }); |
| 54 | 51 | ||
| 55 | gulp.task('clean', function() { | 52 | gulp.task('clean', function() { |
| 56 | return gulp.src(['tmp', 'dist'], {read: false}) | 53 | return gulp.src(['tmp', 'dist'], {read: false}) |
| 57 | .pipe(clean()); | 54 | .pipe(clean()); |
| 58 | }); | 55 | }); |
| 59 | 56 | ||
| 60 | gulp.task('pre-commit', function() { | 57 | gulp.task('pre-commit', function() { |
| 61 | return pump( | 58 | return pump( |
| 62 | [ | 59 | [ |
| 63 | gulp.src(paths.srcJS), | 60 | gulp.src(paths.srcJS), |
| 64 | jshint('.jshintrc'), | 61 | jshint('.jshintrc'), |
| 65 | jshint.reporter('default'), | 62 | jshint.reporter('default'), |
| 66 | jshint.reporter('fail') | 63 | jshint.reporter('fail') |
| 67 | ] | 64 | ] |
| 68 | ); | 65 | ); |
| 69 | 66 | ||
| 70 | gulp.start('uglify'); | 67 | gulp.start('uglify'); |
| 71 | }); | 68 | }); |
| 72 | 69 | ||
| 73 | gulp.task('webserver', function() { | 70 | gulp.task('webserver', function() { |
| 74 | pump [ | 71 | pump [ |
| 75 | connect.server({port: 3300, host: '0.0.0.0'}) | 72 | connect.server({port: 3300, host: '0.0.0.0'}) |
| 76 | ] | 73 | ] |
| 77 | }); | 74 | }); |
| 78 | 75 | ||
| 79 | gulp.task('clean-post-install', function() { | 76 | gulp.task('clean-post-install', function() { |
| 80 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 77 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
| 81 | 'index.html'], {read: false}) | 78 | 'index.html'], {read: false}) |
| 82 | .pipe(clean()); | 79 | .pipe(clean()); |
| 83 | }); | 80 | }); |
| 84 | 81 | ||
| 85 | gulp.task('default', ['webserver']); | 82 | gulp.task('default', ['webserver']); |
| 86 | 83 | ||
| 87 | gulp.task('watch', function() { | 84 | gulp.task('watch', function() { |
| 88 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | 85 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); |
| 89 | }); | 86 | }); |
| 90 | 87 |
src/js/app.js
| 1 | angular.module('focaCrearCobranza', [ | 1 | angular.module('focaCrearCobranza', []); |
| 2 | 'ngRoute', | ||
| 3 | 'ui.bootstrap', | ||
| 4 | 'focaBotoneraLateral', | ||
| 5 | 'focaModal', | ||
| 6 | 'focaModalFactura', | ||
| 7 | 'focaBusquedaCliente', | ||
| 8 | 'focaDirectivas', | ||
| 9 | 'focaModalMoneda', | ||
| 10 | 'focaModalCotizacion' | ||
| 11 | ]); | ||
| 12 | 2 |
src/js/controller.js
| 1 | angular.module('focaCrearCobranza') .controller('cobranzaController', | 1 | angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 2 | [ | 2 | [ |
| 3 | '$scope', | 3 | '$scope', |
| 4 | '$rootScope', | 4 | '$rootScope', |
| 5 | '$timeout', | 5 | '$timeout', |
| 6 | '$uibModal', | 6 | '$uibModal', |
| 7 | '$location', | 7 | '$location', |
| 8 | 'focaCrearCobranzaService', | 8 | 'focaCrearCobranzaService', |
| 9 | 'focaModalService', | 9 | 'focaModalService', |
| 10 | '$filter', | 10 | '$filter', |
| 11 | '$cookies', | 11 | '$cookies', |
| 12 | 'focaSeguimientoService', | 12 | 'focaSeguimientoService', |
| 13 | 'focaBotoneraLateralService', | 13 | 'focaBotoneraLateralService', |
| 14 | 'APP', | ||
| 15 | 'focaLoginService', | ||
| 14 | function($scope, $rootScope, $timeout, $uibModal, $location, focaCrearCobranzaService, | 16 | function($scope, $rootScope, $timeout, $uibModal, $location, focaCrearCobranzaService, |
| 15 | focaModalService, $filter, $cookies, focaSeguimientoService, focaBotoneraLateralService) | 17 | focaModalService, $filter, $cookies, focaSeguimientoService, |
| 18 | focaBotoneraLateralService, APP, loginService) | ||
| 16 | { | 19 | { |
| 17 | 20 | ||
| 18 | $scope.botonera = focaCrearCobranzaService.getBotonera(); | 21 | if(APP === 'cobranza') { |
| 22 | var idCobrador = loginService.getLoginData().vendedorCobrador; | ||
| 23 | $scope.botonera = focaCrearCobranzaService.getBotonera(idCobrador); | ||
| 24 | focaCrearCobranzaService.getVendedorById(idCobrador).then( | ||
| 25 | function(res) { | ||
| 26 | var cobrador = res.data; | ||
| 27 | $scope.$broadcast('addCabecera', { | ||
| 28 | label: 'Cobrador:', | ||
| 29 | valor: cobrador.NomVen | ||
| 30 | }); | ||
| 31 | $scope.cobranza.cobrador = cobrador; | ||
| 32 | } | ||
| 33 | ); | ||
| 34 | }else { | ||
| 35 | $scope.botonera = focaCrearCobranzaService.getBotonera(); | ||
| 36 | } | ||
| 19 | $scope.datepickerAbierto = false; | 37 | $scope.datepickerAbierto = false; |
| 20 | $scope.cobroDeuda = true; | 38 | $scope.cobroDeuda = true; |
| 21 | $scope.show = false; | 39 | $scope.show = false; |
| 22 | $scope.cargando = true; | 40 | $scope.cargando = true; |
| 23 | $scope.dateOptions = { | 41 | $scope.dateOptions = { |
| 24 | maxDate: new Date(), | 42 | maxDate: new Date(), |
| 25 | minDate: new Date(2010, 0, 1) | 43 | minDate: new Date(2010, 0, 1) |
| 26 | }; | 44 | }; |
| 27 | 45 | ||
| 28 | $scope.cobranza = {}; | 46 | $scope.cobranza = {}; |
| 29 | 47 | ||
| 30 | $scope.fecha = new Date(); | 48 | $scope.fecha = new Date(); |
| 31 | $scope.puntoVenta = '0000'; | 49 | $scope.puntoVenta = '0000'; |
| 32 | $scope.comprobante = '00000000'; | 50 | $scope.comprobante = '00000000'; |
| 33 | $scope.facturaTabla = []; | 51 | $scope.facturaTabla = []; |
| 34 | $scope.cobrosTabla = []; | 52 | $scope.cobrosTabla = []; |
| 35 | 53 | ||
| 36 | focaCrearCobranzaService.getUsuario($cookies.get('idUsuario')).then(function(data) { | 54 | focaCrearCobranzaService.getUsuario($cookies.get('idUsuario')).then(function(data) { |
| 37 | $scope.usuario = data.data; | 55 | $scope.usuario = data.data; |
| 38 | }); | 56 | }); |
| 39 | 57 | ||
| 40 | $timeout(function() { | 58 | $timeout(function() { |
| 41 | focaBotoneraLateralService.showSalir(false); | 59 | focaBotoneraLateralService.showSalir(false); |
| 42 | focaBotoneraLateralService.showPausar(true); | 60 | focaBotoneraLateralService.showPausar(true); |
| 43 | focaBotoneraLateralService.showGuardar(true, $scope.crearCobranza); | 61 | focaBotoneraLateralService.showGuardar(true, $scope.crearCobranza); |
| 44 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 62 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
| 45 | }); | 63 | }); |
| 46 | 64 | ||
| 47 | $scope.crearCobranza = function() { | 65 | $scope.crearCobranza = function() { |
| 48 | if(!$scope.cobranza.cliente) { | 66 | if(!$scope.cobranza.cliente) { |
| 49 | focaModalService.alert('Ingrese Cliente'); | 67 | focaModalService.alert('Ingrese Cliente'); |
| 50 | return; | 68 | return; |
| 51 | } | 69 | } |
| 52 | if(!$scope.cobranza.cobrador) { | 70 | if(!$scope.cobranza.cobrador) { |
| 53 | focaModalService.alert('Ingrese Cobrador'); | 71 | focaModalService.alert('Ingrese Cobrador'); |
| 54 | return; | 72 | return; |
| 55 | } | 73 | } |
| 56 | if($scope.facturaTabla.length < 1) { | 74 | if($scope.facturaTabla.length < 1) { |
| 57 | focaModalService.alert('Ingrese al menos una factura'); | 75 | focaModalService.alert('Ingrese al menos una factura'); |
| 58 | return; | 76 | return; |
| 59 | } | 77 | } |
| 60 | if($scope.getTotalCobrado() + $scope.getTotalDeuda() !== 0) { | 78 | if($scope.getTotalCobrado() + $scope.getTotalDeuda() !== 0) { |
| 61 | focaModalService.alert('La diferencia debe ser ' + | 79 | focaModalService.alert('La diferencia debe ser ' + |
| 62 | $scope.cobranza.moneda.SIMBOLO + '0,00'); | 80 | $scope.cobranza.moneda.SIMBOLO + '0,00'); |
| 63 | return; | 81 | return; |
| 64 | } | 82 | } |
| 65 | var cobranza = {}; | 83 | var cobranza = {}; |
| 66 | var cheques = []; | 84 | var cheques = []; |
| 67 | var cuerpos = []; | 85 | var cuerpos = []; |
| 68 | //TODO: habilitar edición | 86 | //TODO: habilitar edición |
| 69 | $scope.editando = false; | 87 | $scope.editando = false; |
| 70 | focaBotoneraLateralService.startGuardar(); | 88 | focaBotoneraLateralService.startGuardar(); |
| 71 | $scope.saveLoading = true; | 89 | $scope.saveLoading = true; |
| 72 | for(var i = 0; i < $scope.facturaTabla.length; i++) { | 90 | for(var i = 0; i < $scope.facturaTabla.length; i++) { |
| 73 | var cuerpoFactura = { | 91 | var cuerpoFactura = { |
| 74 | CYV: 'V', | 92 | CYV: 'V', |
| 75 | TIP: 'C', | 93 | TIP: 'C', |
| 76 | TCO: 'RC', | 94 | TCO: 'RC', |
| 77 | PVE: $scope.puntoVenta, | 95 | PVE: $scope.puntoVenta, |
| 78 | NCO: $scope.comprobante, | 96 | NCO: $scope.comprobante, |
| 79 | LOP: 'L', | 97 | LOP: 'L', |
| 80 | TIL: $scope.facturaTabla[i].TCO, | 98 | TIL: $scope.facturaTabla[i].TCO, |
| 81 | COM: $scope.facturaTabla[i].numeroFactura + '-' + | 99 | COM: $scope.facturaTabla[i].numeroFactura + '-' + |
| 82 | $scope.rellenar($scope.facturaTabla[i].NCU,2), | 100 | $scope.rellenar($scope.facturaTabla[i].NCU,2), |
| 83 | FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), | 101 | FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), |
| 84 | IMP: Math.abs($scope.facturaTabla[i].IPA), | 102 | IMP: Math.abs($scope.facturaTabla[i].IPA), |
| 85 | RES: 0,//caja de tesorería | 103 | RES: 0,//caja de tesorería |
| 86 | SUBM: 0 | 104 | SUBM: 0 |
| 87 | }; | 105 | }; |
| 88 | cuerpos.push(cuerpoFactura); | 106 | cuerpos.push(cuerpoFactura); |
| 89 | } | 107 | } |
| 90 | 108 | ||
| 91 | for (var j = 0; j < $scope.cobrosTabla.length; j++) { | 109 | for (var j = 0; j < $scope.cobrosTabla.length; j++) { |
| 92 | 110 | ||
| 93 | var efectivo = $scope.cobrosTabla[j].tipo === 'Efectivo' ? true : false; | 111 | var efectivo = $scope.cobrosTabla[j].tipo === 'Efectivo' ? true : false; |
| 94 | 112 | ||
| 95 | var cuerpoCobros = { | 113 | var cuerpoCobros = { |
| 96 | CYV: 'V', | 114 | CYV: 'V', |
| 97 | TIP: 'C', | 115 | TIP: 'C', |
| 98 | TCO: 'RC', | 116 | TCO: 'RC', |
| 99 | PVE: $scope.puntoVenta, | 117 | PVE: $scope.puntoVenta, |
| 100 | NCO: $scope.comprobante, | 118 | NCO: $scope.comprobante, |
| 101 | LOP: 'P', | 119 | LOP: 'P', |
| 102 | TIL: 'EF', | 120 | TIL: 'EF', |
| 103 | COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : 'ch(' + | 121 | COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : 'ch(' + |
| 104 | $scope.cobrosTabla[j].numero + ')' + $scope.cobrosTabla[j].banco.desbco, | 122 | $scope.cobrosTabla[j].numero + ')' + $scope.cobrosTabla[j].banco.desbco, |
| 105 | FEC: efectivo ? | 123 | FEC: efectivo ? |
| 106 | $scope.cobrosTabla[j].fecha | 124 | $scope.cobrosTabla[j].fecha |
| 107 | .toISOString().slice(0, 19).replace('T', ' ') : | 125 | .toISOString().slice(0, 19).replace('T', ' ') : |
| 108 | $scope.cobrosTabla[j].fechaPresentacion | 126 | $scope.cobrosTabla[j].fechaPresentacion |
| 109 | .toISOString().slice(0, 19).replace('T', ' '), | 127 | .toISOString().slice(0, 19).replace('T', ' '), |
| 110 | IMP: Math.abs($scope.cobrosTabla[j].importe), | 128 | IMP: Math.abs($scope.cobrosTabla[j].importe), |
| 111 | RES: 0,//caja de tesorería | 129 | RES: 0,//caja de tesorería |
| 112 | SUBM: 0 | 130 | SUBM: 0 |
| 113 | }; | 131 | }; |
| 114 | cuerpos.push(cuerpoCobros); | 132 | cuerpos.push(cuerpoCobros); |
| 115 | 133 | ||
| 116 | if(!efectivo) { | 134 | if(!efectivo) { |
| 117 | var cheque = { | 135 | var cheque = { |
| 118 | BCO: $scope.cobrosTabla[j].banco.ID, | 136 | BCO: $scope.cobrosTabla[j].banco.ID, |
| 119 | NUM: $scope.comprobante, | 137 | NUM: $scope.comprobante, |
| 120 | FEP: $scope.cobrosTabla[j].fechaPresentacion | 138 | FEP: $scope.cobrosTabla[j].fechaPresentacion |
| 121 | .toISOString().slice(0, 19).replace('T', ' '), | 139 | .toISOString().slice(0, 19).replace('T', ' '), |
| 122 | FEE: $scope.cobrosTabla[j].fechaEmision | 140 | FEE: $scope.cobrosTabla[j].fechaEmision |
| 123 | .toISOString().slice(0, 19).replace('T', ' '), | 141 | .toISOString().slice(0, 19).replace('T', ' '), |
| 124 | LUG: $scope.cobrosTabla[j].localidad.NOMBRE, | 142 | LUG: $scope.cobrosTabla[j].localidad.NOMBRE, |
| 125 | IMP: $scope.cobrosTabla[j].importe, | 143 | IMP: $scope.cobrosTabla[j].importe, |
| 126 | LIB: $scope.cobrosTabla[j].librador, | 144 | LIB: $scope.cobrosTabla[j].librador, |
| 127 | EST: 'C',//'D' depositado, 'E' entregado, 'C' en cartera | 145 | EST: 'C',//'D' depositado, 'E' entregado, 'C' en cartera |
| 128 | PCI: $scope.cobrosTabla[j].provincia.ID, | 146 | PCI: $scope.cobrosTabla[j].provincia.ID, |
| 129 | LPLA: 0, | 147 | LPLA: 0, |
| 130 | PLA: 0, | 148 | PLA: 0, |
| 131 | VEN: $scope.usuario.CodVen,//Id vendedor | 149 | VEN: $scope.usuario.CodVen,//Id vendedor |
| 132 | CCLIE: $scope.cobranza.cliente.COD,//Id cliente | 150 | CCLIE: $scope.cobranza.cliente.COD,//Id cliente |
| 133 | REN: 0, | 151 | REN: 0, |
| 134 | PVEC: $scope.puntoVenta, | 152 | PVEC: $scope.puntoVenta, |
| 135 | NCOC: $scope.comprobante, | 153 | NCOC: $scope.comprobante, |
| 136 | OBSE: $scope.cobrosTabla[j].observaciones, | 154 | OBSE: $scope.cobrosTabla[j].observaciones, |
| 137 | LUV: 0, | 155 | LUV: 0, |
| 138 | ORI: 've', | 156 | ORI: 've', |
| 139 | FER: '', | 157 | FER: '', |
| 140 | BIMP: 0, | 158 | BIMP: 0, |
| 141 | COMP: 'C ' +'RC ' + $scope.puntoVenta + '-' + $scope.comprobante, | 159 | COMP: 'C ' +'RC ' + $scope.puntoVenta + '-' + $scope.comprobante, |
| 142 | VAL_E: '',//Cuando egresa por ingresos y egresos en el numero de egreso | 160 | VAL_E: '',//Cuando egresa por ingresos y egresos en el numero de egreso |
| 143 | VAL_I: '',//Cuando Ingresa por ingresos y egresos en el numero ingreso | 161 | VAL_I: '',//Cuando Ingresa por ingresos y egresos en el numero ingreso |
| 144 | REC_CAJ: 'D', | 162 | REC_CAJ: 'D', |
| 145 | TIPO_C: 0,//?? | 163 | TIPO_C: 0,//?? |
| 146 | SALDO_CAJ: 'S', | 164 | SALDO_CAJ: 'S', |
| 147 | FECHA_INGRESO: $scope.fecha | 165 | FECHA_INGRESO: $scope.fecha |
| 148 | .toISOString().slice(0, 19).replace('T', ' '), | 166 | .toISOString().slice(0, 19).replace('T', ' '), |
| 149 | Vendedor_valor: 0, | 167 | Vendedor_valor: 0, |
| 150 | FAMILIA: 0, | 168 | FAMILIA: 0, |
| 151 | CUIT_LIB: '', | 169 | CUIT_LIB: '', |
| 152 | COD_LUG: $scope.cobrosTabla[j].localidad.ID,//código lugar | 170 | COD_LUG: $scope.cobrosTabla[j].localidad.ID,//código lugar |
| 153 | SEN: '', | 171 | SEN: '', |
| 154 | NRC: 0, | 172 | NRC: 0, |
| 155 | COD_LARGO: '', | 173 | COD_LARGO: '', |
| 156 | VN: 0, | 174 | VN: 0, |
| 157 | ID_LECTOR: 0, | 175 | ID_LECTOR: 0, |
| 158 | NATHB: '' | 176 | NATHB: '' |
| 159 | }; | 177 | }; |
| 160 | cheques.push(cheque); | 178 | cheques.push(cheque); |
| 161 | } | 179 | } |
| 162 | } | 180 | } |
| 163 | 181 | ||
| 164 | cobranza = { | 182 | cobranza = { |
| 165 | recibo: { | 183 | recibo: { |
| 166 | CYV: 'V', | 184 | CYV: 'V', |
| 167 | TIP: 'C', | 185 | TIP: 'C', |
| 168 | TCO: 'RC', | 186 | TCO: 'RC', |
| 169 | PVE: $scope.puntoVenta, //Sucursar, punto de venta | 187 | PVE: $scope.puntoVenta, //Sucursar, punto de venta |
| 170 | NCO: $scope.comprobante, //Numero de comprobante | 188 | NCO: $scope.comprobante, //Numero de comprobante |
| 171 | FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), | 189 | FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), |
| 172 | CLI: $scope.cobranza.cliente.COD, | 190 | CLI: $scope.cobranza.cliente.COD, |
| 173 | ATO: 0, //número de asiento | 191 | ATO: 0, //número de asiento |
| 174 | CFE: $scope.cobranza.cobrador.NomVen, | 192 | CFE: $scope.cobranza.cobrador.NomVen, |
| 175 | PLA: '',//Numero de planilla, sin uso | 193 | PLA: '',//Numero de planilla, sin uso |
| 176 | ID_MONEDA: $scope.cobranza.moneda.ID, | 194 | ID_MONEDA: $scope.cobranza.moneda.ID, |
| 177 | COTIZACION: $scope.cobranza.cotizacion.VENDEDOR, | 195 | COTIZACION: $scope.cobranza.cotizacion.VENDEDOR, |
| 178 | idCobrador: $scope.cobranza.cobrador.CodVen | 196 | idCobrador: $scope.cobranza.cobrador.CodVen |
| 179 | }, | 197 | }, |
| 180 | cuerpo: cuerpos, | 198 | cuerpo: cuerpos, |
| 181 | cheques: cheques, | 199 | cheques: cheques, |
| 182 | acobypag: { | 200 | acobypag: { |
| 183 | CYV: 'V', | 201 | CYV: 'V', |
| 184 | COD: $scope.cobranza.cliente.COD, | 202 | COD: $scope.cobranza.cliente.COD, |
| 185 | FEP: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), | 203 | FEP: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), |
| 186 | TIP: 'C', | 204 | TIP: 'C', |
| 187 | TCO: 'RC', | 205 | TCO: 'RC', |
| 188 | SUC: $scope.puntoVenta, | 206 | SUC: $scope.puntoVenta, |
| 189 | NCO: $scope.comprobante, | 207 | NCO: $scope.comprobante, |
| 190 | IPA: $scope.getTotalCobrado(), | 208 | IPA: $scope.getTotalCobrado(), |
| 191 | SAL: '',//?? | 209 | SAL: '',//?? |
| 192 | TCA: 1, | 210 | TCA: 1, |
| 193 | ZONA: 1, | 211 | ZONA: 1, |
| 194 | FPA: 2,//Forma de pago | 212 | FPA: 2,//Forma de pago |
| 195 | REC: 0, | 213 | REC: 0, |
| 196 | REP: 0, | 214 | REP: 0, |
| 197 | FER: null, | 215 | FER: null, |
| 198 | REM: 0, | 216 | REM: 0, |
| 199 | FRE: null,//?? | 217 | FRE: null,//?? |
| 200 | PRO: 'N', | 218 | PRO: 'N', |
| 201 | FEV: $scope.fecha.toISOString().slice(0, 19).replace('T', ' ') | 219 | FEV: $scope.fecha.toISOString().slice(0, 19).replace('T', ' ') |
| 202 | }, | 220 | }, |
| 203 | datosCobrador: { | 221 | datosCobrador: { |
| 204 | COD: $scope.cobranza.cobrador.CodVen, | 222 | COD: $scope.cobranza.cobrador.CodVen, |
| 205 | PVE: $scope.puntoVenta, | 223 | PVE: $scope.puntoVenta, |
| 206 | NUM: $scope.comprobante, | 224 | NUM: $scope.comprobante, |
| 207 | EST: 'C', | 225 | EST: 'C', |
| 208 | OBS: 'RC: ' + $scope.comprobante + '-' + $scope.fecha.toLocaleDateString(), | 226 | OBS: 'RC: ' + $scope.comprobante + '-' + $scope.fecha.toLocaleDateString(), |
| 209 | DAT1: 'C', | 227 | DAT1: 'C', |
| 210 | CLI: $scope.cobranza.cliente.COD | 228 | CLI: $scope.cobranza.cliente.COD |
| 211 | } | 229 | } |
| 212 | }; | 230 | }; |
| 213 | focaCrearCobranzaService.guardarCobranza(cobranza).then( | 231 | focaCrearCobranzaService.guardarCobranza(cobranza).then( |
| 214 | function(result) { | 232 | function(result) { |
| 215 | focaBotoneraLateralService.endGuardar(true); | 233 | focaBotoneraLateralService.endGuardar(true); |
| 216 | $scope.saveLoading = false; | 234 | $scope.saveLoading = false; |
| 217 | focaModalService.alert('Cobranza guardada con éxito'); | 235 | focaModalService.alert('Cobranza guardada con éxito'); |
| 218 | 236 | ||
| 219 | focaSeguimientoService.guardarPosicion( | 237 | focaSeguimientoService.guardarPosicion( |
| 220 | result.data.numero, | 238 | result.data.numero, |
| 221 | 'Cobranza', | 239 | 'Cobranza', |
| 222 | 'Nº: ' + $filter('comprobante')([ | 240 | 'Nº: ' + $filter('comprobante')([ |
| 223 | result.data.sucursal, | 241 | result.data.sucursal, |
| 224 | result.data.numero | 242 | result.data.numero |
| 225 | ]) + '<br/>' + | 243 | ]) + '<br/>' + |
| 226 | 'Vendedor: ' + $scope.cobranza.cobrador.NomVen + '<br/>' + | 244 | 'Vendedor: ' + $scope.cobranza.cobrador.NomVen + '<br/>' + |
| 227 | 'Total: ' + $filter('currency')($scope.getTotalCobrado()), | 245 | 'Total: ' + $filter('currency')($scope.getTotalCobrado()), |
| 228 | result.data.sucursal | 246 | result.data.sucursal |
| 229 | ); | 247 | ); |
| 230 | 248 | ||
| 231 | $scope.cobranza = { | 249 | $scope.cobranza = { |
| 232 | fecha: new Date() | 250 | fecha: new Date() |
| 233 | }; | 251 | }; |
| 234 | setearMonedaPorDefecto(); | 252 | setearMonedaPorDefecto(); |
| 235 | obtenerNumeroComprobante(); | 253 | obtenerNumeroComprobante(); |
| 236 | 254 | ||
| 237 | $scope.$broadcast('cleanCabecera'); | 255 | $scope.$broadcast('cleanCabecera'); |
| 238 | $scope.fecha = new Date(); | 256 | $scope.fecha = new Date(); |
| 239 | $scope.facturaTabla = []; | 257 | $scope.facturaTabla = []; |
| 240 | $scope.cobrosTabla = []; | 258 | $scope.cobrosTabla = []; |
| 241 | }, function(error) { | 259 | }, function(error) { |
| 242 | focaModalService.alert('Hubo un problema al cargar la cobranza'); | 260 | focaModalService.alert('Hubo un problema al cargar la cobranza'); |
| 243 | focaBotoneraLateralService.endGuardar(); | 261 | focaBotoneraLateralService.endGuardar(); |
| 244 | $scope.saveLoading = false; | 262 | $scope.saveLoading = false; |
| 245 | console.info(error); | 263 | console.info(error); |
| 246 | } | 264 | } |
| 247 | ); | 265 | ); |
| 248 | }; | 266 | }; |
| 249 | 267 | ||
| 250 | $scope.seleccionarCobros = function() { | 268 | $scope.seleccionarCobros = function() { |
| 251 | $scope.cobroDeuda = false; | 269 | $scope.cobroDeuda = false; |
| 252 | }; | 270 | }; |
| 253 | 271 | ||
| 254 | $scope.seleccionarComprobantes = function() { | 272 | $scope.seleccionarComprobantes = function() { |
| 255 | $scope.cobroDeuda = true; | 273 | $scope.cobroDeuda = true; |
| 256 | }; | 274 | }; |
| 257 | 275 | ||
| 258 | $scope.seleccionarCobranza = function() { | 276 | $scope.seleccionarCobranza = function() { |
| 259 | 277 | ||
| 260 | var modalInstance = $uibModal.open( | 278 | var modalInstance = $uibModal.open( |
| 261 | { | 279 | { |
| 262 | ariaLabelledBy: 'Busqueda de Cobranzas', | 280 | ariaLabelledBy: 'Busqueda de Cobranzas', |
| 263 | templateUrl: 'foca-modal-cobranza.html', | 281 | templateUrl: 'foca-modal-cobranza.html', |
| 264 | controller: 'focaModalCobranzaController', | 282 | controller: 'focaModalCobranzaController', |
| 265 | size: 'lg' | 283 | size: 'lg' |
| 266 | } | 284 | } |
| 267 | ); | 285 | ); |
| 268 | modalInstance.result.then(function(cobranza) { | 286 | modalInstance.result.then(function(cobranza) { |
| 269 | $scope.editando = true; | 287 | $scope.editando = true; |
| 270 | $scope.facturaTabla = []; | 288 | $scope.facturaTabla = []; |
| 271 | $scope.cobrosTabla = []; | 289 | $scope.cobrosTabla = []; |
| 272 | $scope.$broadcast('cleanCabecera'); | 290 | $scope.$broadcast('cleanCabecera'); |
| 273 | 291 | ||
| 274 | $scope.fecha = new Date(cobranza.fecha); | 292 | $scope.fecha = new Date(cobranza.fecha); |
| 275 | 293 | ||
| 276 | $scope.$broadcast('addCabecera', { | 294 | $scope.$broadcast('addCabecera', { |
| 277 | label: 'Cliente:', | 295 | label: 'Cliente:', |
| 278 | valor: cobranza.cliente.NOM | 296 | valor: cobranza.cliente.NOM |
| 279 | }); | 297 | }); |
| 280 | $scope.$broadcast('addCabecera', { | 298 | $scope.$broadcast('addCabecera', { |
| 281 | label: 'Cobrador:', | 299 | label: 'Cobrador:', |
| 282 | valor: cobranza.cobrador | 300 | valor: cobranza.cobrador |
| 283 | }); | 301 | }); |
| 284 | 302 | ||
| 285 | $scope.facturaTabla = cobranza.facturas; | 303 | $scope.facturaTabla = cobranza.facturas; |
| 286 | $scope.cobrosTabla = cobranza.cobros; | 304 | $scope.cobrosTabla = cobranza.cobros; |
| 287 | }); | 305 | }); |
| 288 | }; | 306 | }; |
| 289 | 307 | ||
| 290 | $scope.seleccionarCliente = function() { | 308 | $scope.seleccionarCliente = function() { |
| 291 | 309 | ||
| 292 | var modalInstance = $uibModal.open( | 310 | var modalInstance = $uibModal.open( |
| 293 | { | 311 | { |
| 294 | ariaLabelledBy: 'Busqueda de Cliente', | 312 | ariaLabelledBy: 'Busqueda de Cliente', |
| 295 | templateUrl: 'foca-busqueda-cliente-modal.html', | 313 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 296 | controller: 'focaBusquedaClienteModalController', | 314 | controller: 'focaBusquedaClienteModalController', |
| 297 | size: 'lg' | 315 | size: 'lg' |
| 298 | } | 316 | } |
| 299 | ); | 317 | ); |
| 300 | modalInstance.result.then( | 318 | modalInstance.result.then( |
| 301 | function(cliente) { | 319 | function(cliente) { |
| 302 | $scope.$broadcast('addCabecera', { | 320 | $scope.$broadcast('addCabecera', { |
| 303 | label: 'Cliente:', | 321 | label: 'Cliente:', |
| 304 | valor: cliente.nom | 322 | valor: cliente.nom |
| 305 | }); | 323 | }); |
| 306 | $scope.cobranza.cliente = { | 324 | $scope.cobranza.cliente = { |
| 307 | COD: cliente.cod, | 325 | COD: cliente.cod, |
| 308 | CUIT: cliente.cuit, | 326 | CUIT: cliente.cuit, |
| 309 | NOM: cliente.nom | 327 | NOM: cliente.nom |
| 310 | }; | 328 | }; |
| 311 | }, function() { | 329 | }, function() { |
| 312 | 330 | ||
| 313 | } | 331 | } |
| 314 | ); | 332 | ); |
| 315 | }; | 333 | }; |
| 316 | 334 | ||
| 317 | $scope.seleccionarFactura = function() { | 335 | $scope.seleccionarFactura = function() { |
| 318 | if(!$scope.cobranza.cliente) { | 336 | if(!$scope.cobranza.cliente) { |
| 319 | focaModalService.alert('Seleccione primero un cliente'); | 337 | focaModalService.alert('Seleccione primero un cliente'); |
| 320 | return; | 338 | return; |
| 321 | } | 339 | } |
| 322 | var modalInstance = $uibModal.open( | 340 | var modalInstance = $uibModal.open( |
| 323 | { | 341 | { |
| 324 | ariaLabelledBy: 'Busqueda de Facturas', | 342 | ariaLabelledBy: 'Busqueda de Facturas', |
| 325 | templateUrl: 'foca-modal-factura.html', | 343 | templateUrl: 'foca-modal-factura.html', |
| 326 | controller: 'focaModalFacturaController', | 344 | controller: 'focaModalFacturaController', |
| 327 | size: 'lg', | 345 | size: 'lg', |
| 328 | resolve: { | 346 | resolve: { |
| 329 | parametrosFactura: function() { | 347 | parametrosFactura: function() { |
| 330 | return { | 348 | return { |
| 331 | cliente: $scope.cobranza.cliente, | 349 | cliente: $scope.cobranza.cliente, |
| 332 | simbolo: $scope.cobranza.moneda.SIMBOLO, | 350 | simbolo: $scope.cobranza.moneda.SIMBOLO, |
| 333 | cotizacion: $scope.cobranza.cotizacion.VENDEDOR, | 351 | cotizacion: $scope.cobranza.cotizacion.VENDEDOR, |
| 334 | moneda: $scope.cobranza.moneda.ID | 352 | moneda: $scope.cobranza.moneda.ID |
| 335 | }; | 353 | }; |
| 336 | } | 354 | } |
| 337 | } | 355 | } |
| 338 | } | 356 | } |
| 339 | ); | 357 | ); |
| 340 | modalInstance.result.then( | 358 | modalInstance.result.then( |
| 341 | function(facturas) { | 359 | function(facturas) { |
| 342 | $scope.facturaTabla = $scope.facturaTabla.concat(facturas); | 360 | $scope.facturaTabla = $scope.facturaTabla.concat(facturas); |
| 343 | }, function() { | 361 | }, function() { |
| 344 | 362 | ||
| 345 | } | 363 | } |
| 346 | ); | 364 | ); |
| 347 | }; | 365 | }; |
| 348 | 366 | ||
| 349 | $scope.seleccionarCheque = function() { | 367 | $scope.seleccionarCheque = function() { |
| 350 | var modalInstance = $uibModal.open( | 368 | var modalInstance = $uibModal.open( |
| 351 | { | 369 | { |
| 352 | ariaLabelledBy: 'Carga de cheques', | 370 | ariaLabelledBy: 'Carga de cheques', |
| 353 | templateUrl: 'modal-cheque.html', | 371 | templateUrl: 'modal-cheque.html', |
| 354 | controller: 'focaModalChequeController', | 372 | controller: 'focaModalChequeController', |
| 355 | size: 'lg', | 373 | size: 'lg', |
| 356 | resolve: { | 374 | resolve: { |
| 357 | sugerido: function() { | 375 | sugerido: function() { |
| 358 | var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); | 376 | var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); |
| 359 | return sugerido < 0 ? sugerido : null; | 377 | return sugerido < 0 ? sugerido : null; |
| 360 | } | 378 | } |
| 361 | } | 379 | } |
| 362 | } | 380 | } |
| 363 | ); | 381 | ); |
| 364 | modalInstance.result.then( | 382 | modalInstance.result.then( |
| 365 | function(cheque) { | 383 | function(cheque) { |
| 366 | var cobro = { | 384 | var cobro = { |
| 367 | tipo: 'Ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco, | 385 | tipo: 'Ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco, |
| 368 | numero: cheque.numero, | 386 | numero: cheque.numero, |
| 369 | banco: cheque.banco, | 387 | banco: cheque.banco, |
| 370 | fecha: cheque.fechaEmision.toLocaleDateString() + '-' + | 388 | fecha: cheque.fechaEmision.toLocaleDateString() + '-' + |
| 371 | cheque.fechaPresentacion.toLocaleDateString(), | 389 | cheque.fechaPresentacion.toLocaleDateString(), |
| 372 | fechaPresentacion: cheque.fechaPresentacion, | 390 | fechaPresentacion: cheque.fechaPresentacion, |
| 373 | fechaEmision: cheque.fechaEmision, | 391 | fechaEmision: cheque.fechaEmision, |
| 374 | importe: cheque.importe * $scope.cobranza.cotizacion.VENDEDOR, | 392 | importe: cheque.importe * $scope.cobranza.cotizacion.VENDEDOR, |
| 375 | localidad: cheque.localidad, | 393 | localidad: cheque.localidad, |
| 376 | librador: cheque.librador, | 394 | librador: cheque.librador, |
| 377 | provincia: cheque.provincia, | 395 | provincia: cheque.provincia, |
| 378 | observaciones: cheque.observaciones | 396 | observaciones: cheque.observaciones |
| 379 | }; | 397 | }; |
| 380 | $scope.cobrosTabla.push(cobro); | 398 | $scope.cobrosTabla.push(cobro); |
| 381 | }, function() { | 399 | }, function() { |
| 382 | 400 | ||
| 383 | } | 401 | } |
| 384 | ); | 402 | ); |
| 385 | }; | 403 | }; |
| 386 | 404 | ||
| 387 | $scope.seleccionarEfectivo = function() { | 405 | $scope.seleccionarEfectivo = function() { |
| 388 | var modalInstance = $uibModal.open( | 406 | var modalInstance = $uibModal.open( |
| 389 | { | 407 | { |
| 390 | ariaLabelledBy: 'Carga de cheques', | 408 | ariaLabelledBy: 'Carga de cheques', |
| 391 | templateUrl: 'modal-efectivo.html', | 409 | templateUrl: 'modal-efectivo.html', |
| 392 | controller: 'focaModalEfectivoController', | 410 | controller: 'focaModalEfectivoController', |
| 393 | size: 'sm', | 411 | size: 'sm', |
| 394 | resolve: { | 412 | resolve: { |
| 395 | sugerido: function() { | 413 | sugerido: function() { |
| 396 | var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); | 414 | var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); |
| 397 | return sugerido < 0 ? sugerido : null; | 415 | return sugerido < 0 ? sugerido : null; |
| 398 | } | 416 | } |
| 399 | } | 417 | } |
| 400 | } | 418 | } |
| 401 | ); | 419 | ); |
| 402 | modalInstance.result.then( | 420 | modalInstance.result.then( |
| 403 | function(efectivo) { | 421 | function(efectivo) { |
| 404 | var cobro = { | 422 | var cobro = { |
| 405 | tipo: 'Efectivo', | 423 | tipo: 'Efectivo', |
| 406 | fecha: new Date(), | 424 | fecha: new Date(), |
| 407 | importe: efectivo * $scope.cobranza.cotizacion.VENDEDOR | 425 | importe: efectivo * $scope.cobranza.cotizacion.VENDEDOR |
| 408 | }; | 426 | }; |
| 409 | $scope.cobrosTabla = $scope.cobrosTabla.filter(function(a) { | 427 | $scope.cobrosTabla = $scope.cobrosTabla.filter(function(a) { |
| 410 | return a.tipo !== 'Efectivo'; | 428 | return a.tipo !== 'Efectivo'; |
| 411 | }); | 429 | }); |
| 412 | $scope.cobrosTabla.push(cobro); | 430 | $scope.cobrosTabla.push(cobro); |
| 413 | }, function() { | 431 | }, function() { |
| 414 | 432 | ||
| 415 | } | 433 | } |
| 416 | ); | 434 | ); |
| 417 | }; | 435 | }; |
| 418 | 436 | ||
| 419 | $scope.seleccionarMoneda = function() { | 437 | $scope.seleccionarMoneda = function() { |
| 420 | var modalInstance = $uibModal.open( | 438 | var modalInstance = $uibModal.open( |
| 421 | { | 439 | { |
| 422 | ariaLabelledBy: 'Busqueda de Moneda', | 440 | ariaLabelledBy: 'Busqueda de Moneda', |
| 423 | templateUrl: 'modal-moneda.html', | 441 | templateUrl: 'modal-moneda.html', |
| 424 | controller: 'focaModalMonedaController', | 442 | controller: 'focaModalMonedaController', |
| 425 | size: 'lg' | 443 | size: 'lg' |
| 426 | } | 444 | } |
| 427 | ); | 445 | ); |
| 428 | modalInstance.result.then( | 446 | modalInstance.result.then( |
| 429 | function(moneda) { | 447 | function(moneda) { |
| 430 | $scope.seleccionarCotizacion(moneda); | 448 | $scope.seleccionarCotizacion(moneda); |
| 431 | }, function() { | 449 | }, function() { |
| 432 | 450 | ||
| 433 | } | 451 | } |
| 434 | ); | 452 | ); |
| 435 | }; | 453 | }; |
| 436 | 454 | ||
| 437 | $scope.seleccionarCotizacion = function(moneda) { | 455 | $scope.seleccionarCotizacion = function(moneda) { |
| 438 | var modalInstance = $uibModal.open( | 456 | var modalInstance = $uibModal.open( |
| 439 | { | 457 | { |
| 440 | ariaLabelledBy: 'Busqueda de Cotización', | 458 | ariaLabelledBy: 'Busqueda de Cotización', |
| 441 | templateUrl: 'modal-cotizacion.html', | 459 | templateUrl: 'modal-cotizacion.html', |
| 442 | controller: 'focaModalCotizacionController', | 460 | controller: 'focaModalCotizacionController', |
| 443 | size: 'lg', | 461 | size: 'lg', |
| 444 | resolve: {idMoneda: function() {return moneda.ID;}} | 462 | resolve: {idMoneda: function() {return moneda.ID;}} |
| 445 | } | 463 | } |
| 446 | ); | 464 | ); |
| 447 | modalInstance.result.then( | 465 | modalInstance.result.then( |
| 448 | function(cotizacion) { | 466 | function(cotizacion) { |
| 449 | $scope.cobranza.moneda = moneda; | 467 | $scope.cobranza.moneda = moneda; |
| 450 | $scope.cobranza.cotizacion = cotizacion; | 468 | $scope.cobranza.cotizacion = cotizacion; |
| 451 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { | 469 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { |
| 452 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 470 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
| 453 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 471 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
| 454 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 472 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
| 455 | }else { | 473 | }else { |
| 456 | $scope.$broadcast('addCabecera', { | 474 | $scope.$broadcast('addCabecera', { |
| 457 | label: 'Moneda:', | 475 | label: 'Moneda:', |
| 458 | valor: moneda.DETALLE | 476 | valor: moneda.DETALLE |
| 459 | }); | 477 | }); |
| 460 | $scope.$broadcast('addCabecera', { | 478 | $scope.$broadcast('addCabecera', { |
| 461 | label: 'Fecha cotizacion:', | 479 | label: 'Fecha cotizacion:', |
| 462 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 480 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 463 | }); | 481 | }); |
| 464 | $scope.$broadcast('addCabecera', { | 482 | $scope.$broadcast('addCabecera', { |
| 465 | label: 'Cotizacion:', | 483 | label: 'Cotizacion:', |
| 466 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 484 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
| 467 | }); | 485 | }); |
| 468 | } | 486 | } |
| 469 | }, function() { | 487 | }, function() { |
| 470 | 488 | ||
| 471 | } | 489 | } |
| 472 | ); | 490 | ); |
| 473 | }; | 491 | }; |
| 474 | 492 | ||
| 475 | $scope.seleccionarCobrador = function() { | 493 | $scope.seleccionarCobrador = function() { |
| 476 | var modalInstance = $uibModal.open( | 494 | var modalInstance = $uibModal.open( |
| 477 | { | 495 | { |
| 478 | ariaLabelledBy: 'Busqueda de Cobradores', | 496 | ariaLabelledBy: 'Busqueda de Cobradores', |
| 479 | templateUrl: 'modal-cobradores.html', | 497 | templateUrl: 'modal-cobradores.html', |
| 480 | controller: 'focaModalCobradoresController', | 498 | controller: 'focaModalCobradoresController', |
| 481 | size: 'lg' | 499 | size: 'lg' |
| 482 | } | 500 | } |
| 483 | ); | 501 | ); |
| 484 | modalInstance.result.then( | 502 | modalInstance.result.then( |
| 485 | function(cobrador) { | 503 | function(cobrador) { |
| 486 | $scope.$broadcast('addCabecera', { | 504 | $scope.$broadcast('addCabecera', { |
| 487 | label: 'Cobrador:', | 505 | label: 'Cobrador:', |
| 488 | valor: cobrador.NomVen | 506 | valor: cobrador.NomVen |
| 489 | }); | 507 | }); |
| 490 | $scope.cobranza.cobrador = cobrador; | 508 | $scope.cobranza.cobrador = cobrador; |
| 491 | }, function() { | 509 | }, function() { |
| 492 | 510 | ||
| 493 | } | 511 | } |
| 494 | ); | 512 | ); |
| 495 | }; | 513 | }; |
| 496 | 514 | ||
| 497 | $scope.getTotalDeuda = function() { | 515 | $scope.getTotalDeuda = function() { |
| 498 | var total = 0; | 516 | var total = 0; |
| 499 | for (var i = 0; i < $scope.facturaTabla.length; i++) { | 517 | for (var i = 0; i < $scope.facturaTabla.length; i++) { |
| 500 | total += $scope.facturaTabla[i].IPA; | 518 | total += $scope.facturaTabla[i].IPA; |
| 501 | } | 519 | } |
| 502 | return parseFloat(total.toFixed(2)); | 520 | return parseFloat(total.toFixed(2)); |
| 503 | }; | 521 | }; |
| 504 | 522 | ||
| 505 | $scope.getTotalCobrado = function() { | 523 | $scope.getTotalCobrado = function() { |
| 506 | var total = 0; | 524 | var total = 0; |
| 507 | for (var i = 0; i < $scope.cobrosTabla.length; i++) { | 525 | for (var i = 0; i < $scope.cobrosTabla.length; i++) { |
| 508 | total += $scope.cobrosTabla[i].importe; | 526 | total += $scope.cobrosTabla[i].importe; |
| 509 | } | 527 | } |
| 510 | return parseFloat(total.toFixed(2)); | 528 | return parseFloat(total.toFixed(2)); |
| 511 | }; | 529 | }; |
| 512 | 530 | ||
| 513 | $scope.getSubTotal = function() { | 531 | $scope.getSubTotal = function() { |
| 514 | if($scope.articuloACargar) { | 532 | if($scope.articuloACargar) { |
| 515 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 533 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 516 | } | 534 | } |
| 517 | }; | 535 | }; |
| 518 | //Recibe aviso si el teclado está en uso | 536 | //Recibe aviso si el teclado está en uso |
| 519 | // $rootScope.$on('usarTeclado', function(event, data) { | 537 | // $rootScope.$on('usarTeclado', function(event, data) { |
| 520 | // if(data) { | 538 | // if(data) { |
| 521 | // $scope.mostrarTeclado = true; | 539 | // $scope.mostrarTeclado = true; |
| 522 | // return; | 540 | // return; |
| 523 | // } | 541 | // } |
| 524 | // $scope.mostrarTeclado = false; | 542 | // $scope.mostrarTeclado = false; |
| 525 | // }) | 543 | // }) |
| 526 | $scope.selectFocus = function($event) { | 544 | $scope.selectFocus = function($event) { |
| 527 | //Si el teclado esta en uso no selecciona el valor | 545 | //Si el teclado esta en uso no selecciona el valor |
| 528 | // if($scope.mostrarTeclado) { | 546 | // if($scope.mostrarTeclado) { |
| 529 | // return; | 547 | // return; |
| 530 | // } | 548 | // } |
| 531 | $event.target.select(); | 549 | $event.target.select(); |
| 532 | }; | 550 | }; |
| 533 | 551 | ||
| 534 | $scope.salir = function() { | 552 | $scope.salir = function() { |
| 535 | $location.path('/'); | 553 | $location.path('/'); |
| 536 | }; | 554 | }; |
| 537 | 555 | ||
| 538 | $scope.parsearATexto = function(articulo) { | 556 | $scope.parsearATexto = function(articulo) { |
| 539 | articulo.cantidad = parseFloat(articulo.cantidad); | 557 | articulo.cantidad = parseFloat(articulo.cantidad); |
| 540 | articulo.precio = parseFloat(articulo.precio); | 558 | articulo.precio = parseFloat(articulo.precio); |
| 541 | }; | 559 | }; |
| 542 | 560 | ||
| 543 | $scope.rellenar = function(relleno, longitud) { | 561 | $scope.rellenar = function(relleno, longitud) { |
| 544 | relleno = '' + relleno; | 562 | relleno = '' + relleno; |
| 545 | while (relleno.length < longitud) { | 563 | while (relleno.length < longitud) { |
| 546 | relleno = '0' + relleno; | 564 | relleno = '0' + relleno; |
| 547 | } | 565 | } |
| 548 | 566 | ||
| 549 | return relleno; | 567 | return relleno; |
| 550 | }; | 568 | }; |
| 551 | 569 | ||
| 552 | $scope.quitarFactura = function(key) { | 570 | $scope.quitarFactura = function(key) { |
| 553 | $scope.facturaTabla.splice(key, 1); | 571 | $scope.facturaTabla.splice(key, 1); |
| 554 | }; | 572 | }; |
| 555 | 573 | ||
| 556 | $scope.quitarCobro = function(key) { | 574 | $scope.quitarCobro = function(key) { |
| 557 | $scope.cobrosTabla.splice(key, 1); | 575 | $scope.cobrosTabla.splice(key, 1); |
| 558 | }; | 576 | }; |
| 559 | 577 | ||
| 560 | function setearMonedaPorDefecto() { | 578 | function setearMonedaPorDefecto() { |
| 561 | var monedaPorDefecto; | 579 | var monedaPorDefecto; |
| 562 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 580 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
| 563 | focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { | 581 | focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { |
| 564 | monedaPorDefecto = res.data[0]; | 582 | monedaPorDefecto = res.data[0]; |
| 565 | $scope.cobranza.moneda = monedaPorDefecto; | 583 | $scope.cobranza.moneda = monedaPorDefecto; |
| 566 | $scope.cobranza.cotizacion = monedaPorDefecto.cotizaciones[0]; | 584 | $scope.cobranza.cotizacion = monedaPorDefecto.cotizaciones[0]; |
| 567 | }); | 585 | }); |
| 568 | } | 586 | } |
| 569 | 587 | ||
| 570 | function obtenerNumeroComprobante() { | 588 | function obtenerNumeroComprobante() { |
| 571 | focaCrearCobranzaService.getNumeroRecibo().then( | 589 | focaCrearCobranzaService.getNumeroRecibo().then( |
| 572 | function(res) { | 590 | function(res) { |
| 573 | $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4); | 591 | $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4); |
| 574 | $scope.comprobante = $scope.rellenar(res.data.numeroRecibo, 8); | 592 | $scope.comprobante = $scope.rellenar(res.data.numeroRecibo, 8); |
| 575 | }, | 593 | }, |
| 576 | function(err) { | 594 | function(err) { |
| 577 | focaModalService.alert('La terminal no esta configurada correctamente'); | 595 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 578 | console.info(err); | 596 | console.info(err); |
| 579 | } | 597 | } |
| 580 | ); | 598 | ); |
| 581 | } | 599 | } |
| 582 | 600 | ||
| 583 | function salir() { | 601 | function salir() { |
| 584 | var cobranza = { | 602 | var cobranza = { |
| 585 | moneda: $scope.cobranza.moneda, | 603 | moneda: $scope.cobranza.moneda, |
| 586 | cotizacion: $scope.cobranza.cotizacion | 604 | cotizacion: $scope.cobranza.cotizacion |
| 587 | }; | 605 | }; |
| 588 | if(JSON.stringify($scope.cobranza) !== JSON.stringify(cobranza)) { | 606 | if(JSON.stringify($scope.cobranza) !== JSON.stringify(cobranza)) { |
| 589 | focaModalService | 607 | focaModalService |
| 590 | .confirm('¿Esta seguro de que desea salir? ' + | 608 | .confirm('¿Esta seguro de que desea salir? ' + |
| 591 | 'Se perderán todos los datos cargados.') | 609 | 'Se perderán todos los datos cargados.') |
| 592 | .then(function(data) { | 610 | .then(function(data) { |
| 593 | if(data) $location.path('/'); | 611 | if(data) $location.path('/'); |
| 594 | }); | 612 | }); |
| 595 | }else { | 613 | }else { |
| 596 | $location.path('/'); | 614 | $location.path('/'); |
| 597 | } | 615 | } |
| 598 | } | 616 | } |
| 599 | obtenerNumeroComprobante(); | 617 | obtenerNumeroComprobante(); |
| 600 | setearMonedaPorDefecto(); | 618 | setearMonedaPorDefecto(); |
| 601 | } | 619 | } |
| 602 | ]); | 620 | ]); |
| 603 | 621 |
src/js/service.js
| 1 | angular.module('focaCrearCobranza') | 1 | angular.module('focaCrearCobranza') |
| 2 | .service('focaCrearCobranzaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 2 | .service('focaCrearCobranzaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { |
| 3 | return { | 3 | return { |
| 4 | getNumeroRecibo: function() { | 4 | getNumeroRecibo: function() { |
| 5 | return $http.get(API_ENDPOINT.URL + '/recibo/numero-siguiente'); | 5 | return $http.get(API_ENDPOINT.URL + '/recibo/numero-siguiente'); |
| 6 | }, | 6 | }, |
| 7 | getCotizacionByIdMoneda: function(id) { | 7 | getCotizacionByIdMoneda: function(id) { |
| 8 | return $http.get(API_ENDPOINT.URL + '/moneda/' + id); | 8 | return $http.get(API_ENDPOINT.URL + '/moneda/' + id); |
| 9 | }, | 9 | }, |
| 10 | getUsuario: function(idUsuario) { | 10 | getUsuario: function(idUsuario) { |
| 11 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + idUsuario); | 11 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + idUsuario); |
| 12 | }, | 12 | }, |
| 13 | guardarCobranza: function(cobranza) { | 13 | guardarCobranza: function(cobranza) { |
| 14 | return $http.post(API_ENDPOINT.URL + '/recibo/guardar', cobranza); | 14 | return $http.post(API_ENDPOINT.URL + '/recibo/guardar', cobranza); |
| 15 | }, | 15 | }, |
| 16 | getBotonera: function() { | 16 | getCobradorById: function(id) { |
| 17 | return [ | 17 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id); |
| 18 | }, | ||
| 19 | getBotonera: function(idCobrador) { | ||
| 20 | var result = [ | ||
| 18 | { | 21 | { |
| 19 | label: 'Cliente', | 22 | label: 'Cliente', |
| 20 | image: 'cliente.png' | 23 | image: 'cliente.png' |
| 21 | }, | 24 | }, |
| 22 | { | 25 | { |
| 23 | label: 'Cobrador', | ||
| 24 | image: 'cobrador.png' | ||
| 25 | }, | ||
| 26 | { | ||
| 27 | label: 'Comprobantes', | 26 | label: 'Comprobantes', |
| 28 | image: 'comprobante.png' | 27 | image: 'comprobante.png' |
| 29 | }, | 28 | }, |
| 30 | { | 29 | { |
| 31 | label: 'Cobros', | 30 | label: 'Cobros', |
| 32 | image: 'cobros.png' | 31 | image: 'cobros.png' |
| 33 | }, | 32 | }, |
| 34 | { | 33 | { |
| 35 | label: 'Moneda', | 34 | label: 'Moneda', |
| 36 | image: 'moneda.png' | 35 | image: 'moneda.png' |
| 37 | } | 36 | } |
| 38 | ]; | 37 | ]; |
| 38 | if(!idCobrador) { | ||
| 39 | var cobradorBoton = { | ||
| 40 | label: 'Cobrador', | ||
| 41 | image: 'cobrador.png' | ||
| 42 | }; | ||
| 43 | result.unshift(cobradorBoton); | ||
| 44 | } | ||
| 45 | return result; |