From 8edbf83107d74486cac03eab3212298982d50fe5 Mon Sep 17 00:00:00 2001 From: Mauricio Cattafi Date: Fri, 18 Oct 2019 12:32:54 -0300 Subject: [PATCH] =?UTF-8?q?se=20agrega=20validaci=C3=B3n=20de=20pago=20ele?= =?UTF-8?q?ctronico?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/controller.js | 813 +++++++++++++++++++++++++++------------------------ src/js/service.js | 3 + 2 files changed, 437 insertions(+), 379 deletions(-) diff --git a/src/js/controller.js b/src/js/controller.js index c4adaac..2d78e44 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -3,10 +3,11 @@ angular.module('focaCrearFactura').controller('facturaController', [ 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService', '$localStorage', 'APP', 'focaLoginService', function ( - $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService, - crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP, loginServ) { + $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService, + crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP, loginServ) { config(); + var loopPagoElectronico = false; function config() { $scope.tmpCantidad = '0'; @@ -82,34 +83,34 @@ angular.module('focaCrearFactura').controller('facturaController', [ if (APP === 'facturador') { crearFacturaService - .getVendedorPlayaById(loginServ.getLoginData().vendedorPlaya) - .then(function (res) { - - validarPlanillaVendedor(res.data) - .then(function () { - - $scope.$broadcast('addCabecera', { - label: 'Vendedor:', - valor: $filter('rellenarDigitos')(res.data.CodVen, 3) + - ' - ' + - res.data.NomVen - }); - $scope.$broadcast('addCabecera', { - label: 'Planilla:', - valor: res.data.NplVen - }); - - $scope.factura.vendedor = res.data; - $scope.inicial.vendedor = res.data; + .getVendedorPlayaById(loginServ.getLoginData().vendedorPlaya) + .then(function (res) { - getProductosByPlanilla(res.data.NplVen); - }) - .catch(function (err) { - console.log(err); - focaModalService.alert('Ocurrió un error al intentar recuperar' + - 'el vendedor logeado'); - }); - }); + validarPlanillaVendedor(res.data) + .then(function () { + + $scope.$broadcast('addCabecera', { + label: 'Vendedor:', + valor: $filter('rellenarDigitos')(res.data.CodVen, 3) + + ' - ' + + res.data.NomVen + }); + $scope.$broadcast('addCabecera', { + label: 'Planilla:', + valor: res.data.NplVen + }); + + $scope.factura.vendedor = res.data; + $scope.inicial.vendedor = res.data; + + getProductosByPlanilla(res.data.NplVen); + }) + .catch(function (err) { + console.log(err); + focaModalService.alert('Ocurrió un error al intentar recuperar' + + 'el vendedor logeado'); + }); + }); } } @@ -122,7 +123,8 @@ angular.module('focaCrearFactura').controller('facturaController', [ $scope.seleccionarFormaDePago = function () { - if (!validarGuardar()) return; + if (!validarGuardar()) + return; if ($scope.factura.formaPago === 2) { $scope.crearFactura(); @@ -130,169 +132,222 @@ angular.module('focaCrearFactura').controller('facturaController', [ } var modalInstance = $uibModal.open( - { - templateUrl: 'modal-forma-pago.html', - controller: 'focaModalFormaPagoController', - resolve: { - parametros: function () { - return { - importe: $scope.getTotal() - }; + { + templateUrl: 'modal-forma-pago.html', + controller: 'focaModalFormaPagoController', + resolve: { + parametros: function () { + return { + importe: $scope.getTotal() + }; + }, }, - }, - size: 'lg', - } + size: 'lg', + } ); modalInstance.result - .then(function (data) { + .then(function (data) { - if (data.tipo === 'tarjeta') { - $scope.factura.formaPago = 4; - } else { - $scope.factura.formaPago = 1; - } + if (data.tipo === 'tarjeta') { + $scope.factura.formaPago = 4; + } else { + $scope.factura.formaPago = 1; + } - $scope.crearFactura(data); - }) + $scope.crearFactura(data); + }) .catch(function (e) { console.error(e); }); }; - $scope.crearFactura = function (formaPago) { + $scope.guardarFactura = function (formaPago) { + + if (typeof formaPago.tipo !== 'undefined') { + switch (formaPago.tipo) { + case 'tarjeta': + $scope.factura.formaPago = 4; + break; + case 'electronico': + $scope.factura.formaPago = 5; + break; + } + } - var save = { - factura: { - - BONIF: 0, - CLI: $scope.factura.cliente.COD, - CUI: $scope.factura.cliente.CUIT, - CTA: $scope.factura.cliente.COD, - DC1: '', - DC2: '', - DE1: '', - DOM: $scope.factura.cliente.DOM, - FACAUT: 0, - DTO: 0, - FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'), - FEC_ANT: '19000101', - FPA: $scope.factura.formaPago, - IDEXCEPCION: 0, - IDLP: $scope.factura.cliente.MOD.trim() || 0, - IDPERSONERIA: 0, - IMI: getImporte('IMI'), - IMI2: getImporte('IMI2'), - IMI3: getImporte('IMI3'), - IMP_LEY: 0, - IRI: getImporte('IVA'), - IRS: 0, - LEG: '', - LUG: $scope.factura.vendedor.LugVen, - MK_M: 0, - NEE: getImporte('NEX'), - NET: getImporte('NET'), - NFI: '', - NNP: 0, - NOM: $scope.factura.cliente.NOM, - OPE: $scope.factura.vendedor.CodVen, - PAG: $scope.getTotal(), - PER: 0, - PER_IVA: 0, - PLA: $scope.factura.vendedor.NplVen, - PRO: '', - REC_ANT: 0, - SUC: parseInt($scope.puntoVenta), - TCA: 1, - TCO: 'FT', - TFI: '', - TIP: $scope.factura.cliente.TIP, - TIV: $scope.factura.cliente.IVA, - TOT: $scope.getTotal(), - TUR: $scope.factura.vendedor.TurVen, - VEN: $scope.factura.vendedor.CodVen, - VTO_CLI: '', - ZON: 1, // TODO: ZON DE APAREMP - OBSERVACIONES: $scope.factura.observaciones - }, - cuerpo: $scope.articulosFiltro(), - despachos: $scope.factura.despachos, - formaPago: formaPago - }; + return new Promise(function (resolve, reject) { + var save = { + factura: { + + BONIF: 0, + CLI: $scope.factura.cliente.COD, + CUI: $scope.factura.cliente.CUIT, + CTA: $scope.factura.cliente.COD, + DC1: '', + DC2: '', + DE1: '', + DOM: $scope.factura.cliente.DOM, + FACAUT: 0, + DTO: 0, + FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'), + FEC_ANT: '19000101', + FPA: $scope.factura.formaPago, + IDEXCEPCION: 0, + IDLP: $scope.factura.cliente.MOD.trim() || 0, + IDPERSONERIA: 0, + IMI: getImporte('IMI'), + IMI2: getImporte('IMI2'), + IMI3: getImporte('IMI3'), + IMP_LEY: 0, + IRI: getImporte('IVA'), + IRS: 0, + LEG: '', + LUG: $scope.factura.vendedor.LugVen, + MK_M: 0, + NEE: getImporte('NEX'), + NET: getImporte('NET'), + NFI: '', + NNP: 0, + NOM: $scope.factura.cliente.NOM, + OPE: $scope.factura.vendedor.CodVen, + PAG: $scope.getTotal(), + PER: 0, + PER_IVA: 0, + PLA: $scope.factura.vendedor.NplVen, + PRO: '', + REC_ANT: 0, + SUC: parseInt($scope.puntoVenta), + TCA: 1, + TCO: 'FT', + TFI: '', + TIP: $scope.factura.cliente.TIP, + TIV: $scope.factura.cliente.IVA, + TOT: $scope.getTotal(), + TUR: $scope.factura.vendedor.TurVen, + VEN: $scope.factura.vendedor.CodVen, + VTO_CLI: '', + ZON: 1, // TODO: ZON DE APAREMP + OBSERVACIONES: $scope.factura.observaciones + }, + cuerpo: $scope.articulosFiltro(), + despachos: $scope.factura.despachos, + formaPago: formaPago + }; - crearFacturaService.guardarFactura(save).then(function () { + crearFacturaService.guardarFactura(save).then(function (res) { + console.log(res.data); + $scope.factura.ID_COMPV2 = res.data.ID_COMPV2; + resolve(); + }).catch(function (err) { + console.error(err); + reject(); + }); + }); + }; - focaBotoneraLateralService.endGuardar(true); + $scope.crearFactura = function (formaPago) { + $scope.guardarFactura(formaPago).then(function () { + focaBotoneraLateralService.endGuardar(true); focaModalService.alert('Comprobante guardado con éxito'); - config(); - - }).catch(function (err) { + }, function () { focaModalService.alert('Hubo un error al guardar la factura'); - console.error(err); }); + }; + $scope.$on('guardarFactura', function (events, args) { + console.log('recibe guardarFactura'); + $scope.guardarFactura(args).then(function() { + $rootScope.$broadcast('callbackGuardarFactura', true); + loopPagoElectronico = true; + $scope.consultarPagoElectronico(); + }, function() { + $rootScope.$broadcast('callbackGuardarFactura', false); + }); + }); + + $scope.$on('cancelarPagoElectronico', function (events, args) { + loopPagoElectronico = false; + }); + + $scope.consultarPagoElectronico = function () { + if (!loopPagoElectronico) { + return; + } + + crearFacturaService.consultarPagoElectronico({ ID_COMPV2: $scope.factura.ID_COMPV2 }).then(function(resp) { + console.log(resp.data); + if (resp.data.EST > 0) { + $rootScope.$broadcast('callbackGuardarFactura', resp.data); + } else { + setTimeout(function() { + $scope.consultarPagoElectronico(); + }, 2000); + } + }).catch(function() { + $rootScope.$broadcast('callbackGuardarFactura', false); + }) }; $scope.seleccionarCliente = function () { var modalInstance = $uibModal.open( - { - ariaLabelledBy: 'Busqueda de Cliente', - templateUrl: 'foca-busqueda-cliente-modal.html', - controller: 'focaBusquedaClienteModalController', - resolve: { - parametros: function () { - return { + { + ariaLabelledBy: 'Busqueda de Cliente', + templateUrl: 'foca-busqueda-cliente-modal.html', + controller: 'focaBusquedaClienteModalController', + resolve: { + parametros: function () { + return { vendedor: function () { return null; }, cobrador: function () { return null; } - }; - } - }, - size: 'lg' - } + }; + } + }, + size: 'lg' + } ); modalInstance.result.then( - function (cliente) { - var modalInstance = $uibModal.open( - { - templateUrl: 'modal-estado-cuenta.html', - controller: 'focaModalEstadoCuentaController', - size: 'lg', - resolve: { - parametros: function () { - return { - idCliente: cliente.COD, - nombreCliente: cliente.NOM - }; - }, - } - } - ); - modalInstance.result - .then(function (data) { + function (cliente) { + var modalInstance = $uibModal.open( + { + templateUrl: 'modal-estado-cuenta.html', + controller: 'focaModalEstadoCuentaController', + size: 'lg', + resolve: { + parametros: function () { + return { + idCliente: cliente.COD, + nombreCliente: cliente.NOM + }; + }, + } + } + ); + modalInstance.result + .then(function (data) { + + $scope.factura.formaPago = data.formaDePago; + $scope.factura.cliente = cliente; + + getNumeroFactura(cliente.TIP); - $scope.factura.formaPago = data.formaDePago; - $scope.factura.cliente = cliente; - - getNumeroFactura(cliente.TIP); - - $scope.$broadcast('addCabecera', { - label: 'Cliente:', - valor: $filter('rellenarDigitos')(cliente.COD, 3) + - ' - ' + cliente.NOM - }); + $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: 'Forma de pago: ', - valor: data.tipo - }); - }) - .catch($scope.seleccionarCliente); + $scope.$broadcast('addCabecera', { + label: 'Forma de pago: ', + valor: data.tipo + }); + }) + .catch($scope.seleccionarCliente); - }, function () { - } + }, function () { + } ); }; @@ -318,39 +373,39 @@ angular.module('focaCrearFactura').controller('facturaController', [ size: 'md' }; focaModalService.modal(parametrosModal).then( - function (vendedor) { + function (vendedor) { - indicarPassword(vendedor) - .then(function () { - validarPlanillaVendedor(vendedor) + indicarPassword(vendedor) .then(function () { - - $filter('filter')($scope.botonera, { - label: 'Vendedor' - })[0].checked = true; - - $scope.$broadcast('addCabecera', { - label: 'Vendedor:', - valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + - ' - ' + - vendedor.NomVen - }); - $scope.$broadcast('addCabecera', { - label: 'Planilla:', - valor: vendedor.NplVen - }); - - $scope.factura.vendedor = vendedor; - - getProductosByPlanilla(vendedor.NplVen); + validarPlanillaVendedor(vendedor) + .then(function () { + + $filter('filter')($scope.botonera, { + label: 'Vendedor' + })[0].checked = true; + + $scope.$broadcast('addCabecera', { + label: 'Vendedor:', + valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + + ' - ' + + vendedor.NomVen + }); + $scope.$broadcast('addCabecera', { + label: 'Planilla:', + valor: vendedor.NplVen + }); + + $scope.factura.vendedor = vendedor; + + getProductosByPlanilla(vendedor.NplVen); + }) + .catch($scope.seleccionarVendedor); }) - .catch($scope.seleccionarVendedor); - }) - .catch(function (err) { - console.error(err); - }); + .catch(function (err) { + console.error(err); + }); - }, function () { } + }, function () { } ); }; @@ -372,49 +427,49 @@ angular.module('focaCrearFactura').controller('facturaController', [ size: 'md' }; focaModalService.modal(parametrosModal).then( - function (moneda) { + function (moneda) { - if (moneda.ID !== 1) { - $scope.abrirModalCotizacion(moneda); - return; - } + if (moneda.ID !== 1) { + $scope.abrirModalCotizacion(moneda); + return; + } - crearRemitoService.getCotizacionByIdMoneda(1) - .then(function (res) { + crearRemitoService.getCotizacionByIdMoneda(1) + .then(function (res) { - var cotizacionPArgentino = res.data[0].cotizaciones[0]; - cotizacionPArgentino.moneda = moneda; + var cotizacionPArgentino = res.data[0].cotizaciones[0]; + cotizacionPArgentino.moneda = moneda; - actualizarCabeceraMoneda(cotizacionPArgentino); + actualizarCabeceraMoneda(cotizacionPArgentino); - $scope.remito.cotizacion = cotizacionPArgentino; - }); - }, function () { + $scope.remito.cotizacion = cotizacionPArgentino; + }); + }, function () { - } + } ); }; $scope.abrirModalCotizacion = function (moneda) { var modalInstance = $uibModal.open( - { - ariaLabelledBy: 'Busqueda de Cotización', - templateUrl: 'modal-cotizacion.html', - controller: 'focaModalCotizacionController', - size: 'lg', - resolve: { idMoneda: function () { return moneda.ID; } } - } + { + ariaLabelledBy: 'Busqueda de Cotización', + templateUrl: 'modal-cotizacion.html', + controller: 'focaModalCotizacionController', + size: 'lg', + resolve: { idMoneda: function () { return moneda.ID; } } + } ); modalInstance.result.then( - function (cotizacion) { + function (cotizacion) { - cotizacion.moneda = moneda; - actualizarCabeceraMoneda(cotizacion); - $scope.factura.cotizacion = cotizacion; + cotizacion.moneda = moneda; + actualizarCabeceraMoneda(cotizacion); + $scope.factura.cotizacion = cotizacion; - }, function () { + }, function () { - } + } ); }; @@ -427,10 +482,10 @@ angular.module('focaCrearFactura').controller('facturaController', [ }; focaModalService - .prompt(observacion) - .then(function (observaciones) { - $scope.factura.observaciones = observaciones; - }); + .prompt(observacion) + .then(function (observaciones) { + $scope.factura.observaciones = observaciones; + }); }; $scope.articulosFiltro = function () { @@ -458,19 +513,19 @@ angular.module('focaCrearFactura').controller('facturaController', [ } crearFacturaService - .setearDespachoDesocupado({ - surtidor: $scope.factura.despachos[index].SUR, - producto: $scope.factura.despachos[index].PRO, - carga: $scope.factura.despachos[index].CAR, - planilla: $scope.factura.despachos[index].PLA - }) - .then(function () { - articulo.desactivado = true; - $scope.factura.despachos.splice(index, 1); - }) - .catch(function () { - focaModalService.alert('Hubo un error al desasociar este despacho'); - }); + .setearDespachoDesocupado({ + surtidor: $scope.factura.despachos[index].SUR, + producto: $scope.factura.despachos[index].PRO, + carga: $scope.factura.despachos[index].CAR, + planilla: $scope.factura.despachos[index].PLA + }) + .then(function () { + articulo.desactivado = true; + $scope.factura.despachos.splice(index, 1); + }) + .catch(function () { + focaModalService.alert('Hubo un error al desasociar este despacho'); + }); }; //Recibe aviso si el teclado está en uso @@ -532,65 +587,65 @@ angular.module('focaCrearFactura').controller('facturaController', [ } var modalInstance = $uibModal.open( - { - ariaLabelledBy: 'Busqueda de Productos', - templateUrl: 'modal-busqueda-productos.html', - controller: 'modalBusquedaProductosCtrl', - resolve: { - parametroProducto: { - idLista: null, - cotizacion: $scope.factura.cotizacion.VENDEDOR, - simbolo: $scope.factura.cotizacion.moneda.SIMBOLO, - buscarTodos: true - } - }, - size: 'lg' - } + { + ariaLabelledBy: 'Busqueda de Productos', + templateUrl: 'modal-busqueda-productos.html', + controller: 'modalBusquedaProductosCtrl', + resolve: { + parametroProducto: { + idLista: null, + cotizacion: $scope.factura.cotizacion.VENDEDOR, + simbolo: $scope.factura.cotizacion.moneda.SIMBOLO, + buscarTodos: true + } + }, + size: 'lg' + } ); modalInstance.result - .then(function (producto) { - - var articulo = { - TIP: $scope.factura.cliente.TIP, - TCO: 'FT', - SUC: parseInt($scope.puntoVenta), - ORD: $scope.articulosFiltro().length + 1, - SEC: producto.sector, - ART: producto.codigo, - RUB: producto.CodRub, - DES: producto.descripcionLarga, - PUN: producto.precio, - IVA: producto.IMPIVA, - NET: producto.IvaCO !== 0 ? parseFloat(producto.neto) : 0, - NEX: producto.IvaCO === 0 ? parseFloat(producto.neto) : 0, - IMI: producto.ImpInt, - IMI2: producto.ImpInt2, - IMI3: producto.ImpInt3, - PUT: producto.precio, - SUR: 0, - PLA: $scope.factura.vendedor.NplVen, - LUG: $scope.factura.vendedor.LugVen, - LEG: $scope.factura.vendedor.CodVen, - TUR: $scope.factura.vendedor.TurVen, - ORDEN_PRECOMPRA: '', - ESC: producto.tipoFactura === 'L' ? 1 : 0, - CMF: 0, - PTA: 0, - IVS: 0, - TIVA: 0, - CON: 0, - SINO: '', - ORD_TRA: 0, - IMP_DESP: 0, - PCD: 0, - RTO: '', - }; + .then(function (producto) { + + var articulo = { + TIP: $scope.factura.cliente.TIP, + TCO: 'FT', + SUC: parseInt($scope.puntoVenta), + ORD: $scope.articulosFiltro().length + 1, + SEC: producto.sector, + ART: producto.codigo, + RUB: producto.CodRub, + DES: producto.descripcionLarga, + PUN: producto.precio, + IVA: producto.IMPIVA, + NET: producto.IvaCO !== 0 ? parseFloat(producto.neto) : 0, + NEX: producto.IvaCO === 0 ? parseFloat(producto.neto) : 0, + IMI: producto.ImpInt, + IMI2: producto.ImpInt2, + IMI3: producto.ImpInt3, + PUT: producto.precio, + SUR: 0, + PLA: $scope.factura.vendedor.NplVen, + LUG: $scope.factura.vendedor.LugVen, + LEG: $scope.factura.vendedor.CodVen, + TUR: $scope.factura.vendedor.TurVen, + ORDEN_PRECOMPRA: '', + ESC: producto.tipoFactura === 'L' ? 1 : 0, + CMF: 0, + PTA: 0, + IVS: 0, + TIVA: 0, + CON: 0, + SINO: '', + ORD_TRA: 0, + IMP_DESP: 0, + PCD: 0, + RTO: '', + }; + + $scope.factura.articulosFactura.push(articulo); + $scope.cambioEdit(articulo, 'cantidad'); - $scope.factura.articulosFactura.push(articulo); - $scope.cambioEdit(articulo, 'cantidad'); - - }) + }) .catch(function (e) { console.error(e); }); }; @@ -602,18 +657,18 @@ angular.module('focaCrearFactura').controller('facturaController', [ } var modalInstance = $uibModal.open( - { - templateUrl: 'modal-ultimos-despachos.html', - controller: 'ultimosDespachosController', - resolve: { - parametros: function () { - return { - planilla: $scope.factura.vendedor.NplVen, - }; - } - }, - size: 'md' - } + { + templateUrl: 'modal-ultimos-despachos.html', + controller: 'ultimosDespachosController', + resolve: { + parametros: function () { + return { + planilla: $scope.factura.vendedor.NplVen, + }; + } + }, + size: 'md' + } ); modalInstance.result.then(function (producto) { @@ -660,20 +715,20 @@ angular.module('focaCrearFactura').controller('facturaController', [ producto: producto.despachos[0].PRO, carga: producto.despachos[0].CAR }) - .then(function () { - $scope.factura.articulosFactura.push(articulo); - $scope.factura.despachos.push(producto.despachos[0]); - }) - .catch(function (err) { + .then(function () { + $scope.factura.articulosFactura.push(articulo); + $scope.factura.despachos.push(producto.despachos[0]); + }) + .catch(function (err) { - console.error(err); - focaModalService.alert('El despacho está en uso'); - }); + console.error(err); + focaModalService.alert('El despacho está en uso'); + }); }) - .catch(function (err) { - console.error(err); - }); + .catch(function (err) { + console.error(err); + }); }; @@ -687,20 +742,20 @@ angular.module('focaCrearFactura').controller('facturaController', [ } var modalInstance = $uibModal.open( - { - templateUrl: 'modal-combustibles.html', - controller: 'focaModalCombustiblesController', - resolve: { - parametros: function () { - return { - despachos: producto.despachos, - nombreProducto: producto.DetArt, - topDespachos: $scope.topDespachos - }; - } - }, - size: 'md' - } + { + templateUrl: 'modal-combustibles.html', + controller: 'focaModalCombustiblesController', + resolve: { + parametros: function () { + return { + despachos: producto.despachos, + nombreProducto: producto.DetArt, + topDespachos: $scope.topDespachos + }; + } + }, + size: 'md' + } ); modalInstance.result.then(function (despacho) { @@ -747,20 +802,20 @@ 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) { - console.error(err); - focaModalService.alert('El despacho está en uso'); - }); + console.error(err); + focaModalService.alert('El despacho está en uso'); + }); }) - .catch(function (err) { - console.error(err); - }); + .catch(function (err) { + console.error(err); + }); }; } @@ -781,23 +836,23 @@ angular.module('focaCrearFactura').controller('facturaController', [ function openPrompt() { return focaModalService - .prompt({ - titulo: 'Indique Contraseña', - value: '', - tipo: 'password' - }) - .then(function (contraseña) { + .prompt({ + titulo: 'Indique Contraseña', + value: '', + tipo: 'password' + }) + .then(function (contraseña) { - if (contraseña !== vendedor.ClaVen.trim()) { + if (contraseña !== vendedor.ClaVen.trim()) { - focaModalService.alert('Clave incorrecta').then(function () { - openPrompt(vendedor); - }); - } else { - resolve(); - } - }) - .catch(reject); + focaModalService.alert('Clave incorrecta').then(function () { + openPrompt(vendedor); + }); + } else { + resolve(); + } + }) + .catch(reject); } openPrompt(); @@ -809,24 +864,24 @@ angular.module('focaCrearFactura').controller('facturaController', [ return new Promise(function (resolve, reject) { crearFacturaService - .validarPlanillaVendedor(vendedor.CodVen.toString().trim()) - .then(function (res) { + .validarPlanillaVendedor(vendedor.CodVen.toString().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(function (err) { - console.log(err); - reject(); - }); + }) + .catch(function (err) { + console.log(err); + reject(); + }); }); } @@ -847,8 +902,8 @@ angular.module('focaCrearFactura').controller('facturaController', [ if (confirmacion) { focaModalService.confirm( - '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' - ).then(function (data) { + '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' + ).then(function (data) { if (data) { $location.path('/'); } @@ -872,12 +927,12 @@ angular.module('focaCrearFactura').controller('facturaController', [ $scope.cabeceras.push({ label: 'Fecha cotizacion:', valor: $filter('date')(factura.cotizacion.FECHA, - 'dd/MM/yyyy') + 'dd/MM/yyyy') }); $scope.cabeceras.push({ label: 'Cotizacion:', valor: $filter('number')(factura.cotizacion.VENDEDOR, - '2') + '2') }); } @@ -889,7 +944,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ $scope.cabeceras.push({ label: 'Cliente:', valor: $filter('rellenarDigitos')(factura.cliente.COD, 3) + ' - ' + - factura.cliente.NOM + factura.cliente.NOM }); $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; @@ -1013,14 +1068,14 @@ angular.module('focaCrearFactura').controller('facturaController', [ function getNumeroFactura(tipoFactura) { crearRemitoService.getNumeroRemito(tipoFactura).then( - function (res) { - $scope.puntoVenta = rellenar(res.data.sucursal, 4); - $scope.comprobante = rellenar(res.data.numeroRemito, 8); - }, - function (err) { - focaModalService.alert('La terminal no está configurada correctamente'); - console.info(err); - } + function (res) { + $scope.puntoVenta = rellenar(res.data.sucursal, 4); + $scope.comprobante = rellenar(res.data.numeroRemito, 8); + }, + function (err) { + focaModalService.alert('La terminal no está configurada correctamente'); + console.info(err); + } ); } } diff --git a/src/js/service.js b/src/js/service.js index f94198c..6dcb742 100644 --- a/src/js/service.js +++ b/src/js/service.js @@ -6,6 +6,9 @@ angular.module('focaCrearFactura') guardarFactura: function (factura) { return $http.post(route + '/factura/guardar', factura); }, + consultarPagoElectronico: function (datos) { + return $http.post(route + '/factura/consultar-pago-electronico', datos); + }, getParametros: function () { return $http.get(API_ENDPOINT.URL + '/parametros/factura'); }, -- 1.9.1