From 558186a93fc1c31c6bbed20132f6acb23300494d Mon Sep 17 00:00:00 2001 From: mpuebla Date: Tue, 23 Jul 2019 17:47:32 -0300 Subject: [PATCH] Agregado modal de estado de cuenta. --- src/js/controller.js | 134 ++++++++++++++++++++----------- src/js/controllerEstadoCuenta.js | 33 ++++++++ src/js/service.js | 90 +++++++++++---------- src/views/modal-estado-cuenta.html | 80 ++++++++++++++++++ src/views/modal-seleccionar-cliente.html | 13 +++ 5 files changed, 261 insertions(+), 89 deletions(-) create mode 100644 src/js/controllerEstadoCuenta.js create mode 100644 src/views/modal-estado-cuenta.html create mode 100644 src/views/modal-seleccionar-cliente.html diff --git a/src/js/controller.js b/src/js/controller.js index 1a1149e..b798f0e 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -1,10 +1,10 @@ angular.module('focaCrearFactura').controller('facturaController', [ '$scope', '$uibModal', '$location', '$filter', 'crearFacturaService', '$timeout', 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService', - '$localStorage', + '$localStorage', 'APP', function ( $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService, - crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage) { + crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP) { config(); @@ -87,6 +87,23 @@ angular.module('focaCrearFactura').controller('facturaController', [ ); $scope.inicial = angular.copy($scope.factura); + if (APP === 'facturador') { + var modalInstance = $uibModal.open( + { + templateUrl: 'modal-estado-cuenta.html', + controller: 'focaModalEstadoCuentaController', + size: 'lg' + } + ); + modalInstance.result + .then(function (data) { + $scope.$broadcast('addCabecera', { + label: 'Tipo de pago: ', + valor: data + }); + }) + .catch(function (e) { console.error(e); }); + } } $scope.$watch('factura', function (newValue) { @@ -175,7 +192,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ despachos: $scope.factura.despachos }; - crearFacturaService.guardarFactura(save).then(function(res) { + crearFacturaService.guardarFactura(save).then(function (res) { focaBotoneraLateralService.endGuardar(true); @@ -183,7 +200,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ config(); - }).catch(function(err) { + }).catch(function (err) { focaModalService.alert('Hubo un error al guardar la factura'); console.log(err); }); @@ -206,14 +223,39 @@ angular.module('focaCrearFactura').controller('facturaController', [ ); modalInstance.result.then( function (cliente) { - $scope.factura.cliente = cliente; + var modalInstance = $uibModal.open( + { + templateUrl: 'modal-estado-cuenta.html', + controller: 'focaModalEstadoCuentaController', + size: 'lg', + resolve: { + parametros: function () { return { idCliente: cliente.cod }; }, + } + } + ); + modalInstance.result + .then(function (data) { - $scope.$broadcast('addCabecera', { - label: 'Cliente:', - valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom - }); + $scope.factura.cliente = cliente; + + $scope.$broadcast('addCabecera', { + label: 'Cliente:', + valor: $filter('rellenarDigitos')(cliente.cod, 3) + + ' - ' + cliente.nom + }); + + $filter('filter')($scope.botonera, + { label: 'Cliente' })[0].checked = true; + + $scope.$broadcast('addCabecera', { + label: 'Tipo de pago: ', + valor: data + }); + }) + .catch(function () { - $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; + $scope.seleccionarCliente(); + }); }, function () { } @@ -221,7 +263,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ }; - $scope.seleccionarVendedor = function() { + $scope.seleccionarVendedor = function () { var parametrosModal = { titulo: 'Búsqueda vendedores', query: '/vendedor-playa', @@ -245,9 +287,9 @@ angular.module('focaCrearFactura').controller('facturaController', [ function (vendedor) { indicarPassword(vendedor) - .then(function() { + .then(function () { validarPlanillaVendedor(vendedor) - .then(function() { + .then(function () { $filter('filter')($scope.botonera, { label: 'Vendedor' @@ -256,8 +298,8 @@ angular.module('focaCrearFactura').controller('facturaController', [ $scope.$broadcast('addCabecera', { label: 'Vendedor:', valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + - ' - ' + - vendedor.NomVen + ' - ' + + vendedor.NomVen }); $scope.factura.vendedor = vendedor; @@ -266,7 +308,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ }) .catch($scope.seleccionarVendedor); }) - .catch(function(err) { + .catch(function (err) { console.log(err) }); @@ -383,14 +425,14 @@ angular.module('focaCrearFactura').controller('facturaController', [ articulo.desactivado = true; $scope.factura.despachos.splice(index, 1); }) - .catch(function() { + .catch(function () { focaModalService.alert('Hubo un error al desasociar este despacho'); }); }; function getProductosByPlanilla(numeroPlanilla) { - crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function(res) { + crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function (res) { res.data.forEach(function (producto) { @@ -408,7 +450,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ function crearFuncionesProductos(producto) { - $scope[nombreFuncion(producto.DetArt)] = function() { + $scope[nombreFuncion(producto.DetArt)] = function () { if (angular.equals($scope.factura.cliente, {})) { focaModalService.alert('Seleccione cliente'); @@ -420,7 +462,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ templateUrl: 'modal-combustibles.html', controller: 'focaModalCombustiblesController', resolve: { - parametros: function() { + parametros: function () { return { despachos: producto.despachos, nombreProducto: producto.DetArt @@ -431,7 +473,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ } ); - modalInstance.result.then(function(despacho) { + modalInstance.result.then(function (despacho) { var articulo = { TIP: $scope.factura.cliente.tipoFactura, @@ -475,19 +517,19 @@ angular.module('focaCrearFactura').controller('facturaController', [ producto: despacho.PRO, carga: despacho.CAR }) - .then(function () { - $scope.factura.articulosFactura.push(articulo); - $scope.factura.despachos.push(despacho); - }) - .catch(function (err) { + .then(function () { + $scope.factura.articulosFactura.push(articulo); + $scope.factura.despachos.push(despacho); + }) + .catch(function (err) { - focaModalService.alert('El despacho esta en uso'); - }); + focaModalService.alert('El despacho esta en uso'); + }); }) - .catch(function (err) { - console.log(err); - }); + .catch(function (err) { + console.log(err); + }); }; } @@ -495,7 +537,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ function nombreFuncion(string) { var texto = 'seleccionar'; var arr = string.split(' '); - arr.forEach(function(palabra) { + arr.forEach(function (palabra) { palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); texto += palabra; }); @@ -504,7 +546,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ function indicarPassword(vendedor) { - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { focaModalService .prompt({ @@ -515,7 +557,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ if (contraseña != vendedor.ClaVen.trim()) { - focaModalService.alert('Clave incorrecta').then(function() { + focaModalService.alert('Clave incorrecta').then(function () { indicarPassword(vendedor); }); } else { @@ -528,24 +570,24 @@ angular.module('focaCrearFactura').controller('facturaController', [ function validarPlanillaVendedor(vendedor) { - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { crearFacturaService - .validarPlanillaVendedor(vendedor.CodVen.trim()) - .then(function (res) { + .validarPlanillaVendedor(vendedor.CodVen.trim()) + .then(function (res) { - if (!res.data.length) { + if (!res.data.length) { - focaModalService - .alert('No se encontró planilla abierta para el vendedor') - .then(reject); + focaModalService + .alert('No se encontró planilla abierta para el vendedor') + .then(reject); - } else { - resolve(); - } + } else { + resolve(); + } - }) - .catch(reject); + }) + .catch(reject); }); } diff --git a/src/js/controllerEstadoCuenta.js b/src/js/controllerEstadoCuenta.js new file mode 100644 index 0000000..d5afb47 --- /dev/null +++ b/src/js/controllerEstadoCuenta.js @@ -0,0 +1,33 @@ +angular.module('focaCrearFactura') + .controller('focaModalEstadoCuentaController', [ + '$scope', '$uibModalInstance', 'crearFacturaService', 'parametros', + function ($scope, $uibModalInstance, crearFacturaService, parametros) { + + $scope.estadoCuenta = { + autorizado: 0.0, + extracciones: 0.0, + saldo: 0.0, + situacion: false, + facturasVencidas: 0.0 + }; + + init(); + + function init() { + crearFacturaService.getResumenCuenta(parametros.idCliente) + .then(function (res) { + console.log(res); + $scope.estadoCuenta = res.data; + }) + .catch(function (e) { console.error(e); }); + } + + $scope.elegirTipoDePago = function (tipoDePago) { + $uibModalInstance.close(tipoDePago); + }; + + $scope.cancel = function () { + $uibModalInstance.dismiss('cancel'); + }; + } + ]); diff --git a/src/js/service.js b/src/js/service.js index 8ee7f97..3894f20 100644 --- a/src/js/service.js +++ b/src/js/service.js @@ -1,45 +1,49 @@ angular.module('focaCrearFactura') .service('crearFacturaService', ['$http', 'API_ENDPOINT', - function($http, API_ENDPOINT) { - var route = API_ENDPOINT.URL; - return { - guardarFactura: function (factura) { - return $http.post(route + '/factura/guardar', factura) - }, - getParametros: function() { - return $http.get(API_ENDPOINT.URL + '/parametros/factura'); - }, - validarPlanillaVendedor: function(idVendedor) { - return $http.get(route + '/turnos/validar-planilla/' + idVendedor); - }, - getProductosByPlanilla: function (numeroPlanilla) { - return $http.get(route + '/turnos/productos/' + numeroPlanilla); - }, - setearDespachoOcupado: function (parametros) { - return $http.post(route + '/turnos/despacho-en-uso', parametros); - }, - setearDespachoDesocupado: function (parametros) { - return $http.post(route + '/turnos/depacho-sin-uso', parametros); - }, - getBotonera: function() { - return [ - { - label: 'Vendedor', - image: 'vendedor.png' - }, - { - label: 'Cliente', - image: 'cliente.png' - }, - { - label: 'Moneda', - image: 'moneda.png' - }, - { - label: 'Observaciones', - image: 'botonObservaciones.png' - } - ]; - } - }; - }]); + function ($http, API_ENDPOINT) { + var route = API_ENDPOINT.URL; + return { + guardarFactura: function (factura) { + return $http.post(route + '/factura/guardar', factura); + }, + getParametros: function () { + return $http.get(API_ENDPOINT.URL + '/parametros/factura'); + }, + validarPlanillaVendedor: function (idVendedor) { + return $http.get(route + '/turnos/validar-planilla/' + idVendedor); + }, + getProductosByPlanilla: function (numeroPlanilla) { + return $http.get(route + '/turnos/productos/' + numeroPlanilla); + }, + setearDespachoOcupado: function (parametros) { + return $http.post(route + '/turnos/despacho-en-uso', parametros); + }, + setearDespachoDesocupado: function (parametros) { + return $http.post(route + '/turnos/depacho-sin-uso', parametros); + }, + getResumenCuenta: function (idCliente) { + return $http.get('http://10.231.45.194:9900' + '/cliente/resumen-cuenta/' + idCliente); + }, + getBotonera: function () { + return [ + { + label: 'Vendedor', + image: 'vendedor.png' + }, + { + label: 'Cliente', + image: 'cliente.png' + }, + { + label: 'Moneda', + image: 'moneda.png' + }, + { + label: 'Observaciones', + image: 'botonObservaciones.png' + } + ]; + } + }; + } + ]); diff --git a/src/views/modal-estado-cuenta.html b/src/views/modal-estado-cuenta.html new file mode 100644 index 0000000..e728b2c --- /dev/null +++ b/src/views/modal-estado-cuenta.html @@ -0,0 +1,80 @@ + + + \ No newline at end of file diff --git a/src/views/modal-seleccionar-cliente.html b/src/views/modal-seleccionar-cliente.html new file mode 100644 index 0000000..6acc947 --- /dev/null +++ b/src/views/modal-seleccionar-cliente.html @@ -0,0 +1,13 @@ + + + \ No newline at end of file -- 1.9.1