Commit b09cc649725462e20674580d321bc4809e06d6ca
1 parent
0d01c9d6c8
Exists in
master
guardar cobranza
Showing
4 changed files
with
237 additions
and
74 deletions
Show diff stats
gulpfile.js
... | ... | @@ -46,6 +46,7 @@ gulp.task('uglify', ['templates'], function() { |
46 | 46 | replace('"ngRoute","ui.bootstrap","focaModal","focaModalFactura","focaBusquedaCliente",'+ |
47 | 47 | '"focaDirectivas","focaModalMoneda","focaModalCotizacion"', ''), |
48 | 48 | gulp.dest(paths.dist) |
49 | + | |
49 | 50 | ] |
50 | 51 | ); |
51 | 52 | }); |
src/js/controller.js
... | ... | @@ -6,7 +6,9 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
6 | 6 | '$filter', |
7 | 7 | 'focaCrearCobranzaService', |
8 | 8 | 'focaModalService', |
9 | - function($scope, $uibModal, $location, $filter, focaCrearCobranzaService, focaModalService) | |
9 | + '$cookies', | |
10 | + function($scope, $uibModal, $location, $filter, focaCrearCobranzaService, focaModalService, | |
11 | + $cookies) | |
10 | 12 | { |
11 | 13 | $scope.botonera = [ |
12 | 14 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
... | ... | @@ -27,46 +29,30 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
27 | 29 | minDate: new Date(2010, 0, 1) |
28 | 30 | }; |
29 | 31 | |
30 | - $scope.cobranza = { | |
31 | - fecha: new Date() | |
32 | - }; | |
33 | - | |
34 | 32 | $scope.cabecera = []; |
35 | 33 | $scope.showCabecera = true; |
36 | 34 | |
37 | - $scope.now = new Date(); | |
35 | + $scope.cobranza = {}; | |
36 | + | |
37 | + $scope.fecha = new Date(); | |
38 | 38 | $scope.puntoVenta = '0000'; |
39 | 39 | $scope.comprobante = '00000000'; |
40 | 40 | $scope.facturaTabla = []; |
41 | 41 | $scope.cobrosTabla = []; |
42 | 42 | |
43 | - var monedaPorDefecto; | |
44 | - //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | |
45 | - focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { | |
46 | - monedaPorDefecto = res.data[0]; | |
47 | - addCabecera('Moneda:', monedaPorDefecto.DETALLE); | |
48 | - addCabecera('Fecha cotizacion:', | |
49 | - new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | |
50 | - addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].VENDEDOR); | |
51 | - $scope.cobranza.moneda = monedaPorDefecto; | |
52 | - $scope.cobranza.cotizacion = monedaPorDefecto.cotizaciones[0]; | |
43 | + focaCrearCobranzaService.getUsuario($cookies.get('idUsuario')).then(function(data) { | |
44 | + $scope.usuario = data.data; | |
53 | 45 | }); |
54 | 46 | |
55 | - focaCrearCobranzaService.getNumeroRecibo().then( | |
56 | - function(res) { | |
57 | - $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4); | |
58 | - $scope.comprobante = $scope.rellenar(res.data.numeroRecibo, 8); | |
59 | - }, | |
60 | - function(err) { | |
61 | - focaModalService.alert('La terminal no esta configurada correctamente'); | |
62 | - console.info(err); | |
63 | - } | |
64 | - ); | |
65 | 47 | $scope.crearCobranza = function() { |
66 | 48 | if(!$scope.cobranza.cliente) { |
67 | 49 | focaModalService.alert('Ingrese Cliente'); |
68 | 50 | return; |
69 | 51 | } |
52 | + if(!$scope.cobranza.cobrador) { | |
53 | + focaModalService.alert('Ingrese Cobrador'); | |
54 | + return; | |
55 | + } | |
70 | 56 | if($scope.facturaTabla.length < 1) { |
71 | 57 | focaModalService.alert('Ingrese al menos una factura'); |
72 | 58 | return; |
... | ... | @@ -76,10 +62,163 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
76 | 62 | $scope.cobranza.moneda.SIMBOLO + '0,00'); |
77 | 63 | return; |
78 | 64 | } |
79 | - //TODO: Guarda cobranza | |
80 | - // var date = new Date(); | |
81 | - // var cobranza = { | |
82 | - // }; | |
65 | + var cobranza = {}; | |
66 | + var cheques = []; | |
67 | + var cuerpos = []; | |
68 | + | |
69 | + for (var i = 0; i < $scope.facturaTabla.length; i++) { | |
70 | + var cuerpoFactura = { | |
71 | + CYV: 'V', | |
72 | + TIP: 'C', | |
73 | + TCO: 'RC', | |
74 | + PVE: $scope.puntoVenta, | |
75 | + NCO: $scope.comprobante, | |
76 | + LOP: 'L', | |
77 | + TIL: $scope.facturaTabla[i].TCO, | |
78 | + COM: $scope.facturaTabla[i].numeroFactura, | |
79 | + FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), | |
80 | + IMP: $scope.facturaTabla[i].IPA, | |
81 | + RES: 0,//caja de tesorería | |
82 | + SUBM: 0 | |
83 | + }; | |
84 | + cuerpos.push(cuerpoFactura); | |
85 | + } | |
86 | + | |
87 | + for (var j = 0; j < $scope.cobrosTabla.length; j++) { | |
88 | + | |
89 | + var efectivo = $scope.cobrosTabla[j].tipo === 'Efectivo' ? true : false; | |
90 | + | |
91 | + var cuerpoCobros = { | |
92 | + CYV: 'V', | |
93 | + TIP: 'C', | |
94 | + TCO: 'RC', | |
95 | + PVE: $scope.puntoVenta, | |
96 | + NCO: $scope.comprobante, | |
97 | + LOP: 'P', | |
98 | + TIL: 'EF', | |
99 | + COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : 'ch(' + | |
100 | + $scope.cobrosTabla[j].numero + ')' + $scope.cobrosTabla[j].banco.desbco, | |
101 | + FEC: efectivo ? | |
102 | + $scope.cobrosTabla[j].fecha | |
103 | + .toISOString().slice(0, 19).replace('T', ' ') : | |
104 | + $scope.cobrosTabla[j].fechaPresentacion | |
105 | + .toISOString().slice(0, 19).replace('T', ' '), | |
106 | + IMP: $scope.cobrosTabla[j].importe, | |
107 | + RES: 0,//caja de tesorería | |
108 | + SUBM: 0 | |
109 | + }; | |
110 | + cuerpos.push(cuerpoCobros); | |
111 | + | |
112 | + if(!efectivo) { | |
113 | + var cheque = { | |
114 | + BCO: $scope.cobrosTabla[j].banco.ID, | |
115 | + NUM: $scope.comprobante, | |
116 | + FEP: $scope.cobrosTabla[j].fechaPresentacion | |
117 | + .toISOString().slice(0, 19).replace('T', ' '), | |
118 | + FEE: $scope.cobrosTabla[j].fechaEmision | |
119 | + .toISOString().slice(0, 19).replace('T', ' '), | |
120 | + LUG: $scope.cobrosTabla[j].localidad.NOMBRE, | |
121 | + IMP: $scope.cobrosTabla[j].importe, | |
122 | + LIB: $scope.cobrosTabla[j].librador, | |
123 | + EST: 'C',//'D' depositado, 'E' entregado, 'C' en cartera | |
124 | + PCI: $scope.cobrosTabla[j].provincia.ID, | |
125 | + LPLA: 0, | |
126 | + PLA: 0, | |
127 | + VEN: $scope.usuario.CodVen,//Id vendedor | |
128 | + CCLIE: $scope.cobranza.cliente.COD,//Id cliente | |
129 | + REN: 0, | |
130 | + PVEC: $scope.puntoVenta, | |
131 | + NCOC: $scope.comprobante, | |
132 | + OBSE: $scope.cobrosTabla[j].observaciones, | |
133 | + LUV: 0, | |
134 | + ORI: 've', | |
135 | + FER: '', | |
136 | + BIMP: 0, | |
137 | + COMP: 'C ' +'RC ' + $scope.puntoVenta + '-' + $scope.comprobante, | |
138 | + VAL_E: '',//Cuando egresa por ingresos y egresos en el numero de egreso | |
139 | + VAL_I: '',//Cuando Ingresa por ingresos y egresos en el numero ingreso | |
140 | + REC_CAJ: 'D', | |
141 | + TIPO_C: 0,//?? | |
142 | + SALDO_CAJ: 'S', | |
143 | + FECHA_INGRESO: $scope.fecha | |
144 | + .toISOString().slice(0, 19).replace('T', ' '), | |
145 | + Vendedor_valor: 0, | |
146 | + FAMILIA: 0, | |
147 | + CUIT_LIB: '', | |
148 | + COD_LUG: $scope.cobrosTabla[j].localidad.ID,//código lugar | |
149 | + SEN: '', | |
150 | + NRC: 0, | |
151 | + COD_LARGO: '', | |
152 | + VN: 0, | |
153 | + ID_LECTOR: 0, | |
154 | + NATHB: '' | |
155 | + }; | |
156 | + cheques.push(cheque); | |
157 | + } | |
158 | + } | |
159 | + | |
160 | + cobranza = { | |
161 | + recibo: { | |
162 | + CYV: 'V', | |
163 | + TIP: 'C', | |
164 | + TCO: 'RC', | |
165 | + PVE: $scope.puntoVenta, //Sucursar, punto de venta | |
166 | + NCO: $scope.comprobante, //Numero de comprobante | |
167 | + FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), | |
168 | + CLI: $scope.cobranza.cliente.COD, | |
169 | + ATO: 0, //número de asiento | |
170 | + CFE: $scope.usuario.NomVen.trim(), | |
171 | + PLA: '',//Numero de planilla, sin uso | |
172 | + ID_MONEDA: $scope.cobranza.moneda.ID, | |
173 | + COTIZACION: $scope.cobranza.cotizacion.VENDEDOR | |
174 | + }, | |
175 | + cuerpo: cuerpos, | |
176 | + cheques: cheques, | |
177 | + acobypag: { | |
178 | + CYV: 'V', | |
179 | + COD: $scope.cobranza.cliente.COD, | |
180 | + FEP: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), | |
181 | + TIP: '',//?? | |
182 | + TCO: 'RC', | |
183 | + SUC: $scope.puntoVenta, | |
184 | + NCO: $scope.comprobante, | |
185 | + IPA: $scope.getTotalCobrado(), | |
186 | + SAL: '',//?? | |
187 | + TCA: 1, | |
188 | + ZONA: 1, | |
189 | + FPA: 2,//Forma de pago | |
190 | + REC: 0, | |
191 | + REP: 0, | |
192 | + FER: null, | |
193 | + REM: 0, | |
194 | + FRE: null,//?? | |
195 | + PRO: 'N', | |
196 | + FEV: $scope.fecha.toISOString().slice(0, 19).replace('T', ' ') | |
197 | + }, | |
198 | + datosCobrador: { | |
199 | + COD: $scope.cobranza.cobrador.id, | |
200 | + PVE: $scope.puntoVenta, | |
201 | + NUM: $scope.comprobante, | |
202 | + EST: 'C', | |
203 | + OBS: 'RC: ' + $scope.comprobante + '-' + $scope.fecha.toLocaleDateString(), | |
204 | + DAT1: 'C', | |
205 | + CLI: $scope.cobranza.cliente.COD | |
206 | + } | |
207 | + }; | |
208 | + focaCrearCobranzaService.guardarCobranza(cobranza).then(function() { | |
209 | + focaModalService.alert('Cobranza guardada con éxito'); | |
210 | + | |
211 | + $scope.cobranza = { | |
212 | + fecha: new Date() | |
213 | + }; | |
214 | + setearMonedaPorDefecto(); | |
215 | + obtenerNumeroComprobante(); | |
216 | + | |
217 | + $scope.cabecera = []; | |
218 | + $scope.fecha = new Date(); | |
219 | + $scope.facturaTabla = []; | |
220 | + $scope.cobrosTabla = []; | |
221 | + }); | |
83 | 222 | }; |
84 | 223 | |
85 | 224 | $scope.swichCobro = function() { |
... | ... | @@ -155,9 +294,18 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
155 | 294 | modalInstance.result.then( |
156 | 295 | function(cheque) { |
157 | 296 | var cobro = { |
158 | - tipo: 'Ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco, | |
159 | - fecha: cheque.fechaPresentacion, | |
160 | - importe: cheque.importe * $scope.cobranza.cotizacion.VENDEDOR | |
297 | + tipo: 'Ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco, | |
298 | + numero: cheque.numero, | |
299 | + banco: cheque.banco, | |
300 | + fecha: cheque.fechaEmision.toLocaleDateString() + '-' + | |
301 | + cheque.fechaPresentacion.toLocaleDateString(), | |
302 | + fechaPresentacion: cheque.fechaPresentacion, | |
303 | + fechaEmision: cheque.fechaEmision, | |
304 | + importe: cheque.importe * $scope.cobranza.cotizacion.VENDEDOR, | |
305 | + localidad: cheque.localidad, | |
306 | + librador: cheque.librador, | |
307 | + provincia: cheque.provincia, | |
308 | + observaciones: cheque.observaciones | |
161 | 309 | }; |
162 | 310 | $scope.cobrosTabla.push(cobro); |
163 | 311 | }, function() { |
... | ... | @@ -206,25 +354,6 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
206 | 354 | } |
207 | 355 | ); |
208 | 356 | }; |
209 | - | |
210 | - $scope.seleccionarCobrador = function() { | |
211 | - var modalInstance = $uibModal.open( | |
212 | - { | |
213 | - ariaLabelledBy: 'Busqueda de Cobradores', | |
214 | - templateUrl: 'modal-cobradores.html', | |
215 | - controller: 'focaModalCobradoresController', | |
216 | - size: 'lg' | |
217 | - } | |
218 | - ); | |
219 | - modalInstance.result.then( | |
220 | - function(cobrador) { | |
221 | - addCabecera('Cobrador:', cobrador.nombre); | |
222 | - $scope.cobranza.cobrador = cobrador; | |
223 | - }, function() { | |
224 | - | |
225 | - } | |
226 | - ); | |
227 | - }; | |
228 | 357 | |
229 | 358 | $scope.seleccionarCotizacion = function(moneda) { |
230 | 359 | var modalInstance = $uibModal.open( |
... | ... | @@ -251,16 +380,24 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
251 | 380 | } |
252 | 381 | ); |
253 | 382 | }; |
254 | - | |
255 | - $scope.agregarCobro = function(key) { | |
256 | - if(key === 13) { | |
257 | - var cobro = { | |
258 | - cobro: 'Efectivo', | |
259 | - fecha: new Date(), | |
260 | - importe: $scope.cobroEfectivo | |
261 | - }; | |
262 | - $scope.cobrosTabla.push(cobro); | |
263 | - } | |
383 | + | |
384 | + $scope.seleccionarCobrador = function() { | |
385 | + var modalInstance = $uibModal.open( | |
386 | + { | |
387 | + ariaLabelledBy: 'Busqueda de Cobradores', | |
388 | + templateUrl: 'modal-cobradores.html', | |
389 | + controller: 'focaModalCobradoresController', | |
390 | + size: 'lg' | |
391 | + } | |
392 | + ); | |
393 | + modalInstance.result.then( | |
394 | + function(cobrador) { | |
395 | + addCabecera('Cobrador:', cobrador.nombre); | |
396 | + $scope.cobranza.cobrador = cobrador; | |
397 | + }, function() { | |
398 | + | |
399 | + } | |
400 | + ); | |
264 | 401 | }; |
265 | 402 | |
266 | 403 | $scope.getTotalDeuda = function() { |
... | ... | @@ -341,5 +478,29 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
341 | 478 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
342 | 479 | } |
343 | 480 | }*/ |
481 | + function setearMonedaPorDefecto() { | |
482 | + var monedaPorDefecto; | |
483 | + //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | |
484 | + focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { | |
485 | + monedaPorDefecto = res.data[0]; | |
486 | + $scope.cobranza.moneda = monedaPorDefecto; | |
487 | + $scope.cobranza.cotizacion = monedaPorDefecto.cotizaciones[0]; | |
488 | + }); | |
489 | + } | |
490 | + | |
491 | + function obtenerNumeroComprobante() { | |
492 | + focaCrearCobranzaService.getNumeroRecibo().then( | |
493 | + function(res) { | |
494 | + $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4); | |
495 | + $scope.comprobante = $scope.rellenar(res.data.numeroRecibo, 8); | |
496 | + }, | |
497 | + function(err) { | |
498 | + focaModalService.alert('La terminal no esta configurada correctamente'); | |
499 | + console.info(err); | |
500 | + } | |
501 | + ); | |
502 | + } | |
503 | + obtenerNumeroComprobante(); | |
504 | + setearMonedaPorDefecto(); | |
344 | 505 | } |
345 | 506 | ]); |
src/js/service.js
... | ... | @@ -2,10 +2,16 @@ angular.module('focaCrearCobranza') |
2 | 2 | .service('focaCrearCobranzaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { |
3 | 3 | return { |
4 | 4 | getNumeroRecibo: function() { |
5 | - return $http.get(API_ENDPOINT.URL + '/cobranza/numero-siguiente'); | |
5 | + return $http.get(API_ENDPOINT.URL + '/recibo/numero-siguiente'); | |
6 | 6 | }, |
7 | 7 | getCotizacionByIdMoneda: function(id) { |
8 | 8 | return $http.get(API_ENDPOINT.URL + '/moneda/' + id); |
9 | + }, | |
10 | + getUsuario: function(idUsuario) { | |
11 | + return $http.get(API_ENDPOINT.URL + '/vendedores/obtener/' + idUsuario); | |
12 | + }, | |
13 | + guardarCobranza: function(cobranza) { | |
14 | + return $http.post(API_ENDPOINT.URL + '/recibo/guardar', cobranza); | |
9 | 15 | } |
10 | 16 | }; |
11 | 17 | }]); |
src/views/cobranza.html
... | ... | @@ -15,14 +15,14 @@ |
15 | 15 | Fecha: |
16 | 16 | <span |
17 | 17 | ng-show="!datepickerAbierto" |
18 | - ng-bind="now | date:'dd/MM/yyyy HH:mm'" | |
18 | + ng-bind="fecha | date:'dd/MM/yyyy HH:mm'" | |
19 | 19 | ng-click="datepickerAbierto = true" |
20 | 20 | > |
21 | 21 | </span> |
22 | 22 | <input |
23 | 23 | ng-show="datepickerAbierto" |
24 | 24 | type="date" |
25 | - ng-model="now" | |
25 | + ng-model="fecha" | |
26 | 26 | ng-change="datepickerAbierto = false" |
27 | 27 | ng-blur="datepickerAbierto = false" |
28 | 28 | class="form-control form-control-sm col-8 float-right" |
... | ... | @@ -119,10 +119,7 @@ |
119 | 119 | ng-show="show || key == facturaTabla.length - 1" |
120 | 120 | > |
121 | 121 | <td ng-bind="key + 1" class="col-auto"></td> |
122 | - <td class="col" | |
123 | - ng-bind= | |
124 | - "(factura.TCO + '-' + factura.TIP + '-' + | |
125 | - factura.SUC + '-' + factura.NCO)" | |
122 | + <td class="col" ng-bind="factura.numeroFactura" | |
126 | 123 | ></td> |
127 | 124 | <td class="col" ng-bind="factura.FEP | date : 'dd/MM/yyyy'"></td> |
128 | 125 | <td |
... | ... | @@ -252,7 +249,7 @@ |
252 | 249 | <a ng-bind="cobrosTabla.length"></a> |
253 | 250 | </td> |
254 | 251 | <td class="text-right ml-auto table-celda-total no-border-top"> |
255 | - <strong>Total Deuda:</strong> | |
252 | + <strong>Cancela:</strong> | |
256 | 253 | </td> |
257 | 254 | <td class="table-celda-total text-right no-border-top"> |
258 | 255 | <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) | |
... | ... | @@ -308,9 +305,7 @@ |
308 | 305 | <div class="col px-0"> |
309 | 306 | <div class="d-flex"> |
310 | 307 | <div class="col-4 px-1"> |
311 | - <span ng-bind= | |
312 | - "(factura.TCO + '-' + factura.TIP + '-' + | |
313 | - factura.SUC + '-' + factura.NCO)" | |
308 | + <span ng-bind="factura.numeroFactura" | |
314 | 309 | ></span> |
315 | 310 | </div> |
316 | 311 | <div class="col-4 px-1"> |
... | ... | @@ -485,7 +480,7 @@ |
485 | 480 | <table class="table-responsive"> |
486 | 481 | <tr class="d-flex row"> |
487 | 482 | <td class="text-center ml-auto table-celda-total no-border-top col-4"> |
488 | - <strong>Deuda:</strong> | |
483 | + <strong>Cancela:</strong> | |
489 | 484 | </td> |
490 | 485 | <td class="text-center ml-auto table-celda-total no-border-top col-4"> |
491 | 486 | <strong>Cobrado:</strong> |