Commit 558186a93fc1c31c6bbed20132f6acb23300494d
1 parent
844727754c
Exists in
master
Agregado modal de estado de cuenta.
Showing
5 changed files
with
261 additions
and
89 deletions
Show diff stats
src/js/controller.js
1 | 1 | angular.module('focaCrearFactura').controller('facturaController', [ |
2 | 2 | '$scope', '$uibModal', '$location', '$filter', 'crearFacturaService', '$timeout', |
3 | 3 | 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService', |
4 | - '$localStorage', | |
4 | + '$localStorage', 'APP', | |
5 | 5 | function ( |
6 | 6 | $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService, |
7 | - crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage) { | |
7 | + crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP) { | |
8 | 8 | |
9 | 9 | config(); |
10 | 10 | |
... | ... | @@ -87,6 +87,23 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
87 | 87 | ); |
88 | 88 | |
89 | 89 | $scope.inicial = angular.copy($scope.factura); |
90 | + if (APP === 'facturador') { | |
91 | + var modalInstance = $uibModal.open( | |
92 | + { | |
93 | + templateUrl: 'modal-estado-cuenta.html', | |
94 | + controller: 'focaModalEstadoCuentaController', | |
95 | + size: 'lg' | |
96 | + } | |
97 | + ); | |
98 | + modalInstance.result | |
99 | + .then(function (data) { | |
100 | + $scope.$broadcast('addCabecera', { | |
101 | + label: 'Tipo de pago: ', | |
102 | + valor: data | |
103 | + }); | |
104 | + }) | |
105 | + .catch(function (e) { console.error(e); }); | |
106 | + } | |
90 | 107 | } |
91 | 108 | |
92 | 109 | $scope.$watch('factura', function (newValue) { |
... | ... | @@ -175,7 +192,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
175 | 192 | despachos: $scope.factura.despachos |
176 | 193 | }; |
177 | 194 | |
178 | - crearFacturaService.guardarFactura(save).then(function(res) { | |
195 | + crearFacturaService.guardarFactura(save).then(function (res) { | |
179 | 196 | |
180 | 197 | focaBotoneraLateralService.endGuardar(true); |
181 | 198 | |
... | ... | @@ -183,7 +200,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
183 | 200 | |
184 | 201 | config(); |
185 | 202 | |
186 | - }).catch(function(err) { | |
203 | + }).catch(function (err) { | |
187 | 204 | focaModalService.alert('Hubo un error al guardar la factura'); |
188 | 205 | console.log(err); |
189 | 206 | }); |
... | ... | @@ -206,14 +223,39 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
206 | 223 | ); |
207 | 224 | modalInstance.result.then( |
208 | 225 | function (cliente) { |
209 | - $scope.factura.cliente = cliente; | |
226 | + var modalInstance = $uibModal.open( | |
227 | + { | |
228 | + templateUrl: 'modal-estado-cuenta.html', | |
229 | + controller: 'focaModalEstadoCuentaController', | |
230 | + size: 'lg', | |
231 | + resolve: { | |
232 | + parametros: function () { return { idCliente: cliente.cod }; }, | |
233 | + } | |
234 | + } | |
235 | + ); | |
236 | + modalInstance.result | |
237 | + .then(function (data) { | |
210 | 238 | |
211 | - $scope.$broadcast('addCabecera', { | |
212 | - label: 'Cliente:', | |
213 | - valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom | |
214 | - }); | |
239 | + $scope.factura.cliente = cliente; | |
240 | + | |
241 | + $scope.$broadcast('addCabecera', { | |
242 | + label: 'Cliente:', | |
243 | + valor: $filter('rellenarDigitos')(cliente.cod, 3) + | |
244 | + ' - ' + cliente.nom | |
245 | + }); | |
246 | + | |
247 | + $filter('filter')($scope.botonera, | |
248 | + { label: 'Cliente' })[0].checked = true; | |
249 | + | |
250 | + $scope.$broadcast('addCabecera', { | |
251 | + label: 'Tipo de pago: ', | |
252 | + valor: data | |
253 | + }); | |
254 | + }) | |
255 | + .catch(function () { | |
215 | 256 | |
216 | - $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; | |
257 | + $scope.seleccionarCliente(); | |
258 | + }); | |
217 | 259 | |
218 | 260 | }, function () { |
219 | 261 | } |
... | ... | @@ -221,7 +263,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
221 | 263 | |
222 | 264 | }; |
223 | 265 | |
224 | - $scope.seleccionarVendedor = function() { | |
266 | + $scope.seleccionarVendedor = function () { | |
225 | 267 | var parametrosModal = { |
226 | 268 | titulo: 'Bรบsqueda vendedores', |
227 | 269 | query: '/vendedor-playa', |
... | ... | @@ -245,9 +287,9 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
245 | 287 | function (vendedor) { |
246 | 288 | |
247 | 289 | indicarPassword(vendedor) |
248 | - .then(function() { | |
290 | + .then(function () { | |
249 | 291 | validarPlanillaVendedor(vendedor) |
250 | - .then(function() { | |
292 | + .then(function () { | |
251 | 293 | |
252 | 294 | $filter('filter')($scope.botonera, { |
253 | 295 | label: 'Vendedor' |
... | ... | @@ -256,8 +298,8 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
256 | 298 | $scope.$broadcast('addCabecera', { |
257 | 299 | label: 'Vendedor:', |
258 | 300 | valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + |
259 | - ' - ' + | |
260 | - vendedor.NomVen | |
301 | + ' - ' + | |
302 | + vendedor.NomVen | |
261 | 303 | }); |
262 | 304 | |
263 | 305 | $scope.factura.vendedor = vendedor; |
... | ... | @@ -266,7 +308,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
266 | 308 | }) |
267 | 309 | .catch($scope.seleccionarVendedor); |
268 | 310 | }) |
269 | - .catch(function(err) { | |
311 | + .catch(function (err) { | |
270 | 312 | console.log(err) |
271 | 313 | }); |
272 | 314 | |
... | ... | @@ -383,14 +425,14 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
383 | 425 | articulo.desactivado = true; |
384 | 426 | $scope.factura.despachos.splice(index, 1); |
385 | 427 | }) |
386 | - .catch(function() { | |
428 | + .catch(function () { | |
387 | 429 | focaModalService.alert('Hubo un error al desasociar este despacho'); |
388 | 430 | }); |
389 | 431 | }; |
390 | 432 | |
391 | 433 | function getProductosByPlanilla(numeroPlanilla) { |
392 | 434 | |
393 | - crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function(res) { | |
435 | + crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function (res) { | |
394 | 436 | |
395 | 437 | res.data.forEach(function (producto) { |
396 | 438 | |
... | ... | @@ -408,7 +450,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
408 | 450 | |
409 | 451 | function crearFuncionesProductos(producto) { |
410 | 452 | |
411 | - $scope[nombreFuncion(producto.DetArt)] = function() { | |
453 | + $scope[nombreFuncion(producto.DetArt)] = function () { | |
412 | 454 | |
413 | 455 | if (angular.equals($scope.factura.cliente, {})) { |
414 | 456 | focaModalService.alert('Seleccione cliente'); |
... | ... | @@ -420,7 +462,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
420 | 462 | templateUrl: 'modal-combustibles.html', |
421 | 463 | controller: 'focaModalCombustiblesController', |
422 | 464 | resolve: { |
423 | - parametros: function() { | |
465 | + parametros: function () { | |
424 | 466 | return { |
425 | 467 | despachos: producto.despachos, |
426 | 468 | nombreProducto: producto.DetArt |
... | ... | @@ -431,7 +473,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
431 | 473 | } |
432 | 474 | ); |
433 | 475 | |
434 | - modalInstance.result.then(function(despacho) { | |
476 | + modalInstance.result.then(function (despacho) { | |
435 | 477 | |
436 | 478 | var articulo = { |
437 | 479 | TIP: $scope.factura.cliente.tipoFactura, |
... | ... | @@ -475,19 +517,19 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
475 | 517 | producto: despacho.PRO, |
476 | 518 | carga: despacho.CAR |
477 | 519 | }) |
478 | - .then(function () { | |
479 | - $scope.factura.articulosFactura.push(articulo); | |
480 | - $scope.factura.despachos.push(despacho); | |
481 | - }) | |
482 | - .catch(function (err) { | |
520 | + .then(function () { | |
521 | + $scope.factura.articulosFactura.push(articulo); | |
522 | + $scope.factura.despachos.push(despacho); | |
523 | + }) | |
524 | + .catch(function (err) { | |
483 | 525 | |
484 | - focaModalService.alert('El despacho esta en uso'); | |
485 | - }); | |
526 | + focaModalService.alert('El despacho esta en uso'); | |
527 | + }); | |
486 | 528 | |
487 | 529 | }) |
488 | - .catch(function (err) { | |
489 | - console.log(err); | |
490 | - }); | |
530 | + .catch(function (err) { | |
531 | + console.log(err); | |
532 | + }); | |
491 | 533 | |
492 | 534 | }; |
493 | 535 | } |
... | ... | @@ -495,7 +537,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
495 | 537 | function nombreFuncion(string) { |
496 | 538 | var texto = 'seleccionar'; |
497 | 539 | var arr = string.split(' '); |
498 | - arr.forEach(function(palabra) { | |
540 | + arr.forEach(function (palabra) { | |
499 | 541 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); |
500 | 542 | texto += palabra; |
501 | 543 | }); |
... | ... | @@ -504,7 +546,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
504 | 546 | |
505 | 547 | function indicarPassword(vendedor) { |
506 | 548 | |
507 | - return new Promise(function(resolve, reject) { | |
549 | + return new Promise(function (resolve, reject) { | |
508 | 550 | |
509 | 551 | focaModalService |
510 | 552 | .prompt({ |
... | ... | @@ -515,7 +557,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
515 | 557 | |
516 | 558 | if (contraseรฑa != vendedor.ClaVen.trim()) { |
517 | 559 | |
518 | - focaModalService.alert('Clave incorrecta').then(function() { | |
560 | + focaModalService.alert('Clave incorrecta').then(function () { | |
519 | 561 | indicarPassword(vendedor); |
520 | 562 | }); |
521 | 563 | } else { |
... | ... | @@ -528,24 +570,24 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
528 | 570 | |
529 | 571 | function validarPlanillaVendedor(vendedor) { |
530 | 572 | |
531 | - return new Promise(function(resolve, reject) { | |
573 | + return new Promise(function (resolve, reject) { | |
532 | 574 | |
533 | 575 | crearFacturaService |
534 | - .validarPlanillaVendedor(vendedor.CodVen.trim()) | |
535 | - .then(function (res) { | |
576 | + .validarPlanillaVendedor(vendedor.CodVen.trim()) | |
577 | + .then(function (res) { | |
536 | 578 | |
537 | - if (!res.data.length) { | |
579 | + if (!res.data.length) { | |
538 | 580 | |
539 | - focaModalService | |
540 | - .alert('No se encontrรณ planilla abierta para el vendedor') | |
541 | - .then(reject); | |
581 | + focaModalService | |
582 | + .alert('No se encontrรณ planilla abierta para el vendedor') | |
583 | + .then(reject); | |
542 | 584 | |
543 | - } else { | |
544 | - resolve(); | |
545 | - } | |
585 | + } else { | |
586 | + resolve(); | |
587 | + } | |
546 | 588 | |
547 | - }) | |
548 | - .catch(reject); | |
589 | + }) | |
590 | + .catch(reject); | |
549 | 591 | }); |
550 | 592 | } |
551 | 593 |
src/js/controllerEstadoCuenta.js
... | ... | @@ -0,0 +1,33 @@ |
1 | +angular.module('focaCrearFactura') | |
2 | + .controller('focaModalEstadoCuentaController', [ | |
3 | + '$scope', '$uibModalInstance', 'crearFacturaService', 'parametros', | |
4 | + function ($scope, $uibModalInstance, crearFacturaService, parametros) { | |
5 | + | |
6 | + $scope.estadoCuenta = { | |
7 | + autorizado: 0.0, | |
8 | + extracciones: 0.0, | |
9 | + saldo: 0.0, | |
10 | + situacion: false, | |
11 | + facturasVencidas: 0.0 | |
12 | + }; | |
13 | + | |
14 | + init(); | |
15 | + | |
16 | + function init() { | |
17 | + crearFacturaService.getResumenCuenta(parametros.idCliente) | |
18 | + .then(function (res) { | |
19 | + console.log(res); | |
20 | + $scope.estadoCuenta = res.data; | |
21 | + }) | |
22 | + .catch(function (e) { console.error(e); }); | |
23 | + } | |
24 | + | |
25 | + $scope.elegirTipoDePago = function (tipoDePago) { | |
26 | + $uibModalInstance.close(tipoDePago); | |
27 | + }; | |
28 | + | |
29 | + $scope.cancel = function () { | |
30 | + $uibModalInstance.dismiss('cancel'); | |
31 | + }; | |
32 | + } | |
33 | + ]); |
src/js/service.js
1 | 1 | angular.module('focaCrearFactura') |
2 | 2 | .service('crearFacturaService', ['$http', 'API_ENDPOINT', |
3 | - function($http, API_ENDPOINT) { | |
4 | - var route = API_ENDPOINT.URL; | |
5 | - return { | |
6 | - guardarFactura: function (factura) { | |
7 | - return $http.post(route + '/factura/guardar', factura) | |
8 | - }, | |
9 | - getParametros: function() { | |
10 | - return $http.get(API_ENDPOINT.URL + '/parametros/factura'); | |
11 | - }, | |
12 | - validarPlanillaVendedor: function(idVendedor) { | |
13 | - return $http.get(route + '/turnos/validar-planilla/' + idVendedor); | |
14 | - }, | |
15 | - getProductosByPlanilla: function (numeroPlanilla) { | |
16 | - return $http.get(route + '/turnos/productos/' + numeroPlanilla); | |
17 | - }, | |
18 | - setearDespachoOcupado: function (parametros) { | |
19 | - return $http.post(route + '/turnos/despacho-en-uso', parametros); | |
20 | - }, | |
21 | - setearDespachoDesocupado: function (parametros) { | |
22 | - return $http.post(route + '/turnos/depacho-sin-uso', parametros); | |
23 | - }, | |
24 | - getBotonera: function() { | |
25 | - return [ | |
26 | - { | |
27 | - label: 'Vendedor', | |
28 | - image: 'vendedor.png' | |
29 | - }, | |
30 | - { | |
31 | - label: 'Cliente', | |
32 | - image: 'cliente.png' | |
33 | - }, | |
34 | - { | |
35 | - label: 'Moneda', | |
36 | - image: 'moneda.png' | |
37 | - }, | |
38 | - { | |
39 | - label: 'Observaciones', | |
40 | - image: 'botonObservaciones.png' | |
41 | - } | |
42 | - ]; | |
43 | - } | |
44 | - }; | |
45 | - }]); | |
3 | + function ($http, API_ENDPOINT) { | |
4 | + var route = API_ENDPOINT.URL; | |
5 | + return { | |
6 | + guardarFactura: function (factura) { | |
7 | + return $http.post(route + '/factura/guardar', factura); | |
8 | + }, | |
9 | + getParametros: function () { | |
10 | + return $http.get(API_ENDPOINT.URL + '/parametros/factura'); | |
11 | + }, | |
12 | + validarPlanillaVendedor: function (idVendedor) { | |
13 | + return $http.get(route + '/turnos/validar-planilla/' + idVendedor); | |
14 | + }, | |
15 | + getProductosByPlanilla: function (numeroPlanilla) { | |
16 | + return $http.get(route + '/turnos/productos/' + numeroPlanilla); | |
17 | + }, | |
18 | + setearDespachoOcupado: function (parametros) { | |
19 | + return $http.post(route + '/turnos/despacho-en-uso', parametros); | |
20 | + }, | |
21 | + setearDespachoDesocupado: function (parametros) { | |
22 | + return $http.post(route + '/turnos/depacho-sin-uso', parametros); | |
23 | + }, | |
24 | + getResumenCuenta: function (idCliente) { | |
25 | + return $http.get('http://10.231.45.194:9900' + '/cliente/resumen-cuenta/' + idCliente); | |
26 | + }, | |
27 | + getBotonera: function () { | |
28 | + return [ | |
29 | + { | |
30 | + label: 'Vendedor', | |
31 | + image: 'vendedor.png' | |
32 | + }, | |
33 | + { | |
34 | + label: 'Cliente', | |
35 | + image: 'cliente.png' | |
36 | + }, | |
37 | + { | |
38 | + label: 'Moneda', | |
39 | + image: 'moneda.png' | |
40 | + }, | |
41 | + { | |
42 | + label: 'Observaciones', | |
43 | + image: 'botonObservaciones.png' | |
44 | + } | |
45 | + ]; | |
46 | + } | |
47 | + }; | |
48 | + } | |
49 | + ]); |
src/views/modal-estado-cuenta.html
... | ... | @@ -0,0 +1,80 @@ |
1 | +<div class="modal-header py-1"> | |
2 | + <div class="row w-100"> | |
3 | + <div class="col-lg-6"> | |
4 | + <h5 class="modal-title text-center my-1">Estado cuenta corriente</h5> | |
5 | + </div> | |
6 | + </div> | |
7 | +</div> | |
8 | +<div class="modal-body" id="modal-body"> | |
9 | + <div class="row m-3"> | |
10 | + <div class="col"> | |
11 | + <div class="row mb-2"> | |
12 | + <div class="col text-center"> | |
13 | + <p class="m-0">Autorizado</p> | |
14 | + <p class="h5 m-0" ng-bind="estadoCuenta.autorizado | currency"></p> | |
15 | + </div> | |
16 | + </div> | |
17 | + <div class="row border-top mb-2"> | |
18 | + <div class="col text-center"> | |
19 | + <p class="m-0">Extracciones</p> | |
20 | + <p class="h5 m-0" ng-bind="estadoCuenta.extracciones | currency"></p> | |
21 | + </div> | |
22 | + </div> | |
23 | + <div class="row border-top mb-2"> | |
24 | + <div class="col text-center"> | |
25 | + <p class="m-0">Saldo</p> | |
26 | + <p class="h5 m-0" ng-bind="estadoCuenta.saldo | currency"></p> | |
27 | + </div> | |
28 | + </div> | |
29 | + <div class="row border-top"> | |
30 | + <div class="col text-center"> | |
31 | + <p class="m-0">Situacion</p> | |
32 | + <h4> | |
33 | + <p | |
34 | + ng-show="estadoCuenta.situacion" | |
35 | + class="badge badge-success m-0 px-3">Permitido | |
36 | + </p> | |
37 | + <p | |
38 | + ng-show="!estadoCuenta.situacion" | |
39 | + class="badge badge-danger m-0 px-3">No permitido | |
40 | + </p> | |
41 | + </h4> | |
42 | + </div> | |
43 | + </div> | |
44 | + <div class="row border-top mb-2"> | |
45 | + <div class="col text-center"> | |
46 | + <p class="m-0">Facturas Vencidas</p> | |
47 | + <p class="h5 m-0" ng-bind="estadoCuenta.facturasVencidas | currency"></p> | |
48 | + </div> | |
49 | + </div> | |
50 | + </div> | |
51 | + </div> | |
52 | + <div class="row h-25 align-items-center mx-0 botonera-secundaria"> | |
53 | + <div class="col-6 col-sm-4 offset-sm-2"> | |
54 | + <button | |
55 | + type="button" | |
56 | + class="btn btn-sm btn-block btn-tarjeta rounded border p-1" | |
57 | + ng-disabled="!estadoCuenta.situacion" | |
58 | + ng-click="elegirTipoDePago('Contado')" | |
59 | + > | |
60 | + <img ng-src="./img/contado.png" alt=""> | |
61 | + <p class="m-0">Contado</p> | |
62 | + </button> | |
63 | + </div> | |
64 | + <div class="col-6 col-sm-4"> | |
65 | + <button | |
66 | + type="button" | |
67 | + class="btn btn-sm btn-block btn-tarjeta rounded border p-1" | |
68 | + ng-disabled="!estadoCuenta.situacion" | |
69 | + foca-focus="true" | |
70 | + ng-click="elegirTipoDePago('Cuenta Corriente')" | |
71 | + > | |
72 | + <img ng-src="./img/cuentaCorriente.png" alt=""> | |
73 | + <p class="m-0">Cta. Corriente</p> | |
74 | + </button> | |
75 | + </div> | |
76 | + </div> | |
77 | +</div> | |
78 | +<div class="modal-footer py-2"> | |
79 | + <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | |
80 | +</div> | |
0 | 81 | \ No newline at end of file |
src/views/modal-seleccionar-cliente.html
... | ... | @@ -0,0 +1,13 @@ |
1 | +<div class="modal-header py-1"> | |
2 | + <div class="row w-100"> | |
3 | + <div class="col-lg-6"> | |
4 | + <h5 class="modal-title my-1">Seleccione Cliente</h5> | |
5 | + </div> | |
6 | + </div> | |
7 | +</div> | |
8 | +<div class="modal-body" id="modal-body"> | |
9 | + | |
10 | +</div> | |
11 | +<div class="modal-footer py-1"> | |
12 | + <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | |
13 | +</div> | |
0 | 14 | \ No newline at end of file |