Commit 68473ec2f2c418775ed11a89a6d18212ea330947

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'develop'

Master

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