From 9ed9207ba4e1bdc5050d16fd4b426a44011c9ffe Mon Sep 17 00:00:00 2001 From: Luigi Date: Fri, 31 May 2019 17:46:20 -0300 Subject: [PATCH] espacio 2 --- src/js/controllerCliente.js | 982 ++++++++++++++++++++++---------------------- 1 file changed, 491 insertions(+), 491 deletions(-) diff --git a/src/js/controllerCliente.js b/src/js/controllerCliente.js index 2dd3d61..f0b8ccd 100644 --- a/src/js/controllerCliente.js +++ b/src/js/controllerCliente.js @@ -4,519 +4,519 @@ angular.module('focaAbmCliente') 'focaAbmClienteService', 'idCliente', function ($scope, $timeout, $uibModalInstance, focaModalService, focaAbmClienteService, idCliente) { - $scope.cliente = { - provincia: {}, - localidad: {}, - zona: {}, - actividad: {}, - cobrador: {}, - vendedor: {}, - iva: {}, - tipoFactura: {}, - tipoComprobante: {}, - formaPago: {} - }; - $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/); - $scope.vendedor = {}; + $scope.cliente = { + provincia: {}, + localidad: {}, + zona: {}, + actividad: {}, + cobrador: {}, + vendedor: {}, + iva: {}, + tipoFactura: {}, + tipoComprobante: {}, + formaPago: {} + }; + $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/); + $scope.vendedor = {}; - focaAbmClienteService.obtenerClientePorCodigo(idCliente) - .then(function (res) { - var data = res.data[0]; - $scope.cliente.codigo = data.COD; - $scope.cliente.DOM = data.DOM; - $scope.cliente.NOM = data.NOM; - $scope.cliente.CPO = data.CPO; - $scope.cliente.provincia.ID = data.PCX; - $scope.cliente.provincia.NOMBRE = data.PCI; - $scope.cliente.localidad.ID = data.LOX; - $scope.cliente.localidad.NOMBRE = data.LOC; - $scope.cliente.zona.ID = data.zona.ID; - $scope.cliente.zona.NOM = data.zona.NOM; - $scope.cliente.actividad.NOM = data.actividad.NOM; - $scope.cliente.actividad.ID = data.actividad.ID; - $scope.cliente.cobrador.NOM = data.cobrador ? data.cobrador.NOM : ''; - $scope.cliente.cobrador.NUM = data.cobrador ? data.cobrador.NUM : undefined; - $scope.cliente.cobrador.ID = data.cobrador ? data.cobrador.id : undefined; - $scope.vendedor.NOM = data.vendedor.NOM; - $scope.vendedor.id = data.vendedor.id; - $scope.cliente.MAIL = data.MAIL; - $scope.cliente.TEL = data.TEL; - $scope.cliente.iva.NOMBRE = data.iva.NOMBRE; - $scope.cliente.tipoFactura.NOMBRE = data.tipoFactura.NOMBRE; - $scope.cliente.tipoFactura.ID = data.tipoFactura.ID; - var cuit = data.CUIT.split('-'); - $scope.cliente.cuit1 = cuit[0]; - $scope.cliente.cuit2 = cuit[1]; - $scope.cliente.cuit3 = cuit[2]; - $scope.cliente.tipoComprobante.NOMBRE = data.tipoComprobante.NOMBRE; - $scope.cliente.tipoComprobante.ID = data.tipoComprobante.ID; - $scope.cliente.formaPago.NOMBRE = data.formaPago.NOMBRE; - $scope.cliente.formaPago.ID = data.formaPago.ID; - $scope.cliente.ES_PROS = data.ES_PROS; - $scope.cliente.ES_MAY = data.ES_MAY; - $scope.editando = true; - }) - .catch(function (e) { console.log(e); }); - - $scope.cancel = function () { - $uibModalInstance.dismiss('cancel'); - }; + focaAbmClienteService.obtenerClientePorCodigo(idCliente) + .then(function (res) { + var data = res.data[0]; + $scope.cliente.codigo = data.COD; + $scope.cliente.DOM = data.DOM; + $scope.cliente.NOM = data.NOM; + $scope.cliente.CPO = data.CPO; + $scope.cliente.provincia.ID = data.PCX; + $scope.cliente.provincia.NOMBRE = data.PCI; + $scope.cliente.localidad.ID = data.LOX; + $scope.cliente.localidad.NOMBRE = data.LOC; + $scope.cliente.zona.ID = data.zona.ID; + $scope.cliente.zona.NOM = data.zona.NOM; + $scope.cliente.actividad.NOM = data.actividad.NOM; + $scope.cliente.actividad.ID = data.actividad.ID; + $scope.cliente.cobrador.NOM = data.cobrador ? data.cobrador.NOM : ''; + $scope.cliente.cobrador.NUM = data.cobrador ? data.cobrador.NUM : undefined; + $scope.cliente.cobrador.ID = data.cobrador ? data.cobrador.id : undefined; + $scope.vendedor.NOM = data.vendedor.NOM; + $scope.vendedor.id = data.vendedor.id; + $scope.cliente.MAIL = data.MAIL; + $scope.cliente.TEL = data.TEL; + $scope.cliente.iva.NOMBRE = data.iva.NOMBRE; + $scope.cliente.tipoFactura.NOMBRE = data.tipoFactura.NOMBRE; + $scope.cliente.tipoFactura.ID = data.tipoFactura.ID; + var cuit = data.CUIT.split('-'); + $scope.cliente.cuit1 = cuit[0]; + $scope.cliente.cuit2 = cuit[1]; + $scope.cliente.cuit3 = cuit[2]; + $scope.cliente.tipoComprobante.NOMBRE = data.tipoComprobante.NOMBRE; + $scope.cliente.tipoComprobante.ID = data.tipoComprobante.ID; + $scope.cliente.formaPago.NOMBRE = data.formaPago.NOMBRE; + $scope.cliente.formaPago.ID = data.formaPago.ID; + $scope.cliente.ES_PROS = data.ES_PROS; + $scope.cliente.ES_MAY = data.ES_MAY; + $scope.editando = true; + }) + .catch(function (e) { console.log(e); }); + + $scope.cancel = function () { + $uibModalInstance.dismiss('cancel'); + }; - $scope.guardar = function () { - if (!$scope.cliente.NOM) { - focaModalService.alert('Ingrese Nombre'); - return; - } else if (!$scope.cliente.CPO) { - focaModalService.alert('Ingrese Codigo Postal'); - return; - } else if (!$scope.cliente.provincia.NOMBRE) { - focaModalService.alert('Seleccione una provincia'); - return; - } else if (!$scope.cliente.DOM) { - focaModalService.alert('Ingrese Domicilio'); - return; - } else if (!$scope.cliente.localidad.NOMBRE) { - focaModalService.alert('Seleccione una localidad'); - return; - } else if (!$scope.cliente.zona.NOM) { - focaModalService.alert('Seleccione una zona'); - return; - } else if (!$scope.cliente.actividad.NOM) { - focaModalService.alert('Seleccione actividad'); - return; - } else if (!$scope.cliente.cobrador.NUM) { - focaModalService.alert('Seleccione un cobrador'); - return; - } else if (!$scope.vendedor.NOM) { - focaModalService.alert('Seleccione un vendedor'); - return; - } else if ($scope.cliente.MAIL && !validateEmails($scope.cliente.MAIL)) { - focaModalService.alert('Ingrese un formato de email válido'); - return; - } else if (!$scope.cliente.TEL) { - focaModalService.alert('Ingrese un numero de telefono'); - return; - } else if (!$scope.cliente.iva.NOMBRE) { - focaModalService.alert('Seleccione responsabilidad ante el IVA'); - return; - } else if (!$scope.cliente.tipoFactura.NOMBRE) { - focaModalService.alert('Seleccione tipo de Factura'); - return; - } else if (!$scope.cliente.cuit1 && !$scope.cliente.cuit2 && !$scope.cliente.cuit3) { - focaModalService.alert('Ingrese CUIT'); - return; - } else if (!$scope.cliente.cuit1 || !$scope.cliente.cuit2 || !$scope.cliente.cuit3) { - focaModalService.alert('Ingrese CUIT válido'); - return; - } else if (!$scope.regexCuit.test($scope.cliente.cuit1 + $scope.cliente.cuit2 + $scope.cliente.cuit3)) { - focaModalService.alert('Ingrese CUIT con formato: XX-XXXXXXXX-X'); - return; - } else if (!$scope.cliente.tipoComprobante.NOMBRE) { - focaModalService.alert('Seleccione un Comprobante'); - return; - } else if (!$scope.cliente.formaPago.NOMBRE) { - focaModalService.alert('Seleccione una forma de pago'); - return; - } - $scope.cliente.actividad.ID = parseInt($scope.cliente.actividad.ID); - var cliente = crearCopia(); - focaAbmClienteService - .guardarCliente(cliente) - .then(function () { - $uibModalInstance.close(cliente); - }) - .catch(function (e) { - console.log(e); + $scope.guardar = function () { + if (!$scope.cliente.NOM) { + focaModalService.alert('Ingrese Nombre'); + return; + } else if (!$scope.cliente.CPO) { + focaModalService.alert('Ingrese Codigo Postal'); + return; + } else if (!$scope.cliente.provincia.NOMBRE) { + focaModalService.alert('Seleccione una provincia'); + return; + } else if (!$scope.cliente.DOM) { + focaModalService.alert('Ingrese Domicilio'); + return; + } else if (!$scope.cliente.localidad.NOMBRE) { + focaModalService.alert('Seleccione una localidad'); + return; + } else if (!$scope.cliente.zona.NOM) { + focaModalService.alert('Seleccione una zona'); + return; + } else if (!$scope.cliente.actividad.NOM) { + focaModalService.alert('Seleccione actividad'); + return; + } else if (!$scope.cliente.cobrador.NUM) { + focaModalService.alert('Seleccione un cobrador'); + return; + } else if (!$scope.vendedor.NOM) { + focaModalService.alert('Seleccione un vendedor'); + return; + } else if ($scope.cliente.MAIL && !validateEmails($scope.cliente.MAIL)) { + focaModalService.alert('Ingrese un formato de email válido'); + return; + } else if (!$scope.cliente.TEL) { + focaModalService.alert('Ingrese un numero de telefono'); + return; + } else if (!$scope.cliente.iva.NOMBRE) { + focaModalService.alert('Seleccione responsabilidad ante el IVA'); + return; + } else if (!$scope.cliente.tipoFactura.NOMBRE) { + focaModalService.alert('Seleccione tipo de Factura'); + return; + } else if (!$scope.cliente.cuit1 && !$scope.cliente.cuit2 && !$scope.cliente.cuit3) { + focaModalService.alert('Ingrese CUIT'); + return; + } else if (!$scope.cliente.cuit1 || !$scope.cliente.cuit2 || !$scope.cliente.cuit3) { + focaModalService.alert('Ingrese CUIT válido'); + return; + } else if (!$scope.regexCuit.test($scope.cliente.cuit1 + $scope.cliente.cuit2 + $scope.cliente.cuit3)) { + focaModalService.alert('Ingrese CUIT con formato: XX-XXXXXXXX-X'); + return; + } else if (!$scope.cliente.tipoComprobante.NOMBRE) { + focaModalService.alert('Seleccione un Comprobante'); + return; + } else if (!$scope.cliente.formaPago.NOMBRE) { + focaModalService.alert('Seleccione una forma de pago'); + return; + } + $scope.cliente.actividad.ID = parseInt($scope.cliente.actividad.ID); + var cliente = crearCopia(); + focaAbmClienteService + .guardarCliente(cliente) + .then(function () { + $uibModalInstance.close(cliente); + }) + .catch(function (e) { + console.log(e); + }); + }; + $scope.seleccionarProvincia = function (key) { + if (key === 13) { + var parametrosModal = { + searchText: $scope.cliente.provincia.NOMBRE, + query: '/provincia', + columnas: [ + { + propiedad: 'ID', + nombre: 'Codigo', + filtro: { + nombre: 'rellenarDigitos', + parametro: 3 + } + }, + { + propiedad: 'NOMBRE', + nombre: 'Nombre' + } + ], + titulo: 'Búsqueda de provincias', + size: 'md' + }; + focaModalService.modal(parametrosModal).then(function (provincia) { + $scope.cliente.provincia = provincia; + $timeout(function () { + $scope.focused = 4; + }); + }, function () { + //TODO: función llamada cuando cancela el modal + }); + } + }; + $scope.seleccionarLocalidad = function (key) { + if ($scope.cliente.provincia.ID === undefined) { + focaModalService.alert('Seleccione una provincia'); + return; + } + if (key === 13) { + var parametrosModal = { + searchText: $scope.cliente.localidad.NOMBRE, + query: '/localidad/' + parseInt($scope.cliente.provincia.ID), + columnas: [ + { + propiedad: 'ID', + nombre: 'Código', + }, + { + propiedad: 'NOMBRE', + nombre: 'Nombre' + } + ], + titulo: 'Búsqueda de localidades', + size: 'md' + }; + focaModalService.modal(parametrosModal).then(function (localidad) { + $scope.cliente.localidad = localidad; + $timeout(function () { + $scope.focused = 5; }); - }; - $scope.seleccionarProvincia = function (key) { - if (key === 13) { - var parametrosModal = { - searchText: $scope.cliente.provincia.NOMBRE, - query: '/provincia', - columnas: [ - { - propiedad: 'ID', - nombre: 'Codigo', - filtro: { - nombre: 'rellenarDigitos', - parametro: 3 - } - }, - { - propiedad: 'NOMBRE', - nombre: 'Nombre' + }, function () { + //TODO: función llamada cuando cancela el modal + }); + } + }; + $scope.seleccionarZona = function (key) { + if (key === 13) { + var parametrosModal = { + searchText: $scope.cliente.zona.NOM, + query: '/zona', + columnas: [ + { + propiedad: 'ID', + nombre: 'Código', + filtro: { + nombre: 'rellenarDigitos', + parametro: 3 } - ], - titulo: 'Búsqueda de provincias', - size: 'md' - }; - focaModalService.modal(parametrosModal).then(function (provincia) { - $scope.cliente.provincia = provincia; + }, + { + propiedad: 'NOM', + nombre: 'Nombre' + } + ], + titulo: 'Búsqueda de zonas', + size: 'md' + }; + focaModalService.modal(parametrosModal).then( + function (zona) { + $scope.cliente.zona = zona; $timeout(function () { - $scope.focused = 4; + $scope.focused = 6; }); }, function () { - //TODO: función llamada cuando cancela el modal + // funcion ejecutada cuando se cancela el modal }); - } - }; - $scope.seleccionarLocalidad = function (key) { - if ($scope.cliente.provincia.ID === undefined) { - focaModalService.alert('Seleccione una provincia'); - return; - } - if (key === 13) { - var parametrosModal = { - searchText: $scope.cliente.localidad.NOMBRE, - query: '/localidad/' + parseInt($scope.cliente.provincia.ID), - columnas: [ - { - propiedad: 'ID', - nombre: 'Código', - }, - { - propiedad: 'NOMBRE', - nombre: 'Nombre' + } + }; + $scope.seleccionarActividad = function (key) { + if (key === 13) { + var parametrosModal = { + searchText: $scope.cliente.actividad.NOM, + query: '/actividad', + columnas: [ + { + propiedad: 'ID', + nombre: 'Código', + filtro: { + nombre: 'rellenarDigitos', + parametro: 3 } - ], - titulo: 'Búsqueda de localidades', - size: 'md' - }; - focaModalService.modal(parametrosModal).then(function (localidad) { - $scope.cliente.localidad = localidad; + }, + { + propiedad: 'NOM', + nombre: 'Nombre' + } + ], + titulo: 'Búsqueda de actividades', + size: 'md' + }; + focaModalService.modal(parametrosModal).then( + function (actividad) { + $scope.cliente.actividad = actividad; $timeout(function () { - $scope.focused = 5; + $scope.focused = 7; }); }, function () { - //TODO: función llamada cuando cancela el modal + // funcion ejecutada cuando se cancela el modal }); - } - }; - $scope.seleccionarZona = function (key) { - if (key === 13) { - var parametrosModal = { - searchText: $scope.cliente.zona.NOM, - query: '/zona', - columnas: [ - { - propiedad: 'ID', - nombre: 'Código', - filtro: { - nombre: 'rellenarDigitos', - parametro: 3 - } - }, - { - propiedad: 'NOM', - nombre: 'Nombre' - } - ], - titulo: 'Búsqueda de zonas', - size: 'md' - }; - focaModalService.modal(parametrosModal).then( - function (zona) { - $scope.cliente.zona = zona; - $timeout(function () { - $scope.focused = 6; - }); - }, function () { - // funcion ejecutada cuando se cancela el modal - }); - } - }; - $scope.seleccionarActividad = function (key) { - if (key === 13) { - var parametrosModal = { - searchText: $scope.cliente.actividad.NOM, - query: '/actividad', - columnas: [ - { - propiedad: 'ID', - nombre: 'Código', - filtro: { - nombre: 'rellenarDigitos', - parametro: 3 - } - }, - { - propiedad: 'NOM', - nombre: 'Nombre' - } - ], - titulo: 'Búsqueda de actividades', - size: 'md' - }; - focaModalService.modal(parametrosModal).then( - function (actividad) { - $scope.cliente.actividad = actividad; - $timeout(function () { - $scope.focused = 7; - }); - }, function () { - // funcion ejecutada cuando se cancela el modal - }); - } - }; - $scope.seleccionarCobrador = function (key) { - if (key === 13) { - var parametrosModal = { - searchText: $scope.cliente.cobrador.NOM, - query: '/cobrador', - columnas: [ - { - propiedad: 'NUM', - nombre: 'Código' - }, - { - propiedad: 'NOM', - nombre: 'Nombre' - } - ], - titulo: 'Búsqueda de cobradores', - size: 'md' - }; - focaModalService.modal(parametrosModal).then( - function (cobrador) { - $scope.cliente.cobrador = cobrador; - }, function () { - // funcion ejecutada cuando se cancela el modal - }); - } - }; - $scope.seleccionarVendedor = function (key) { - if (key === 13) { - var parametrosModal = { - titulo: 'Búsqueda vendedores', - query: '/vendedor', - columnas: [ - { - propiedad: 'NUM', - nombre: 'Código', - filtro: { - nombre: 'rellenarDigitos', - parametro: 3 - } - }, - { - propiedad: 'NOM', - nombre: 'Nombre' - } - ], - size: 'md' - }; - focaModalService.modal(parametrosModal).then( - function (vendedor) { - $scope.vendedor = vendedor; - }, function () { - // funcion ejecutada cuando se cancela el modal - }); - } - }; - $scope.seleccionarIva = function (key) { - if (key === 13) { - var parametrosModal = { - query: '/iva', - searchText: $scope.cliente.iva.NOMBRE, - columnas: [ - { - propiedad: 'ID', - nombre: 'Código', - filtro: { - nombre: 'rellenarDigitos', - parametro: 3 - } - }, - { - propiedad: 'NOMBRE', - nombre: 'Nombre' + } + }; + $scope.seleccionarCobrador = function (key) { + if (key === 13) { + var parametrosModal = { + searchText: $scope.cliente.cobrador.NOM, + query: '/cobrador', + columnas: [ + { + propiedad: 'NUM', + nombre: 'Código' + }, + { + propiedad: 'NOM', + nombre: 'Nombre' + } + ], + titulo: 'Búsqueda de cobradores', + size: 'md' + }; + focaModalService.modal(parametrosModal).then( + function (cobrador) { + $scope.cliente.cobrador = cobrador; + }, function () { + // funcion ejecutada cuando se cancela el modal + }); + } + }; + $scope.seleccionarVendedor = function (key) { + if (key === 13) { + var parametrosModal = { + titulo: 'Búsqueda vendedores', + query: '/vendedor', + columnas: [ + { + propiedad: 'NUM', + nombre: 'Código', + filtro: { + nombre: 'rellenarDigitos', + parametro: 3 } - ], - titulo: 'Búsqueda de responsabilidad ante el IVA', - size: 'md' - }; - focaModalService.modal(parametrosModal).then( - function (iva) { - if (iva) { - delete $scope.cliente.tipoFactura.NOMBRE; + }, + { + propiedad: 'NOM', + nombre: 'Nombre' + } + ], + size: 'md' + }; + focaModalService.modal(parametrosModal).then( + function (vendedor) { + $scope.vendedor = vendedor; + }, function () { + // funcion ejecutada cuando se cancela el modal + }); + } + }; + $scope.seleccionarIva = function (key) { + if (key === 13) { + var parametrosModal = { + query: '/iva', + searchText: $scope.cliente.iva.NOMBRE, + columnas: [ + { + propiedad: 'ID', + nombre: 'Código', + filtro: { + nombre: 'rellenarDigitos', + parametro: 3 } - $scope.cliente.iva = iva; - $timeout(function () { - $scope.focused = 12; - }); - }, function () { - // funcion ejecutada cuando se cancela el modal + }, + { + propiedad: 'NOMBRE', + nombre: 'Nombre' + } + ], + titulo: 'Búsqueda de responsabilidad ante el IVA', + size: 'md' + }; + focaModalService.modal(parametrosModal).then( + function (iva) { + if (iva) { + delete $scope.cliente.tipoFactura.NOMBRE; + } + $scope.cliente.iva = iva; + $timeout(function () { + $scope.focused = 12; }); - } - }; - $scope.seleccionarTipoFactura = function (key) { + }, function () { + // funcion ejecutada cuando se cancela el modal + }); + } + }; + $scope.seleccionarTipoFactura = function (key) { - if ($scope.cliente.iva.NOMBRE == '') { - focaModalService.alert('Seleccione una responsabilidad ante el IVA'); - return; - } + if ($scope.cliente.iva.NOMBRE == '') { + focaModalService.alert('Seleccione una responsabilidad ante el IVA'); + return; + } - if (key === 13) { - var datos; - if ($scope.cliente.iva.ID == 1) { - datos = [ - { - ID: 'A', - NOMBRE: 'Factura A' - }, - { - ID: 'M', - NOMBRE: 'Factura M' - }, - { - ID: 'R', - NOMBRE: 'Remito' - } - ]; - } else { - datos = [ - { - ID: 'B', - NOMBRE: 'Factura B' - }, - { - ID: 'R', - NOMBRE: 'Remito' - } - ]; - } - focaModalService.modal({ - titulo: 'Seleccionar Factura', - data: datos, - size: 'md', - columnas: [ - { - propiedad: 'ID', - NOMBRE: 'Codigo' - }, - { - propiedad: 'NOMBRE', - NOMBRE: 'Factura' - } - ], - }).then(function (res) { - $scope.cliente.tipoFactura = res; - }); + if (key === 13) { + var datos; + if ($scope.cliente.iva.ID == 1) { + datos = [ + { + ID: 'A', + NOMBRE: 'Factura A' + }, + { + ID: 'M', + NOMBRE: 'Factura M' + }, + { + ID: 'R', + NOMBRE: 'Remito' + } + ]; + } else { + datos = [ + { + ID: 'B', + NOMBRE: 'Factura B' + }, + { + ID: 'R', + NOMBRE: 'Remito' + } + ]; } - }; - $scope.pasarCampoCuit = function (numeroCuit) { - if (numeroCuit === 1 && $scope.cliente.cuit1.length === 2) { - $scope.cuitActivo = 2; - } else if (numeroCuit === 2 && $scope.cliente.cuit2.length === 8) { - $scope.cuitActivo = 3; - } - }; - $scope.seleccionarTipoComprobante = function (key) { - if (key === 13) { - var parametrosModal = { - searchText: $scope.cliente.tipoComprobante.NOMBRE, - query: '/tipo-comprobante', - columnas: [ - { - propiedad: 'ID', - nombre: 'Código' - }, - { - propiedad: 'NOMBRE', - nombre: 'Nombre' - } - ], - titulo: 'Búsqueda de tipos de comprobante', - size: 'md' - }; - focaModalService.modal(parametrosModal).then( - function (tipoComprobante) { - $scope.cliente.tipoComprobante = tipoComprobante; - $timeout(function () { - $scope.focused = 17; - }); - }, function () { - // funcion ejecutada cuando se cancela el modal + focaModalService.modal({ + titulo: 'Seleccionar Factura', + data: datos, + size: 'md', + columnas: [ + { + propiedad: 'ID', + NOMBRE: 'Codigo' + }, + { + propiedad: 'NOMBRE', + NOMBRE: 'Factura' + } + ], + }).then(function (res) { + $scope.cliente.tipoFactura = res; + }); + } + }; + $scope.pasarCampoCuit = function (numeroCuit) { + if (numeroCuit === 1 && $scope.cliente.cuit1.length === 2) { + $scope.cuitActivo = 2; + } else if (numeroCuit === 2 && $scope.cliente.cuit2.length === 8) { + $scope.cuitActivo = 3; + } + }; + $scope.seleccionarTipoComprobante = function (key) { + if (key === 13) { + var parametrosModal = { + searchText: $scope.cliente.tipoComprobante.NOMBRE, + query: '/tipo-comprobante', + columnas: [ + { + propiedad: 'ID', + nombre: 'Código' + }, + { + propiedad: 'NOMBRE', + nombre: 'Nombre' + } + ], + titulo: 'Búsqueda de tipos de comprobante', + size: 'md' + }; + focaModalService.modal(parametrosModal).then( + function (tipoComprobante) { + $scope.cliente.tipoComprobante = tipoComprobante; + $timeout(function () { + $scope.focused = 17; }); - } - }; - $scope.seleccionarFormaPago = function (key) { - if (key === 13) { - var parametrosModal = { - searchText: $scope.cliente.formaPago.NOMBRE, - query: '/forma-pago', - columnas: [ - { - propiedad: 'ID', - nombre: 'Código', - filtro: { - nombre: 'rellenarDigitos', - parametro: 3 - } - }, - { - propiedad: 'NOMBRE', - nombre: 'Nombre' + }, function () { + // funcion ejecutada cuando se cancela el modal + }); + } + }; + $scope.seleccionarFormaPago = function (key) { + if (key === 13) { + var parametrosModal = { + searchText: $scope.cliente.formaPago.NOMBRE, + query: '/forma-pago', + columnas: [ + { + propiedad: 'ID', + nombre: 'Código', + filtro: { + nombre: 'rellenarDigitos', + parametro: 3 } - ], - titulo: 'Búsqueda de formas de pago', - size: 'md' - }; - focaModalService.modal(parametrosModal).then( - function (formaPago) { - $scope.cliente.formaPago = formaPago; - }, function () { - // funcion ejecutada cuando se cancela el modal - }); - } - }; - - function crearCopia() { - var cliente = angular.copy($scope.cliente); - cliente.COD = cliente.codigo; - cliente.CPO = cliente.CPO; - cliente.PCX = parseInt(cliente.provincia.ID); - cliente.LOX = parseInt(cliente.localidad.ID); - cliente.LOC = cliente.localidad.NOMBRE; - cliente.PCI = cliente.provincia.NOMBRE; - cliente.IVA = cliente.iva.ID; - cliente.ACT = cliente.actividad.ID; - cliente.ZON = (parseInt(cliente.zona.ID)).toString(); - cliente.TIP = cliente.tipoFactura.ID; - cliente.TCO = cliente.tipoComprobante.ID; - cliente.FPA = cliente.formaPago.ID; - cliente.VEN = $scope.vendedor.id; - cliente.CUIT = `${cliente.cuit1}-${cliente.cuit2}-${cliente.cuit3}`; - cliente.idCobrador = cliente.cobrador.ID; + }, + { + propiedad: 'NOMBRE', + nombre: 'Nombre' + } + ], + titulo: 'Búsqueda de formas de pago', + size: 'md' + }; + focaModalService.modal(parametrosModal).then( + function (formaPago) { + $scope.cliente.formaPago = formaPago; + }, function () { + // funcion ejecutada cuando se cancela el modal + }); + } + }; + + function crearCopia() { + var cliente = angular.copy($scope.cliente); + cliente.COD = cliente.codigo; + cliente.CPO = cliente.CPO; + cliente.PCX = parseInt(cliente.provincia.ID); + cliente.LOX = parseInt(cliente.localidad.ID); + cliente.LOC = cliente.localidad.NOMBRE; + cliente.PCI = cliente.provincia.NOMBRE; + cliente.IVA = cliente.iva.ID; + cliente.ACT = cliente.actividad.ID; + cliente.ZON = (parseInt(cliente.zona.ID)).toString(); + cliente.TIP = cliente.tipoFactura.ID; + cliente.TCO = cliente.tipoComprobante.ID; + cliente.FPA = cliente.formaPago.ID; + cliente.VEN = $scope.vendedor.id; + cliente.CUIT = `${cliente.cuit1}-${cliente.cuit2}-${cliente.cuit3}`; + cliente.idCobrador = cliente.cobrador.ID; - delete cliente.codigo; - delete cliente.provincia; - delete cliente.localidad; - delete cliente.iva; - delete cliente.actividad; - delete cliente.zona; - delete cliente.tipoFactura; - delete cliente.tipoComprobante; - delete cliente.formaPago; - delete cliente.cobrador; - delete cliente.cuit1; - delete cliente.cuit2; - delete cliente.cuit3; - delete cliente.vendedor; + delete cliente.codigo; + delete cliente.provincia; + delete cliente.localidad; + delete cliente.iva; + delete cliente.actividad; + delete cliente.zona; + delete cliente.tipoFactura; + delete cliente.tipoComprobante; + delete cliente.formaPago; + delete cliente.cobrador; + delete cliente.cuit1; + delete cliente.cuit2; + delete cliente.cuit3; + delete cliente.vendedor; - return cliente; - } - function validateEmails(emails) { - var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; - var arr = emails.split(','); - var result = true; - arr.forEach(function (email) { - var val = String(email).trim().toLowerCase(); - if (!re.test(val)) result = false; - }); - return result; - } + return cliente; + } + function validateEmails(emails) { + var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + var arr = emails.split(','); + var result = true; + arr.forEach(function (email) { + var val = String(email).trim().toLowerCase(); + if (!re.test(val)) result = false; + }); + return result; + } - }]); + }]); \ No newline at end of file -- 1.9.1