Commit db25b151280e5096fb4d34a2cec89e3649700f01

Authored by Eric Fernandez
1 parent 0cf3df0ce6
Exists in master

Modal cobranza

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