Commit d012bdbe99b90bb4f4e7b6647e7c15ff28096946

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'develop'

Master(mpuebla)

See merge request !8
src/js/controller.js
... ... @@ -12,6 +12,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
12 12 $scope.tmpCantidad = Number;
13 13 $scope.tmpPrecio = Number;
14 14 $scope.botonera = crearFacturaService.getBotonera();
  15 + $scope.botoneraProductos = [];
15 16 $scope.isNumber = angular.isNumber;
16 17 $scope.datepickerAbierto = false;
17 18 $scope.show = false;
... ... @@ -190,7 +191,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
190 191  
191 192 }).catch(function (err) {
192 193 focaModalService.alert('Hubo un error al guardar la factura');
193   - console.log(err);
  194 + console.error(err);
194 195 });
195 196  
196 197 };
... ... @@ -297,7 +298,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
297 298 .catch($scope.seleccionarVendedor);
298 299 })
299 300 .catch(function (err) {
300   - console.log(err)
  301 + console.error(err);
301 302 });
302 303  
303 304 }, function () { }
... ... @@ -332,7 +333,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
332 333 crearRemitoService.getCotizacionByIdMoneda(1)
333 334 .then(function (res) {
334 335  
335   - cotizacionPArgentino = res.data[0].cotizaciones[0];
  336 + var cotizacionPArgentino = res.data[0].cotizaciones[0];
336 337 cotizacionPArgentino.moneda = moneda;
337 338  
338 339 actualizarCabeceraMoneda(cotizacionPArgentino);
... ... @@ -421,21 +422,99 @@ angular.module('focaCrearFactura').controller('facturaController', [
421 422 function getProductosByPlanilla(numeroPlanilla) {
422 423  
423 424 crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function (res) {
424   -
  425 + $scope.botoneraProductos.length = 0;
425 426 res.data.forEach(function (producto) {
426 427  
427   - $scope.botonera.push({
  428 + $scope.botoneraProductos.push({
428 429 label: producto.DetArt,
429   - image: 'productos.png'
  430 + image: 'buscarProductos.png'
430 431 });
431 432  
432 433  
433 434 crearFuncionesProductos(producto);
434 435  
435 436 });
  437 + $scope.botoneraProductos.push({
  438 + label: 'Busqueda Productos',
  439 + image: 'buscarProductos.png'
  440 + });
436 441 });
437 442 }
438 443  
  444 + $scope.seleccionarBusquedaProductos = function () {
  445 +
  446 + var modalInstance = $uibModal.open(
  447 + {
  448 + ariaLabelledBy: 'Busqueda de Productos',
  449 + templateUrl: 'modal-busqueda-productos.html',
  450 + controller: 'modalBusquedaProductosCtrl',
  451 + resolve: {
  452 + parametroProducto: {
  453 + idLista: null,
  454 + cotizacion: $scope.factura.cotizacion.VENDEDOR,
  455 + simbolo: $scope.factura.cotizacion.moneda.SIMBOLO,
  456 + buscarTodos: true
  457 + }
  458 + },
  459 + size: 'lg'
  460 + }
  461 + );
  462 +
  463 + modalInstance.result
  464 + .then(function (producto) {
  465 +
  466 + var articulo = {
  467 + TIP: $scope.factura.cliente.tipoFactura,
  468 + TCO: 'FT',
  469 + SUC: parseInt($scope.puntoVenta),
  470 + ORD: $scope.articulosFiltro().length + 1,
  471 + SEC: producto.sector,
  472 + ART: producto.codigo,
  473 + RUB: producto.CodRub,
  474 + DES: producto.descripcionLarga,
  475 + PUN: producto.precio, // TODO
  476 + IVA: producto.IMPIVA, // TODO
  477 + NET: 0, // TODO
  478 + NEX: 0, // TODO
  479 + IMI: producto.ImpInt, // TODO
  480 + IMI2: producto.ImpInt2, // TODO
  481 + IMI3: producto.ImpInt3, // TODO
  482 + PUT: producto.PreNet, // TODO
  483 + SUR: 0,
  484 + PLA: $scope.factura.vendedor.NplVen,
  485 + LUG: $scope.factura.vendedor.LugVen,
  486 + LEG: $scope.factura.vendedor.CodVen,
  487 + TUR: $scope.factura.vendedor.TurVen,
  488 + ORDEN_PRECOMPRA: '',
  489 + ESC: producto.tipoFactura === 'L' ? 1 : 0,
  490 + CMF: 0,
  491 + PTA: 0,
  492 + IVS: 0,
  493 + TIVA: 0,
  494 + CON: 0,
  495 + SINO: '',
  496 + ORD_TRA: 0,
  497 + IMP_DESP: 0,
  498 + PCD: 0,
  499 + RTO: ''
  500 + };
  501 + // crearFacturaService.setearDespachoOcupado({
  502 + // surtidor: articulo.SUR,
  503 + // producto: articulo.PRO,
  504 + // carga: articulo.CAR
  505 + // })
  506 + // .then(function () {
  507 + $scope.factura.articulosFactura.push(articulo);
  508 + $scope.cambioEdit(articulo, 'cantidad');
  509 + // })
  510 + // .catch(function (err) {
  511 +
  512 + // focaModalService.alert('El despacho esta en uso');
  513 + // });
  514 + })
  515 + .catch(function (e) { console.error(e); });
  516 + };
  517 +
439 518 function crearFuncionesProductos(producto) {
440 519  
441 520 $scope[nombreFuncion(producto.DetArt)] = function () {
... ... @@ -454,7 +533,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
454 533 return {
455 534 despachos: producto.despachos,
456 535 nombreProducto: producto.DetArt
457   - }
  536 + };
458 537 }
459 538 },
460 539 size: 'md'
... ... @@ -487,7 +566,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
487 566 LEG: $scope.factura.vendedor.CodVen,
488 567 TUR: $scope.factura.vendedor.TurVen,
489 568 ORDEN_PRECOMPRA: '',
490   - ESC: producto.tipoFactura == 'L' ? 1 : 0,
  569 + ESC: producto.tipoFactura === 'L' ? 1 : 0,
491 570 CMF: 0,
492 571 PTA: 0,
493 572 IVS: 0,
... ... @@ -511,12 +590,13 @@ angular.module('focaCrearFactura').controller('facturaController', [
511 590 })
512 591 .catch(function (err) {
513 592  
  593 + console.error(err);
514 594 focaModalService.alert('El despacho esta en uso');
515 595 });
516 596  
517 597 })
518 598 .catch(function (err) {
519   - console.log(err);
  599 + console.error(err);
520 600 });
521 601  
522 602 };
... ... @@ -543,7 +623,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
543 623 })
544 624 .then(function (contraseรฑa) {
545 625  
546   - if (contraseรฑa != vendedor.ClaVen.trim()) {
  626 + if (contraseรฑa !== vendedor.ClaVen.trim()) {
547 627  
548 628 focaModalService.alert('Clave incorrecta').then(function () {
549 629 indicarPassword(vendedor);
... ... @@ -668,6 +748,34 @@ angular.module('focaCrearFactura').controller('facturaController', [
668 748 }
669 749 }
670 750  
  751 + $scope.cambioEdit = function (articulo, propiedad) {
  752 + if (propiedad === 'cantidad') {
  753 + articulo.editCantidad = true;
  754 + }
  755 + };
  756 +
  757 + $scope.editarArticulo = function (key, articulo, tmpCantidad) {
  758 + if (key === 13) {
  759 + if (!articulo.cantidad && !tmpCantidad) {
  760 + focaModalService.alert('Los valores deben ser al menos 1');
  761 + return;
  762 + } else if (tmpCantidad === '0') {
  763 + focaModalService.alert('Esta ingresando un producto con valor 0');
  764 + } else if (articulo.cantidad < 0) {
  765 + focaModalService.alert('Los valores no pueden ser negativos');
  766 + return;
  767 + }
  768 + articulo.CAN = parseInt(tmpCantidad);
  769 + $scope.getTotal();
  770 + articulo.editCantidad = false;
  771 + }
  772 + };
  773 +
  774 + $scope.cancelarEditar = function (articulo) {
  775 + $scope.tmpCantidad = articulo.CAN;
  776 + articulo.editCantidad = false;
  777 + };
  778 +
671 779 function actualizarCabeceraMoneda(cotizacion) {
672 780  
673 781 $scope.factura.articulosFactura.forEach(function (art) {
... ... @@ -703,7 +811,7 @@ angular.module(&#39;focaCrearFactura&#39;).controller(&#39;facturaController&#39;, [
703 811 return false;
704 812 } else if (angular.equals({}, $scope.factura.cliente)) {
705 813  
706   - focaModalService.alert('Seleccione Cliente')
  814 + focaModalService.alert('Seleccione Cliente');
707 815 return false;
708 816 } else if (!$scope.articulosFiltro().length) {
709 817  
src/views/factura.html
1 1 <div class="crear-nota-remito foca-crear row">
2   - <foca-cabecera-facturador
  2 + <foca-cabecera-facturador
3 3 titulo="'Factura'"
4 4 numero="puntoVenta + '-' + comprobante"
5 5 fecha="now"
6 6 class="mb-0 col-lg-12"
7 7 busqueda="seleccionarRemito"
8   - ></foca-cabecera-facturador>
9   - <marquee
10   - bgcolor="#FF9900"
11   - behavior="scroll"
12   - direction="left"
13   - ng-bind="factura.observaciones"
14   - ></marquee>
15   - <div class="col-lg-12">
16   - <div class="row mt-4">
17   - <div class="col-12 col-md-10 col-lg-10 border border-light rounded">
18   - <div class="row p-1 botonera-secundaria px-5 py-2">
  8 + ></foca-cabecera-facturador>
  9 + <marquee
  10 + bgcolor="#FF9900"
  11 + behavior="scroll"
  12 + direction="left"
  13 + ng-bind="factura.observaciones"
  14 + ></marquee>
  15 + <div class="col-lg-12 p-2">
  16 + <div class="row border border-light rounded m-0">
  17 + <div class="col-12 col-md-10 col-lg-10">
  18 + <div class="row p-1 botonera-secundaria px-3 py-2">
19 19 <div class="col-12">
20   - <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador>
  20 + <foca-botonera-facturador
  21 + botones="botonera"
  22 + max="botonera.length"
  23 + class="row">
  24 + </foca-botonera-facturador>
  25 + </div>
  26 + </div>
  27 + <div ng-show="botoneraProductos.length > 0" class="row botonera-secundaria pb-3 px-3">
  28 + <div class="col-12">
  29 + <foca-botonera-productos
  30 + botones="botoneraProductos"
  31 + max="1"
  32 + class="row"
  33 + >
  34 + </foca-botonera-productos>
21 35 </div>
22 36 </div>
23 37 <!-- PC -->
... ... @@ -74,9 +88,9 @@
74 88 foca-tipo-input
75 89 min="1"
76 90 foca-focus="articulo.editCantidad"
77   - ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);"
  91 + ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad);"
78 92 esc-key="cancelarEditar(articulo)"
79   - ng-focus="selectFocus($event); tmpCantidad = articulo.CAN; tmpPrecio = articulo.PUN"
  93 + ng-focus="selectFocus($event); tmpCantidad = articulo.CAN;"
80 94 teclado-virtual
81 95 >
82 96 <i
... ... @@ -87,25 +101,8 @@
87 101 </i>
88 102 </td>
89 103 <td class="col text-right">
90   - <input
91   - ng-show="articulo.editPrecio"
92   - ng-model="tmpPrecio"
93   - class="form-control"
94   - foca-tipo-input
95   - min="1"
96   - step="0.0001"
97   - foca-focus="articulo.editPrecio"
98   - ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);"
99   - esc-key="cancelarEditar(articulo)"
100   - ng-focus="selectFocus($event);
101   - tmpCantidad = articulo.CAN;
102   - tmpPrecio = articulo.PUN"
103   - teclado-virtual
104   - >
105 104 <i
106 105 class="selectable"
107   - ng-click="cambioEdit(articulo, 'precio')"
108   - ng-hide="articulo.editPrecio"
109 106 ng-bind="articulo.PUN | number: 4">
110 107 </i>
111 108 </td>
... ... @@ -156,133 +153,135 @@
156 153 </div>
157 154 <!-- MOBILE -->
158 155 <div class="row d-sm-none">
159   - <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile">
160   - <thead>
161   - <tr class="d-flex">
162   - <th class="">#</th>
163   - <th class="col px-0">
164   - <div class="d-flex">
165   - <div class="col-4 px-1">Cรณdigo</div>
166   - <div class="col-8 px-1">Descripciรณn</div>
167   - </div>
168   - <div class="d-flex">
169   - <div class="col-3 px-1">Cantidad</div>
170   - <div class="col px-1 text-right">P. Uni.</div>
171   - <div class="col px-1 text-right">Subtotal</div>
172   - </div>
173   - </th>
174   - <th class="text-center tamaรฑo-boton">
175   - &nbsp;
176   - </th>
177   - </tr>
178   - </thead>
179   - <tbody>
180   - <tr
181   - ng-repeat="(key, articulo) in articulosFiltro()"
182   - ng-show="show || key == articulosFiltro().length - 1"
183   - >
184   - <td class="w-100 d-flex p-0">
185   - <div class="p-1 m-auto">
186   - <span ng-bind="key + 1"></span>
187   - </div>
188   - <div class="col px-0">
  156 + <div class="col p-0 m-2 mb-5">
  157 + <table class="table table-sm table-striped tabla-articulo">
  158 + <thead>
  159 + <tr class="d-flex">
  160 + <th class="">#</th>
  161 + <th class="col px-0">
189 162 <div class="d-flex">
190   - <div class="col-4 px-1">
191   - <span
192   - ng-bind="articulo.SEC + '-' + articulo.ART"
193   - ></span>
194   - </div>
195   - <div class="col-8 px-1">
196   - <span ng-bind="articulo.DES"></span>
197   - </div>
  163 + <div class="col-4 px-1">Cรณdigo</div>
  164 + <div class="col-8 px-1">Descripciรณn</div>
198 165 </div>
199 166 <div class="d-flex">
200   - <div class="col-4 px-1">
201   - <span
202   - ng-bind="'x' + articulo.CAN"
203   - ng-hide="articulo.editCantidad"
204   - ></span>
205   - <i
206   - class="fa fa-pencil text-white-50"
207   - aria-hidden="true"
208   - ng-hide="articulo.editCantidad"
209   - ng-click="articulo.editCantidad = true"
210   - ></i>
211   - <input
212   - ng-show="articulo.editCantidad"
213   - ng-model="articulo.CAN"
214   - class="form-control"
215   - foca-tipo-input
216   - min="1"
217   - step="0.001"
218   - foca-focus="articulo.editCantidad"
219   - ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio)"
220   - ng-focus="selectFocus($event)"
221   - >
222   - </div>
223   - <div class="col px-1 text-right">
224   - <span ng-bind="articulo.PUN |
225   - currency: factura.cotizacion.moneda.SIMBOLO : 4"></span>
226   - ></span>
  167 + <div class="col-3 px-1">Cantidad</div>
  168 + <div class="col px-1 text-right">P. Uni.</div>
  169 + <div class="col px-1 text-right">Subtotal</div>
  170 + </div>
  171 + </th>
  172 + <th class="text-center tamaรฑo-boton">
  173 + &nbsp;
  174 + </th>
  175 + </tr>
  176 + </thead>
  177 + <tbody>
  178 + <tr
  179 + ng-repeat="(key, articulo) in articulosFiltro()"
  180 + ng-show="show || key == articulosFiltro().length - 1"
  181 + >
  182 + <td class="w-100 d-flex p-0">
  183 + <div class="p-1 m-auto">
  184 + <span ng-bind="key + 1"></span>
  185 + </div>
  186 + <div class="col px-0">
  187 + <div class="d-flex">
  188 + <div class="col-4 px-1">
  189 + <span
  190 + ng-bind="articulo.SEC + '-' + articulo.ART"
  191 + ></span>
  192 + </div>
  193 + <div class="col-8 px-1">
  194 + <span ng-bind="articulo.DES"></span>
  195 + </div>
227 196 </div>
228   - <div class="col px-1 text-right">
229   - <span
230   - ng-bind="(articulo.PUN * articulo.CAN) |
231   - currency: factura.cotizacion.moneda.SIMBOLO"
232   - >
233   - </span>
  197 + <div class="d-flex">
  198 + <div class="col-4 px-1">
  199 + <span
  200 + ng-bind="'x' + articulo.CAN"
  201 + ng-hide="articulo.editCantidad"
  202 + ></span>
  203 + <i
  204 + class="fa fa-pencil text-white-50"
  205 + aria-hidden="true"
  206 + ng-hide="articulo.editCantidad"
  207 + ng-click="articulo.editCantidad = true"
  208 + ></i>
  209 + <input
  210 + ng-show="articulo.editCantidad"
  211 + ng-model="articulo.CAN"
  212 + class="form-control"
  213 + foca-tipo-input
  214 + min="1"
  215 + step="0.001"
  216 + foca-focus="articulo.editCantidad"
  217 + ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio)"
  218 + ng-focus="selectFocus($event)"
  219 + >
  220 + </div>
  221 + <div class="col px-1 text-right">
  222 + <span ng-bind="articulo.PUN |
  223 + currency: factura.cotizacion.moneda.SIMBOLO : 4"></span>
  224 + ></span>
  225 + </div>
  226 + <div class="col px-1 text-right">
  227 + <span
  228 + ng-bind="(articulo.PUN * articulo.CAN) |
  229 + currency: factura.cotizacion.moneda.SIMBOLO"
  230 + >
  231 + </span>
  232 + </div>
234 233 </div>
235 234 </div>
236   - </div>
237   - <div class="m-auto p-1">
  235 + <div class="m-auto p-1">
  236 + <button
  237 + class="btn btn-outline-light"
  238 + ng-click="quitarDespacho(key)"
  239 + >
  240 + <i class="fa fa-trash"></i>
  241 + </button>
  242 + </div>
  243 + </td>
  244 + </tr>
  245 + </tbody>
  246 + <tfoot>
  247 + <!-- TOOGLE EXPANDIR -->
  248 + <tr>
  249 + <td class="col">
238 250 <button
239   - class="btn btn-outline-light"
240   - ng-click="quitarDespacho(key)"
  251 + class="btn btn-outline-light selectable w-100"
  252 + ng-click="show = !show; masMenos()"
  253 + ng-show="articulosFiltro().length > 0"
241 254 >
242   - <i class="fa fa-trash"></i>
  255 + <i
  256 + class="fa fa-chevron-down"
  257 + ng-hide="show"
  258 + aria-hidden="true"
  259 + >
  260 + </i>
  261 + <i
  262 + class="fa fa-chevron-up"
  263 + ng-show="show"
  264 + aria-hidden="true">
  265 + </i>
243 266 </button>
244   - </div>
245   - </td>
246   - </tr>
247   - </tbody>
248   - <tfoot>
249   - <!-- TOOGLE EXPANDIR -->
250   - <tr>
251   - <td class="col">
252   - <button
253   - class="btn btn-outline-light selectable w-100"
254   - ng-click="show = !show; masMenos()"
255   - ng-show="articulosFiltro().length > 0"
256   - >
257   - <i
258   - class="fa fa-chevron-down"
259   - ng-hide="show"
260   - aria-hidden="true"
261   - >
262   - </i>
263   - <i
264   - class="fa fa-chevron-up"
265   - ng-show="show"
266   - aria-hidden="true">
267   - </i>
268   - </button>
269   - </td>
270   - </tr>
271   - <!-- FOOTER -->
272   - <tr class="d-flex">
273   - <td class="m-auto no-border-top" colspan="2">
274   - <strong>Cantidad Items:</strong>
275   - <a ng-bind="articulosFiltro().length"></a>
276   - </td>
277   - <td class="text-right ml-auto table-celda-total no-border-top">
278   - <h3>Total:</h3>
279   - </td>
280   - <td class="table-celda-total text-right no-border-top">
281   - <h3>{{getTotal() | currency: factura.cotizacion.moneda.SIMBOLO}}</h3>
282   - </td>
283   - </tr>
284   - </tfoot>
285   - </table>
  267 + </td>
  268 + </tr>
  269 + <!-- FOOTER -->
  270 + <tr class="d-flex">
  271 + <td class="m-auto no-border-top" colspan="2">
  272 + <strong>Cantidad Items:</strong>
  273 + <a ng-bind="articulosFiltro().length"></a>
  274 + </td>
  275 + <td class="text-right ml-auto table-celda-total no-border-top">
  276 + <h3>Total:</h3>
  277 + </td>
  278 + <td class="table-celda-total text-right no-border-top">
  279 + <h3>{{getTotal() | currency: factura.cotizacion.moneda.SIMBOLO}}</h3>
  280 + </td>
  281 + </tr>
  282 + </tfoot>
  283 + </table>
  284 + </div>
286 285 </div>
287 286 </div>
288 287 </div>