Commit d9670980e8ee7f93e3f188eeec908eaa96ecc272
1 parent
c505dd56e6
Exists in
master
enviar recibo por mail al guardar
Showing
2 changed files
with
65 additions
and
24 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -97,7 +97,8 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
97 | 97 | FEC: $scope.fecha.toISOString().slice(0, 19).replace('T', ' '), |
98 | 98 | IMP: Math.abs($scope.facturaTabla[i].IPA), |
99 | 99 | RES: 0,//caja de tesorería |
100 | - SUBM: 0 | |
100 | + SUBM: 0, | |
101 | + NCU: $scope.facturaTabla[i].NCU | |
101 | 102 | }; |
102 | 103 | cuerpos.push(cuerpoFactura); |
103 | 104 | } |
... | ... | @@ -105,7 +106,6 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
105 | 106 | for (var j = 0; j < $scope.cobrosTabla.length; j++) { |
106 | 107 | |
107 | 108 | var efectivo = $scope.cobrosTabla[j].tipo === 'Efectivo' ? true : false; |
108 | - | |
109 | 109 | var cuerpoCobros = { |
110 | 110 | CYV: 'V', |
111 | 111 | TIP: 'C', |
... | ... | @@ -222,13 +222,39 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
222 | 222 | OBS: 'RC: ' + $scope.comprobante + '-' + $scope.fecha.toLocaleDateString(), |
223 | 223 | DAT1: 'C', |
224 | 224 | CLI: $scope.cobranza.cliente.COD |
225 | - } | |
225 | + }, | |
226 | + cliente: $scope.cobranza.cliente | |
226 | 227 | }; |
227 | - focaCrearCobranzaService.guardarCobranza(cobranza).then( | |
228 | + //COPIO cobranzaMail Y A cobranza LE ELIMINO EL VALOR NCU DE LOS CUERPOS | |
229 | + var cobranzaMail = angular.copy(cobranza); | |
230 | + cobranza.cuerpo = cobranza.cuerpo.map(function(c) { | |
231 | + if (c.NCU) delete c.NCU; | |
232 | + return c; | |
233 | + }); | |
234 | + | |
235 | + | |
236 | + focaCrearCobranzaService | |
237 | + .guardarCobranza(cobranza) | |
238 | + .then( | |
228 | 239 | function(result) { |
240 | + var cliente = angular.copy($scope.cobranza.cliente); | |
229 | 241 | focaBotoneraLateralService.endGuardar(true); |
230 | 242 | $scope.saveLoading = false; |
231 | - focaModalService.alert('Cobranza guardada con éxito'); | |
243 | + | |
244 | + focaModalService | |
245 | + .prompt('Ingrese los emails separados por coma para enviar comprobante', | |
246 | + cliente.MAIL) | |
247 | + .then(function(res) { | |
248 | + return Promise.all([ | |
249 | + focaCrearCobranzaService | |
250 | + .enviarComprobantePorMail(res, cobranzaMail), | |
251 | + focaCrearCobranzaService | |
252 | + .actualizarEmail(res, cliente.COD) | |
253 | + ]); | |
254 | + }) | |
255 | + .then(function() { | |
256 | + focaModalService.alert('Mensaje enviado correctamente'); | |
257 | + }); | |
232 | 258 | |
233 | 259 | focaSeguimientoService.guardarPosicion( |
234 | 260 | 'Cobranza', |
... | ... | @@ -300,30 +326,37 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
300 | 326 | }; |
301 | 327 | |
302 | 328 | $scope.seleccionarCliente = function() { |
303 | - var modalInstance = $uibModal.open( | |
304 | - { | |
305 | - ariaLabelledBy: 'Busqueda de Cliente', | |
306 | - templateUrl: 'foca-busqueda-cliente-modal.html', | |
307 | - controller: 'focaBusquedaClienteModalController', | |
308 | - size: 'lg', | |
309 | - resolve: { | |
310 | - vendedor: function(){ return null; } | |
329 | + var parametrosModal = { | |
330 | + titulo: 'Búsqueda de Clientes', | |
331 | + query: '/cliente/listar', | |
332 | + columnas: [ | |
333 | + { | |
334 | + nombre: 'Código', | |
335 | + propiedad: 'COD', | |
336 | + filtro: { | |
337 | + nombre: 'rellenarDigitos', | |
338 | + parametro: 5 | |
339 | + } | |
340 | + }, | |
341 | + { | |
342 | + nombre: 'Nombre', | |
343 | + propiedad: 'NOM' | |
344 | + }, | |
345 | + { | |
346 | + nombre: 'CUIT', | |
347 | + propiedad: 'CUIT' | |
311 | 348 | } |
312 | - } | |
313 | - ); | |
314 | - modalInstance.result.then( | |
349 | + ], | |
350 | + tipo: 'POST', | |
351 | + json: {'nombreOCuit': ''} | |
352 | + }; | |
353 | + focaModalService.modal(parametrosModal).then( | |
315 | 354 | function(cliente) { |
316 | 355 | $scope.$broadcast('addCabecera', { |
317 | 356 | label: 'Cliente:', |
318 | - valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom | |
357 | + valor: $filter('rellenarDigitos')(cliente.COD, 5) + ' - ' + cliente.NOM | |
319 | 358 | }); |
320 | - $scope.cobranza.cliente = { | |
321 | - COD: cliente.cod, | |
322 | - CUIT: cliente.cuit, | |
323 | - NOM: cliente.nom | |
324 | - }; | |
325 | - }, function() { | |
326 | - | |
359 | + $scope.cobranza.cliente = cliente; | |
327 | 360 | } |
328 | 361 | ); |
329 | 362 | }; |
src/js/service.js
... | ... | @@ -16,6 +16,14 @@ angular.module('focaCrearCobranza') |
16 | 16 | getCobradorById: function(id) { |
17 | 17 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id); |
18 | 18 | }, |
19 | + enviarComprobantePorMail: function(mail, data) { | |
20 | + return $http.post(API_ENDPOINT.URL + '/mail/comprobante', | |
21 | + {receiver: mail, comprobante: data}); | |
22 | + }, | |
23 | + actualizarEmail: function(mail, idCliente) { | |
24 | + return $http.post(API_ENDPOINT.URL + '/cliente/update/email', | |
25 | + {mail: mail, id: idCliente}); | |
26 | + }, | |
19 | 27 | getBotonera: function(idCobrador) { |
20 | 28 | var result = [ |
21 | 29 | { |