Commit 9ab132e96ba19fd02bb3ed3f25ea5c38b7ab5e8e

Authored by Marcelo Puebla
1 parent 117ea07ec6
Exists in master

Agegada logica para buscar y seleccionar un producto.

Showing 2 changed files with 106 additions and 20 deletions   Show diff stats
src/js/controller.js
... ... @@ -430,12 +430,87 @@ angular.module('focaCrearFactura').controller('facturaController', [
430 430  
431 431 });
432 432 $scope.botoneraProductos.push({
433   - label: 'BusquedaProductos',
  433 + label: 'Busqueda Productos',
434 434 image: 'buscarProductos.png'
435 435 });
436 436 });
437 437 }
438 438  
  439 + $scope.seleccionarBusquedaProductos = function () {
  440 +
  441 + var modalInstance = $uibModal.open(
  442 + {
  443 + ariaLabelledBy: 'Busqueda de Productos',
  444 + templateUrl: 'modal-busqueda-productos.html',
  445 + controller: 'modalBusquedaProductosCtrl',
  446 + resolve: {
  447 + parametroProducto: {
  448 + idLista: null,
  449 + cotizacion: $scope.factura.cotizacion.VENDEDOR,
  450 + simbolo: $scope.factura.cotizacion.moneda.SIMBOLO,
  451 + buscarTodos: true
  452 + }
  453 + },
  454 + size: 'lg'
  455 + }
  456 + );
  457 +
  458 + modalInstance.result
  459 + .then(function (producto) {
  460 +
  461 + console.log(producto);
  462 + var articulo = {
  463 + TIP: $scope.factura.cliente.tipoFactura,
  464 + TCO: 'FT',
  465 + SUC: parseInt($scope.puntoVenta),
  466 + ORD: $scope.articulosFiltro().length + 1,
  467 + SEC: producto.sector,
  468 + ART: producto.codigo,
  469 + RUB: producto.CodRub,
  470 + DES: producto.descripcionLarga,
  471 + PUN: producto.precio, // TODO
  472 + IVA: producto.IMPIVA, // TODO
  473 + NET: 0, // TODO
  474 + NEX: 0, // TODO
  475 + IMI: producto.ImpInt, // TODO
  476 + IMI2: producto.ImpInt2, // TODO
  477 + IMI3: producto.ImpInt3, // TODO
  478 + PUT: producto.PreNet, // TODO
  479 + SUR: 0,
  480 + PLA: $scope.factura.vendedor.NplVen,
  481 + LUG: $scope.factura.vendedor.LugVen,
  482 + LEG: $scope.factura.vendedor.CodVen,
  483 + TUR: $scope.factura.vendedor.TurVen,
  484 + ORDEN_PRECOMPRA: '',
  485 + ESC: producto.tipoFactura === 'L' ? 1 : 0,
  486 + CMF: 0,
  487 + PTA: 0,
  488 + IVS: 0,
  489 + TIVA: 0,
  490 + CON: 0,
  491 + SINO: '',
  492 + ORD_TRA: 0,
  493 + IMP_DESP: 0,
  494 + PCD: 0,
  495 + RTO: ''
  496 + };
  497 + // crearFacturaService.setearDespachoOcupado({
  498 + // surtidor: articulo.SUR,
  499 + // producto: articulo.PRO,
  500 + // carga: articulo.CAR
  501 + // })
  502 + // .then(function () {
  503 + $scope.factura.articulosFactura.push(articulo);
  504 + $scope.cambioEdit(articulo, 'cantidad');
  505 + // })
  506 + // .catch(function (err) {
  507 +
  508 + // focaModalService.alert('El despacho esta en uso');
  509 + // });
  510 + })
  511 + .catch(function (e) { console.log(e); });
  512 + };
  513 +
439 514 function crearFuncionesProductos(producto) {
440 515  
441 516 $scope[nombreFuncion(producto.DetArt)] = function () {
... ... @@ -668,6 +743,34 @@ angular.module('focaCrearFactura').controller('facturaController', [
668 743 }
669 744 }
670 745  
  746 + $scope.cambioEdit = function (articulo, propiedad) {
  747 + if (propiedad === 'cantidad') {
  748 + articulo.editCantidad = true;
  749 + }
  750 + };
  751 +
  752 + $scope.editarArticulo = function (key, articulo, tmpCantidad) {
  753 + if (key === 13) {
  754 + if (!articulo.cantidad && !tmpCantidad) {
  755 + focaModalService.alert('Los valores deben ser al menos 1');
  756 + return;
  757 + } else if (tmpCantidad === '0') {
  758 + focaModalService.alert('Esta ingresando un producto con valor 0');
  759 + } else if (articulo.cantidad < 0) {
  760 + focaModalService.alert('Los valores no pueden ser negativos');
  761 + return;
  762 + }
  763 + articulo.CAN = parseInt(tmpCantidad);
  764 + $scope.getTotal();
  765 + articulo.editCantidad = false;
  766 + }
  767 + };
  768 +
  769 + $scope.cancelarEditar = function (articulo) {
  770 + $scope.tmpCantidad = articulo.CAN;
  771 + articulo.editCantidad = false;
  772 + };
  773 +
671 774 function actualizarCabeceraMoneda(cotizacion) {
672 775  
673 776 $scope.factura.articulosFactura.forEach(function (art) {
src/views/factura.html
... ... @@ -88,9 +88,9 @@
88 88 foca-tipo-input
89 89 min="1"
90 90 foca-focus="articulo.editCantidad"
91   - ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);"
  91 + ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad);"
92 92 esc-key="cancelarEditar(articulo)"
93   - ng-focus="selectFocus($event); tmpCantidad = articulo.CAN; tmpPrecio = articulo.PUN"
  93 + ng-focus="selectFocus($event); tmpCantidad = articulo.CAN;"
94 94 teclado-virtual
95 95 >
96 96 <i
... ... @@ -101,25 +101,8 @@
101 101 </i>
102 102 </td>
103 103 <td class="col text-right">
104   - <input
105   - ng-show="articulo.editPrecio"
106   - ng-model="tmpPrecio"
107   - class="form-control"
108   - foca-tipo-input
109   - min="1"
110   - step="0.0001"
111   - foca-focus="articulo.editPrecio"
112   - ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);"
113   - esc-key="cancelarEditar(articulo)"
114   - ng-focus="selectFocus($event);
115   - tmpCantidad = articulo.CAN;
116   - tmpPrecio = articulo.PUN"
117   - teclado-virtual
118   - >
119 104 <i
120 105 class="selectable"
121   - ng-click="cambioEdit(articulo, 'precio')"
122   - ng-hide="articulo.editPrecio"
123 106 ng-bind="articulo.PUN | number: 4">
124 107 </i>
125 108 </td>