Commit 3b8f25490ce73a817035622408b9839f734553b8

Authored by Jose Pinto
1 parent ffa256fb35
Exists in master

ok errores moneda

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