Commit 4770decbd8d958eda1257246dbea8c123b98eb53

Authored by Jose Pinto
1 parent f9bf8cd3fb
Exists in master

agrego foca-cabecera-facturador

Showing 2 changed files with 45 additions and 108 deletions   Show diff stats
src/js/controller.js
1 angular.module('focaCrearCobranza') .controller('cobranzaController', 1 angular.module('focaCrearCobranza') .controller('cobranzaController',
2 [ 2 [
3 '$scope', 3 '$scope',
4 '$uibModal', 4 '$uibModal',
5 '$location', 5 '$location',
6 '$filter', 6 '$filter',
7 'focaCrearCobranzaService', 7 'focaCrearCobranzaService',
8 'focaModalService', 8 'focaModalService',
9 '$cookies', 9 '$cookies',
10 'focaSeguimientoService', 10 'focaSeguimientoService',
11 function($scope, $uibModal, $location, $filter, focaCrearCobranzaService, focaModalService, 11 function($scope, $uibModal, $location, $filter, focaCrearCobranzaService, focaModalService,
12 $cookies, focaSeguimientoService) 12 $cookies, focaSeguimientoService)
13 { 13 {
14
14 $scope.botonera = focaCrearCobranzaService.getBotonera(); 15 $scope.botonera = focaCrearCobranzaService.getBotonera();
15 $scope.datepickerAbierto = false; 16 $scope.datepickerAbierto = false;
16 $scope.cobroDeuda = true; 17 $scope.cobroDeuda = true;
17 $scope.show = false; 18 $scope.show = false;
18 $scope.cargando = true; 19 $scope.cargando = true;
19 $scope.dateOptions = { 20 $scope.dateOptions = {
20 maxDate: new Date(), 21 maxDate: new Date(),
21 minDate: new Date(2010, 0, 1) 22 minDate: new Date(2010, 0, 1)
22 }; 23 };
23 24
24 $scope.cabecera = [];
25 $scope.showCabecera = true;
26
27 $scope.cobranza = {}; 25 $scope.cobranza = {};
28 26
29 $scope.fecha = new Date(); 27 $scope.fecha = new Date();
30 $scope.puntoVenta = '0000'; 28 $scope.puntoVenta = '0000';
31 $scope.comprobante = '00000000'; 29 $scope.comprobante = '00000000';
32 $scope.facturaTabla = []; 30 $scope.facturaTabla = [];
33 $scope.cobrosTabla = []; 31 $scope.cobrosTabla = [];
34 32
35 focaCrearCobranzaService.getUsuario($cookies.get('idUsuario')).then(function(data) { 33 focaCrearCobranzaService.getUsuario($cookies.get('idUsuario')).then(function(data) {
36 $scope.usuario = data.data; 34 $scope.usuario = data.data;
37 }); 35 });
38 36
39 $scope.crearCobranza = function() { 37 $scope.crearCobranza = function() {
40 if(!$scope.cobranza.cliente) { 38 if(!$scope.cobranza.cliente) {
41 focaModalService.alert('Ingrese Cliente'); 39 focaModalService.alert('Ingrese Cliente');
42 return; 40 return;
43 } 41 }
44 if(!$scope.cobranza.cobrador) { 42 if(!$scope.cobranza.cobrador) {
45 focaModalService.alert('Ingrese Cobrador'); 43 focaModalService.alert('Ingrese Cobrador');
46 return; 44 return;
47 } 45 }
48 if($scope.facturaTabla.length < 1) { 46 if($scope.facturaTabla.length < 1) {
49 focaModalService.alert('Ingrese al menos una factura'); 47 focaModalService.alert('Ingrese al menos una factura');
50 return; 48 return;
51 } 49 }
52 if($scope.getTotalCobrado() + $scope.getTotalDeuda() !== 0) { 50 if($scope.getTotalCobrado() + $scope.getTotalDeuda() !== 0) {
53 focaModalService.alert('La diferencia debe ser ' + 51 focaModalService.alert('La diferencia debe ser ' +
54 $scope.cobranza.moneda.SIMBOLO + '0,00'); 52 $scope.cobranza.moneda.SIMBOLO + '0,00');
55 return; 53 return;
56 } 54 }
57 var cobranza = {}; 55 var cobranza = {};
58 var cheques = []; 56 var cheques = [];
59 var cuerpos = []; 57 var cuerpos = [];
60 //TODO: habilitar edición 58 //TODO: habilitar edición
61 $scope.editando = false; 59 $scope.editando = false;
62 $scope.saveLoading = true; 60 $scope.saveLoading = true;
63 for (var i = 0; i < $scope.facturaTabla.length; i++) { 61 for (var i = 0; i < $scope.facturaTabla.length; i++) {
64 var cuerpoFactura = { 62 var cuerpoFactura = {
65 CYV: 'V', 63 CYV: 'V',
66 TIP: 'C', 64 TIP: 'C',
67 TCO: 'RC', 65 TCO: 'RC',
68 PVE: $scope.puntoVenta, 66 PVE: $scope.puntoVenta,
69 NCO: $scope.comprobante, 67 NCO: $scope.comprobante,
70 LOP: 'L', 68 LOP: 'L',
71 TIL: $scope.facturaTabla[i].TCO, 69 TIL: $scope.facturaTabla[i].TCO,
72 COM: $scope.facturaTabla[i].numeroFactura + '-' + 70 COM: $scope.facturaTabla[i].numeroFactura + '-' +
73 $scope.rellenar($scope.facturaTabla[i].NCU,2), 71 $scope.rellenar($scope.facturaTabla[i].NCU,2),
74 FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), 72 FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '),
75 IMP: Math.abs($scope.facturaTabla[i].IPA), 73 IMP: Math.abs($scope.facturaTabla[i].IPA),
76 RES: 0,//caja de tesorería 74 RES: 0,//caja de tesorería
77 SUBM: 0 75 SUBM: 0
78 }; 76 };
79 cuerpos.push(cuerpoFactura); 77 cuerpos.push(cuerpoFactura);
80 } 78 }
81 79
82 for (var j = 0; j < $scope.cobrosTabla.length; j++) { 80 for (var j = 0; j < $scope.cobrosTabla.length; j++) {
83 81
84 var efectivo = $scope.cobrosTabla[j].tipo === 'Efectivo' ? true : false; 82 var efectivo = $scope.cobrosTabla[j].tipo === 'Efectivo' ? true : false;
85 83
86 var cuerpoCobros = { 84 var cuerpoCobros = {
87 CYV: 'V', 85 CYV: 'V',
88 TIP: 'C', 86 TIP: 'C',
89 TCO: 'RC', 87 TCO: 'RC',
90 PVE: $scope.puntoVenta, 88 PVE: $scope.puntoVenta,
91 NCO: $scope.comprobante, 89 NCO: $scope.comprobante,
92 LOP: 'P', 90 LOP: 'P',
93 TIL: 'EF', 91 TIL: 'EF',
94 COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : 'ch(' + 92 COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : 'ch(' +
95 $scope.cobrosTabla[j].numero + ')' + $scope.cobrosTabla[j].banco.desbco, 93 $scope.cobrosTabla[j].numero + ')' + $scope.cobrosTabla[j].banco.desbco,
96 FEC: efectivo ? 94 FEC: efectivo ?
97 $scope.cobrosTabla[j].fecha 95 $scope.cobrosTabla[j].fecha
98 .toISOString().slice(0, 19).replace('T', ' ') : 96 .toISOString().slice(0, 19).replace('T', ' ') :
99 $scope.cobrosTabla[j].fechaPresentacion 97 $scope.cobrosTabla[j].fechaPresentacion
100 .toISOString().slice(0, 19).replace('T', ' '), 98 .toISOString().slice(0, 19).replace('T', ' '),
101 IMP: Math.abs($scope.cobrosTabla[j].importe), 99 IMP: Math.abs($scope.cobrosTabla[j].importe),
102 RES: 0,//caja de tesorería 100 RES: 0,//caja de tesorería
103 SUBM: 0 101 SUBM: 0
104 }; 102 };
105 cuerpos.push(cuerpoCobros); 103 cuerpos.push(cuerpoCobros);
106 104
107 if(!efectivo) { 105 if(!efectivo) {
108 var cheque = { 106 var cheque = {
109 BCO: $scope.cobrosTabla[j].banco.ID, 107 BCO: $scope.cobrosTabla[j].banco.ID,
110 NUM: $scope.comprobante, 108 NUM: $scope.comprobante,
111 FEP: $scope.cobrosTabla[j].fechaPresentacion 109 FEP: $scope.cobrosTabla[j].fechaPresentacion
112 .toISOString().slice(0, 19).replace('T', ' '), 110 .toISOString().slice(0, 19).replace('T', ' '),
113 FEE: $scope.cobrosTabla[j].fechaEmision 111 FEE: $scope.cobrosTabla[j].fechaEmision
114 .toISOString().slice(0, 19).replace('T', ' '), 112 .toISOString().slice(0, 19).replace('T', ' '),
115 LUG: $scope.cobrosTabla[j].localidad.NOMBRE, 113 LUG: $scope.cobrosTabla[j].localidad.NOMBRE,
116 IMP: $scope.cobrosTabla[j].importe, 114 IMP: $scope.cobrosTabla[j].importe,
117 LIB: $scope.cobrosTabla[j].librador, 115 LIB: $scope.cobrosTabla[j].librador,
118 EST: 'C',//'D' depositado, 'E' entregado, 'C' en cartera 116 EST: 'C',//'D' depositado, 'E' entregado, 'C' en cartera
119 PCI: $scope.cobrosTabla[j].provincia.ID, 117 PCI: $scope.cobrosTabla[j].provincia.ID,
120 LPLA: 0, 118 LPLA: 0,
121 PLA: 0, 119 PLA: 0,
122 VEN: $scope.usuario.CodVen,//Id vendedor 120 VEN: $scope.usuario.CodVen,//Id vendedor
123 CCLIE: $scope.cobranza.cliente.COD,//Id cliente 121 CCLIE: $scope.cobranza.cliente.COD,//Id cliente
124 REN: 0, 122 REN: 0,
125 PVEC: $scope.puntoVenta, 123 PVEC: $scope.puntoVenta,
126 NCOC: $scope.comprobante, 124 NCOC: $scope.comprobante,
127 OBSE: $scope.cobrosTabla[j].observaciones, 125 OBSE: $scope.cobrosTabla[j].observaciones,
128 LUV: 0, 126 LUV: 0,
129 ORI: 've', 127 ORI: 've',
130 FER: '', 128 FER: '',
131 BIMP: 0, 129 BIMP: 0,
132 COMP: 'C ' +'RC ' + $scope.puntoVenta + '-' + $scope.comprobante, 130 COMP: 'C ' +'RC ' + $scope.puntoVenta + '-' + $scope.comprobante,
133 VAL_E: '',//Cuando egresa por ingresos y egresos en el numero de egreso 131 VAL_E: '',//Cuando egresa por ingresos y egresos en el numero de egreso
134 VAL_I: '',//Cuando Ingresa por ingresos y egresos en el numero ingreso 132 VAL_I: '',//Cuando Ingresa por ingresos y egresos en el numero ingreso
135 REC_CAJ: 'D', 133 REC_CAJ: 'D',
136 TIPO_C: 0,//?? 134 TIPO_C: 0,//??
137 SALDO_CAJ: 'S', 135 SALDO_CAJ: 'S',
138 FECHA_INGRESO: $scope.fecha 136 FECHA_INGRESO: $scope.fecha
139 .toISOString().slice(0, 19).replace('T', ' '), 137 .toISOString().slice(0, 19).replace('T', ' '),
140 Vendedor_valor: 0, 138 Vendedor_valor: 0,
141 FAMILIA: 0, 139 FAMILIA: 0,
142 CUIT_LIB: '', 140 CUIT_LIB: '',
143 COD_LUG: $scope.cobrosTabla[j].localidad.ID,//código lugar 141 COD_LUG: $scope.cobrosTabla[j].localidad.ID,//código lugar
144 SEN: '', 142 SEN: '',
145 NRC: 0, 143 NRC: 0,
146 COD_LARGO: '', 144 COD_LARGO: '',
147 VN: 0, 145 VN: 0,
148 ID_LECTOR: 0, 146 ID_LECTOR: 0,
149 NATHB: '' 147 NATHB: ''
150 }; 148 };
151 cheques.push(cheque); 149 cheques.push(cheque);
152 } 150 }
153 } 151 }
154 152
155 cobranza = { 153 cobranza = {
156 recibo: { 154 recibo: {
157 CYV: 'V', 155 CYV: 'V',
158 TIP: 'C', 156 TIP: 'C',
159 TCO: 'RC', 157 TCO: 'RC',
160 PVE: $scope.puntoVenta, //Sucursar, punto de venta 158 PVE: $scope.puntoVenta, //Sucursar, punto de venta
161 NCO: $scope.comprobante, //Numero de comprobante 159 NCO: $scope.comprobante, //Numero de comprobante
162 FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), 160 FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '),
163 CLI: $scope.cobranza.cliente.COD, 161 CLI: $scope.cobranza.cliente.COD,
164 ATO: 0, //número de asiento 162 ATO: 0, //número de asiento
165 CFE: $scope.cobranza.cobrador.nombre, 163 CFE: $scope.cobranza.cobrador.nombre,
166 PLA: '',//Numero de planilla, sin uso 164 PLA: '',//Numero de planilla, sin uso
167 ID_MONEDA: $scope.cobranza.moneda.ID, 165 ID_MONEDA: $scope.cobranza.moneda.ID,
168 COTIZACION: $scope.cobranza.cotizacion.VENDEDOR, 166 COTIZACION: $scope.cobranza.cotizacion.VENDEDOR,
169 idCobrador: $scope.cobranza.cobrador.id 167 idCobrador: $scope.cobranza.cobrador.id
170 }, 168 },
171 cuerpo: cuerpos, 169 cuerpo: cuerpos,
172 cheques: cheques, 170 cheques: cheques,
173 acobypag: { 171 acobypag: {
174 CYV: 'V', 172 CYV: 'V',
175 COD: $scope.cobranza.cliente.COD, 173 COD: $scope.cobranza.cliente.COD,
176 FEP: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), 174 FEP: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '),
177 TIP: 'C', 175 TIP: 'C',
178 TCO: 'RC', 176 TCO: 'RC',
179 SUC: $scope.puntoVenta, 177 SUC: $scope.puntoVenta,
180 NCO: $scope.comprobante, 178 NCO: $scope.comprobante,
181 IPA: $scope.getTotalCobrado(), 179 IPA: $scope.getTotalCobrado(),
182 SAL: '',//?? 180 SAL: '',//??
183 TCA: 1, 181 TCA: 1,
184 ZONA: 1, 182 ZONA: 1,
185 FPA: 2,//Forma de pago 183 FPA: 2,//Forma de pago
186 REC: 0, 184 REC: 0,
187 REP: 0, 185 REP: 0,
188 FER: null, 186 FER: null,
189 REM: 0, 187 REM: 0,
190 FRE: null,//?? 188 FRE: null,//??
191 PRO: 'N', 189 PRO: 'N',
192 FEV: $scope.fecha.toISOString().slice(0, 19).replace('T', ' ') 190 FEV: $scope.fecha.toISOString().slice(0, 19).replace('T', ' ')
193 }, 191 },
194 datosCobrador: { 192 datosCobrador: {
195 COD: $scope.cobranza.cobrador.id, 193 COD: $scope.cobranza.cobrador.id,
196 PVE: $scope.puntoVenta, 194 PVE: $scope.puntoVenta,
197 NUM: $scope.comprobante, 195 NUM: $scope.comprobante,
198 EST: 'C', 196 EST: 'C',
199 OBS: 'RC: ' + $scope.comprobante + '-' + $scope.fecha.toLocaleDateString(), 197 OBS: 'RC: ' + $scope.comprobante + '-' + $scope.fecha.toLocaleDateString(),
200 DAT1: 'C', 198 DAT1: 'C',
201 CLI: $scope.cobranza.cliente.COD 199 CLI: $scope.cobranza.cliente.COD
202 } 200 }
203 }; 201 };
204 focaCrearCobranzaService.guardarCobranza(cobranza).then( 202 focaCrearCobranzaService.guardarCobranza(cobranza).then(
205 function(result) { 203 function(result) {
206 $scope.saveLoading = false; 204 $scope.saveLoading = false;
207 focaModalService.alert('Cobranza guardada con éxito'); 205 focaModalService.alert('Cobranza guardada con éxito');
208 206
209 focaSeguimientoService.guardarPosicion( 207 focaSeguimientoService.guardarPosicion(
210 result.data.numero, 208 result.data.numero,
211 'Cobranza', 209 'Cobranza',
212 'Nº: ' + $filter('comprobante')([ 210 'Nº: ' + $filter('comprobante')([
213 result.data.sucursal, 211 result.data.sucursal,
214 result.data.numero 212 result.data.numero
215 ]) + '<br/>' + 213 ]) + '<br/>' +
216 'Vendedor: ' + $scope.cobranza.cobrador.nombre + '<br/>' + 214 'Vendedor: ' + $scope.cobranza.cobrador.nombre + '<br/>' +
217 'Total: ' + $filter('currency')($scope.getTotalCobrado()), 215 'Total: ' + $filter('currency')($scope.getTotalCobrado()),
218 result.data.sucursal 216 result.data.sucursal
219 ); 217 );
220 218
221 $scope.cobranza = { 219 $scope.cobranza = {
222 fecha: new Date() 220 fecha: new Date()
223 }; 221 };
224 setearMonedaPorDefecto(); 222 setearMonedaPorDefecto();
225 obtenerNumeroComprobante(); 223 obtenerNumeroComprobante();
226 224
227 $scope.cabecera = []; 225 $scope.$broadcast('cleanCabecera');
228 $scope.fecha = new Date(); 226 $scope.fecha = new Date();
229 $scope.facturaTabla = []; 227 $scope.facturaTabla = [];
230 $scope.cobrosTabla = []; 228 $scope.cobrosTabla = [];
231 }, function(error) { 229 }, function(error) {
232 focaModalService.alert('Hubo un problema al cargar la cobranza'); 230 focaModalService.alert('Hubo un problema al cargar la cobranza');
233 $scope.saveLoading = false; 231 $scope.saveLoading = false;
234 console.info(error); 232 console.info(error);
235 } 233 }
236 ); 234 );
237 }; 235 };
238 236
239 $scope.seleccionarCobros = function() { 237 $scope.seleccionarCobros = function() {
240 $scope.cobroDeuda = false; 238 $scope.cobroDeuda = false;
241 }; 239 };
242 240
243 $scope.seleccionarComprobantes = function() { 241 $scope.seleccionarComprobantes = function() {
244 $scope.cobroDeuda = true; 242 $scope.cobroDeuda = true;
245 }; 243 };
246 244
247 $scope.seleccionarCobranza = function() { 245 $scope.seleccionarCobranza = function() {
248 246
249 var modalInstance = $uibModal.open( 247 var modalInstance = $uibModal.open(
250 { 248 {
251 ariaLabelledBy: 'Busqueda de Cobranzas', 249 ariaLabelledBy: 'Busqueda de Cobranzas',
252 templateUrl: 'foca-modal-cobranza.html', 250 templateUrl: 'foca-modal-cobranza.html',
253 controller: 'focaModalCobranzaController', 251 controller: 'focaModalCobranzaController',
254 size: 'lg' 252 size: 'lg'
255 } 253 }
256 ); 254 );
257 modalInstance.result.then(function(cobranza) { 255 modalInstance.result.then(function(cobranza) {
258 $scope.editando = true; 256 $scope.editando = true;
259 $scope.cabecera = [];
260 $scope.facturaTabla = []; 257 $scope.facturaTabla = [];
261 $scope.cobrosTabla = []; 258 $scope.cobrosTabla = [];
259 $scope.$broadcast('cleanCabecera');
262 260
263 $scope.fecha = new Date(cobranza.fecha); 261 $scope.fecha = new Date(cobranza.fecha);
264 262
265 addCabecera('Cliente:', cobranza.cliente.NOM); 263 $scope.$broadcast('addCabecera', {
266 addCabecera('Cobrador:', cobranza.cobrador); 264 label: 'Cliente:',
265 valor: cobranza.cliente.NOM
266 });
267 $scope.$broadcast('addCabecera', {
268 label: 'Cobrador:',
269 valor: cobranza.cobrador
270 });
267 271
268 $scope.facturaTabla = cobranza.facturas; 272 $scope.facturaTabla = cobranza.facturas;
269 $scope.cobrosTabla = cobranza.cobros; 273 $scope.cobrosTabla = cobranza.cobros;
270 274
271 }); 275 });
272 }; 276 };
273 277
274 $scope.seleccionarCliente = function() { 278 $scope.seleccionarCliente = function() {
275 279
276 var modalInstance = $uibModal.open( 280 var modalInstance = $uibModal.open(
277 { 281 {
278 ariaLabelledBy: 'Busqueda de Cliente', 282 ariaLabelledBy: 'Busqueda de Cliente',
279 templateUrl: 'foca-busqueda-cliente-modal.html', 283 templateUrl: 'foca-busqueda-cliente-modal.html',
280 controller: 'focaBusquedaClienteModalController', 284 controller: 'focaBusquedaClienteModalController',
281 size: 'lg' 285 size: 'lg'
282 } 286 }
283 ); 287 );
284 modalInstance.result.then( 288 modalInstance.result.then(
285 function(cliente) { 289 function(cliente) {
286 addCabecera('Cliente:', cliente.nom); 290 $scope.$broadcast('addCabecera', {
291 label: 'Cliente:',
292 valor: cliente.nom
293 });
287 $scope.cobranza.cliente = { 294 $scope.cobranza.cliente = {
288 COD: cliente.cod, 295 COD: cliente.cod,
289 CUIT: cliente.cuit, 296 CUIT: cliente.cuit,
290 NOM: cliente.nom 297 NOM: cliente.nom
291 }; 298 };
292 }, function() { 299 }, function() {
293 300
294 } 301 }
295 ); 302 );
296 }; 303 };
297 304
298 $scope.seleccionarFactura = function() { 305 $scope.seleccionarFactura = function() {
299 if(!$scope.cobranza.cliente) { 306 if(!$scope.cobranza.cliente) {
300 focaModalService.alert('Seleccione primero un cliente'); 307 focaModalService.alert('Seleccione primero un cliente');
301 return; 308 return;
302 } 309 }
303 var modalInstance = $uibModal.open( 310 var modalInstance = $uibModal.open(
304 { 311 {
305 ariaLabelledBy: 'Busqueda de Facturas', 312 ariaLabelledBy: 'Busqueda de Facturas',
306 templateUrl: 'foca-modal-factura.html', 313 templateUrl: 'foca-modal-factura.html',
307 controller: 'focaModalFacturaController', 314 controller: 'focaModalFacturaController',
308 size: 'lg', 315 size: 'lg',
309 resolve: { 316 resolve: {
310 parametrosFactura: function() { 317 parametrosFactura: function() {
311 return { 318 return {
312 cliente: $scope.cobranza.cliente.COD, 319 cliente: $scope.cobranza.cliente.COD,
313 simbolo: $scope.cobranza.moneda.SIMBOLO, 320 simbolo: $scope.cobranza.moneda.SIMBOLO,
314 cotizacion: $scope.cobranza.cotizacion.VENDEDOR, 321 cotizacion: $scope.cobranza.cotizacion.VENDEDOR,
315 moneda: $scope.cobranza.moneda.ID 322 moneda: $scope.cobranza.moneda.ID
316 }; 323 };
317 } 324 }
318 } 325 }
319 } 326 }
320 ); 327 );
321 modalInstance.result.then( 328 modalInstance.result.then(
322 function(facturas) { 329 function(facturas) {
323 $scope.facturaTabla = $scope.facturaTabla.concat(facturas); 330 $scope.facturaTabla = $scope.facturaTabla.concat(facturas);
324 }, function() { 331 }, function() {
325 332
326 } 333 }
327 ); 334 );
328 }; 335 };
329 336
330 $scope.seleccionarCheque = function() { 337 $scope.seleccionarCheque = function() {
331 var modalInstance = $uibModal.open( 338 var modalInstance = $uibModal.open(
332 { 339 {
333 ariaLabelledBy: 'Carga de cheques', 340 ariaLabelledBy: 'Carga de cheques',
334 templateUrl: 'modal-cheque.html', 341 templateUrl: 'modal-cheque.html',
335 controller: 'focaModalChequeController', 342 controller: 'focaModalChequeController',
336 size: 'lg' 343 size: 'lg'
337 } 344 }
338 ); 345 );
339 modalInstance.result.then( 346 modalInstance.result.then(
340 function(cheque) { 347 function(cheque) {
341 var cobro = { 348 var cobro = {
342 tipo: 'Ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco, 349 tipo: 'Ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco,
343 numero: cheque.numero, 350 numero: cheque.numero,
344 banco: cheque.banco, 351 banco: cheque.banco,
345 fecha: cheque.fechaEmision.toLocaleDateString() + '-' + 352 fecha: cheque.fechaEmision.toLocaleDateString() + '-' +
346 cheque.fechaPresentacion.toLocaleDateString(), 353 cheque.fechaPresentacion.toLocaleDateString(),
347 fechaPresentacion: cheque.fechaPresentacion, 354 fechaPresentacion: cheque.fechaPresentacion,
348 fechaEmision: cheque.fechaEmision, 355 fechaEmision: cheque.fechaEmision,
349 importe: cheque.importe * $scope.cobranza.cotizacion.VENDEDOR, 356 importe: cheque.importe * $scope.cobranza.cotizacion.VENDEDOR,
350 localidad: cheque.localidad, 357 localidad: cheque.localidad,
351 librador: cheque.librador, 358 librador: cheque.librador,
352 provincia: cheque.provincia, 359 provincia: cheque.provincia,
353 observaciones: cheque.observaciones 360 observaciones: cheque.observaciones
354 }; 361 };
355 $scope.cobrosTabla.push(cobro); 362 $scope.cobrosTabla.push(cobro);
356 }, function() { 363 }, function() {
357 364
358 } 365 }
359 ); 366 );
360 }; 367 };
361 368
362 $scope.seleccionarEfectivo = function() { 369 $scope.seleccionarEfectivo = function() {
363 var modalInstance = $uibModal.open( 370 var modalInstance = $uibModal.open(
364 { 371 {
365 ariaLabelledBy: 'Carga de cheques', 372 ariaLabelledBy: 'Carga de cheques',
366 templateUrl: 'modal-efectivo.html', 373 templateUrl: 'modal-efectivo.html',
367 controller: 'focaModalEfectivoController', 374 controller: 'focaModalEfectivoController',
368 size: 'sm', 375 size: 'sm',
369 resolve: { 376 resolve: {
370 sugerido: function() { 377 sugerido: function() {
371 var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); 378 var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado();
372 return sugerido < 0 ? sugerido : null ; 379 return sugerido < 0 ? sugerido : null ;
373 } 380 }
374 } 381 }
375 } 382 }
376 ); 383 );
377 modalInstance.result.then( 384 modalInstance.result.then(
378 function(efectivo) { 385 function(efectivo) {
379 var cobro = { 386 var cobro = {
380 tipo: 'Efectivo', 387 tipo: 'Efectivo',
381 fecha: new Date(), 388 fecha: new Date(),
382 importe: efectivo * $scope.cobranza.cotizacion.VENDEDOR 389 importe: efectivo * $scope.cobranza.cotizacion.VENDEDOR
383 }; 390 };
384 $scope.cobrosTabla = $scope.cobrosTabla.filter(function(a) { 391 $scope.cobrosTabla = $scope.cobrosTabla.filter(function(a) {
385 return a.tipo !== 'Efectivo'; 392 return a.tipo !== 'Efectivo';
386 }); 393 });
387 $scope.cobrosTabla.push(cobro); 394 $scope.cobrosTabla.push(cobro);
388 }, function() { 395 }, function() {
389 396
390 } 397 }
391 ); 398 );
392 }; 399 };
393 400
394 $scope.seleccionarMoneda = function() { 401 $scope.seleccionarMoneda = function() {
395 var modalInstance = $uibModal.open( 402 var modalInstance = $uibModal.open(
396 { 403 {
397 ariaLabelledBy: 'Busqueda de Moneda', 404 ariaLabelledBy: 'Busqueda de Moneda',
398 templateUrl: 'modal-moneda.html', 405 templateUrl: 'modal-moneda.html',
399 controller: 'focaModalMonedaController', 406 controller: 'focaModalMonedaController',
400 size: 'lg' 407 size: 'lg'
401 } 408 }
402 ); 409 );
403 modalInstance.result.then( 410 modalInstance.result.then(
404 function(moneda) { 411 function(moneda) {
405 $scope.seleccionarCotizacion(moneda); 412 $scope.seleccionarCotizacion(moneda);
406 }, function() { 413 }, function() {
407 414
408 } 415 }
409 ); 416 );
410 }; 417 };
411 418
412 $scope.seleccionarCotizacion = function(moneda) { 419 $scope.seleccionarCotizacion = function(moneda) {
413 var modalInstance = $uibModal.open( 420 var modalInstance = $uibModal.open(
414 { 421 {
415 ariaLabelledBy: 'Busqueda de Cotización', 422 ariaLabelledBy: 'Busqueda de Cotización',
416 templateUrl: 'modal-cotizacion.html', 423 templateUrl: 'modal-cotizacion.html',
417 controller: 'focaModalCotizacionController', 424 controller: 'focaModalCotizacionController',
418 size: 'lg', 425 size: 'lg',
419 resolve: {idMoneda: function() {return moneda.ID;}} 426 resolve: {idMoneda: function() {return moneda.ID;}}
420 } 427 }
421 ); 428 );
422 modalInstance.result.then( 429 modalInstance.result.then(
423 function(cotizacion) { 430 function(cotizacion) {
424 $scope.cobranza.moneda = moneda; 431 $scope.cobranza.moneda = moneda;
425 $scope.cobranza.cotizacion = cotizacion; 432 $scope.cobranza.cotizacion = cotizacion;
426 addCabecera('Moneda:', moneda.DETALLE); 433 if(moneda.DETALLE === 'PESOS ARGENTINOS'){
427 addCabecera( 434 $scope.$broadcast('removeCabecera', 'Moneda:');
428 'Fecha cotizacion:', 435 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
429 $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 436 $scope.$broadcast('removeCabecera', 'Cotizacion:');
430 ); 437 }else{
431 addCabecera('Cotizacion:', cotizacion.VENDEDOR); 438 $scope.$broadcast('addCabecera', {
439 label: 'Moneda:',
440 valor: moneda.DETALLE
441 });
442 $scope.$broadcast('addCabecera', {
443 label: 'Fecha cotizacion:',
444 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
445 });
446 $scope.$broadcast('addCabecera', {
447 label: 'Cotizacion:',
448 valor: cotizacion.VENDEDOR
449 });
450 }
432 }, function() { 451 }, function() {
433 452
434 } 453 }
435 ); 454 );
436 }; 455 };
437 456
438 $scope.seleccionarCobrador = function() { 457 $scope.seleccionarCobrador = function() {
439 var modalInstance = $uibModal.open( 458 var modalInstance = $uibModal.open(
440 { 459 {
441 ariaLabelledBy: 'Busqueda de Cobradores', 460 ariaLabelledBy: 'Busqueda de Cobradores',
442 templateUrl: 'modal-cobradores.html', 461 templateUrl: 'modal-cobradores.html',
443 controller: 'focaModalCobradoresController', 462 controller: 'focaModalCobradoresController',
444 size: 'lg' 463 size: 'lg'
445 } 464 }
446 ); 465 );
447 modalInstance.result.then( 466 modalInstance.result.then(
448 function(cobrador) { 467 function(cobrador) {
449 addCabecera('Cobrador:', cobrador.nombre); 468 $scope.$broadcast('addCabecera', {
469 label: 'Cobrador:',
470 valor: cobrador.nombre
471 });
450 $scope.cobranza.cobrador = cobrador; 472 $scope.cobranza.cobrador = cobrador;
451 }, function() { 473 }, function() {
452 474
453 } 475 }
454 ); 476 );
455 }; 477 };
456 478
457 $scope.getTotalDeuda = function() { 479 $scope.getTotalDeuda = function() {
458 var total = 0; 480 var total = 0;
459 for (var i = 0; i < $scope.facturaTabla.length; i++) { 481 for (var i = 0; i < $scope.facturaTabla.length; i++) {
460 total += $scope.facturaTabla[i].IPA; 482 total += $scope.facturaTabla[i].IPA;
461 } 483 }
462 return parseFloat(total.toFixed(2)); 484 return parseFloat(total.toFixed(2));
463 }; 485 };
464 486
465 $scope.getTotalCobrado = function() { 487 $scope.getTotalCobrado = function() {
466 var total = 0; 488 var total = 0;
467 for (var i = 0; i < $scope.cobrosTabla.length; i++) { 489 for (var i = 0; i < $scope.cobrosTabla.length; i++) {
468 total += $scope.cobrosTabla[i].importe; 490 total += $scope.cobrosTabla[i].importe;
469 } 491 }
470 return parseFloat(total.toFixed(2)); 492 return parseFloat(total.toFixed(2));
471 }; 493 };
472 494
473 $scope.getSubTotal = function() { 495 $scope.getSubTotal = function() {
474 if($scope.articuloACargar) { 496 if($scope.articuloACargar) {
475 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 497 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
476 } 498 }
477 }; 499 };
478 //Recibe aviso si el teclado está en uso 500 //Recibe aviso si el teclado está en uso
479 // $rootScope.$on('usarTeclado', function(event, data) { 501 // $rootScope.$on('usarTeclado', function(event, data) {
480 // if(data) { 502 // if(data) {
481 // $scope.mostrarTeclado = true; 503 // $scope.mostrarTeclado = true;
482 // return; 504 // return;
483 // } 505 // }
484 // $scope.mostrarTeclado = false; 506 // $scope.mostrarTeclado = false;
485 // }) 507 // })
486 $scope.selectFocus = function($event) { 508 $scope.selectFocus = function($event) {
487 //Si el teclado esta en uso no selecciona el valor 509 //Si el teclado esta en uso no selecciona el valor
488 // if($scope.mostrarTeclado) { 510 // if($scope.mostrarTeclado) {
489 // return; 511 // return;
490 // } 512 // }
491 $event.target.select(); 513 $event.target.select();
492 }; 514 };
493 515
494 $scope.salir = function() { 516 $scope.salir = function() {
495 $location.path('/'); 517 $location.path('/');
496 }; 518 };
497 519
498 $scope.parsearATexto = function(articulo) { 520 $scope.parsearATexto = function(articulo) {
499 articulo.cantidad = parseFloat(articulo.cantidad); 521 articulo.cantidad = parseFloat(articulo.cantidad);
500 articulo.precio = parseFloat(articulo.precio); 522 articulo.precio = parseFloat(articulo.precio);
501 }; 523 };
502 524
503 $scope.rellenar = function(relleno, longitud) { 525 $scope.rellenar = function(relleno, longitud) {
504 relleno = '' + relleno; 526 relleno = '' + relleno;
505 while (relleno.length < longitud) { 527 while (relleno.length < longitud) {
506 relleno = '0' + relleno; 528 relleno = '0' + relleno;
507 } 529 }
508 530
509 return relleno; 531 return relleno;
510 }; 532 };
511 533
512 $scope.quitarFactura = function(key) { 534 $scope.quitarFactura = function(key) {
513 $scope.facturaTabla.splice(key, 1); 535 $scope.facturaTabla.splice(key, 1);
514 }; 536 };
515 537
516 $scope.quitarCobro = function(key) { 538 $scope.quitarCobro = function(key) {
517 $scope.cobrosTabla.splice(key, 1); 539 $scope.cobrosTabla.splice(key, 1);
518 }; 540 };
519 541
520 function addCabecera(label, valor) {
521 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
522 if(propiedad.length === 1) {
523 propiedad[0].valor = valor;
524 } else {
525 $scope.cabecera.push({label: label, valor: valor});
526 }
527 }
528 // TODO: descomentar cuando se use
529 /*function removeCabecera(label) {
530 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
531 if(propiedad.length === 1){
532 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
533 }
534 }*/
535 function setearMonedaPorDefecto() { 542 function setearMonedaPorDefecto() {
536 var monedaPorDefecto; 543 var monedaPorDefecto;
537 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' 544 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
538 focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { 545 focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) {
539 monedaPorDefecto = res.data[0]; 546 monedaPorDefecto = res.data[0];
540 $scope.cobranza.moneda = monedaPorDefecto; 547 $scope.cobranza.moneda = monedaPorDefecto;
541 $scope.cobranza.cotizacion = monedaPorDefecto.cotizaciones[0]; 548 $scope.cobranza.cotizacion = monedaPorDefecto.cotizaciones[0];
542 }); 549 });
src/views/cobranza.html
1 <div class="crear-nota-pedido foca-crear one-row row"> 1 <div class="crear-nota-pedido foca-crear one-row row">
2 <form name="formCrearNota" ng-submit="crearNotaPedido()" class="mb-0 col-lg-12"> 2 <foca-cabecera-facturador
3 <div class="row"> 3 titulo="'RECIBO DE COBRANZA'"
4 <div class="col-md-10 col-lg-12"> 4 numero="puntoVenta + '-' + comprobante"
5 <div class="row panel-informativo"> 5 fecha="fecha"
6 <div class="col-12"> 6 class="mb-0 col-lg-12"
7 <div class="row titulares"> 7 busqueda="seleccionarCobranza"
8 <div class="col-12 col-sm-3 nota-pedido border border-left-0 border-white align-middle"> 8 ></foca-cabecera-facturador>
9 <h5 class="mb-0">RECIBO DE COBRANZA</h5>
10 </div>
11 <div class="col-12 col-sm-3 numero-pedido text-center text-md-left border border-white align-middle"
12 >Nº {{puntoVenta}}-{{comprobante}}
13 <button
14 class="btn btn-xs btn-outline-light float-right"
15 type="button"
16 ng-click="seleccionarCobranza()"
17 >
18 <i class="fa fa-search"></i>
19 </button>
20 </div>
21 <div class="col-7 col-sm-3 border border-white align-middle">
22 Fecha:
23 <span
24 ng-show="!datepickerAbierto"
25 ng-bind="fecha | date:'dd/MM/yyyy'"
26 ng-click="datepickerAbierto = true"
27 >
28 </span>
29 <input
30 ng-show="datepickerAbierto"
31 type="date"
32 ng-model="fecha"
33 ng-change="datepickerAbierto = false"
34 ng-blur="datepickerAbierto = false"
35 class="form-control form-control-sm col-8 float-right"
36 foca-focus="datepickerAbierto"
37 hasta-hoy
38 />
39 </div>
40 <div class="col-5 col-sm-3 border border-white border-right-0 align-middle">
41 Hora:
42 <span
43 ng-show="!datepickerAbierto"
44 ng-bind="fecha | date:'HH:mm'"
45 ng-click="datepickerAbierto = true"
46 >
47 </span>
48 </div>
49 </div>
50 <div class="row py-2">
51 <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera">
52 <span class="label" ng-bind="cab.label"></span>
53 <span class="valor" ng-bind="cab.valor"></span>
54 </div>
55 <a
56 class="btn col-12 btn-secondary d-sm-none"
57 ng-show="cabecera.length > 0"
58 ng-click="showCabecera = !showCabecera"
59 >
60 <i
61 class="fa fa-chevron-down"
62 ng-hide="showCabecera"
63 aria-hidden="true"
64 >
65 </i>
66 <i
67 class="fa fa-chevron-up"
68 ng-show="showCabecera"
69 aria-hidden="true">
70 </i>
71 </a>
72 </div>
73 </div>
74 </div>
75 </div>
76 </div>
77 </form>
78 <div class="col-lg-12"> 9 <div class="col-lg-12">
79 <div class="row mt-4"> 10 <div class="row mt-4">
80 <div class="col-12 col-md-10 border border-light rounded"> 11 <div class="col-12 col-md-10 border border-light rounded">
81 <div class="row px-5 py-2 botonera-secundaria"> 12 <div class="row px-5 py-2 botonera-secundaria">
82 <div class="col-12"> 13 <div class="col-12">
83 <foca-botonera-facturador botones="botonera" extra="1" class="row"></foca-botonera-facturador> 14 <foca-botonera-facturador botones="botonera" extra="1" class="row"></foca-botonera-facturador>
84 </div> 15 </div>
85 </div> 16 </div>
86 <!-- PC --> 17 <!-- PC -->
87 <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">
88 <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">
89 <thead> 20 <thead>
90 <tr class="d-flex"> 21 <tr class="d-flex">
91 <th class="col-auto">#</th> 22 <th class="col-auto">#</th>
92 <th class="col">Comprobante</th> 23 <th class="col">Comprobante</th>
93 <th class="col">Fecha</th> 24 <th class="col">Fecha</th>
94 <th class="col">Importe</th> 25 <th class="col">Importe</th>
95 <th class="col-auto"> 26 <th class="col-auto">
96 <button 27 <button
97 class="btn btn-outline-light selectable" 28 class="btn btn-outline-light selectable"
98 ng-click="show = !show; masMenos()" 29 ng-click="show = !show; masMenos()"
99 > 30 >
100 <i 31 <i
101 class="fa fa-chevron-down" 32 class="fa fa-chevron-down"
102 ng-show="show" 33 ng-show="show"
103 aria-hidden="true" 34 aria-hidden="true"
104 > 35 >
105 </i> 36 </i>
106 <i 37 <i
107 class="fa fa-chevron-up" 38 class="fa fa-chevron-up"
108 ng-hide="show" 39 ng-hide="show"
109 aria-hidden="true"> 40 aria-hidden="true">
110 </i> 41 </i>
111 </button> 42 </button>
112 </th> 43 </th>
113 </th> 44 </th>
114 </tr> 45 </tr>
115 </thead> 46 </thead>
116 <tbody class="tabla-articulo-body"> 47 <tbody class="tabla-articulo-body">
117 <tr 48 <tr
118 ng-repeat="(key, factura) in facturaTabla" 49 ng-repeat="(key, factura) in facturaTabla"
119 class="d-flex" 50 class="d-flex"
120 ng-show="show || key == facturaTabla.length - 1" 51 ng-show="show || key == facturaTabla.length - 1"
121 > 52 >
122 <td ng-bind="key + 1" class="col-auto"></td> 53 <td ng-bind="key + 1" class="col-auto"></td>
123 <td class="col" ng-bind="factura.numeroFactura" 54 <td class="col" ng-bind="factura.numeroFactura"
124 ></td> 55 ></td>
125 <td class="col" ng-bind="factura.FEP | date : 'dd/MM/yyyy'"></td> 56 <td class="col" ng-bind="factura.FEP | date : 'dd/MM/yyyy'"></td>
126 <td 57 <td
127 class="col" 58 class="col"
128 ng-bind="(factura.IPA / cobranza.cotizacion.VENDEDOR) | 59 ng-bind="(factura.IPA / cobranza.cotizacion.VENDEDOR) |
129 currency: cobranza.moneda.SIMBOLO : 4"></td> 60 currency: cobranza.moneda.SIMBOLO : 4"></td>
130 <td class="text-center col-auto"> 61 <td class="text-center col-auto">
131 <button 62 <button
132 class="btn btn-outline-light" 63 class="btn btn-outline-light"
133 ng-click="quitarFactura(key)" 64 ng-click="quitarFactura(key)"
134 > 65 >
135 <i class="fa fa-trash"></i> 66 <i class="fa fa-trash"></i>
136 </button> 67 </button>
137 </td> 68 </td>
138 </tr> 69 </tr>
139 </tbody> 70 </tbody>
140 <tfoot> 71 <tfoot>
141 <tr ng-show="cargando" class="d-flex"> 72 <tr ng-show="cargando" class="d-flex">
142 <td class="col-2 border-top-0"> 73 <td class="col-2 border-top-0">
143 <a 74 <a
144 class="form-control form-control-sm btn btn-secondary" 75 class="form-control form-control-sm btn btn-secondary"
145 ng-click="seleccionarFactura()" 76 ng-click="seleccionarFactura()"
146 >Pendientes</a> 77 >Pendientes</a>
147 </td> 78 </td>
148 </tr> 79 </tr>
149 <tr class="d-flex"> 80 <tr class="d-flex">
150 <td class="col-auto px-1 border-top-0"> 81 <td class="col-auto px-1 border-top-0">
151 <strong>Comprobantes:</strong> 82 <strong>Comprobantes:</strong>
152 <a ng-bind="facturaTabla.length"></a> 83 <a ng-bind="facturaTabla.length"></a>
153 </td> 84 </td>
154 <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">
155 <strong>Cancela:</strong> 86 <strong>Cancela:</strong>
156 </td> 87 </td>
157 <td class="table-celda-total text-right no-border-top"> 88 <td class="table-celda-total text-right no-border-top">
158 <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) | 89 <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) |
159 currency: cobranza.moneda.SIMBOLO}}</strong> 90 currency: cobranza.moneda.SIMBOLO}}</strong>
160 </td> 91 </td>
161 <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">
162 <strong>Total Cobrado:</strong> 93 <strong>Total Cobrado:</strong>
163 </td> 94 </td>
164 <td class="table-celda-total text-right no-border-top"> 95 <td class="table-celda-total text-right no-border-top">
165 <strong>{{(getTotalCobrado() / cobranza.cotizacion.VENDEDOR) | 96 <strong>{{(getTotalCobrado() / cobranza.cotizacion.VENDEDOR) |
166 currency: cobranza.moneda.SIMBOLO}}</strong> 97 currency: cobranza.moneda.SIMBOLO}}</strong>
167 </td> 98 </td>
168 <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">
169 <strong>DF:</strong> 100 <strong>DF:</strong>
170 </td> 101 </td>
171 <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">
172 <strong>{{((getTotalCobrado() + getTotalDeuda()) / 103 <strong>{{((getTotalCobrado() + getTotalDeuda()) /
173 cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}} 104 cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}
174 </strong> 105 </strong>
175 </td> 106 </td>
176 </tr> 107 </tr>
177 </tfoot> 108 </tfoot>
178 </table> 109 </table>
179 </div> 110 </div>
180 <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">
181 <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">
182 <thead> 113 <thead>
183 <tr class="d-flex"> 114 <tr class="d-flex">
184 <th class="col-auto">#</th> 115 <th class="col-auto">#</th>
185 <th class="col">Cobro</th> 116 <th class="col">Cobro</th>
186 <th class="col">Fecha</th> 117 <th class="col">Fecha</th>
187 <th class="col">Importe</th> 118 <th class="col">Importe</th>
188 <th class="col-auto"> 119 <th class="col-auto">
189 <button 120 <button
190 class="btn btn-outline-light selectable" 121 class="btn btn-outline-light selectable"
191 ng-click="show = !show; masMenos()" 122 ng-click="show = !show; masMenos()"
192 > 123 >
193 <i 124 <i
194 class="fa fa-chevron-down" 125 class="fa fa-chevron-down"
195 ng-show="show" 126 ng-show="show"
196 aria-hidden="true" 127 aria-hidden="true"
197 > 128 >
198 </i> 129 </i>
199 <i 130 <i
200 class="fa fa-chevron-up" 131 class="fa fa-chevron-up"
201 ng-hide="show" 132 ng-hide="show"
202 aria-hidden="true"> 133 aria-hidden="true">
203 </i> 134 </i>
204 </button> 135 </button>
205 </th> 136 </th>
206 </th> 137 </th>
207 </tr> 138 </tr>
208 </thead> 139 </thead>
209 <tbody class="tabla-articulo-body"> 140 <tbody class="tabla-articulo-body">
210 <tr 141 <tr
211 ng-repeat="(key, cobro) in cobrosTabla" 142 ng-repeat="(key, cobro) in cobrosTabla"
212 class="d-flex" 143 class="d-flex"
213 ng-show="show || key == cobrosTabla.length - 1" 144 ng-show="show || key == cobrosTabla.length - 1"
214 > 145 >
215 <td ng-bind="key + 1" class="col-auto"></td> 146 <td ng-bind="key + 1" class="col-auto"></td>
216 <td class="col" ng-bind="cobro.tipo"></td> 147 <td class="col" ng-bind="cobro.tipo"></td>
217 <td class="col" ng-bind="cobro.fecha | date : 'dd/MM/yyyy'"></td> 148 <td class="col" ng-bind="cobro.fecha | date : 'dd/MM/yyyy'"></td>
218 <td 149 <td
219 class="col" 150 class="col"
220 ng-bind="(cobro.importe / cobranza.cotizacion.VENDEDOR) | 151 ng-bind="(cobro.importe / cobranza.cotizacion.VENDEDOR) |
221 currency: cobranza.moneda.SIMBOLO : 4"></td> 152 currency: cobranza.moneda.SIMBOLO : 4"></td>
222 <td class="text-center col-auto"> 153 <td class="text-center col-auto">
223 <button 154 <button
224 class="btn btn-outline-light" 155 class="btn btn-outline-light"
225 ng-click="quitarCobro(key)" 156 ng-click="quitarCobro(key)"
226 > 157 >
227 <i class="fa fa-trash"></i> 158 <i class="fa fa-trash"></i>
228 </button> 159 </button>
229 </td> 160 </td>
230 </tr> 161 </tr>
231 </tbody> 162 </tbody>
232 <tfoot> 163 <tfoot>
233 <tr ng-show="cargando" class="d-flex"> 164 <tr ng-show="cargando" class="d-flex">
234 <td class="col-2 border-top-0"> 165 <td class="col-2 border-top-0">
235 <a 166 <a
236 class="form-control form-control-sm btn btn-secondary" 167 class="form-control form-control-sm btn btn-secondary"
237 ng-click="seleccionarCheque()" 168 ng-click="seleccionarCheque()"
238 >Cheque</a> 169 >Cheque</a>
239 </td> 170 </td>
240 <td class="col-2 border-top-0"> 171 <td class="col-2 border-top-0">
241 <a 172 <a
242 class="form-control form-control-sm btn btn-secondary" 173 class="form-control form-control-sm btn btn-secondary"
243 ng-click="seleccionarEfectivo()" 174 ng-click="seleccionarEfectivo()"
244 >Efectivo</a> 175 >Efectivo</a>
245 </td> 176 </td>
246 </tr> 177 </tr>
247 <tr class="d-flex"> 178 <tr class="d-flex">
248 <td class="col-auto px-1 border-top-0"> 179 <td class="col-auto px-1 border-top-0">
249 <strong>Cobros:</strong> 180 <strong>Cobros:</strong>
250 <a ng-bind="cobrosTabla.length"></a> 181 <a ng-bind="cobrosTabla.length"></a>
251 </td> 182 </td>
252 <td class="text-right ml-auto table-celda-total no-border-top"> 183 <td class="text-right ml-auto table-celda-total no-border-top">
253 <strong>Cancela:</strong> 184 <strong>Cancela:</strong>
254 </td> 185 </td>
255 <td class="table-celda-total text-right no-border-top"> 186 <td class="table-celda-total text-right no-border-top">
256 <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) | 187 <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) |
257 currency: cobranza.moneda.SIMBOLO}}</strong> 188 currency: cobranza.moneda.SIMBOLO}}</strong>
258 </td> 189 </td>
259 <td class="text-right ml-auto table-celda-total no-border-top"> 190 <td class="text-right ml-auto table-celda-total no-border-top">
260 <strong>Total Cobrado:</strong> 191 <strong>Total Cobrado:</strong>
261 </td> 192 </td>
262 <td class="table-celda-total text-right no-border-top"> 193 <td class="table-celda-total text-right no-border-top">
263 <strong>{{(getTotalCobrado() / cobranza.cotizacion.VENDEDOR) | 194 <strong>{{(getTotalCobrado() / cobranza.cotizacion.VENDEDOR) |
264 currency: cobranza.moneda.SIMBOLO}}</strong> 195 currency: cobranza.moneda.SIMBOLO}}</strong>
265 </td> 196 </td>
266 <td class="text-right ml-auto table-celda-total no-border-top"> 197 <td class="text-right ml-auto table-celda-total no-border-top">
267 <strong>DF:</strong> 198 <strong>DF:</strong>
268 </td> 199 </td>
269 <td class="table-celda-total text-right no-border-top mr-1"> 200 <td class="table-celda-total text-right no-border-top mr-1">
270 <strong>{{((getTotalCobrado() + getTotalDeuda()) / 201 <strong>{{((getTotalCobrado() + getTotalDeuda()) /
271 cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}} 202 cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}
272 </strong> 203 </strong>
273 </td> 204 </td>
274 </tr> 205 </tr>
275 </tfoot> 206 </tfoot>
276 </table> 207 </table>
277 </div> 208 </div>
278 <!-- MOBILE --> 209 <!-- MOBILE -->
279 <div class="row d-sm-none mb-5"> 210 <div class="row d-sm-none mb-5">
280 <!-- FACTURAS --> 211 <!-- FACTURAS -->
281 <table class="table table-sm table-striped tabla-articulo mb-5" ng-show="cobroDeuda"> 212 <table class="table table-sm table-striped tabla-articulo mb-5" ng-show="cobroDeuda">
282 <thead> 213 <thead>
283 <tr class="d-flex"> 214 <tr class="d-flex">
284 <th class="">#</th> 215 <th class="">#</th>
285 <th class="col px-0"> 216 <th class="col px-0">
286 <div class="d-flex"> 217 <div class="d-flex">
287 <div class="col-4 px-1">Factura</div> 218 <div class="col-4 px-1">Factura</div>
288 <div class="col-4 px-1">Fecha</div> 219 <div class="col-4 px-1">Fecha</div>
289 <div class="col-4 px-1">Importe</div> 220 <div class="col-4 px-1">Importe</div>
290 </div> 221 </div>
291 </th> 222 </th>
292 <th class="text-center tamaño-boton"> 223 <th class="text-center tamaño-boton">
293 &nbsp; 224 &nbsp;
294 </th> 225 </th>
295 </tr> 226 </tr>
296 </thead> 227 </thead>
297 <tbody> 228 <tbody>
298 <tr 229 <tr
299 ng-repeat="(key, factura) in facturaTabla" 230 ng-repeat="(key, factura) in facturaTabla"
300 ng-show="show || key == facturaTabla.length - 1" 231 ng-show="show || key == facturaTabla.length - 1"
301 > 232 >
302 <td class="w-100 align-middle d-flex p-0"> 233 <td class="w-100 align-middle d-flex p-0">
303 <div class="align-middle p-1"> 234 <div class="align-middle p-1">
304 <span ng-bind="key+1" class="align-middle"></span> 235 <span ng-bind="key+1" class="align-middle"></span>
305 </div> 236 </div>
306 <div class="col px-0"> 237 <div class="col px-0">
307 <div class="d-flex"> 238 <div class="d-flex">
308 <div class="col-4 p-1"> 239 <div class="col-4 p-1">
309 <span ng-bind="factura.numeroFactura" 240 <span ng-bind="factura.numeroFactura"
310 ></span> 241 ></span>
311 </div> 242 </div>
312 <div class="col-4 p-1"> 243 <div class="col-4 p-1">
313 <span ng-bind="factura.FEP | date : 'dd/MM/yyyy'"></span> 244 <span ng-bind="factura.FEP | date : 'dd/MM/yyyy'"></span>
314 </div> 245 </div>
315 <div class="col-4 p-1"> 246 <div class="col-4 p-1">
316 <span 247 <span
317 ng-bind="(factura.IPA / cobranza.cotizacion.VENDEDOR) | 248 ng-bind="(factura.IPA / cobranza.cotizacion.VENDEDOR) |
318 currency:cobranza.moneda.SIMBOLO : 4"></span> 249 currency:cobranza.moneda.SIMBOLO : 4"></span>
319 </div> 250 </div>
320 </div> 251 </div>
321 </div> 252 </div>
322 <div class="align-middle p-1"> 253 <div class="align-middle p-1">
323 <button 254 <button
324 class="btn btn-outline-light" 255 class="btn btn-outline-light"
325 ng-click="quitarFactura(key)" 256 ng-click="quitarFactura(key)"
326 > 257 >
327 <i class="fa fa-trash"></i> 258 <i class="fa fa-trash"></i>
328 </button> 259 </button>
329 </div> 260 </div>
330 </td> 261 </td>
331 </tr> 262 </tr>
332 </tbody> 263 </tbody>
333 <tfoot> 264 <tfoot>
334 <!-- SELECCIONAR PRODUCTO --> 265 <!-- SELECCIONAR PRODUCTO -->
335 <tr ng-show="cargando" class="d-flex"> 266 <tr ng-show="cargando" class="d-flex">
336 <td class="col-12"> 267 <td class="col-12">
337 <input 268 <input
338 placeholder="Seleccione Factura" 269 placeholder="Seleccione Factura"
339 class="form-control form-control-sm" 270 class="form-control form-control-sm"
340 readonly 271 readonly
341 ng-click="seleccionarFactura()" 272 ng-click="seleccionarFactura()"
342 /> 273 />
343 </td> 274 </td>
344 </tr> 275 </tr>
345 <!-- TOOGLE EXPANDIR --> 276 <!-- TOOGLE EXPANDIR -->
346 <tr> 277 <tr>
347 <td class="col"> 278 <td class="col">
348 <button 279 <button
349 class="btn btn-outline-light selectable w-100" 280 class="btn btn-outline-light selectable w-100"
350 ng-click="show = !show; masMenos()" 281 ng-click="show = !show; masMenos()"
351 ng-show="facturaTabla.length > 0" 282 ng-show="facturaTabla.length > 0"
352 > 283 >
353 <i 284 <i
354 class="fa fa-chevron-down" 285 class="fa fa-chevron-down"
355 ng-hide="show" 286 ng-hide="show"
356 aria-hidden="true" 287 aria-hidden="true"
357 > 288 >
358 </i> 289 </i>
359 <i 290 <i
360 class="fa fa-chevron-up" 291 class="fa fa-chevron-up"
361 ng-show="show" 292 ng-show="show"
362 aria-hidden="true"> 293 aria-hidden="true">
363 </i> 294 </i>
364 </button> 295 </button>
365 </td> 296 </td>
366 </tr> 297 </tr>
367 <!-- FOOTER --> 298 <!-- FOOTER -->
368 <tr class="d-flex"> 299 <tr class="d-flex">
369 <td class="align-middle no-border-top" colspan="2"> 300 <td class="align-middle no-border-top" colspan="2">
370 <strong>Cantidad Items:</strong> 301 <strong>Cantidad Items:</strong>
371 <a ng-bind="facturaTabla.length"></a> 302 <a ng-bind="facturaTabla.length"></a>
372 </td> 303 </td>
373 </tr> 304 </tr>
374 </tfoot> 305 </tfoot>
375 </table> 306 </table>
376 <!-- COBROS --> 307 <!-- COBROS -->
377 <table class="table table-sm table-striped tabla-articulo mb-5" ng-show="!cobroDeuda"> 308 <table class="table table-sm table-striped tabla-articulo mb-5" ng-show="!cobroDeuda">
378 <thead> 309 <thead>
379 <tr class="d-flex"> 310 <tr class="d-flex">
380 <th class="">#</th> 311 <th class="">#</th>
381 <th class="col px-0"> 312 <th class="col px-0">
382 <div class="d-flex"> 313 <div class="d-flex">
383 <div class="col-4 px-1">Cobro</div> 314 <div class="col-4 px-1">Cobro</div>
384 <div class="col-4 px-1">Fecha</div> 315 <div class="col-4 px-1">Fecha</div>
385 <div class="col-4 px-1">Importe</div> 316 <div class="col-4 px-1">Importe</div>
386 </div> 317 </div>
387 </th> 318 </th>
388 <th class="text-center tamaño-boton"> 319 <th class="text-center tamaño-boton">
389 &nbsp; 320 &nbsp;
390 </th> 321 </th>
391 </tr> 322 </tr>
392 </thead> 323 </thead>
393 <tbody> 324 <tbody>
394 <tr 325 <tr
395 ng-repeat="(key, cobro) in cobrosTabla" 326 ng-repeat="(key, cobro) in cobrosTabla"
396 ng-show="show || key == cobrosTabla.length - 1" 327 ng-show="show || key == cobrosTabla.length - 1"
397 > 328 >
398 <td class="w-100 align-middle d-flex p-0"> 329 <td class="w-100 align-middle d-flex p-0">
399 <div class="align-middle p-1"> 330 <div class="align-middle p-1">
400 <span ng-bind="key+1" class="align-middle"></span> 331 <span ng-bind="key+1" class="align-middle"></span>
401 </div> 332 </div>
402 <div class="col px-0"> 333 <div class="col px-0">
403 <div class="d-flex"> 334 <div class="d-flex">
404 <div class="col-4 p-1"> 335 <div class="col-4 p-1">
405 <span ng-bind="cobro.tipo" 336 <span ng-bind="cobro.tipo"
406 ></span> 337 ></span>
407 </div> 338 </div>
408 <div class="col-4 p-1"> 339 <div class="col-4 p-1">
409 <span ng-bind="cobro.fecha | date : 'dd/MM/yyyy'"></span> 340 <span ng-bind="cobro.fecha | date : 'dd/MM/yyyy'"></span>
410 </div> 341 </div>
411 <div class="col-4 p-1"> 342 <div class="col-4 p-1">
412 <span 343 <span
413 ng-bind="(cobro.importe / cobranza.cotizacion.VENDEDOR) | 344 ng-bind="(cobro.importe / cobranza.cotizacion.VENDEDOR) |
414 currency: cobranza.moneda.SIMBOLO : 4"></span> 345 currency: cobranza.moneda.SIMBOLO : 4"></span>
415 </div> 346 </div>
416 </div> 347 </div>
417 </div> 348 </div>
418 <div class="align-middle p-1"> 349 <div class="align-middle p-1">
419 <button 350 <button
420 class="btn btn-outline-light" 351 class="btn btn-outline-light"
421 ng-click="quitarCobro(key)" 352 ng-click="quitarCobro(key)"
422 > 353 >
423 <i class="fa fa-trash"></i> 354 <i class="fa fa-trash"></i>
424 </button> 355 </button>
425 </div> 356 </div>
426 </td> 357 </td>
427 </tr> 358 </tr>
428 </tbody> 359 </tbody>
429 <tfoot> 360 <tfoot>
430 <!-- SELECCIONAR PRODUCTO --> 361 <!-- SELECCIONAR PRODUCTO -->
431 <tr ng-show="cargando" class="d-flex"> 362 <tr ng-show="cargando" class="d-flex">
432 <td class="col-6"> 363 <td class="col-6">
433 <input 364 <input
434 placeholder="Cheque" 365 placeholder="Cheque"
435 class="form-control form-control-sm" 366 class="form-control form-control-sm"
436 readonly 367 readonly
437 ng-click="seleccionarCheque()" 368 ng-click="seleccionarCheque()"
438 /> 369 />
439 </td> 370 </td>
440 <td class="col-6"> 371 <td class="col-6">
441 <input 372 <input
442 placeholder="Efectivo" 373 placeholder="Efectivo"
443 class="form-control form-control-sm" 374 class="form-control form-control-sm"
444 readonly 375 readonly
445 ng-click="seleccionarEfectivo()" 376 ng-click="seleccionarEfectivo()"
446 /> 377 />
447 </td> 378 </td>
448 </tr> 379 </tr>
449 <!-- TOOGLE EXPANDIR --> 380 <!-- TOOGLE EXPANDIR -->
450 <tr> 381 <tr>
451 <td class="col"> 382 <td class="col">
452 <button 383 <button
453 class="btn btn-outline-light selectable w-100" 384 class="btn btn-outline-light selectable w-100"
454 ng-click="show = !show; masMenos()" 385 ng-click="show = !show; masMenos()"
455 ng-show="cobrosTabla.length > 0" 386 ng-show="cobrosTabla.length > 0"
456 > 387 >
457 <i 388 <i
458 class="fa fa-chevron-down" 389 class="fa fa-chevron-down"
459 ng-hide="show" 390 ng-hide="show"
460 aria-hidden="true" 391 aria-hidden="true"
461 > 392 >
462 </i> 393 </i>
463 <i 394 <i
464 class="fa fa-chevron-up" 395 class="fa fa-chevron-up"
465 ng-show="show" 396 ng-show="show"
466 aria-hidden="true"> 397 aria-hidden="true">
467 </i> 398 </i>
468 </button> 399 </button>
469 </td> 400 </td>
470 </tr> 401 </tr>
471 <!-- FOOTER --> 402 <!-- FOOTER -->
472 <tr class="d-flex"> 403 <tr class="d-flex">
473 <td class="align-middle no-border-top col-6"> 404 <td class="align-middle no-border-top col-6">
474 <strong>Cantidad Items:</strong> 405 <strong>Cantidad Items:</strong>
475 <a ng-bind="cobrosTabla.length"></a> 406 <a ng-bind="cobrosTabla.length"></a>
476 </td> 407 </td>
477 </tfoot> 408 </tfoot>
478 </table> 409 </table>
479 </tr> 410 </tr>
480 <!-- DEUDA, COBRADO, DIFERENCIA --> 411 <!-- DEUDA, COBRADO, DIFERENCIA -->
481 <table class="table-responsive fixed-bottom mb-5"> 412 <table class="table-responsive fixed-bottom mb-5">
482 <tr class="d-flex row"> 413 <tr class="d-flex row">
483 <td class="text-center ml-auto table-celda-total no-border-top col-4"> 414 <td class="text-center ml-auto table-celda-total no-border-top col-4">
484 <strong>Cancela:</strong> 415 <strong>Cancela:</strong>
485 </td> 416 </td>
486 <td class="text-center ml-auto table-celda-total no-border-top col-4"> 417 <td class="text-center ml-auto table-celda-total no-border-top col-4">
487 <strong>Cobrado:</strong> 418 <strong>Cobrado:</strong>
488 </td> 419 </td>
489 <td class="text-center ml-auto table-celda-total no-border-top col-4"> 420 <td class="text-center ml-auto table-celda-total no-border-top col-4">
490 <strong>Diferencia:</strong> 421 <strong>Diferencia:</strong>
491 </td> 422 </td>
492 <td class="table-celda-total text-center no-border-top col-4"> 423 <td class="table-celda-total text-center no-border-top col-4">
493 <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong> 424 <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong>
494 </td> 425 </td>
495 <td class="table-celda-total text-center no-border-top col-4"> 426 <td class="table-celda-total text-center no-border-top col-4">
496 <strong>{{(getTotalCobrado() / cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong> 427 <strong>{{(getTotalCobrado() / cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong>
497 </td> 428 </td>
498 <td class="table-celda-total text-center no-border-top col-4"> 429 <td class="table-celda-total text-center no-border-top col-4">
499 <strong>{{((getTotalCobrado() + getTotalDeuda()) / cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong> 430 <strong>{{((getTotalCobrado() + getTotalDeuda()) / cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong>
500 </td> 431 </td>
501 </tr> 432 </tr>
502 </table> 433 </table>
503 </div> 434 </div>
504 </div> 435 </div>
505 <div class="col-auto my-2 col-lg-2 botonera-lateral d-none d-md-block"> 436 <div class="col-auto my-2 col-lg-2 botonera-lateral d-none d-md-block">
506 <div class="col-12 mt-auto"> 437 <div class="col-12 mt-auto">
507 <button 438 <button
508 ng-click="crearCobranza()" 439 ng-click="crearCobranza()"
509 title="Crear nota pedido" 440 title="Crear nota pedido"
510 class="btn btn-default btn-block mb-2 border border-dark" 441 class="btn btn-default btn-block mb-2 border border-dark"
511 ng-disabled="editando || saveLoading" 442 ng-disabled="editando || saveLoading">
512 >
513 <strong>GUARDAR</strong> 443 <strong>GUARDAR</strong>
514 </button> 444 </button>
515 <button 445 <button
516 type="button" 446 type="button"
517 title="Salir" 447 title="Salir"
518 class="btn btn-default btn-block border border-dark"> 448 class="btn btn-default btn-block border border-dark">
519 <strong>PAUSAR</strong> 449 <strong>PAUSAR</strong>
520 </button> 450 </button>
521 <button 451 <button
522 ng-click="salir()" 452 ng-click="salir()"
523 type="button" 453 type="button"
524 title="Salir" 454 title="Salir"
525 class="btn btn-default btn-block border border-dark"> 455 class="btn btn-default btn-block border border-dark">
526 <strong>SALIR</strong> 456 <strong>SALIR</strong>
527 </button> 457 </button>
528 </div> 458 </div>
529 </div> 459 </div>
530 </div> 460 </div>
531 </div> 461 </div>
532 <div class="row d-md-none fixed-bottom"> 462 <div class="row d-md-none fixed-bottom">
533 <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> 463 <div class="w-100 bg-dark d-flex px-3 acciones-mobile">
534 <span class="ml-3 text-muted" ng-click="salir()">Salir</span> 464 <span class="ml-3 text-muted" ng-click="salir()">Salir</span>
535 <span 465 <span
536 class="mr-3 ml-auto" 466 class="mr-3 ml-auto"
537 ng-class="saveLoading ? 'text-muted' : ''" 467 ng-class="saveLoading ? 'text-muted' : ''"
538 ng-click="crearCobranza()" 468 ng-click="crearCobranza()"
539 ng-show="!editando" 469 ng-show="!editando"
540 ladda="saveLoading" 470 ladda="saveLoading"
541 data-style="expand-left" 471 data-style="expand-left"
542 >Guardar</span> 472 >Guardar</span>
543 </div> 473 </div>
544 </div> 474 </div>
545 </div> 475 </div>
546 476