Commit 8edbf83107d74486cac03eab3212298982d50fe5

Authored by Mauricio Cattafi
1 parent 81fcc1d481
Exists in ultimos_despachos

se agrega validación de pago electronico

Showing 2 changed files with 437 additions and 379 deletions   Show diff stats
src/js/controller.js
... ... @@ -3,10 +3,11 @@ angular.module('focaCrearFactura').controller('facturaController', [
3 3 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService',
4 4 '$localStorage', 'APP', 'focaLoginService',
5 5 function (
6   - $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService,
7   - crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP, loginServ) {
  6 + $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService,
  7 + crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP, loginServ) {
8 8  
9 9 config();
  10 + var loopPagoElectronico = false;
10 11  
11 12 function config() {
12 13 $scope.tmpCantidad = '0';
... ... @@ -82,34 +83,34 @@ angular.module('focaCrearFactura').controller('facturaController', [
82 83  
83 84 if (APP === 'facturador') {
84 85 crearFacturaService
85   - .getVendedorPlayaById(loginServ.getLoginData().vendedorPlaya)
86   - .then(function (res) {
87   -
88   - validarPlanillaVendedor(res.data)
89   - .then(function () {
90   -
91   - $scope.$broadcast('addCabecera', {
92   - label: 'Vendedor:',
93   - valor: $filter('rellenarDigitos')(res.data.CodVen, 3) +
94   - ' - ' +
95   - res.data.NomVen
96   - });
97   - $scope.$broadcast('addCabecera', {
98   - label: 'Planilla:',
99   - valor: res.data.NplVen
100   - });
101   -
102   - $scope.factura.vendedor = res.data;
103   - $scope.inicial.vendedor = res.data;
  86 + .getVendedorPlayaById(loginServ.getLoginData().vendedorPlaya)
  87 + .then(function (res) {
104 88  
105   - getProductosByPlanilla(res.data.NplVen);
106   - })
107   - .catch(function (err) {
108   - console.log(err);
109   - focaModalService.alert('Ocurrió un error al intentar recuperar' +
110   - 'el vendedor logeado');
111   - });
112   - });
  89 + validarPlanillaVendedor(res.data)
  90 + .then(function () {
  91 +
  92 + $scope.$broadcast('addCabecera', {
  93 + label: 'Vendedor:',
  94 + valor: $filter('rellenarDigitos')(res.data.CodVen, 3) +
  95 + ' - ' +
  96 + res.data.NomVen
  97 + });
  98 + $scope.$broadcast('addCabecera', {
  99 + label: 'Planilla:',
  100 + valor: res.data.NplVen
  101 + });
  102 +
  103 + $scope.factura.vendedor = res.data;
  104 + $scope.inicial.vendedor = res.data;
  105 +
  106 + getProductosByPlanilla(res.data.NplVen);
  107 + })
  108 + .catch(function (err) {
  109 + console.log(err);
  110 + focaModalService.alert('Ocurrió un error al intentar recuperar' +
  111 + 'el vendedor logeado');
  112 + });
  113 + });
113 114 }
114 115 }
115 116  
... ... @@ -122,7 +123,8 @@ angular.module('focaCrearFactura').controller('facturaController', [
122 123  
123 124 $scope.seleccionarFormaDePago = function () {
124 125  
125   - if (!validarGuardar()) return;
  126 + if (!validarGuardar())
  127 + return;
126 128  
127 129 if ($scope.factura.formaPago === 2) {
128 130 $scope.crearFactura();
... ... @@ -130,169 +132,222 @@ angular.module('focaCrearFactura').controller('facturaController', [
130 132 }
131 133  
132 134 var modalInstance = $uibModal.open(
133   - {
134   - templateUrl: 'modal-forma-pago.html',
135   - controller: 'focaModalFormaPagoController',
136   - resolve: {
137   - parametros: function () {
138   - return {
139   - importe: $scope.getTotal()
140   - };
  135 + {
  136 + templateUrl: 'modal-forma-pago.html',
  137 + controller: 'focaModalFormaPagoController',
  138 + resolve: {
  139 + parametros: function () {
  140 + return {
  141 + importe: $scope.getTotal()
  142 + };
  143 + },
141 144 },
142   - },
143   - size: 'lg',
144   - }
  145 + size: 'lg',
  146 + }
145 147 );
146 148 modalInstance.result
147   - .then(function (data) {
  149 + .then(function (data) {
148 150  
149   - if (data.tipo === 'tarjeta') {
150   - $scope.factura.formaPago = 4;
151   - } else {
152   - $scope.factura.formaPago = 1;
153   - }
  151 + if (data.tipo === 'tarjeta') {
  152 + $scope.factura.formaPago = 4;
  153 + } else {
  154 + $scope.factura.formaPago = 1;
  155 + }
154 156  
155   - $scope.crearFactura(data);
156   - })
  157 + $scope.crearFactura(data);
  158 + })
157 159 .catch(function (e) { console.error(e); });
158 160 };
159 161  
160   - $scope.crearFactura = function (formaPago) {
  162 + $scope.guardarFactura = function (formaPago) {
  163 +
  164 + if (typeof formaPago.tipo !== 'undefined') {
  165 + switch (formaPago.tipo) {
  166 + case 'tarjeta':
  167 + $scope.factura.formaPago = 4;
  168 + break;
  169 + case 'electronico':
  170 + $scope.factura.formaPago = 5;
  171 + break;
  172 + }
  173 + }
161 174  
162   - var save = {
163   - factura: {
164   -
165   - BONIF: 0,
166   - CLI: $scope.factura.cliente.COD,
167   - CUI: $scope.factura.cliente.CUIT,
168   - CTA: $scope.factura.cliente.COD,
169   - DC1: '',
170   - DC2: '',
171   - DE1: '',
172   - DOM: $scope.factura.cliente.DOM,
173   - FACAUT: 0,
174   - DTO: 0,
175   - FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'),
176   - FEC_ANT: '19000101',
177   - FPA: $scope.factura.formaPago,
178   - IDEXCEPCION: 0,
179   - IDLP: $scope.factura.cliente.MOD.trim() || 0,
180   - IDPERSONERIA: 0,
181   - IMI: getImporte('IMI'),
182   - IMI2: getImporte('IMI2'),
183   - IMI3: getImporte('IMI3'),
184   - IMP_LEY: 0,
185   - IRI: getImporte('IVA'),
186   - IRS: 0,
187   - LEG: '',
188   - LUG: $scope.factura.vendedor.LugVen,
189   - MK_M: 0,
190   - NEE: getImporte('NEX'),
191   - NET: getImporte('NET'),
192   - NFI: '',
193   - NNP: 0,
194   - NOM: $scope.factura.cliente.NOM,
195   - OPE: $scope.factura.vendedor.CodVen,
196   - PAG: $scope.getTotal(),
197   - PER: 0,
198   - PER_IVA: 0,
199   - PLA: $scope.factura.vendedor.NplVen,
200   - PRO: '',
201   - REC_ANT: 0,
202   - SUC: parseInt($scope.puntoVenta),
203   - TCA: 1,
204   - TCO: 'FT',
205   - TFI: '',
206   - TIP: $scope.factura.cliente.TIP,
207   - TIV: $scope.factura.cliente.IVA,
208   - TOT: $scope.getTotal(),
209   - TUR: $scope.factura.vendedor.TurVen,
210   - VEN: $scope.factura.vendedor.CodVen,
211   - VTO_CLI: '',
212   - ZON: 1, // TODO: ZON DE APAREMP
213   - OBSERVACIONES: $scope.factura.observaciones
214   - },
215   - cuerpo: $scope.articulosFiltro(),
216   - despachos: $scope.factura.despachos,
217   - formaPago: formaPago
218   - };
  175 + return new Promise(function (resolve, reject) {
  176 + var save = {
  177 + factura: {
  178 +
  179 + BONIF: 0,
  180 + CLI: $scope.factura.cliente.COD,
  181 + CUI: $scope.factura.cliente.CUIT,
  182 + CTA: $scope.factura.cliente.COD,
  183 + DC1: '',
  184 + DC2: '',
  185 + DE1: '',
  186 + DOM: $scope.factura.cliente.DOM,
  187 + FACAUT: 0,
  188 + DTO: 0,
  189 + FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'),
  190 + FEC_ANT: '19000101',
  191 + FPA: $scope.factura.formaPago,
  192 + IDEXCEPCION: 0,
  193 + IDLP: $scope.factura.cliente.MOD.trim() || 0,
  194 + IDPERSONERIA: 0,
  195 + IMI: getImporte('IMI'),
  196 + IMI2: getImporte('IMI2'),
  197 + IMI3: getImporte('IMI3'),
  198 + IMP_LEY: 0,
  199 + IRI: getImporte('IVA'),
  200 + IRS: 0,
  201 + LEG: '',
  202 + LUG: $scope.factura.vendedor.LugVen,
  203 + MK_M: 0,
  204 + NEE: getImporte('NEX'),
  205 + NET: getImporte('NET'),
  206 + NFI: '',
  207 + NNP: 0,
  208 + NOM: $scope.factura.cliente.NOM,
  209 + OPE: $scope.factura.vendedor.CodVen,
  210 + PAG: $scope.getTotal(),
  211 + PER: 0,
  212 + PER_IVA: 0,
  213 + PLA: $scope.factura.vendedor.NplVen,
  214 + PRO: '',
  215 + REC_ANT: 0,
  216 + SUC: parseInt($scope.puntoVenta),
  217 + TCA: 1,
  218 + TCO: 'FT',
  219 + TFI: '',
  220 + TIP: $scope.factura.cliente.TIP,
  221 + TIV: $scope.factura.cliente.IVA,
  222 + TOT: $scope.getTotal(),
  223 + TUR: $scope.factura.vendedor.TurVen,
  224 + VEN: $scope.factura.vendedor.CodVen,
  225 + VTO_CLI: '',
  226 + ZON: 1, // TODO: ZON DE APAREMP
  227 + OBSERVACIONES: $scope.factura.observaciones
  228 + },
  229 + cuerpo: $scope.articulosFiltro(),
  230 + despachos: $scope.factura.despachos,
  231 + formaPago: formaPago
  232 + };
219 233  
220   - crearFacturaService.guardarFactura(save).then(function () {
  234 + crearFacturaService.guardarFactura(save).then(function (res) {
  235 + console.log(res.data);
  236 + $scope.factura.ID_COMPV2 = res.data.ID_COMPV2;
  237 + resolve();
  238 + }).catch(function (err) {
  239 + console.error(err);
  240 + reject();
  241 + });
  242 + });
  243 + };
221 244  
222   - focaBotoneraLateralService.endGuardar(true);
  245 + $scope.crearFactura = function (formaPago) {
223 246  
  247 + $scope.guardarFactura(formaPago).then(function () {
  248 + focaBotoneraLateralService.endGuardar(true);
224 249 focaModalService.alert('Comprobante guardado con éxito');
225   -
226 250 config();
227   -
228   - }).catch(function (err) {
  251 + }, function () {
229 252 focaModalService.alert('Hubo un error al guardar la factura');
230   - console.error(err);
231 253 });
  254 + };
232 255  
  256 + $scope.$on('guardarFactura', function (events, args) {
  257 + console.log('recibe guardarFactura');
  258 + $scope.guardarFactura(args).then(function() {
  259 + $rootScope.$broadcast('callbackGuardarFactura', true);
  260 + loopPagoElectronico = true;
  261 + $scope.consultarPagoElectronico();
  262 + }, function() {
  263 + $rootScope.$broadcast('callbackGuardarFactura', false);
  264 + });
  265 + });
  266 +
  267 + $scope.$on('cancelarPagoElectronico', function (events, args) {
  268 + loopPagoElectronico = false;
  269 + });
  270 +
  271 + $scope.consultarPagoElectronico = function () {
  272 + if (!loopPagoElectronico) {
  273 + return;
  274 + }
  275 +
  276 + crearFacturaService.consultarPagoElectronico({ ID_COMPV2: $scope.factura.ID_COMPV2 }).then(function(resp) {
  277 + console.log(resp.data);
  278 + if (resp.data.EST > 0) {
  279 + $rootScope.$broadcast('callbackGuardarFactura', resp.data);
  280 + } else {
  281 + setTimeout(function() {
  282 + $scope.consultarPagoElectronico();
  283 + }, 2000);
  284 + }
  285 + }).catch(function() {
  286 + $rootScope.$broadcast('callbackGuardarFactura', false);
  287 + })
233 288 };
234 289  
235 290 $scope.seleccionarCliente = function () {
236 291  
237 292 var modalInstance = $uibModal.open(
238   - {
239   - ariaLabelledBy: 'Busqueda de Cliente',
240   - templateUrl: 'foca-busqueda-cliente-modal.html',
241   - controller: 'focaBusquedaClienteModalController',
242   - resolve: {
243   - parametros: function () {
244   - return {
  293 + {
  294 + ariaLabelledBy: 'Busqueda de Cliente',
  295 + templateUrl: 'foca-busqueda-cliente-modal.html',
  296 + controller: 'focaBusquedaClienteModalController',
  297 + resolve: {
  298 + parametros: function () {
  299 + return {
245 300 vendedor: function () { return null; },
246 301 cobrador: function () { return null; }
247   - };
248   - }
249   - },
250   - size: 'lg'
251   - }
  302 + };
  303 + }
  304 + },
  305 + size: 'lg'
  306 + }
252 307 );
253 308 modalInstance.result.then(
254   - function (cliente) {
255   - var modalInstance = $uibModal.open(
256   - {
257   - templateUrl: 'modal-estado-cuenta.html',
258   - controller: 'focaModalEstadoCuentaController',
259   - size: 'lg',
260   - resolve: {
261   - parametros: function () {
262   - return {
263   - idCliente: cliente.COD,
264   - nombreCliente: cliente.NOM
265   - };
266   - },
267   - }
268   - }
269   - );
270   - modalInstance.result
271   - .then(function (data) {
  309 + function (cliente) {
  310 + var modalInstance = $uibModal.open(
  311 + {
  312 + templateUrl: 'modal-estado-cuenta.html',
  313 + controller: 'focaModalEstadoCuentaController',
  314 + size: 'lg',
  315 + resolve: {
  316 + parametros: function () {
  317 + return {
  318 + idCliente: cliente.COD,
  319 + nombreCliente: cliente.NOM
  320 + };
  321 + },
  322 + }
  323 + }
  324 + );
  325 + modalInstance.result
  326 + .then(function (data) {
  327 +
  328 + $scope.factura.formaPago = data.formaDePago;
  329 + $scope.factura.cliente = cliente;
  330 +
  331 + getNumeroFactura(cliente.TIP);
272 332  
273   - $scope.factura.formaPago = data.formaDePago;
274   - $scope.factura.cliente = cliente;
275   -
276   - getNumeroFactura(cliente.TIP);
277   -
278   - $scope.$broadcast('addCabecera', {
279   - label: 'Cliente:',
280   - valor: $filter('rellenarDigitos')(cliente.COD, 3) +
281   - ' - ' + cliente.NOM
282   - });
  333 + $scope.$broadcast('addCabecera', {
  334 + label: 'Cliente:',
  335 + valor: $filter('rellenarDigitos')(cliente.COD, 3) +
  336 + ' - ' + cliente.NOM
  337 + });
283 338  
284 339 $filter('filter')($scope.botonera,
285 340 { label: 'Cliente' })[0].checked = true;
286 341  
287   - $scope.$broadcast('addCabecera', {
288   - label: 'Forma de pago: ',
289   - valor: data.tipo
290   - });
291   - })
292   - .catch($scope.seleccionarCliente);
  342 + $scope.$broadcast('addCabecera', {
  343 + label: 'Forma de pago: ',
  344 + valor: data.tipo
  345 + });
  346 + })
  347 + .catch($scope.seleccionarCliente);
293 348  
294   - }, function () {
295   - }
  349 + }, function () {
  350 + }
296 351 );
297 352  
298 353 };
... ... @@ -318,39 +373,39 @@ angular.module('focaCrearFactura').controller('facturaController', [
318 373 size: 'md'
319 374 };
320 375 focaModalService.modal(parametrosModal).then(
321   - function (vendedor) {
  376 + function (vendedor) {
322 377  
323   - indicarPassword(vendedor)
324   - .then(function () {
325   - validarPlanillaVendedor(vendedor)
  378 + indicarPassword(vendedor)
326 379 .then(function () {
327   -
328   - $filter('filter')($scope.botonera, {
329   - label: 'Vendedor'
330   - })[0].checked = true;
331   -
332   - $scope.$broadcast('addCabecera', {
333   - label: 'Vendedor:',
334   - valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) +
335   - ' - ' +
336   - vendedor.NomVen
337   - });
338   - $scope.$broadcast('addCabecera', {
339   - label: 'Planilla:',
340   - valor: vendedor.NplVen
341   - });
342   -
343   - $scope.factura.vendedor = vendedor;
344   -
345   - getProductosByPlanilla(vendedor.NplVen);
  380 + validarPlanillaVendedor(vendedor)
  381 + .then(function () {
  382 +
  383 + $filter('filter')($scope.botonera, {
  384 + label: 'Vendedor'
  385 + })[0].checked = true;
  386 +
  387 + $scope.$broadcast('addCabecera', {
  388 + label: 'Vendedor:',
  389 + valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) +
  390 + ' - ' +
  391 + vendedor.NomVen
  392 + });
  393 + $scope.$broadcast('addCabecera', {
  394 + label: 'Planilla:',
  395 + valor: vendedor.NplVen
  396 + });
  397 +
  398 + $scope.factura.vendedor = vendedor;
  399 +
  400 + getProductosByPlanilla(vendedor.NplVen);
  401 + })
  402 + .catch($scope.seleccionarVendedor);
346 403 })
347   - .catch($scope.seleccionarVendedor);
348   - })
349   - .catch(function (err) {
350   - console.error(err);
351   - });
  404 + .catch(function (err) {
  405 + console.error(err);
  406 + });
352 407  
353   - }, function () { }
  408 + }, function () { }
354 409 );
355 410 };
356 411  
... ... @@ -372,49 +427,49 @@ angular.module('focaCrearFactura').controller('facturaController', [
372 427 size: 'md'
373 428 };
374 429 focaModalService.modal(parametrosModal).then(
375   - function (moneda) {
  430 + function (moneda) {
376 431  
377   - if (moneda.ID !== 1) {
378   - $scope.abrirModalCotizacion(moneda);
379   - return;
380   - }
  432 + if (moneda.ID !== 1) {
  433 + $scope.abrirModalCotizacion(moneda);
  434 + return;
  435 + }
381 436  
382   - crearRemitoService.getCotizacionByIdMoneda(1)
383   - .then(function (res) {
  437 + crearRemitoService.getCotizacionByIdMoneda(1)
  438 + .then(function (res) {
384 439  
385   - var cotizacionPArgentino = res.data[0].cotizaciones[0];
386   - cotizacionPArgentino.moneda = moneda;
  440 + var cotizacionPArgentino = res.data[0].cotizaciones[0];
  441 + cotizacionPArgentino.moneda = moneda;
387 442  
388   - actualizarCabeceraMoneda(cotizacionPArgentino);
  443 + actualizarCabeceraMoneda(cotizacionPArgentino);
389 444  
390   - $scope.remito.cotizacion = cotizacionPArgentino;
391   - });
392   - }, function () {
  445 + $scope.remito.cotizacion = cotizacionPArgentino;
  446 + });
  447 + }, function () {
393 448  
394   - }
  449 + }
395 450 );
396 451 };
397 452  
398 453 $scope.abrirModalCotizacion = function (moneda) {
399 454 var modalInstance = $uibModal.open(
400   - {
401   - ariaLabelledBy: 'Busqueda de Cotización',
402   - templateUrl: 'modal-cotizacion.html',
403   - controller: 'focaModalCotizacionController',
404   - size: 'lg',
405   - resolve: { idMoneda: function () { return moneda.ID; } }
406   - }
  455 + {
  456 + ariaLabelledBy: 'Busqueda de Cotización',
  457 + templateUrl: 'modal-cotizacion.html',
  458 + controller: 'focaModalCotizacionController',
  459 + size: 'lg',
  460 + resolve: { idMoneda: function () { return moneda.ID; } }
  461 + }
407 462 );
408 463 modalInstance.result.then(
409   - function (cotizacion) {
  464 + function (cotizacion) {
410 465  
411   - cotizacion.moneda = moneda;
412   - actualizarCabeceraMoneda(cotizacion);
413   - $scope.factura.cotizacion = cotizacion;
  466 + cotizacion.moneda = moneda;
  467 + actualizarCabeceraMoneda(cotizacion);
  468 + $scope.factura.cotizacion = cotizacion;
414 469  
415   - }, function () {
  470 + }, function () {
416 471  
417   - }
  472 + }
418 473 );
419 474 };
420 475  
... ... @@ -427,10 +482,10 @@ angular.module('focaCrearFactura').controller('facturaController', [
427 482 };
428 483  
429 484 focaModalService
430   - .prompt(observacion)
431   - .then(function (observaciones) {
432   - $scope.factura.observaciones = observaciones;
433   - });
  485 + .prompt(observacion)
  486 + .then(function (observaciones) {
  487 + $scope.factura.observaciones = observaciones;
  488 + });
434 489 };
435 490  
436 491 $scope.articulosFiltro = function () {
... ... @@ -458,19 +513,19 @@ angular.module('focaCrearFactura').controller('facturaController', [
458 513 }
459 514  
460 515 crearFacturaService
461   - .setearDespachoDesocupado({
462   - surtidor: $scope.factura.despachos[index].SUR,
463   - producto: $scope.factura.despachos[index].PRO,
464   - carga: $scope.factura.despachos[index].CAR,
465   - planilla: $scope.factura.despachos[index].PLA
466   - })
467   - .then(function () {
468   - articulo.desactivado = true;
469   - $scope.factura.despachos.splice(index, 1);
470   - })
471   - .catch(function () {
472   - focaModalService.alert('Hubo un error al desasociar este despacho');
473   - });
  516 + .setearDespachoDesocupado({
  517 + surtidor: $scope.factura.despachos[index].SUR,
  518 + producto: $scope.factura.despachos[index].PRO,
  519 + carga: $scope.factura.despachos[index].CAR,
  520 + planilla: $scope.factura.despachos[index].PLA
  521 + })
  522 + .then(function () {
  523 + articulo.desactivado = true;
  524 + $scope.factura.despachos.splice(index, 1);
  525 + })
  526 + .catch(function () {
  527 + focaModalService.alert('Hubo un error al desasociar este despacho');
  528 + });
474 529 };
475 530  
476 531 //Recibe aviso si el teclado está en uso
... ... @@ -532,65 +587,65 @@ angular.module('focaCrearFactura').controller('facturaController', [
532 587 }
533 588  
534 589 var modalInstance = $uibModal.open(
535   - {
536   - ariaLabelledBy: 'Busqueda de Productos',
537   - templateUrl: 'modal-busqueda-productos.html',
538   - controller: 'modalBusquedaProductosCtrl',
539   - resolve: {
540   - parametroProducto: {
541   - idLista: null,
542   - cotizacion: $scope.factura.cotizacion.VENDEDOR,
543   - simbolo: $scope.factura.cotizacion.moneda.SIMBOLO,
544   - buscarTodos: true
545   - }
546   - },
547   - size: 'lg'
548   - }
  590 + {
  591 + ariaLabelledBy: 'Busqueda de Productos',
  592 + templateUrl: 'modal-busqueda-productos.html',
  593 + controller: 'modalBusquedaProductosCtrl',
  594 + resolve: {
  595 + parametroProducto: {
  596 + idLista: null,
  597 + cotizacion: $scope.factura.cotizacion.VENDEDOR,
  598 + simbolo: $scope.factura.cotizacion.moneda.SIMBOLO,
  599 + buscarTodos: true
  600 + }
  601 + },
  602 + size: 'lg'
  603 + }
549 604 );
550 605  
551 606 modalInstance.result
552   - .then(function (producto) {
553   -
554   - var articulo = {
555   - TIP: $scope.factura.cliente.TIP,
556   - TCO: 'FT',
557   - SUC: parseInt($scope.puntoVenta),
558   - ORD: $scope.articulosFiltro().length + 1,
559   - SEC: producto.sector,
560   - ART: producto.codigo,
561   - RUB: producto.CodRub,
562   - DES: producto.descripcionLarga,
563   - PUN: producto.precio,
564   - IVA: producto.IMPIVA,
565   - NET: producto.IvaCO !== 0 ? parseFloat(producto.neto) : 0,
566   - NEX: producto.IvaCO === 0 ? parseFloat(producto.neto) : 0,
567   - IMI: producto.ImpInt,
568   - IMI2: producto.ImpInt2,
569   - IMI3: producto.ImpInt3,
570   - PUT: producto.precio,
571   - SUR: 0,
572   - PLA: $scope.factura.vendedor.NplVen,
573   - LUG: $scope.factura.vendedor.LugVen,
574   - LEG: $scope.factura.vendedor.CodVen,
575   - TUR: $scope.factura.vendedor.TurVen,
576   - ORDEN_PRECOMPRA: '',
577   - ESC: producto.tipoFactura === 'L' ? 1 : 0,
578   - CMF: 0,
579   - PTA: 0,
580   - IVS: 0,
581   - TIVA: 0,
582   - CON: 0,
583   - SINO: '',
584   - ORD_TRA: 0,
585   - IMP_DESP: 0,
586   - PCD: 0,
587   - RTO: '',
588   - };
  607 + .then(function (producto) {
  608 +
  609 + var articulo = {
  610 + TIP: $scope.factura.cliente.TIP,
  611 + TCO: 'FT',
  612 + SUC: parseInt($scope.puntoVenta),
  613 + ORD: $scope.articulosFiltro().length + 1,
  614 + SEC: producto.sector,
  615 + ART: producto.codigo,
  616 + RUB: producto.CodRub,
  617 + DES: producto.descripcionLarga,
  618 + PUN: producto.precio,
  619 + IVA: producto.IMPIVA,
  620 + NET: producto.IvaCO !== 0 ? parseFloat(producto.neto) : 0,
  621 + NEX: producto.IvaCO === 0 ? parseFloat(producto.neto) : 0,
  622 + IMI: producto.ImpInt,
  623 + IMI2: producto.ImpInt2,
  624 + IMI3: producto.ImpInt3,
  625 + PUT: producto.precio,
  626 + SUR: 0,
  627 + PLA: $scope.factura.vendedor.NplVen,
  628 + LUG: $scope.factura.vendedor.LugVen,
  629 + LEG: $scope.factura.vendedor.CodVen,
  630 + TUR: $scope.factura.vendedor.TurVen,
  631 + ORDEN_PRECOMPRA: '',
  632 + ESC: producto.tipoFactura === 'L' ? 1 : 0,
  633 + CMF: 0,
  634 + PTA: 0,
  635 + IVS: 0,
  636 + TIVA: 0,
  637 + CON: 0,
  638 + SINO: '',
  639 + ORD_TRA: 0,
  640 + IMP_DESP: 0,
  641 + PCD: 0,
  642 + RTO: '',
  643 + };
  644 +
  645 + $scope.factura.articulosFactura.push(articulo);
  646 + $scope.cambioEdit(articulo, 'cantidad');
589 647  
590   - $scope.factura.articulosFactura.push(articulo);
591   - $scope.cambioEdit(articulo, 'cantidad');
592   -
593   - })
  648 + })
594 649 .catch(function (e) { console.error(e); });
595 650 };
596 651  
... ... @@ -602,18 +657,18 @@ angular.module('focaCrearFactura').controller('facturaController', [
602 657 }
603 658  
604 659 var modalInstance = $uibModal.open(
605   - {
606   - templateUrl: 'modal-ultimos-despachos.html',
607   - controller: 'ultimosDespachosController',
608   - resolve: {
609   - parametros: function () {
610   - return {
611   - planilla: $scope.factura.vendedor.NplVen,
612   - };
613   - }
614   - },
615   - size: 'md'
616   - }
  660 + {
  661 + templateUrl: 'modal-ultimos-despachos.html',
  662 + controller: 'ultimosDespachosController',
  663 + resolve: {
  664 + parametros: function () {
  665 + return {
  666 + planilla: $scope.factura.vendedor.NplVen,
  667 + };
  668 + }
  669 + },
  670 + size: 'md'
  671 + }
617 672 );
618 673  
619 674 modalInstance.result.then(function (producto) {
... ... @@ -660,20 +715,20 @@ angular.module('focaCrearFactura').controller('facturaController', [
660 715 producto: producto.despachos[0].PRO,
661 716 carga: producto.despachos[0].CAR
662 717 })
663   - .then(function () {
664   - $scope.factura.articulosFactura.push(articulo);
665   - $scope.factura.despachos.push(producto.despachos[0]);
666   - })
667   - .catch(function (err) {
  718 + .then(function () {
  719 + $scope.factura.articulosFactura.push(articulo);
  720 + $scope.factura.despachos.push(producto.despachos[0]);
  721 + })
  722 + .catch(function (err) {
668 723  
669   - console.error(err);
670   - focaModalService.alert('El despacho está en uso');
671   - });
  724 + console.error(err);
  725 + focaModalService.alert('El despacho está en uso');
  726 + });
672 727  
673 728 })
674   - .catch(function (err) {
675   - console.error(err);
676   - });
  729 + .catch(function (err) {
  730 + console.error(err);
  731 + });
677 732  
678 733 };
679 734  
... ... @@ -687,20 +742,20 @@ angular.module('focaCrearFactura').controller('facturaController', [
687 742 }
688 743  
689 744 var modalInstance = $uibModal.open(
690   - {
691   - templateUrl: 'modal-combustibles.html',
692   - controller: 'focaModalCombustiblesController',
693   - resolve: {
694   - parametros: function () {
695   - return {
696   - despachos: producto.despachos,
697   - nombreProducto: producto.DetArt,
698   - topDespachos: $scope.topDespachos
699   - };
700   - }
701   - },
702   - size: 'md'
703   - }
  745 + {
  746 + templateUrl: 'modal-combustibles.html',
  747 + controller: 'focaModalCombustiblesController',
  748 + resolve: {
  749 + parametros: function () {
  750 + return {
  751 + despachos: producto.despachos,
  752 + nombreProducto: producto.DetArt,
  753 + topDespachos: $scope.topDespachos
  754 + };
  755 + }
  756 + },
  757 + size: 'md'
  758 + }
704 759 );
705 760  
706 761 modalInstance.result.then(function (despacho) {
... ... @@ -747,20 +802,20 @@ angular.module('focaCrearFactura').controller('facturaController', [
747 802 producto: despacho.PRO,
748 803 carga: despacho.CAR
749 804 })
750   - .then(function () {
751   - $scope.factura.articulosFactura.push(articulo);
752   - $scope.factura.despachos.push(despacho);
753   - })
754   - .catch(function (err) {
  805 + .then(function () {
  806 + $scope.factura.articulosFactura.push(articulo);
  807 + $scope.factura.despachos.push(despacho);
  808 + })
  809 + .catch(function (err) {
755 810  
756   - console.error(err);
757   - focaModalService.alert('El despacho está en uso');
758   - });
  811 + console.error(err);
  812 + focaModalService.alert('El despacho está en uso');
  813 + });
759 814  
760 815 })
761   - .catch(function (err) {
762   - console.error(err);
763   - });
  816 + .catch(function (err) {
  817 + console.error(err);
  818 + });
764 819  
765 820 };
766 821 }
... ... @@ -781,23 +836,23 @@ angular.module('focaCrearFactura').controller('facturaController', [
781 836  
782 837 function openPrompt() {
783 838 return focaModalService
784   - .prompt({
785   - titulo: 'Indique Contraseña',
786   - value: '',
787   - tipo: 'password'
788   - })
789   - .then(function (contraseña) {
  839 + .prompt({
  840 + titulo: 'Indique Contraseña',
  841 + value: '',
  842 + tipo: 'password'
  843 + })
  844 + .then(function (contraseña) {
790 845  
791   - if (contraseña !== vendedor.ClaVen.trim()) {
  846 + if (contraseña !== vendedor.ClaVen.trim()) {
792 847  
793   - focaModalService.alert('Clave incorrecta').then(function () {
794   - openPrompt(vendedor);
795   - });
796   - } else {
797   - resolve();
798   - }
799   - })
800   - .catch(reject);
  848 + focaModalService.alert('Clave incorrecta').then(function () {
  849 + openPrompt(vendedor);
  850 + });
  851 + } else {
  852 + resolve();
  853 + }
  854 + })
  855 + .catch(reject);
801 856 }
802 857  
803 858 openPrompt();
... ... @@ -809,24 +864,24 @@ angular.module('focaCrearFactura').controller('facturaController', [
809 864 return new Promise(function (resolve, reject) {
810 865  
811 866 crearFacturaService
812   - .validarPlanillaVendedor(vendedor.CodVen.toString().trim())
813   - .then(function (res) {
  867 + .validarPlanillaVendedor(vendedor.CodVen.toString().trim())
  868 + .then(function (res) {
814 869  
815   - if (!res.data.length) {
  870 + if (!res.data.length) {
816 871  
817   - focaModalService
818   - .alert('No se encontró planilla abierta para el vendedor')
819   - .then(reject);
  872 + focaModalService
  873 + .alert('No se encontró planilla abierta para el vendedor')
  874 + .then(reject);
820 875  
821   - } else {
822   - resolve();
823   - }
  876 + } else {
  877 + resolve();
  878 + }
824 879  
825   - })
826   - .catch(function (err) {
827   - console.log(err);
828   - reject();
829   - });
  880 + })
  881 + .catch(function (err) {
  882 + console.log(err);
  883 + reject();
  884 + });
830 885 });
831 886 }
832 887  
... ... @@ -847,8 +902,8 @@ angular.module('focaCrearFactura').controller('facturaController', [
847 902  
848 903 if (confirmacion) {
849 904 focaModalService.confirm(
850   - '¿Está seguro de que desea salir? Se perderán todos los datos cargados.'
851   - ).then(function (data) {
  905 + '¿Está seguro de que desea salir? Se perderán todos los datos cargados.'
  906 + ).then(function (data) {
852 907 if (data) {
853 908 $location.path('/');
854 909 }
... ... @@ -872,12 +927,12 @@ angular.module('focaCrearFactura').controller('facturaController', [
872 927 $scope.cabeceras.push({
873 928 label: 'Fecha cotizacion:',
874 929 valor: $filter('date')(factura.cotizacion.FECHA,
875   - 'dd/MM/yyyy')
  930 + 'dd/MM/yyyy')
876 931 });
877 932 $scope.cabeceras.push({
878 933 label: 'Cotizacion:',
879 934 valor: $filter('number')(factura.cotizacion.VENDEDOR,
880   - '2')
  935 + '2')
881 936 });
882 937 }
883 938  
... ... @@ -889,7 +944,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
889 944 $scope.cabeceras.push({
890 945 label: 'Cliente:',
891 946 valor: $filter('rellenarDigitos')(factura.cliente.COD, 3) + ' - ' +
892   - factura.cliente.NOM
  947 + factura.cliente.NOM
893 948 });
894 949  
895 950 $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true;
... ... @@ -1013,14 +1068,14 @@ angular.module('focaCrearFactura').controller('facturaController', [
1013 1068 function getNumeroFactura(tipoFactura) {
1014 1069  
1015 1070 crearRemitoService.getNumeroRemito(tipoFactura).then(
1016   - function (res) {
1017   - $scope.puntoVenta = rellenar(res.data.sucursal, 4);
1018   - $scope.comprobante = rellenar(res.data.numeroRemito, 8);
1019   - },
1020   - function (err) {
1021   - focaModalService.alert('La terminal no está configurada correctamente');
1022   - console.info(err);
1023   - }
  1071 + function (res) {
  1072 + $scope.puntoVenta = rellenar(res.data.sucursal, 4);
  1073 + $scope.comprobante = rellenar(res.data.numeroRemito, 8);
  1074 + },
  1075 + function (err) {
  1076 + focaModalService.alert('La terminal no está configurada correctamente');
  1077 + console.info(err);
  1078 + }
1024 1079 );
1025 1080 }
1026 1081 }
... ... @@ -6,6 +6,9 @@ angular.module('focaCrearFactura')
6 6 guardarFactura: function (factura) {
7 7 return $http.post(route + '/factura/guardar', factura);
8 8 },
  9 + consultarPagoElectronico: function (datos) {
  10 + return $http.post(route + '/factura/consultar-pago-electronico', datos);
  11 + },
9 12 getParametros: function () {
10 13 return $http.get(API_ENDPOINT.URL + '/parametros/factura');
11 14 },