Commit 8f5c2df345a91c40c6cd82edbc1e1adbd9ee5f68

Authored by Jose Pinto
Exists in master

Merge remote-tracking branch 'upstream/master'

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
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 var modalInstance = $uibModal.open( 309 var modalInstance = $uibModal.open(
292 { 310 {
293 ariaLabelledBy: 'Busqueda de Cliente', 311 ariaLabelledBy: 'Busqueda de Cliente',
294 templateUrl: 'foca-busqueda-cliente-modal.html', 312 templateUrl: 'foca-busqueda-cliente-modal.html',
295 controller: 'focaBusquedaClienteModalController', 313 controller: 'focaBusquedaClienteModalController',
296 size: 'lg', 314 size: 'lg',
297 resolve: { 315 resolve: {
298 vendedor: function(){ return null; } 316 vendedor: function(){ return null; }
299 } 317 }
300 } 318 }
301 ); 319 );
302 modalInstance.result.then( 320 modalInstance.result.then(
303 function(cliente) { 321 function(cliente) {
304 $scope.$broadcast('addCabecera', { 322 $scope.$broadcast('addCabecera', {
305 label: 'Cliente:', 323 label: 'Cliente:',
306 valor: cliente.nom 324 valor: cliente.nom
307 }); 325 });
308 $scope.cobranza.cliente = { 326 $scope.cobranza.cliente = {
309 COD: cliente.cod, 327 COD: cliente.cod,
310 CUIT: cliente.cuit, 328 CUIT: cliente.cuit,
311 NOM: cliente.nom 329 NOM: cliente.nom
312 }; 330 };
313 }, function() { 331 }, function() {
314 332
315 } 333 }
316 ); 334 );
317 }; 335 };
318 336
319 $scope.seleccionarFactura = function() { 337 $scope.seleccionarFactura = function() {
320 if(!$scope.cobranza.cliente) { 338 if(!$scope.cobranza.cliente) {
321 focaModalService.alert('Seleccione primero un cliente'); 339 focaModalService.alert('Seleccione primero un cliente');
322 return; 340 return;
323 } 341 }
324 var modalInstance = $uibModal.open( 342 var modalInstance = $uibModal.open(
325 { 343 {
326 ariaLabelledBy: 'Busqueda de Facturas', 344 ariaLabelledBy: 'Busqueda de Facturas',
327 templateUrl: 'foca-modal-factura.html', 345 templateUrl: 'foca-modal-factura.html',
328 controller: 'focaModalFacturaController', 346 controller: 'focaModalFacturaController',
329 size: 'lg', 347 size: 'lg',
330 resolve: { 348 resolve: {
331 parametrosFactura: function() { 349 parametrosFactura: function() {
332 return { 350 return {
333 cliente: $scope.cobranza.cliente, 351 cliente: $scope.cobranza.cliente,
334 simbolo: $scope.cobranza.moneda.SIMBOLO, 352 simbolo: $scope.cobranza.moneda.SIMBOLO,
335 cotizacion: $scope.cobranza.cotizacion.VENDEDOR, 353 cotizacion: $scope.cobranza.cotizacion.VENDEDOR,
336 moneda: $scope.cobranza.moneda.ID 354 moneda: $scope.cobranza.moneda.ID
337 }; 355 };
338 } 356 }
339 } 357 }
340 } 358 }
341 ); 359 );
342 modalInstance.result.then( 360 modalInstance.result.then(
343 function(facturas) { 361 function(facturas) {
344 $scope.facturaTabla = $scope.facturaTabla.concat(facturas); 362 $scope.facturaTabla = $scope.facturaTabla.concat(facturas);
345 }, function() { 363 }, function() {
346 364
347 } 365 }
348 ); 366 );
349 }; 367 };
350 368
351 $scope.seleccionarCheque = function() { 369 $scope.seleccionarCheque = function() {
352 var modalInstance = $uibModal.open( 370 var modalInstance = $uibModal.open(
353 { 371 {
354 ariaLabelledBy: 'Carga de cheques', 372 ariaLabelledBy: 'Carga de cheques',
355 templateUrl: 'modal-cheque.html', 373 templateUrl: 'modal-cheque.html',
356 controller: 'focaModalChequeController', 374 controller: 'focaModalChequeController',
357 size: 'lg', 375 size: 'lg',
358 resolve: { 376 resolve: {
359 sugerido: function() { 377 sugerido: function() {
360 var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); 378 var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado();
361 return sugerido < 0 ? sugerido : null; 379 return sugerido < 0 ? sugerido : null;
362 } 380 }
363 } 381 }
364 } 382 }
365 ); 383 );
366 modalInstance.result.then( 384 modalInstance.result.then(
367 function(cheque) { 385 function(cheque) {
368 var cobro = { 386 var cobro = {
369 tipo: 'Ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco, 387 tipo: 'Ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco,
370 numero: cheque.numero, 388 numero: cheque.numero,
371 banco: cheque.banco, 389 banco: cheque.banco,
372 fecha: cheque.fechaEmision.toLocaleDateString() + '-' + 390 fecha: cheque.fechaEmision.toLocaleDateString() + '-' +
373 cheque.fechaPresentacion.toLocaleDateString(), 391 cheque.fechaPresentacion.toLocaleDateString(),
374 fechaPresentacion: cheque.fechaPresentacion, 392 fechaPresentacion: cheque.fechaPresentacion,
375 fechaEmision: cheque.fechaEmision, 393 fechaEmision: cheque.fechaEmision,
376 importe: cheque.importe * $scope.cobranza.cotizacion.VENDEDOR, 394 importe: cheque.importe * $scope.cobranza.cotizacion.VENDEDOR,
377 localidad: cheque.localidad, 395 localidad: cheque.localidad,
378 librador: cheque.librador, 396 librador: cheque.librador,
379 provincia: cheque.provincia, 397 provincia: cheque.provincia,
380 observaciones: cheque.observaciones 398 observaciones: cheque.observaciones
381 }; 399 };
382 $scope.cobrosTabla.push(cobro); 400 $scope.cobrosTabla.push(cobro);
383 }, function() { 401 }, function() {
384 402
385 } 403 }
386 ); 404 );
387 }; 405 };
388 406
389 $scope.seleccionarEfectivo = function() { 407 $scope.seleccionarEfectivo = function() {
390 var modalInstance = $uibModal.open( 408 var modalInstance = $uibModal.open(
391 { 409 {
392 ariaLabelledBy: 'Carga de cheques', 410 ariaLabelledBy: 'Carga de cheques',
393 templateUrl: 'modal-efectivo.html', 411 templateUrl: 'modal-efectivo.html',
394 controller: 'focaModalEfectivoController', 412 controller: 'focaModalEfectivoController',
395 size: 'sm', 413 size: 'sm',
396 resolve: { 414 resolve: {
397 sugerido: function() { 415 sugerido: function() {
398 var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); 416 var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado();
399 return sugerido < 0 ? sugerido : null; 417 return sugerido < 0 ? sugerido : null;
400 } 418 }
401 } 419 }
402 } 420 }
403 ); 421 );
404 modalInstance.result.then( 422 modalInstance.result.then(
405 function(efectivo) { 423 function(efectivo) {
406 var cobro = { 424 var cobro = {
407 tipo: 'Efectivo', 425 tipo: 'Efectivo',
408 fecha: new Date(), 426 fecha: new Date(),
409 importe: efectivo * $scope.cobranza.cotizacion.VENDEDOR 427 importe: efectivo * $scope.cobranza.cotizacion.VENDEDOR
410 }; 428 };
411 $scope.cobrosTabla = $scope.cobrosTabla.filter(function(a) { 429 $scope.cobrosTabla = $scope.cobrosTabla.filter(function(a) {
412 return a.tipo !== 'Efectivo'; 430 return a.tipo !== 'Efectivo';
413 }); 431 });
414 $scope.cobrosTabla.push(cobro); 432 $scope.cobrosTabla.push(cobro);
415 }, function() { 433 }, function() {
416 434
417 } 435 }
418 ); 436 );
419 }; 437 };
420 438
421 $scope.seleccionarMoneda = function() { 439 $scope.seleccionarMoneda = function() {
422 var modalInstance = $uibModal.open( 440 var modalInstance = $uibModal.open(
423 { 441 {
424 ariaLabelledBy: 'Busqueda de Moneda', 442 ariaLabelledBy: 'Busqueda de Moneda',
425 templateUrl: 'modal-moneda.html', 443 templateUrl: 'modal-moneda.html',
426 controller: 'focaModalMonedaController', 444 controller: 'focaModalMonedaController',
427 size: 'lg' 445 size: 'lg'
428 } 446 }
429 ); 447 );
430 modalInstance.result.then( 448 modalInstance.result.then(
431 function(moneda) { 449 function(moneda) {
432 $scope.seleccionarCotizacion(moneda); 450 $scope.seleccionarCotizacion(moneda);
433 }, function() { 451 }, function() {
434 452
435 } 453 }
436 ); 454 );
437 }; 455 };
438 456
439 $scope.seleccionarCotizacion = function(moneda) { 457 $scope.seleccionarCotizacion = function(moneda) {
440 var modalInstance = $uibModal.open( 458 var modalInstance = $uibModal.open(
441 { 459 {
442 ariaLabelledBy: 'Busqueda de Cotización', 460 ariaLabelledBy: 'Busqueda de Cotización',
443 templateUrl: 'modal-cotizacion.html', 461 templateUrl: 'modal-cotizacion.html',
444 controller: 'focaModalCotizacionController', 462 controller: 'focaModalCotizacionController',
445 size: 'lg', 463 size: 'lg',
446 resolve: {idMoneda: function() {return moneda.ID;}} 464 resolve: {idMoneda: function() {return moneda.ID;}}
447 } 465 }
448 ); 466 );
449 modalInstance.result.then( 467 modalInstance.result.then(
450 function(cotizacion) { 468 function(cotizacion) {
451 $scope.cobranza.moneda = moneda; 469 $scope.cobranza.moneda = moneda;
452 $scope.cobranza.cotizacion = cotizacion; 470 $scope.cobranza.cotizacion = cotizacion;
453 if(moneda.DETALLE === 'PESOS ARGENTINOS') { 471 if(moneda.DETALLE === 'PESOS ARGENTINOS') {
454 $scope.$broadcast('removeCabecera', 'Moneda:'); 472 $scope.$broadcast('removeCabecera', 'Moneda:');
455 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); 473 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
456 $scope.$broadcast('removeCabecera', 'Cotizacion:'); 474 $scope.$broadcast('removeCabecera', 'Cotizacion:');
457 }else { 475 }else {
458 $scope.$broadcast('addCabecera', { 476 $scope.$broadcast('addCabecera', {
459 label: 'Moneda:', 477 label: 'Moneda:',
460 valor: moneda.DETALLE 478 valor: moneda.DETALLE
461 }); 479 });
462 $scope.$broadcast('addCabecera', { 480 $scope.$broadcast('addCabecera', {
463 label: 'Fecha cotizacion:', 481 label: 'Fecha cotizacion:',
464 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 482 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
465 }); 483 });
466 $scope.$broadcast('addCabecera', { 484 $scope.$broadcast('addCabecera', {
467 label: 'Cotizacion:', 485 label: 'Cotizacion:',
468 valor: $filter('number')(cotizacion.VENDEDOR, '2') 486 valor: $filter('number')(cotizacion.VENDEDOR, '2')
469 }); 487 });
470 } 488 }
471 }, function() { 489 }, function() {
472 490
473 } 491 }
474 ); 492 );
475 }; 493 };
476 494
477 $scope.seleccionarCobrador = function() { 495 $scope.seleccionarCobrador = function() {
478 var modalInstance = $uibModal.open( 496 var modalInstance = $uibModal.open(
479 { 497 {
480 ariaLabelledBy: 'Busqueda de Cobradores', 498 ariaLabelledBy: 'Busqueda de Cobradores',
481 templateUrl: 'modal-cobradores.html', 499 templateUrl: 'modal-cobradores.html',
482 controller: 'focaModalCobradoresController', 500 controller: 'focaModalCobradoresController',
483 size: 'lg' 501 size: 'lg'
484 } 502 }
485 ); 503 );
486 modalInstance.result.then( 504 modalInstance.result.then(
487 function(cobrador) { 505 function(cobrador) {
488 $scope.$broadcast('addCabecera', { 506 $scope.$broadcast('addCabecera', {
489 label: 'Cobrador:', 507 label: 'Cobrador:',
490 valor: cobrador.NomVen 508 valor: cobrador.NomVen
491 }); 509 });
492 $scope.cobranza.cobrador = cobrador; 510 $scope.cobranza.cobrador = cobrador;
493 }, function() { 511 }, function() {
494 512
495 } 513 }
496 ); 514 );
497 }; 515 };
498 516
499 $scope.getTotalDeuda = function() { 517 $scope.getTotalDeuda = function() {
500 var total = 0; 518 var total = 0;
501 for (var i = 0; i < $scope.facturaTabla.length; i++) { 519 for (var i = 0; i < $scope.facturaTabla.length; i++) {
502 total += $scope.facturaTabla[i].IPA; 520 total += $scope.facturaTabla[i].IPA;
503 } 521 }
504 return parseFloat(total.toFixed(2)); 522 return parseFloat(total.toFixed(2));
505 }; 523 };
506 524
507 $scope.getTotalCobrado = function() { 525 $scope.getTotalCobrado = function() {
508 var total = 0; 526 var total = 0;
509 for (var i = 0; i < $scope.cobrosTabla.length; i++) { 527 for (var i = 0; i < $scope.cobrosTabla.length; i++) {
510 total += $scope.cobrosTabla[i].importe; 528 total += $scope.cobrosTabla[i].importe;
511 } 529 }
512 return parseFloat(total.toFixed(2)); 530 return parseFloat(total.toFixed(2));
513 }; 531 };
514 532
515 $scope.getSubTotal = function() { 533 $scope.getSubTotal = function() {
516 if($scope.articuloACargar) { 534 if($scope.articuloACargar) {
517 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 535 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
518 } 536 }
519 }; 537 };
520 //Recibe aviso si el teclado está en uso 538 //Recibe aviso si el teclado está en uso
521 // $rootScope.$on('usarTeclado', function(event, data) { 539 // $rootScope.$on('usarTeclado', function(event, data) {
522 // if(data) { 540 // if(data) {
523 // $scope.mostrarTeclado = true; 541 // $scope.mostrarTeclado = true;
524 // return; 542 // return;
525 // } 543 // }
526 // $scope.mostrarTeclado = false; 544 // $scope.mostrarTeclado = false;
527 // }) 545 // })
528 $scope.selectFocus = function($event) { 546 $scope.selectFocus = function($event) {
529 //Si el teclado esta en uso no selecciona el valor 547 //Si el teclado esta en uso no selecciona el valor
530 // if($scope.mostrarTeclado) { 548 // if($scope.mostrarTeclado) {
531 // return; 549 // return;
532 // } 550 // }
533 $event.target.select(); 551 $event.target.select();
534 }; 552 };
535 553
536 $scope.salir = function() { 554 $scope.salir = function() {
537 $location.path('/'); 555 $location.path('/');
538 }; 556 };
539 557
540 $scope.parsearATexto = function(articulo) { 558 $scope.parsearATexto = function(articulo) {
541 articulo.cantidad = parseFloat(articulo.cantidad); 559 articulo.cantidad = parseFloat(articulo.cantidad);
542 articulo.precio = parseFloat(articulo.precio); 560 articulo.precio = parseFloat(articulo.precio);
543 }; 561 };
544 562
545 $scope.rellenar = function(relleno, longitud) { 563 $scope.rellenar = function(relleno, longitud) {
546 relleno = '' + relleno; 564 relleno = '' + relleno;
547 while (relleno.length < longitud) { 565 while (relleno.length < longitud) {
548 relleno = '0' + relleno; 566 relleno = '0' + relleno;
549 } 567 }
550 568
551 return relleno; 569 return relleno;
552 }; 570 };
553 571
554 $scope.quitarFactura = function(key) { 572 $scope.quitarFactura = function(key) {
555 $scope.facturaTabla.splice(key, 1); 573 $scope.facturaTabla.splice(key, 1);
556 }; 574 };
557 575
558 $scope.quitarCobro = function(key) { 576 $scope.quitarCobro = function(key) {
559 $scope.cobrosTabla.splice(key, 1); 577 $scope.cobrosTabla.splice(key, 1);
560 }; 578 };
561 579
562 function setearMonedaPorDefecto() { 580 function setearMonedaPorDefecto() {
563 var monedaPorDefecto; 581 var monedaPorDefecto;
564 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' 582 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
565 focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { 583 focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) {
566 monedaPorDefecto = res.data[0]; 584 monedaPorDefecto = res.data[0];
567 $scope.cobranza.moneda = monedaPorDefecto; 585 $scope.cobranza.moneda = monedaPorDefecto;
568 $scope.cobranza.cotizacion = monedaPorDefecto.cotizaciones[0]; 586 $scope.cobranza.cotizacion = monedaPorDefecto.cotizaciones[0];
569 }); 587 });
570 } 588 }
571 589
572 function obtenerNumeroComprobante() { 590 function obtenerNumeroComprobante() {
573 focaCrearCobranzaService.getNumeroRecibo().then( 591 focaCrearCobranzaService.getNumeroRecibo().then(
574 function(res) { 592 function(res) {
575 $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4); 593 $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4);
576 $scope.comprobante = $scope.rellenar(res.data.numeroRecibo, 8); 594 $scope.comprobante = $scope.rellenar(res.data.numeroRecibo, 8);
577 }, 595 },
578 function(err) { 596 function(err) {
579 focaModalService.alert('La terminal no esta configurada correctamente'); 597 focaModalService.alert('La terminal no esta configurada correctamente');
580 console.info(err); 598 console.info(err);
581 } 599 }
582 ); 600 );
583 } 601 }
584 602
585 function salir() { 603 function salir() {
586 var cobranza = { 604 var cobranza = {
587 moneda: $scope.cobranza.moneda, 605 moneda: $scope.cobranza.moneda,
588 cotizacion: $scope.cobranza.cotizacion 606 cotizacion: $scope.cobranza.cotizacion
589 }; 607 };
590 if(JSON.stringify($scope.cobranza) !== JSON.stringify(cobranza)) { 608 if(JSON.stringify($scope.cobranza) !== JSON.stringify(cobranza)) {
591 focaModalService 609 focaModalService
592 .confirm('¿Esta seguro de que desea salir? ' + 610 .confirm('¿Esta seguro de que desea salir? ' +
593 'Se perderán todos los datos cargados.') 611 'Se perderán todos los datos cargados.')
594 .then(function(data) { 612 .then(function(data) {
595 if(data) $location.path('/'); 613 if(data) $location.path('/');
596 }); 614 });
597 }else { 615 }else {
598 $location.path('/'); 616 $location.path('/');
599 } 617 }
600 } 618 }
601 obtenerNumeroComprobante(); 619 obtenerNumeroComprobante();
602 setearMonedaPorDefecto(); 620 setearMonedaPorDefecto();
603 } 621 }
604 ]); 622 ]);
605 623
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;