Commit e84b5020b9a58b8369d87e1aec5078e8b561f3c6

Authored by Jose Pinto
1 parent 4ba3587f27
Exists in master

seleccionar cobrador al seleccionar cliente

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