Commit 9ed9207ba4e1bdc5050d16fd4b426a44011c9ffe

Authored by Luigi
1 parent 04844c0a54
Exists in master

espacio 2

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