Commit 0cf3df0ce6d78a624e1b2b122a05a89c08801eac
Exists in
master
Merge branch 'master' into 'master'
Master See merge request !5
Showing
5 changed files
Show diff stats
.jshintrc
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,10 @@ 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 | + 'focaSeguimientoService', | |
11 | + function($scope, $uibModal, $location, $filter, focaCrearCobranzaService, focaModalService, | |
12 | + $cookies, focaSeguimientoService) | |
10 | 13 | { |
11 | 14 | $scope.botonera = [ |
12 | 15 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
... | ... | @@ -27,46 +30,30 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
27 | 30 | minDate: new Date(2010, 0, 1) |
28 | 31 | }; |
29 | 32 | |
30 | - $scope.cobranza = { | |
31 | - fecha: new Date() | |
32 | - }; | |
33 | - | |
34 | 33 | $scope.cabecera = []; |
35 | 34 | $scope.showCabecera = true; |
36 | 35 | |
37 | - $scope.now = new Date(); | |
36 | + $scope.cobranza = {}; | |
37 | + | |
38 | + $scope.fecha = new Date(); | |
38 | 39 | $scope.puntoVenta = '0000'; |
39 | 40 | $scope.comprobante = '00000000'; |
40 | 41 | $scope.facturaTabla = []; |
41 | 42 | $scope.cobrosTabla = []; |
42 | 43 | |
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]; | |
44 | + focaCrearCobranzaService.getUsuario($cookies.get('idUsuario')).then(function(data) { | |
45 | + $scope.usuario = data.data; | |
53 | 46 | }); |
54 | 47 | |
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 | 48 | $scope.crearCobranza = function() { |
66 | 49 | if(!$scope.cobranza.cliente) { |
67 | 50 | focaModalService.alert('Ingrese Cliente'); |
68 | 51 | return; |
69 | 52 | } |
53 | + if(!$scope.cobranza.cobrador) { | |
54 | + focaModalService.alert('Ingrese Cobrador'); | |
55 | + return; | |
56 | + } | |
70 | 57 | if($scope.facturaTabla.length < 1) { |
71 | 58 | focaModalService.alert('Ingrese al menos una factura'); |
72 | 59 | return; |
... | ... | @@ -76,10 +63,174 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
76 | 63 | $scope.cobranza.moneda.SIMBOLO + '0,00'); |
77 | 64 | return; |
78 | 65 | } |
79 | - //TODO: Guarda cobranza | |
80 | - // var date = new Date(); | |
81 | - // var cobranza = { | |
82 | - // }; | |
66 | + var cobranza = {}; | |
67 | + var cheques = []; | |
68 | + var cuerpos = []; | |
69 | + | |
70 | + for (var i = 0; i < $scope.facturaTabla.length; i++) { | |
71 | + var cuerpoFactura = { | |
72 | + CYV: 'V', | |
73 | + TIP: 'C', | |
74 | + TCO: 'RC', | |
75 | + PVE: $scope.puntoVenta, | |
76 | + NCO: $scope.comprobante, | |
77 | + LOP: 'L', | |
78 | + TIL: $scope.facturaTabla[i].TCO, | |
79 | + COM: $scope.facturaTabla[i].numeroFactura, | |
80 | + FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), | |
81 | + IMP: $scope.facturaTabla[i].IPA, | |
82 | + RES: 0,//caja de tesorería | |
83 | + SUBM: 0 | |
84 | + }; | |
85 | + cuerpos.push(cuerpoFactura); | |
86 | + } | |
87 | + | |
88 | + for (var j = 0; j < $scope.cobrosTabla.length; j++) { | |
89 | + | |
90 | + var efectivo = $scope.cobrosTabla[j].tipo === 'Efectivo' ? true : false; | |
91 | + | |
92 | + var cuerpoCobros = { | |
93 | + CYV: 'V', | |
94 | + TIP: 'C', | |
95 | + TCO: 'RC', | |
96 | + PVE: $scope.puntoVenta, | |
97 | + NCO: $scope.comprobante, | |
98 | + LOP: 'P', | |
99 | + TIL: 'EF', | |
100 | + COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : 'ch(' + | |
101 | + $scope.cobrosTabla[j].numero + ')' + $scope.cobrosTabla[j].banco.desbco, | |
102 | + FEC: efectivo ? | |
103 | + $scope.cobrosTabla[j].fecha | |
104 | + .toISOString().slice(0, 19).replace('T', ' ') : | |
105 | + $scope.cobrosTabla[j].fechaPresentacion | |
106 | + .toISOString().slice(0, 19).replace('T', ' '), | |
107 | + IMP: $scope.cobrosTabla[j].importe, | |
108 | + RES: 0,//caja de tesorería | |
109 | + SUBM: 0 | |
110 | + }; | |
111 | + cuerpos.push(cuerpoCobros); | |
112 | + | |
113 | + if(!efectivo) { | |
114 | + var cheque = { | |
115 | + BCO: $scope.cobrosTabla[j].banco.ID, | |
116 | + NUM: $scope.comprobante, | |
117 | + FEP: $scope.cobrosTabla[j].fechaPresentacion | |
118 | + .toISOString().slice(0, 19).replace('T', ' '), | |
119 | + FEE: $scope.cobrosTabla[j].fechaEmision | |
120 | + .toISOString().slice(0, 19).replace('T', ' '), | |
121 | + LUG: $scope.cobrosTabla[j].localidad.NOMBRE, | |
122 | + IMP: $scope.cobrosTabla[j].importe, | |
123 | + LIB: $scope.cobrosTabla[j].librador, | |
124 | + EST: 'C',//'D' depositado, 'E' entregado, 'C' en cartera | |
125 | + PCI: $scope.cobrosTabla[j].provincia.ID, | |
126 | + LPLA: 0, | |
127 | + PLA: 0, | |
128 | + VEN: $scope.usuario.CodVen,//Id vendedor | |
129 | + CCLIE: $scope.cobranza.cliente.COD,//Id cliente | |
130 | + REN: 0, | |
131 | + PVEC: $scope.puntoVenta, | |
132 | + NCOC: $scope.comprobante, | |
133 | + OBSE: $scope.cobrosTabla[j].observaciones, | |
134 | + LUV: 0, | |
135 | + ORI: 've', | |
136 | + FER: '', | |
137 | + BIMP: 0, | |
138 | + COMP: 'C ' +'RC ' + $scope.puntoVenta + '-' + $scope.comprobante, | |
139 | + 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 | |
141 | + REC_CAJ: 'D', | |
142 | + TIPO_C: 0,//?? | |
143 | + SALDO_CAJ: 'S', | |
144 | + FECHA_INGRESO: $scope.fecha | |
145 | + .toISOString().slice(0, 19).replace('T', ' '), | |
146 | + Vendedor_valor: 0, | |
147 | + FAMILIA: 0, | |
148 | + CUIT_LIB: '', | |
149 | + COD_LUG: $scope.cobrosTabla[j].localidad.ID,//código lugar | |
150 | + SEN: '', | |
151 | + NRC: 0, | |
152 | + COD_LARGO: '', | |
153 | + VN: 0, | |
154 | + ID_LECTOR: 0, | |
155 | + NATHB: '' | |
156 | + }; | |
157 | + cheques.push(cheque); | |
158 | + } | |
159 | + } | |
160 | + | |
161 | + cobranza = { | |
162 | + recibo: { | |
163 | + CYV: 'V', | |
164 | + TIP: 'C', | |
165 | + TCO: 'RC', | |
166 | + PVE: $scope.puntoVenta, //Sucursar, punto de venta | |
167 | + NCO: $scope.comprobante, //Numero de comprobante | |
168 | + FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), | |
169 | + CLI: $scope.cobranza.cliente.COD, | |
170 | + ATO: 0, //número de asiento | |
171 | + CFE: $scope.usuario.NomVen.trim(), | |
172 | + PLA: '',//Numero de planilla, sin uso | |
173 | + ID_MONEDA: $scope.cobranza.moneda.ID, | |
174 | + COTIZACION: $scope.cobranza.cotizacion.VENDEDOR | |
175 | + }, | |
176 | + cuerpo: cuerpos, | |
177 | + cheques: cheques, | |
178 | + acobypag: { | |
179 | + CYV: 'V', | |
180 | + COD: $scope.cobranza.cliente.COD, | |
181 | + FEP: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), | |
182 | + TIP: '',//?? | |
183 | + TCO: 'RC', | |
184 | + SUC: $scope.puntoVenta, | |
185 | + NCO: $scope.comprobante, | |
186 | + IPA: $scope.getTotalCobrado(), | |
187 | + SAL: '',//?? | |
188 | + TCA: 1, | |
189 | + ZONA: 1, | |
190 | + FPA: 2,//Forma de pago | |
191 | + REC: 0, | |
192 | + REP: 0, | |
193 | + FER: null, | |
194 | + REM: 0, | |
195 | + FRE: null,//?? | |
196 | + PRO: 'N', | |
197 | + FEV: $scope.fecha.toISOString().slice(0, 19).replace('T', ' ') | |
198 | + }, | |
199 | + datosCobrador: { | |
200 | + COD: $scope.cobranza.cobrador.id, | |
201 | + PVE: $scope.puntoVenta, | |
202 | + NUM: $scope.comprobante, | |
203 | + EST: 'C', | |
204 | + OBS: 'RC: ' + $scope.comprobante + '-' + $scope.fecha.toLocaleDateString(), | |
205 | + DAT1: 'C', | |
206 | + CLI: $scope.cobranza.cliente.COD | |
207 | + } | |
208 | + }; | |
209 | + focaCrearCobranzaService.guardarCobranza(cobranza).then(function() { | |
210 | + focaModalService.alert('Cobranza guardada con éxito'); | |
211 | + | |
212 | + focaSeguimientoService.guardarPosicion( | |
213 | + $scope.sucursal+$scope.comprobante, | |
214 | + 'Cobranza', | |
215 | + 'Nº: ' + $filter('comprobante')([ | |
216 | + $scope.puntoVenta, | |
217 | + $scope.comprobante | |
218 | + ]) + '<br/>' + | |
219 | + 'Vendedor: ' + $scope.usuario.NomVen + '<br/>' + | |
220 | + 'Total: ' + $filter('currency')($scope.getTotalCobrado()) | |
221 | + ); | |
222 | + | |
223 | + $scope.cobranza = { | |
224 | + fecha: new Date() | |
225 | + }; | |
226 | + setearMonedaPorDefecto(); | |
227 | + obtenerNumeroComprobante(); | |
228 | + | |
229 | + $scope.cabecera = []; | |
230 | + $scope.fecha = new Date(); | |
231 | + $scope.facturaTabla = []; | |
232 | + $scope.cobrosTabla = []; | |
233 | + }); | |
83 | 234 | }; |
84 | 235 | |
85 | 236 | $scope.swichCobro = function() { |
... | ... | @@ -155,9 +306,18 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
155 | 306 | modalInstance.result.then( |
156 | 307 | function(cheque) { |
157 | 308 | var cobro = { |
158 | - tipo: 'Ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco, | |
159 | - fecha: cheque.fechaPresentacion, | |
160 | - importe: cheque.importe * $scope.cobranza.cotizacion.VENDEDOR | |
309 | + tipo: 'Ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco, | |
310 | + numero: cheque.numero, | |
311 | + banco: cheque.banco, | |
312 | + fecha: cheque.fechaEmision.toLocaleDateString() + '-' + | |
313 | + cheque.fechaPresentacion.toLocaleDateString(), | |
314 | + fechaPresentacion: cheque.fechaPresentacion, | |
315 | + fechaEmision: cheque.fechaEmision, | |
316 | + importe: cheque.importe * $scope.cobranza.cotizacion.VENDEDOR, | |
317 | + localidad: cheque.localidad, | |
318 | + librador: cheque.librador, | |
319 | + provincia: cheque.provincia, | |
320 | + observaciones: cheque.observaciones | |
161 | 321 | }; |
162 | 322 | $scope.cobrosTabla.push(cobro); |
163 | 323 | }, function() { |
... | ... | @@ -206,25 +366,6 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
206 | 366 | } |
207 | 367 | ); |
208 | 368 | }; |
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 | 369 | |
229 | 370 | $scope.seleccionarCotizacion = function(moneda) { |
230 | 371 | var modalInstance = $uibModal.open( |
... | ... | @@ -251,16 +392,24 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
251 | 392 | } |
252 | 393 | ); |
253 | 394 | }; |
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 | - } | |
395 | + | |
396 | + $scope.seleccionarCobrador = function() { | |
397 | + var modalInstance = $uibModal.open( | |
398 | + { | |
399 | + ariaLabelledBy: 'Busqueda de Cobradores', | |
400 | + templateUrl: 'modal-cobradores.html', | |
401 | + controller: 'focaModalCobradoresController', | |
402 | + size: 'lg' | |
403 | + } | |
404 | + ); | |
405 | + modalInstance.result.then( | |
406 | + function(cobrador) { | |
407 | + addCabecera('Cobrador:', cobrador.nombre); | |
408 | + $scope.cobranza.cobrador = cobrador; | |
409 | + }, function() { | |
410 | + | |
411 | + } | |
412 | + ); | |
264 | 413 | }; |
265 | 414 | |
266 | 415 | $scope.getTotalDeuda = function() { |
... | ... | @@ -341,5 +490,29 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
341 | 490 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
342 | 491 | } |
343 | 492 | }*/ |
493 | + function setearMonedaPorDefecto() { | |
494 | + var monedaPorDefecto; | |
495 | + //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | |
496 | + focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { | |
497 | + monedaPorDefecto = res.data[0]; | |
498 | + $scope.cobranza.moneda = monedaPorDefecto; | |
499 | + $scope.cobranza.cotizacion = monedaPorDefecto.cotizaciones[0]; | |
500 | + }); | |
501 | + } | |
502 | + | |
503 | + function obtenerNumeroComprobante() { | |
504 | + focaCrearCobranzaService.getNumeroRecibo().then( | |
505 | + function(res) { | |
506 | + $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4); | |
507 | + $scope.comprobante = $scope.rellenar(res.data.numeroRecibo, 8); | |
508 | + }, | |
509 | + function(err) { | |
510 | + focaModalService.alert('La terminal no esta configurada correctamente'); | |
511 | + console.info(err); | |
512 | + } | |
513 | + ); | |
514 | + } | |
515 | + obtenerNumeroComprobante(); | |
516 | + setearMonedaPorDefecto(); | |
344 | 517 | } |
345 | 518 | ]); |
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> |