Commit 4d9ec829f4dccb86e85eb4860985a070ee99726f
1 parent
7c48dfd19c
Exists in
master
Elimino c.log
Showing
2 changed files
with
0 additions
and
3 deletions
 
Show diff stats
src/js/controller.js
| 1 | angular.module('focaAbmCliente') | 1 | angular.module('focaAbmCliente') | 
| 2 | .controller('focaAbmClienteController', [ | 2 | .controller('focaAbmClienteController', [ | 
| 3 | '$scope', 'focaBotoneraLateralService', '$timeout', '$uibModal','focaModalService', | 3 | '$scope', 'focaBotoneraLateralService', '$timeout', '$uibModal','focaModalService', | 
| 4 | 'focaAbmClienteService','$filter', | 4 | 'focaAbmClienteService','$filter', | 
| 5 | function($scope, focaBotoneraLateralService, $timeout, $uibModal,focaModalService, | 5 | function($scope, focaBotoneraLateralService, $timeout, $uibModal,focaModalService, | 
| 6 | focaAbmClienteService, $filter) { | 6 | focaAbmClienteService, $filter) { | 
| 7 | $scope.cliente= { | 7 | $scope.cliente= { | 
| 8 | NOM: undefined, | 8 | NOM: undefined, | 
| 9 | COD: undefined | 9 | COD: undefined | 
| 10 | }; | 10 | }; | 
| 11 | $scope.vendedor = {}; | 11 | $scope.vendedor = {}; | 
| 12 | 12 | ||
| 13 | $scope.botonCliente = [{ | 13 | $scope.botonCliente = [{ | 
| 14 | label: 'Cliente', | 14 | label: 'Cliente', | 
| 15 | image: 'cliente.png' | 15 | image: 'cliente.png' | 
| 16 | }]; | 16 | }]; | 
| 17 | 17 | ||
| 18 | $scope.botonera = [ | 18 | $scope.botonera = [ | 
| 19 | { | 19 | { | 
| 20 | label: 'Datos Cliente', | 20 | label: 'Datos Cliente', | 
| 21 | image: 'datoscliente.png', | 21 | image: 'datoscliente.png', | 
| 22 | }, | 22 | }, | 
| 23 | { | 23 | { | 
| 24 | label: 'Domicilios de entrega', | 24 | label: 'Domicilios de entrega', | 
| 25 | image: 'dimiciliodeentrega.png' | 25 | image: 'dimiciliodeentrega.png' | 
| 26 | }, | 26 | }, | 
| 27 | { | 27 | { | 
| 28 | label: 'Precio y Condiciones', | 28 | label: 'Precio y Condiciones', | 
| 29 | image: 'precios-condiciones.png' | 29 | image: 'precios-condiciones.png' | 
| 30 | } | 30 | } | 
| 31 | ]; | 31 | ]; | 
| 32 | 32 | ||
| 33 | //SETEO BOTONERA LATERAL | 33 | //SETEO BOTONERA LATERAL | 
| 34 | $timeout(function() { | 34 | $timeout(function() { | 
| 35 | focaBotoneraLateralService.showSalir(true); | 35 | focaBotoneraLateralService.showSalir(true); | 
| 36 | focaBotoneraLateralService.showPausar(false); | 36 | focaBotoneraLateralService.showPausar(false); | 
| 37 | focaBotoneraLateralService.showCancelar(false); | 37 | focaBotoneraLateralService.showCancelar(false); | 
| 38 | focaBotoneraLateralService.showGuardar(false); | 38 | focaBotoneraLateralService.showGuardar(false); | 
| 39 | }); | 39 | }); | 
| 40 | 40 | ||
| 41 | $scope.seleccionarCliente = function() { | 41 | $scope.seleccionarCliente = function() { | 
| 42 | var datos = null; | 42 | var datos = null; | 
| 43 | focaAbmClienteService.getAllClientes() | 43 | focaAbmClienteService.getAllClientes() | 
| 44 | .then(function (res) { | 44 | .then(function (res) { | 
| 45 | datos = res.data; | 45 | datos = res.data; | 
| 46 | focaModalService.modal({ | 46 | focaModalService.modal({ | 
| 47 | titulo: 'Clientes', | 47 | titulo: 'Clientes', | 
| 48 | data: datos, | 48 | data: datos, | 
| 49 | size: 'md', | 49 | size: 'md', | 
| 50 | columnas: [ | 50 | columnas: [ | 
| 51 | { | 51 | { | 
| 52 | propiedad: 'COD', | 52 | propiedad: 'COD', | 
| 53 | nombre: 'Codigo' | 53 | nombre: 'Codigo' | 
| 54 | }, | 54 | }, | 
| 55 | { | 55 | { | 
| 56 | propiedad: 'NOM', | 56 | propiedad: 'NOM', | 
| 57 | nombre: 'Nombre' | 57 | nombre: 'Nombre' | 
| 58 | }, | 58 | }, | 
| 59 | { | 59 | { | 
| 60 | propiedad: 'CUIT', | 60 | propiedad: 'CUIT', | 
| 61 | nombre: 'CUIT' | 61 | nombre: 'CUIT' | 
| 62 | } | 62 | } | 
| 63 | ], | 63 | ], | 
| 64 | }).then(function (res) { | 64 | }).then(function (res) { | 
| 65 | $scope.cliente.NOM = res.NOM; | 65 | $scope.cliente.NOM = res.NOM; | 
| 66 | $scope.cliente.COD = res.COD; | 66 | $scope.cliente.COD = res.COD; | 
| 67 | $scope.$broadcast('addCabecera', { | 67 | $scope.$broadcast('addCabecera', { | 
| 68 | label: 'Cliente:', | 68 | label: 'Cliente:', | 
| 69 | valor: $filter('rellenarDigitos') | 69 | valor: $filter('rellenarDigitos') | 
| 70 | ($scope.cliente.COD, 5) + ' - ' + $scope.cliente.NOM | 70 | ($scope.cliente.COD, 5) + ' - ' + $scope.cliente.NOM | 
| 71 | }); | 71 | }); | 
| 72 | }).catch(function (e) { | 72 | }).catch(function (e) { | 
| 73 | console.log(e); | 73 | console.log(e); | 
| 74 | }); | 74 | }); | 
| 75 | }); | 75 | }); | 
| 76 | }; | 76 | }; | 
| 77 | 77 | ||
| 78 | $scope.seleccionarDatosCliente = function () { | 78 | $scope.seleccionarDatosCliente = function () { | 
| 79 | if ($scope.cliente.NOM === undefined || $scope.cliente.COD === undefined) { | 79 | if ($scope.cliente.NOM === undefined || $scope.cliente.COD === undefined) { | 
| 80 | focaModalService.alert('Seleccione cliente'); | 80 | focaModalService.alert('Seleccione cliente'); | 
| 81 | return; | 81 | return; | 
| 82 | } else { | 82 | } else { | 
| 83 | var modalInstanceCliente = $uibModal.open( | 83 | var modalInstanceCliente = $uibModal.open( | 
| 84 | { | 84 | { | 
| 85 | ariaLabelledBy: '', | 85 | ariaLabelledBy: '', | 
| 86 | templateUrl: 'foca-modal-cliente.html', | 86 | templateUrl: 'foca-modal-cliente.html', | 
| 87 | controller: 'focaModalClienteController', | 87 | controller: 'focaModalClienteController', | 
| 88 | resolve: { | 88 | resolve: { | 
| 89 | idCliente: function () { return $scope.cliente.COD; }, | 89 | idCliente: function () { return $scope.cliente.COD; }, | 
| 90 | }, | 90 | }, | 
| 91 | size: 'lg', | 91 | size: 'lg', | 
| 92 | } | 92 | } | 
| 93 | ); | 93 | ); | 
| 94 | modalInstanceCliente.result | 94 | modalInstanceCliente.result | 
| 95 | .then( function(data) { | 95 | .then( function(data) { | 
| 96 | if (data) { | 96 | if (data) { | 
| 97 | console.log('Data 2: ', data); | ||
| 98 | $scope.cliente.NOM = data.NOM; | 97 | $scope.cliente.NOM = data.NOM; | 
| 99 | $scope.$broadcast('cleanCabecera'); | 98 | $scope.$broadcast('cleanCabecera'); | 
| 100 | $scope.$broadcast('addCabecera', { | 99 | $scope.$broadcast('addCabecera', { | 
| 101 | label: 'Cliente:', | 100 | label: 'Cliente:', | 
| 102 | valor: $filter('rellenarDigitos')($scope.cliente.NOM) | 101 | valor: $filter('rellenarDigitos')($scope.cliente.NOM) | 
| 103 | }); | 102 | }); | 
| 104 | console.log('Data', data); | ||
| 105 | } | 103 | } | 
| 106 | }); | 104 | }); | 
| 107 | } | 105 | } | 
| 108 | }; | 106 | }; | 
| 109 | 107 | ||
| 110 | $scope.seleccionarDomiciliosDeEntrega = function () { | 108 | $scope.seleccionarDomiciliosDeEntrega = function () { | 
| 111 | if ($scope.cliente.NOM === undefined || $scope.cliente.COD === undefined) { | 109 | if ($scope.cliente.NOM === undefined || $scope.cliente.COD === undefined) { | 
| 112 | focaModalService.alert('Seleccione un cliente'); | 110 | focaModalService.alert('Seleccione un cliente'); | 
| 113 | return; | 111 | return; | 
| 114 | } | 112 | } | 
| 115 | var modalInstanceDomicilio = $uibModal.open( | 113 | var modalInstanceDomicilio = $uibModal.open( | 
| 116 | { | 114 | { | 
| 117 | ariaLabelledBy: 'Busqueda de Domicilios', | 115 | ariaLabelledBy: 'Busqueda de Domicilios', | 
| 118 | templateUrl: 'modal-domicilio.html', | 116 | templateUrl: 'modal-domicilio.html', | 
| 119 | controller: 'focaModalDomicilioController', | 117 | controller: 'focaModalDomicilioController', | 
| 120 | resolve: { | 118 | resolve: { | 
| 121 | idCliente: function () { return $scope.cliente.COD; }, | 119 | idCliente: function () { return $scope.cliente.COD; }, | 
| 122 | esNuevo: function () { return $scope.cliente.esNuevo; } | 120 | esNuevo: function () { return $scope.cliente.esNuevo; } | 
| 123 | }, | 121 | }, | 
| 124 | size: 'lg', | 122 | size: 'lg', | 
| 125 | } | 123 | } | 
| 126 | ); | 124 | ); | 
| 127 | modalInstanceDomicilio.result.then( function(data) { | 125 | modalInstanceDomicilio.result.then( function(data) { | 
| 128 | if (data) { | 126 | if (data) { | 
| 129 | $scope.$broadcast('addCabecera', { | 127 | $scope.$broadcast('addCabecera', { | 
| 130 | label: 'Domicilio:', | 128 | label: 'Domicilio:', | 
| 131 | valor: data.Calle + ' ' + data.Numero + ' - ' + data.Localidad + | 129 | valor: data.Calle + ' ' + data.Numero + ' - ' + data.Localidad + | 
| 132 | ' - ' + data.Provincia | 130 | ' - ' + data.Provincia | 
| 133 | }); | 131 | }); | 
| 134 | } | 132 | } | 
| 135 | }); | 133 | }); | 
| 136 | }; | 134 | }; | 
| 137 | 135 | ||
| 138 | $scope.seleccionarPrecioYCondiciones = function () { | 136 | $scope.seleccionarPrecioYCondiciones = function () { | 
| 139 | 137 | ||
| 140 | if ($scope.cliente.NOM === undefined || $scope.cliente.COD === undefined) { | 138 | if ($scope.cliente.NOM === undefined || $scope.cliente.COD === undefined) { | 
| 141 | focaModalService.alert('Seleccione cliente'); | 139 | focaModalService.alert('Seleccione cliente'); | 
| 142 | return; | 140 | return; | 
| 143 | } | 141 | } | 
| 144 | var modalInstance = $uibModal.open( | 142 | var modalInstance = $uibModal.open( | 
| 145 | { | 143 | { | 
| 146 | ariaLabelledBy: 'Busqueda de Precio Condición', | 144 | ariaLabelledBy: 'Busqueda de Precio Condición', | 
| 147 | templateUrl: 'modal-precio-condicion.html', | 145 | templateUrl: 'modal-precio-condicion.html', | 
| 148 | controller: 'focaModalPrecioCondicionController', | 146 | controller: 'focaModalPrecioCondicionController', | 
| 149 | size: 'lg', | 147 | size: 'lg', | 
| 150 | resolve: { | 148 | resolve: { | 
| 151 | idListaPrecio: function () { | 149 | idListaPrecio: function () { | 
| 152 | return $scope.cliente.MOD || null; | 150 | return $scope.cliente.MOD || null; | 
| 153 | } | 151 | } | 
| 154 | } | 152 | } | 
| 155 | } | 153 | } | 
| 156 | ); | 154 | ); | 
| 157 | 155 | ||
| 158 | modalInstance.result.then( function (data) { | 156 | modalInstance.result.then( function (data) { | 
| 159 | if (data) { | 157 | if (data) { | 
| 160 | console.log('Data: ', data); | 158 | console.log('Data: ', data); | 
| 161 | } | 159 | } | 
| 162 | 160 | ||
| 163 | }, function () { | 161 | }, function () { | 
| 164 | 162 | ||
| 165 | } | 163 | } | 
| 166 | ); | 164 | ); | 
| 167 | }; | 165 | }; | 
| 168 | 166 | ||
| 169 | 167 | ||
| 170 | } | 168 | } | 
| 171 | ]); | 169 | ]); | 
| 172 | 170 | 
src/js/controllerCliente.js
| 1 | angular.module('focaAbmCliente') | 1 | angular.module('focaAbmCliente') | 
| 2 | .controller('focaModalClienteController', [ | 2 | .controller('focaModalClienteController', [ | 
| 3 | '$scope', '$timeout', '$uibModalInstance', 'focaModalService', | 3 | '$scope', '$timeout', '$uibModalInstance', 'focaModalService', | 
| 4 | 'focaAbmClienteService', 'idCliente', | 4 | 'focaAbmClienteService', 'idCliente', | 
| 5 | 5 | ||
| 6 | function ($scope, $timeout, $uibModalInstance, focaModalService, | 6 | function ($scope, $timeout, $uibModalInstance, focaModalService, | 
| 7 | focaAbmClienteService, idCliente) { | 7 | focaAbmClienteService, idCliente) { | 
| 8 | 8 | ||
| 9 | $scope.cliente = { | 9 | $scope.cliente = { | 
| 10 | provincia: {}, | 10 | provincia: {}, | 
| 11 | localidad: {}, | 11 | localidad: {}, | 
| 12 | zona: {}, | 12 | zona: {}, | 
| 13 | actividad: {}, | 13 | actividad: {}, | 
| 14 | cobrador: {}, | 14 | cobrador: {}, | 
| 15 | vendedor: {}, | 15 | vendedor: {}, | 
| 16 | iva: {}, | 16 | iva: {}, | 
| 17 | tipoFactura: {}, | 17 | tipoFactura: {}, | 
| 18 | tipoComprobante: {}, | 18 | tipoComprobante: {}, | 
| 19 | formaPago: {} | 19 | formaPago: {} | 
| 20 | }; | 20 | }; | 
| 21 | $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/); | 21 | $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/); | 
| 22 | 22 | ||
| 23 | $scope.vendedor = {}; | 23 | $scope.vendedor = {}; | 
| 24 | 24 | ||
| 25 | focaAbmClienteService.obtenerClientePorCodigo(idCliente) | 25 | focaAbmClienteService.obtenerClientePorCodigo(idCliente) | 
| 26 | .then(function (res) { | 26 | .then(function (res) { | 
| 27 | var data = res.data[0]; | 27 | var data = res.data[0]; | 
| 28 | $scope.cliente.codigo = data.COD; | 28 | $scope.cliente.codigo = data.COD; | 
| 29 | $scope.cliente.DOM = data.DOM; | 29 | $scope.cliente.DOM = data.DOM; | 
| 30 | $scope.cliente.NOM = data.NOM; | 30 | $scope.cliente.NOM = data.NOM; | 
| 31 | $scope.cliente.CPO = data.CPO; | 31 | $scope.cliente.CPO = data.CPO; | 
| 32 | $scope.cliente.provincia.ID = data.PCX; | 32 | $scope.cliente.provincia.ID = data.PCX; | 
| 33 | $scope.cliente.provincia.NOMBRE = data.PCI; | 33 | $scope.cliente.provincia.NOMBRE = data.PCI; | 
| 34 | $scope.cliente.localidad.ID = data.LOX; | 34 | $scope.cliente.localidad.ID = data.LOX; | 
| 35 | $scope.cliente.localidad.NOMBRE = data.LOC; | 35 | $scope.cliente.localidad.NOMBRE = data.LOC; | 
| 36 | $scope.cliente.zona.ID = data.zona.ID; | 36 | $scope.cliente.zona.ID = data.zona.ID; | 
| 37 | $scope.cliente.zona.NOM = data.zona.NOM; | 37 | $scope.cliente.zona.NOM = data.zona.NOM; | 
| 38 | $scope.cliente.actividad.NOM = data.actividad.NOM; | 38 | $scope.cliente.actividad.NOM = data.actividad.NOM; | 
| 39 | $scope.cliente.actividad.ID = data.actividad.ID; | 39 | $scope.cliente.actividad.ID = data.actividad.ID; | 
| 40 | $scope.cliente.cobrador.NOM = data.cobrador ? data.cobrador.NOM : ''; | 40 | $scope.cliente.cobrador.NOM = data.cobrador ? data.cobrador.NOM : ''; | 
| 41 | $scope.cliente.cobrador.NUM = data.cobrador ? data.cobrador.NUM : undefined; | 41 | $scope.cliente.cobrador.NUM = data.cobrador ? data.cobrador.NUM : undefined; | 
| 42 | $scope.cliente.cobrador.ID = data.cobrador ? data.cobrador.id : undefined; | 42 | $scope.cliente.cobrador.ID = data.cobrador ? data.cobrador.id : undefined; | 
| 43 | $scope.vendedor.NOM = data.vendedor.NOM; | 43 | $scope.vendedor.NOM = data.vendedor.NOM; | 
| 44 | $scope.vendedor.id = data.vendedor.id; | 44 | $scope.vendedor.id = data.vendedor.id; | 
| 45 | $scope.cliente.MAIL = data.MAIL; | 45 | $scope.cliente.MAIL = data.MAIL; | 
| 46 | $scope.cliente.TEL = data.TEL; | 46 | $scope.cliente.TEL = data.TEL; | 
| 47 | $scope.cliente.iva.NOMBRE = data.iva.NOMBRE; | 47 | $scope.cliente.iva.NOMBRE = data.iva.NOMBRE; | 
| 48 | $scope.cliente.tipoFactura.NOMBRE = data.tipoFactura.NOMBRE; | 48 | $scope.cliente.tipoFactura.NOMBRE = data.tipoFactura.NOMBRE; | 
| 49 | $scope.cliente.tipoFactura.ID = data.tipoFactura.ID; | 49 | $scope.cliente.tipoFactura.ID = data.tipoFactura.ID; | 
| 50 | var cuit = data.CUIT.split('-'); | 50 | var cuit = data.CUIT.split('-'); | 
| 51 | $scope.cliente.cuit1 = cuit[0]; | 51 | $scope.cliente.cuit1 = cuit[0]; | 
| 52 | $scope.cliente.cuit2 = cuit[1]; | 52 | $scope.cliente.cuit2 = cuit[1]; | 
| 53 | $scope.cliente.cuit3 = cuit[2]; | 53 | $scope.cliente.cuit3 = cuit[2]; | 
| 54 | $scope.cliente.tipoComprobante.NOMBRE = data.tipoComprobante.NOMBRE; | 54 | $scope.cliente.tipoComprobante.NOMBRE = data.tipoComprobante.NOMBRE; | 
| 55 | $scope.cliente.tipoComprobante.ID = data.tipoComprobante.ID; | 55 | $scope.cliente.tipoComprobante.ID = data.tipoComprobante.ID; | 
| 56 | $scope.cliente.formaPago.NOMBRE = data.formaPago.NOMBRE; | 56 | $scope.cliente.formaPago.NOMBRE = data.formaPago.NOMBRE; | 
| 57 | $scope.cliente.formaPago.ID = data.formaPago.ID; | 57 | $scope.cliente.formaPago.ID = data.formaPago.ID; | 
| 58 | $scope.cliente.ES_PROS = data.ES_PROS; | 58 | $scope.cliente.ES_PROS = data.ES_PROS; | 
| 59 | $scope.cliente.ES_MAY = data.ES_MAY; | 59 | $scope.cliente.ES_MAY = data.ES_MAY; | 
| 60 | 60 | ||
| 61 | 61 | ||
| 62 | $scope.editando = true; | 62 | $scope.editando = true; | 
| 63 | 63 | ||
| 64 | }) | 64 | }) | 
| 65 | .catch(function (e) { console.log(e); }); | 65 | .catch(function (e) { console.log(e); }); | 
| 66 | 66 | ||
| 67 | 67 | ||
| 68 | 68 | ||
| 69 | 69 | ||
| 70 | $scope.cancel = function () { | 70 | $scope.cancel = function () { | 
| 71 | $uibModalInstance.dismiss('cancel'); | 71 | $uibModalInstance.dismiss('cancel'); | 
| 72 | }; | 72 | }; | 
| 73 | 73 | ||
| 74 | $scope.guardar = function () { | 74 | $scope.guardar = function () { | 
| 75 | if (!$scope.cliente.NOM) { | 75 | if (!$scope.cliente.NOM) { | 
| 76 | focaModalService.alert('Ingrese Nombre'); | 76 | focaModalService.alert('Ingrese Nombre'); | 
| 77 | return; | 77 | return; | 
| 78 | } else if (!$scope.cliente.CPO) { | 78 | } else if (!$scope.cliente.CPO) { | 
| 79 | focaModalService.alert('Ingrese Codigo Postal'); | 79 | focaModalService.alert('Ingrese Codigo Postal'); | 
| 80 | return; | 80 | return; | 
| 81 | } else if (!$scope.cliente.provincia.NOMBRE) { | 81 | } else if (!$scope.cliente.provincia.NOMBRE) { | 
| 82 | focaModalService.alert('Seleccione una provincia'); | 82 | focaModalService.alert('Seleccione una provincia'); | 
| 83 | return; | 83 | return; | 
| 84 | } else if (!$scope.cliente.DOM) { | 84 | } else if (!$scope.cliente.DOM) { | 
| 85 | focaModalService.alert('Ingrese Domicilio'); | 85 | focaModalService.alert('Ingrese Domicilio'); | 
| 86 | return; | 86 | return; | 
| 87 | } else if (!$scope.cliente.localidad.NOMBRE) { | 87 | } else if (!$scope.cliente.localidad.NOMBRE) { | 
| 88 | focaModalService.alert('Seleccione una localidad'); | 88 | focaModalService.alert('Seleccione una localidad'); | 
| 89 | return; | 89 | return; | 
| 90 | } else if (!$scope.cliente.zona.NOM) { | 90 | } else if (!$scope.cliente.zona.NOM) { | 
| 91 | focaModalService.alert('Seleccione una zona'); | 91 | focaModalService.alert('Seleccione una zona'); | 
| 92 | return; | 92 | return; | 
| 93 | } else if (!$scope.cliente.actividad.NOM) { | 93 | } else if (!$scope.cliente.actividad.NOM) { | 
| 94 | focaModalService.alert('Seleccione actividad'); | 94 | focaModalService.alert('Seleccione actividad'); | 
| 95 | return; | 95 | return; | 
| 96 | } else if (!$scope.cliente.cobrador.NUM) { | 96 | } else if (!$scope.cliente.cobrador.NUM) { | 
| 97 | focaModalService.alert('Seleccione un cobrador'); | 97 | focaModalService.alert('Seleccione un cobrador'); | 
| 98 | return; | 98 | return; | 
| 99 | } else if (!$scope.vendedor.NOM) { | 99 | } else if (!$scope.vendedor.NOM) { | 
| 100 | focaModalService.alert('Seleccione un vendedor'); | 100 | focaModalService.alert('Seleccione un vendedor'); | 
| 101 | return; | 101 | return; | 
| 102 | } else if ($scope.cliente.MAIL && !validateEmails($scope.cliente.MAIL)) { | 102 | } else if ($scope.cliente.MAIL && !validateEmails($scope.cliente.MAIL)) { | 
| 103 | focaModalService.alert('Ingrese un formato de email válido'); | 103 | focaModalService.alert('Ingrese un formato de email válido'); | 
| 104 | return; | 104 | return; | 
| 105 | } else if (!$scope.cliente.TEL) { | 105 | } else if (!$scope.cliente.TEL) { | 
| 106 | focaModalService.alert('Ingrese un numero de telefono'); | 106 | focaModalService.alert('Ingrese un numero de telefono'); | 
| 107 | return; | 107 | return; | 
| 108 | } else if (!$scope.cliente.iva.NOMBRE) { | 108 | } else if (!$scope.cliente.iva.NOMBRE) { | 
| 109 | focaModalService.alert('Seleccione responsabilidad ante el IVA'); | 109 | focaModalService.alert('Seleccione responsabilidad ante el IVA'); | 
| 110 | return; | 110 | return; | 
| 111 | } else if (!$scope.cliente.tipoFactura.NOMBRE) { | 111 | } else if (!$scope.cliente.tipoFactura.NOMBRE) { | 
| 112 | focaModalService.alert('Seleccione tipo de Factura'); | 112 | focaModalService.alert('Seleccione tipo de Factura'); | 
| 113 | return; | 113 | return; | 
| 114 | } else if (!$scope.cliente.cuit1 && !$scope.cliente.cuit2 && !$scope.cliente.cuit3) { | 114 | } else if (!$scope.cliente.cuit1 && !$scope.cliente.cuit2 && !$scope.cliente.cuit3) { | 
| 115 | focaModalService.alert('Ingrese CUIT'); | 115 | focaModalService.alert('Ingrese CUIT'); | 
| 116 | return; | 116 | return; | 
| 117 | } else if (!$scope.cliente.cuit1 || !$scope.cliente.cuit2 || !$scope.cliente.cuit3) { | 117 | } else if (!$scope.cliente.cuit1 || !$scope.cliente.cuit2 || !$scope.cliente.cuit3) { | 
| 118 | focaModalService.alert('Ingrese CUIT válido'); | 118 | focaModalService.alert('Ingrese CUIT válido'); | 
| 119 | return; | 119 | return; | 
| 120 | } else if (!$scope.regexCuit.test($scope.cliente.cuit1 + $scope.cliente.cuit2 + $scope.cliente.cuit3)) { | 120 | } else if (!$scope.regexCuit.test($scope.cliente.cuit1 + $scope.cliente.cuit2 + $scope.cliente.cuit3)) { | 
| 121 | focaModalService.alert('Ingrese CUIT con formato: XX-XXXXXXXX-X'); | 121 | focaModalService.alert('Ingrese CUIT con formato: XX-XXXXXXXX-X'); | 
| 122 | return; | 122 | return; | 
| 123 | } else if (!$scope.cliente.tipoComprobante.NOMBRE) { | 123 | } else if (!$scope.cliente.tipoComprobante.NOMBRE) { | 
| 124 | focaModalService.alert('Seleccione un Comprobante'); | 124 | focaModalService.alert('Seleccione un Comprobante'); | 
| 125 | return; | 125 | return; | 
| 126 | } else if (!$scope.cliente.formaPago.NOMBRE) { | 126 | } else if (!$scope.cliente.formaPago.NOMBRE) { | 
| 127 | focaModalService.alert('Seleccione una forma de pago'); | 127 | focaModalService.alert('Seleccione una forma de pago'); | 
| 128 | return; | 128 | return; | 
| 129 | } | 129 | } | 
| 130 | 130 | ||
| 131 | $scope.cliente.actividad.ID = parseInt($scope.cliente.actividad.ID); | 131 | $scope.cliente.actividad.ID = parseInt($scope.cliente.actividad.ID); | 
| 132 | 132 | ||
| 133 | var cliente = crearCopia(); | 133 | var cliente = crearCopia(); | 
| 134 | 134 | ||
| 135 | focaAbmClienteService | 135 | focaAbmClienteService | 
| 136 | .guardarCliente(cliente) | 136 | .guardarCliente(cliente) | 
| 137 | .then(function () { | 137 | .then(function () { | 
| 138 | $uibModalInstance.close(cliente); | 138 | $uibModalInstance.close(cliente); | 
| 139 | }) | 139 | }) | 
| 140 | .catch(function (e) { | 140 | .catch(function (e) { | 
| 141 | console.log(e); | 141 | console.log(e); | 
| 142 | }); | 142 | }); | 
| 143 | }; | 143 | }; | 
| 144 | $scope.seleccionarProvincia = function (key) { | 144 | $scope.seleccionarProvincia = function (key) { | 
| 145 | if (key === 13) { | 145 | if (key === 13) { | 
| 146 | var parametrosModal = { | 146 | var parametrosModal = { | 
| 147 | searchText: $scope.cliente.provincia.NOMBRE, | 147 | searchText: $scope.cliente.provincia.NOMBRE, | 
| 148 | query: '/provincia', | 148 | query: '/provincia', | 
| 149 | columnas: [ | 149 | columnas: [ | 
| 150 | { | 150 | { | 
| 151 | propiedad: 'ID', | 151 | propiedad: 'ID', | 
| 152 | nombre: 'Codigo', | 152 | nombre: 'Codigo', | 
| 153 | filtro: { | 153 | filtro: { | 
| 154 | nombre: 'rellenarDigitos', | 154 | nombre: 'rellenarDigitos', | 
| 155 | parametro: 3 | 155 | parametro: 3 | 
| 156 | } | 156 | } | 
| 157 | }, | 157 | }, | 
| 158 | { | 158 | { | 
| 159 | propiedad: 'NOMBRE', | 159 | propiedad: 'NOMBRE', | 
| 160 | nombre: 'Nombre' | 160 | nombre: 'Nombre' | 
| 161 | } | 161 | } | 
| 162 | ], | 162 | ], | 
| 163 | titulo: 'Búsqueda de provincias', | 163 | titulo: 'Búsqueda de provincias', | 
| 164 | size: 'md' | 164 | size: 'md' | 
| 165 | }; | 165 | }; | 
| 166 | focaModalService.modal(parametrosModal).then(function (provincia) { | 166 | focaModalService.modal(parametrosModal).then(function (provincia) { | 
| 167 | $scope.cliente.provincia = provincia; | 167 | $scope.cliente.provincia = provincia; | 
| 168 | $timeout(function () { | 168 | $timeout(function () { | 
| 169 | $scope.focused = 4; | 169 | $scope.focused = 4; | 
| 170 | }); | 170 | }); | 
| 171 | }, function () { | 171 | }, function () { | 
| 172 | //TODO: función llamada cuando cancela el modal | 172 | //TODO: función llamada cuando cancela el modal | 
| 173 | }); | 173 | }); | 
| 174 | } | 174 | } | 
| 175 | }; | 175 | }; | 
| 176 | $scope.seleccionarLocalidad = function (key) { | 176 | $scope.seleccionarLocalidad = function (key) { | 
| 177 | if ($scope.cliente.provincia.ID === undefined) { | 177 | if ($scope.cliente.provincia.ID === undefined) { | 
| 178 | focaModalService.alert('Seleccione una provincia'); | 178 | focaModalService.alert('Seleccione una provincia'); | 
| 179 | return; | 179 | return; | 
| 180 | } | 180 | } | 
| 181 | if (key === 13) { | 181 | if (key === 13) { | 
| 182 | var parametrosModal = { | 182 | var parametrosModal = { | 
| 183 | searchText: $scope.cliente.localidad.NOMBRE, | 183 | searchText: $scope.cliente.localidad.NOMBRE, | 
| 184 | query: '/localidad/' + parseInt($scope.cliente.provincia.ID), | 184 | query: '/localidad/' + parseInt($scope.cliente.provincia.ID), | 
| 185 | columnas: [ | 185 | columnas: [ | 
| 186 | { | 186 | { | 
| 187 | propiedad: 'ID', | 187 | propiedad: 'ID', | 
| 188 | nombre: 'Código', | 188 | nombre: 'Código', | 
| 189 | }, | 189 | }, | 
| 190 | { | 190 | { | 
| 191 | propiedad: 'NOMBRE', | 191 | propiedad: 'NOMBRE', | 
| 192 | nombre: 'Nombre' | 192 | nombre: 'Nombre' | 
| 193 | } | 193 | } | 
| 194 | ], | 194 | ], | 
| 195 | titulo: 'Búsqueda de localidades', | 195 | titulo: 'Búsqueda de localidades', | 
| 196 | size: 'md' | 196 | size: 'md' | 
| 197 | }; | 197 | }; | 
| 198 | focaModalService.modal(parametrosModal).then(function (localidad) { | 198 | focaModalService.modal(parametrosModal).then(function (localidad) { | 
| 199 | $scope.cliente.localidad = localidad; | 199 | $scope.cliente.localidad = localidad; | 
| 200 | $timeout(function () { | 200 | $timeout(function () { | 
| 201 | $scope.focused = 5; | 201 | $scope.focused = 5; | 
| 202 | }); | 202 | }); | 
| 203 | }, function () { | 203 | }, function () { | 
| 204 | //TODO: función llamada cuando cancela el modal | 204 | //TODO: función llamada cuando cancela el modal | 
| 205 | }); | 205 | }); | 
| 206 | } | 206 | } | 
| 207 | }; | 207 | }; | 
| 208 | $scope.seleccionarZona = function (key) { | 208 | $scope.seleccionarZona = function (key) { | 
| 209 | if (key === 13) { | 209 | if (key === 13) { | 
| 210 | var parametrosModal = { | 210 | var parametrosModal = { | 
| 211 | searchText: $scope.cliente.zona.NOM, | 211 | searchText: $scope.cliente.zona.NOM, | 
| 212 | query: '/zona', | 212 | query: '/zona', | 
| 213 | columnas: [ | 213 | columnas: [ | 
| 214 | { | 214 | { | 
| 215 | propiedad: 'ID', | 215 | propiedad: 'ID', | 
| 216 | nombre: 'Código', | 216 | nombre: 'Código', | 
| 217 | filtro: { | 217 | filtro: { | 
| 218 | nombre: 'rellenarDigitos', | 218 | nombre: 'rellenarDigitos', | 
| 219 | parametro: 3 | 219 | parametro: 3 | 
| 220 | } | 220 | } | 
| 221 | }, | 221 | }, | 
| 222 | { | 222 | { | 
| 223 | propiedad: 'NOM', | 223 | propiedad: 'NOM', | 
| 224 | nombre: 'Nombre' | 224 | nombre: 'Nombre' | 
| 225 | } | 225 | } | 
| 226 | ], | 226 | ], | 
| 227 | titulo: 'Búsqueda de zonas', | 227 | titulo: 'Búsqueda de zonas', | 
| 228 | size: 'md' | 228 | size: 'md' | 
| 229 | }; | 229 | }; | 
| 230 | focaModalService.modal(parametrosModal).then( | 230 | focaModalService.modal(parametrosModal).then( | 
| 231 | function (zona) { | 231 | function (zona) { | 
| 232 | $scope.cliente.zona = zona; | 232 | $scope.cliente.zona = zona; | 
| 233 | $timeout(function () { | 233 | $timeout(function () { | 
| 234 | $scope.focused = 6; | 234 | $scope.focused = 6; | 
| 235 | }); | 235 | }); | 
| 236 | }, function () { | 236 | }, function () { | 
| 237 | // funcion ejecutada cuando se cancela el modal | 237 | // funcion ejecutada cuando se cancela el modal | 
| 238 | }); | 238 | }); | 
| 239 | } | 239 | } | 
| 240 | }; | 240 | }; | 
| 241 | $scope.seleccionarActividad = function (key) { | 241 | $scope.seleccionarActividad = function (key) { | 
| 242 | if (key === 13) { | 242 | if (key === 13) { | 
| 243 | var parametrosModal = { | 243 | var parametrosModal = { | 
| 244 | searchText: $scope.cliente.actividad.NOM, | 244 | searchText: $scope.cliente.actividad.NOM, | 
| 245 | query: '/actividad', | 245 | query: '/actividad', | 
| 246 | columnas: [ | 246 | columnas: [ | 
| 247 | { | 247 | { | 
| 248 | propiedad: 'ID', | 248 | propiedad: 'ID', | 
| 249 | nombre: 'Código', | 249 | nombre: 'Código', | 
| 250 | filtro: { | 250 | filtro: { | 
| 251 | nombre: 'rellenarDigitos', | 251 | nombre: 'rellenarDigitos', | 
| 252 | parametro: 3 | 252 | parametro: 3 | 
| 253 | } | 253 | } | 
| 254 | }, | 254 | }, | 
| 255 | { | 255 | { | 
| 256 | propiedad: 'NOM', | 256 | propiedad: 'NOM', | 
| 257 | nombre: 'Nombre' | 257 | nombre: 'Nombre' | 
| 258 | } | 258 | } | 
| 259 | ], | 259 | ], | 
| 260 | titulo: 'Búsqueda de actividades', | 260 | titulo: 'Búsqueda de actividades', | 
| 261 | size: 'md' | 261 | size: 'md' | 
| 262 | }; | 262 | }; | 
| 263 | focaModalService.modal(parametrosModal).then( | 263 | focaModalService.modal(parametrosModal).then( | 
| 264 | function (actividad) { | 264 | function (actividad) { | 
| 265 | $scope.cliente.actividad = actividad; | 265 | $scope.cliente.actividad = actividad; | 
| 266 | $timeout(function () { | 266 | $timeout(function () { | 
| 267 | $scope.focused = 7; | 267 | $scope.focused = 7; | 
| 268 | }); | 268 | }); | 
| 269 | }, function () { | 269 | }, function () { | 
| 270 | // funcion ejecutada cuando se cancela el modal | 270 | // funcion ejecutada cuando se cancela el modal | 
| 271 | }); | 271 | }); | 
| 272 | } | 272 | } | 
| 273 | }; | 273 | }; | 
| 274 | $scope.seleccionarCobrador = function (key) { | 274 | $scope.seleccionarCobrador = function (key) { | 
| 275 | if (key === 13) { | 275 | if (key === 13) { | 
| 276 | var parametrosModal = { | 276 | var parametrosModal = { | 
| 277 | searchText: $scope.cliente.cobrador.NOM, | 277 | searchText: $scope.cliente.cobrador.NOM, | 
| 278 | query: '/cobrador', | 278 | query: '/cobrador', | 
| 279 | columnas: [ | 279 | columnas: [ | 
| 280 | { | 280 | { | 
| 281 | propiedad: 'NUM', | 281 | propiedad: 'NUM', | 
| 282 | nombre: 'Código' | 282 | nombre: 'Código' | 
| 283 | }, | 283 | }, | 
| 284 | { | 284 | { | 
| 285 | propiedad: 'NOM', | 285 | propiedad: 'NOM', | 
| 286 | nombre: 'Nombre' | 286 | nombre: 'Nombre' | 
| 287 | } | 287 | } | 
| 288 | ], | 288 | ], | 
| 289 | titulo: 'Búsqueda de cobradores', | 289 | titulo: 'Búsqueda de cobradores', | 
| 290 | size: 'md' | 290 | size: 'md' | 
| 291 | }; | 291 | }; | 
| 292 | focaModalService.modal(parametrosModal).then( | 292 | focaModalService.modal(parametrosModal).then( | 
| 293 | function (cobrador) { | 293 | function (cobrador) { | 
| 294 | $scope.cliente.cobrador = cobrador; | 294 | $scope.cliente.cobrador = cobrador; | 
| 295 | }, function () { | 295 | }, function () { | 
| 296 | // funcion ejecutada cuando se cancela el modal | 296 | // funcion ejecutada cuando se cancela el modal | 
| 297 | }); | 297 | }); | 
| 298 | } | 298 | } | 
| 299 | }; | 299 | }; | 
| 300 | $scope.seleccionarVendedor = function (key) { | 300 | $scope.seleccionarVendedor = function (key) { | 
| 301 | if (key === 13) { | 301 | if (key === 13) { | 
| 302 | var parametrosModal = { | 302 | var parametrosModal = { | 
| 303 | titulo: 'Búsqueda vendedores', | 303 | titulo: 'Búsqueda vendedores', | 
| 304 | query: '/vendedor', | 304 | query: '/vendedor', | 
| 305 | columnas: [ | 305 | columnas: [ | 
| 306 | { | 306 | { | 
| 307 | propiedad: 'NUM', | 307 | propiedad: 'NUM', | 
| 308 | nombre: 'Código', | 308 | nombre: 'Código', | 
| 309 | filtro: { | 309 | filtro: { | 
| 310 | nombre: 'rellenarDigitos', | 310 | nombre: 'rellenarDigitos', | 
| 311 | parametro: 3 | 311 | parametro: 3 | 
| 312 | } | 312 | } | 
| 313 | }, | 313 | }, | 
| 314 | { | 314 | { | 
| 315 | propiedad: 'NOM', | 315 | propiedad: 'NOM', | 
| 316 | nombre: 'Nombre' | 316 | nombre: 'Nombre' | 
| 317 | } | 317 | } | 
| 318 | ], | 318 | ], | 
| 319 | size: 'md' | 319 | size: 'md' | 
| 320 | }; | 320 | }; | 
| 321 | focaModalService.modal(parametrosModal).then( | 321 | focaModalService.modal(parametrosModal).then( | 
| 322 | function (vendedor) { | 322 | function (vendedor) { | 
| 323 | console.log("vendedor seleccionado => ", vendedor); | ||
| 324 | $scope.vendedor = vendedor; | 323 | $scope.vendedor = vendedor; | 
| 325 | }, function () { | 324 | }, function () { | 
| 326 | // funcion ejecutada cuando se cancela el modal | 325 | // funcion ejecutada cuando se cancela el modal | 
| 327 | }); | 326 | }); | 
| 328 | } | 327 | } | 
| 329 | }; | 328 | }; | 
| 330 | $scope.seleccionarIva = function (key) { | 329 | $scope.seleccionarIva = function (key) { | 
| 331 | if (key === 13) { | 330 | if (key === 13) { | 
| 332 | var parametrosModal = { | 331 | var parametrosModal = { | 
| 333 | query: '/iva', | 332 | query: '/iva', | 
| 334 | searchText: $scope.cliente.iva.NOMBRE, | 333 | searchText: $scope.cliente.iva.NOMBRE, | 
| 335 | columnas: [ | 334 | columnas: [ | 
| 336 | { | 335 | { | 
| 337 | propiedad: 'ID', | 336 | propiedad: 'ID', | 
| 338 | nombre: 'Código', | 337 | nombre: 'Código', | 
| 339 | filtro: { | 338 | filtro: { | 
| 340 | nombre: 'rellenarDigitos', | 339 | nombre: 'rellenarDigitos', | 
| 341 | parametro: 3 | 340 | parametro: 3 | 
| 342 | } | 341 | } | 
| 343 | }, | 342 | }, | 
| 344 | { | 343 | { | 
| 345 | propiedad: 'NOMBRE', | 344 | propiedad: 'NOMBRE', | 
| 346 | nombre: 'Nombre' | 345 | nombre: 'Nombre' | 
| 347 | } | 346 | } | 
| 348 | ], | 347 | ], | 
| 349 | titulo: 'Búsqueda de responsabilidad ante el IVA', | 348 | titulo: 'Búsqueda de responsabilidad ante el IVA', | 
| 350 | size: 'md' | 349 | size: 'md' | 
| 351 | }; | 350 | }; | 
| 352 | focaModalService.modal(parametrosModal).then( | 351 | focaModalService.modal(parametrosModal).then( | 
| 353 | function (iva) { | 352 | function (iva) { | 
| 354 | if (iva) { | 353 | if (iva) { | 
| 355 | delete $scope.cliente.tipoFactura.NOMBRE; | 354 | delete $scope.cliente.tipoFactura.NOMBRE; | 
| 356 | } | 355 | } | 
| 357 | $scope.cliente.iva = iva; | 356 | $scope.cliente.iva = iva; | 
| 358 | $timeout(function () { | 357 | $timeout(function () { | 
| 359 | $scope.focused = 12; | 358 | $scope.focused = 12; | 
| 360 | }); | 359 | }); | 
| 361 | }, function () { | 360 | }, function () { | 
| 362 | // funcion ejecutada cuando se cancela el modal | 361 | // funcion ejecutada cuando se cancela el modal | 
| 363 | }); | 362 | }); | 
| 364 | } | 363 | } | 
| 365 | }; | 364 | }; | 
| 366 | $scope.seleccionarTipoFactura = function (key) { | 365 | $scope.seleccionarTipoFactura = function (key) { | 
| 367 | 366 | ||
| 368 | if ($scope.cliente.iva.NOMBRE == '') { | 367 | if ($scope.cliente.iva.NOMBRE == '') { | 
| 369 | focaModalService.alert('Seleccione una responsabilidad ante el IVA'); | 368 | focaModalService.alert('Seleccione una responsabilidad ante el IVA'); | 
| 370 | return; | 369 | return; | 
| 371 | } | 370 | } | 
| 372 | 371 | ||
| 373 | if (key === 13) { | 372 | if (key === 13) { | 
| 374 | var datos; | 373 | var datos; | 
| 375 | if ($scope.cliente.iva.ID == 1) { | 374 | if ($scope.cliente.iva.ID == 1) { | 
| 376 | datos = [ | 375 | datos = [ | 
| 377 | { | 376 | { | 
| 378 | ID: 'A', | 377 | ID: 'A', | 
| 379 | NOMBRE: 'Factura A' | 378 | NOMBRE: 'Factura A' | 
| 380 | }, | 379 | }, | 
| 381 | { | 380 | { | 
| 382 | ID: 'M', | 381 | ID: 'M', | 
| 383 | NOMBRE: 'Factura M' | 382 | NOMBRE: 'Factura M' | 
| 384 | }, | 383 | }, | 
| 385 | { | 384 | { | 
| 386 | ID: 'R', | 385 | ID: 'R', | 
| 387 | NOMBRE: 'Remito' | 386 | NOMBRE: 'Remito' | 
| 388 | } | 387 | } | 
| 389 | ]; | 388 | ]; | 
| 390 | } else { | 389 | } else { | 
| 391 | datos = [ | 390 | datos = [ | 
| 392 | { | 391 | { | 
| 393 | ID: 'B', | 392 | ID: 'B', | 
| 394 | NOMBRE: 'Factura B' | 393 | NOMBRE: 'Factura B' | 
| 395 | }, | 394 | }, | 
| 396 | { | 395 | { | 
| 397 | ID: 'R', | 396 | ID: 'R', | 
| 398 | NOMBRE: 'Remito' | 397 | NOMBRE: 'Remito' | 
| 399 | } | 398 | } | 
| 400 | ]; | 399 | ]; | 
| 401 | } | 400 | } | 
| 402 | focaModalService.modal({ | 401 | focaModalService.modal({ | 
| 403 | titulo: 'Seleccionar Factura', | 402 | titulo: 'Seleccionar Factura', | 
| 404 | data: datos, | 403 | data: datos, | 
| 405 | size: 'md', | 404 | size: 'md', | 
| 406 | columnas: [ | 405 | columnas: [ | 
| 407 | { | 406 | { | 
| 408 | propiedad: 'ID', | 407 | propiedad: 'ID', | 
| 409 | NOMBRE: 'Codigo' | 408 | NOMBRE: 'Codigo' | 
| 410 | }, | 409 | }, | 
| 411 | { | 410 | { | 
| 412 | propiedad: 'NOMBRE', | 411 | propiedad: 'NOMBRE', | 
| 413 | NOMBRE: 'Factura' | 412 | NOMBRE: 'Factura' | 
| 414 | } | 413 | } | 
| 415 | ], | 414 | ], | 
| 416 | }).then(function (res) { | 415 | }).then(function (res) { | 
| 417 | $scope.cliente.tipoFactura = res; | 416 | $scope.cliente.tipoFactura = res; | 
| 418 | }); | 417 | }); | 
| 419 | } | 418 | } | 
| 420 | }; | 419 | }; | 
| 421 | $scope.pasarCampoCuit = function (numeroCuit) { | 420 | $scope.pasarCampoCuit = function (numeroCuit) { | 
| 422 | if (numeroCuit === 1 && $scope.cliente.cuit1.length === 2) { | 421 | if (numeroCuit === 1 && $scope.cliente.cuit1.length === 2) { | 
| 423 | $scope.cuitActivo = 2; | 422 | $scope.cuitActivo = 2; | 
| 424 | } else if (numeroCuit === 2 && $scope.cliente.cuit2.length === 8) { | 423 | } else if (numeroCuit === 2 && $scope.cliente.cuit2.length === 8) { | 
| 425 | $scope.cuitActivo = 3; | 424 | $scope.cuitActivo = 3; | 
| 426 | } | 425 | } | 
| 427 | }; | 426 | }; | 
| 428 | $scope.seleccionarTipoComprobante = function (key) { | 427 | $scope.seleccionarTipoComprobante = function (key) { | 
| 429 | if (key === 13) { | 428 | if (key === 13) { | 
| 430 | var parametrosModal = { | 429 | var parametrosModal = { | 
| 431 | searchText: $scope.cliente.tipoComprobante.NOMBRE, | 430 | searchText: $scope.cliente.tipoComprobante.NOMBRE, | 
| 432 | query: '/tipo-comprobante', | 431 | query: '/tipo-comprobante', | 
| 433 | columnas: [ | 432 | columnas: [ | 
| 434 | { | 433 | { | 
| 435 | propiedad: 'ID', | 434 | propiedad: 'ID', | 
| 436 | nombre: 'Código' | 435 | nombre: 'Código' | 
| 437 | }, | 436 | }, | 
| 438 | { | 437 | { | 
| 439 | propiedad: 'NOMBRE', | 438 | propiedad: 'NOMBRE', | 
| 440 | nombre: 'Nombre' | 439 | nombre: 'Nombre' | 
| 441 | } | 440 | } | 
| 442 | ], | 441 | ], | 
| 443 | titulo: 'Búsqueda de tipos de comprobante', | 442 | titulo: 'Búsqueda de tipos de comprobante', | 
| 444 | size: 'md' | 443 | size: 'md' | 
| 445 | }; | 444 | }; | 
| 446 | focaModalService.modal(parametrosModal).then( | 445 | focaModalService.modal(parametrosModal).then( | 
| 447 | function (tipoComprobante) { | 446 | function (tipoComprobante) { | 
| 448 | $scope.cliente.tipoComprobante = tipoComprobante; | 447 | $scope.cliente.tipoComprobante = tipoComprobante; | 
| 449 | $timeout(function () { | 448 | $timeout(function () { | 
| 450 | $scope.focused = 17; | 449 | $scope.focused = 17; | 
| 451 | }); | 450 | }); | 
| 452 | }, function () { | 451 | }, function () { | 
| 453 | // funcion ejecutada cuando se cancela el modal | 452 | // funcion ejecutada cuando se cancela el modal | 
| 454 | }); | 453 | }); | 
| 455 | } | 454 | } | 
| 456 | }; | 455 | }; | 
| 457 | $scope.seleccionarFormaPago = function (key) { | 456 | $scope.seleccionarFormaPago = function (key) { | 
| 458 | if (key === 13) { | 457 | if (key === 13) { | 
| 459 | var parametrosModal = { | 458 | var parametrosModal = { | 
| 460 | searchText: $scope.cliente.formaPago.NOMBRE, | 459 | searchText: $scope.cliente.formaPago.NOMBRE, | 
| 461 | query: '/forma-pago', | 460 | query: '/forma-pago', | 
| 462 | columnas: [ | 461 | columnas: [ | 
| 463 | { | 462 | { | 
| 464 | propiedad: 'ID', | 463 | propiedad: 'ID', | 
| 465 | nombre: 'Código', | 464 | nombre: 'Código', | 
| 466 | filtro: { | 465 | filtro: { | 
| 467 | nombre: 'rellenarDigitos', | 466 | nombre: 'rellenarDigitos', | 
| 468 | parametro: 3 | 467 | parametro: 3 | 
| 469 | } | 468 | } | 
| 470 | }, | 469 | }, | 
| 471 | { | 470 | { | 
| 472 | propiedad: 'NOMBRE', | 471 | propiedad: 'NOMBRE', | 
| 473 | nombre: 'Nombre' | 472 | nombre: 'Nombre' | 
| 474 | } | 473 | } | 
| 475 | ], | 474 | ], | 
| 476 | titulo: 'Búsqueda de formas de pago', | 475 | titulo: 'Búsqueda de formas de pago', | 
| 477 | size: 'md' | 476 | size: 'md' | 
| 478 | }; | 477 | }; | 
| 479 | focaModalService.modal(parametrosModal).then( | 478 | focaModalService.modal(parametrosModal).then( | 
| 480 | function (formaPago) { | 479 | function (formaPago) { | 
| 481 | $scope.cliente.formaPago = formaPago; | 480 | $scope.cliente.formaPago = formaPago; | 
| 482 | }, function () { | 481 | }, function () { | 
| 483 | // funcion ejecutada cuando se cancela el modal | 482 | // funcion ejecutada cuando se cancela el modal | 
| 484 | }); | 483 | }); | 
| 485 | } | 484 | } | 
| 486 | }; | 485 | }; | 
| 487 | 486 | ||
| 488 | function crearCopia() { | 487 | function crearCopia() { | 
| 489 | var cliente = angular.copy($scope.cliente); | 488 | var cliente = angular.copy($scope.cliente); | 
| 490 | cliente.COD = cliente.codigo; | 489 | cliente.COD = cliente.codigo; | 
| 491 | cliente.CPO = cliente.CPO; | 490 | cliente.CPO = cliente.CPO; | 
| 492 | cliente.PCX = parseInt(cliente.provincia.ID); | 491 | cliente.PCX = parseInt(cliente.provincia.ID); | 
| 493 | cliente.LOX = parseInt(cliente.localidad.ID); | 492 | cliente.LOX = parseInt(cliente.localidad.ID); | 
| 494 | cliente.LOC = cliente.localidad.NOMBRE; | 493 | cliente.LOC = cliente.localidad.NOMBRE; | 
| 495 | cliente.PCI = cliente.provincia.NOMBRE; | 494 | cliente.PCI = cliente.provincia.NOMBRE; | 
| 496 | cliente.IVA = cliente.iva.ID; | 495 | cliente.IVA = cliente.iva.ID; | 
| 497 | cliente.ACT = cliente.actividad.ID; | 496 | cliente.ACT = cliente.actividad.ID; | 
| 498 | cliente.ZON = (parseInt(cliente.zona.ID)).toString(); | 497 | cliente.ZON = (parseInt(cliente.zona.ID)).toString(); | 
| 499 | cliente.TIP = cliente.tipoFactura.ID; | 498 | cliente.TIP = cliente.tipoFactura.ID; | 
| 500 | cliente.TCO = cliente.tipoComprobante.ID; | 499 | cliente.TCO = cliente.tipoComprobante.ID; | 
| 501 | cliente.FPA = cliente.formaPago.ID; | 500 | cliente.FPA = cliente.formaPago.ID; | 
| 502 | cliente.VEN = $scope.vendedor.id; | 501 | cliente.VEN = $scope.vendedor.id; | 
| 503 | cliente.CUIT = `${cliente.cuit1}-${cliente.cuit2}-${cliente.cuit3}`; | 502 | cliente.CUIT = `${cliente.cuit1}-${cliente.cuit2}-${cliente.cuit3}`; | 
| 504 | cliente.idCobrador = cliente.cobrador.ID; | 503 | cliente.idCobrador = cliente.cobrador.ID; | 
| 505 | 504 | ||
| 506 | delete cliente.codigo; | 505 | delete cliente.codigo; | 
| 507 | delete cliente.provincia; | 506 | delete cliente.provincia; | 
| 508 | delete cliente.localidad; | 507 | delete cliente.localidad; | 
| 509 | delete cliente.iva; | 508 | delete cliente.iva; | 
| 510 | delete cliente.actividad; | 509 | delete cliente.actividad; | 
| 511 | delete cliente.zona; | 510 | delete cliente.zona; | 
| 512 | delete cliente.tipoFactura; | 511 | delete cliente.tipoFactura; | 
| 513 | delete cliente.tipoComprobante; | 512 | delete cliente.tipoComprobante; | 
| 514 | delete cliente.formaPago; | 513 | delete cliente.formaPago; | 
| 515 | delete cliente.cobrador; | 514 | delete cliente.cobrador; | 
| 516 | delete cliente.cuit1; | 515 | delete cliente.cuit1; | 
| 517 | delete cliente.cuit2; | 516 | delete cliente.cuit2; | 
| 518 | delete cliente.cuit3; | 517 | delete cliente.cuit3; | 
| 519 | delete cliente.vendedor; | 518 | delete cliente.vendedor; | 
| 520 | 519 | ||
| 521 | return cliente; | 520 | return cliente; | 
| 522 | } | 521 | } | 
| 523 | function validateEmails(emails) { | 522 | function validateEmails(emails) { | 
| 524 | 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,}))$/; | 523 | 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,}))$/; | 
| 525 | var arr = emails.split(','); | 524 | var arr = emails.split(','); | 
| 526 | var result = true; | 525 | var result = true; | 
| 527 | arr.forEach(function (email) { | 526 | arr.forEach(function (email) { | 
| 528 | var val = String(email).trim().toLowerCase(); | 527 | var val = String(email).trim().toLowerCase(); | 
| 529 | if (!re.test(val)) result = false; | 528 | if (!re.test(val)) result = false; | 
| 530 | }); | 529 | }); | 
| 531 | return result; | 530 | return result; | 
| 532 | } | 531 | } | 
| 533 | 532 | ||
| 534 | }]); | 533 | }]); |