Commit a3d7762f9554e764fe516a1d7f37f51f31a64b44

Authored by Nicolás Guarnieri
Exists in master

merge

... ... @@ -45,7 +45,8 @@ gulp.task('uglify', ['templates'], function() {
45 45 uglify(),
46 46 replace('"ngRoute","ui.bootstrap","focaModalVendedores","focaBusquedaProductos",'+
47 47 '"focaModalProveedor","focaBusquedaCliente","focaModalPrecioCondicion",'+
48   - '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio"', ''),
  48 + '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio",'+
  49 + '"angular-ladda"', ''),
49 50 gulp.dest(paths.dist)
50 51 ]
51 52 );
... ... @@ -6,6 +6,7 @@
6 6 <!--CSS-->
7 7 <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/>
8 8 <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
  9 + <link href="node_modules/ladda/dist/ladda-themeless.min.css" rel="stylesheet">
9 10  
10 11 <!--VENDOR JS-->
11 12 <script src="node_modules/jquery/dist/jquery.min.js"></script>
... ... @@ -13,6 +14,9 @@
13 14 <script src="node_modules/angular/angular.min.js"></script>
14 15 <script src="node_modules/angular-route/angular-route.min.js"></script>
15 16 <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script>
  17 + <script src="node_modules/ladda/dist/spin.min.js"></script>
  18 + <script src="node_modules/ladda/dist/ladda.min.js"></script>
  19 + <script src="node_modules/angular-ladda/dist/angular-ladda.min.js"></script>
16 20  
17 21 <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script>
18 22 <script src="node_modules/foca-modal-vendedores/dist/foca-modal-vendedores.min.js"></script>
... ... @@ -8,7 +8,7 @@
8 8 "compile": "gulp uglify",
9 9 "gulp-pre-commit": "gulp pre-commit",
10 10 "postinstall": "npm run compile && gulp clean-post-install",
11   - "install-dev": "npm install -D jasmine-core pre-commit angular angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+https://debo.suite.repo/modulos-npm/foca-directivas.git git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git git+https://debo.suite.repo/modulos-npm/foca-modal-flete git+https://debo.suite.repo/modulos-npm/foca-modal.git git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git"
  11 + "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+https://debo.suite.repo/modulos-npm/foca-directivas.git git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git git+https://debo.suite.repo/modulos-npm/foca-modal-flete git+https://debo.suite.repo/modulos-npm/foca-modal.git git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git"
12 12 },
13 13 "pre-commit": [
14 14 "gulp-pre-commit"
... ... @@ -28,6 +28,7 @@
28 28 },
29 29 "devDependencies": {
30 30 "angular": "^1.7.5",
  31 + "angular-ladda": "^0.4.3",
31 32 "angular-route": "^1.7.5",
32 33 "bootstrap": "^4.1.3",
33 34 "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git",
... ... @@ -36,12 +37,12 @@
36 37 "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos",
37 38 "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git",
38 39 "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete",
39   - "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git",
40 40 "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git",
  41 + "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git",
41 42 "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git",
42 43 "font-awesome": "^4.7.0",
43 44 "gulp": "^3.9.1",
44   - "gulp-angular-templatecache": "2.2.2",
  45 + "gulp-angular-templatecache": "^2.2.2",
45 46 "gulp-clean": "^0.4.0",
46 47 "gulp-concat": "^2.6.1",
47 48 "gulp-connect": "^5.6.1",
... ... @@ -52,9 +53,10 @@
52 53 "gulp-sequence": "^1.0.0",
53 54 "gulp-uglify": "^3.0.1",
54 55 "gulp-uglify-es": "^1.0.4",
55   - "jasmine-core": "^3.2.1",
  56 + "jasmine-core": "^3.3.0",
56 57 "jquery": "^3.3.1",
57 58 "jshint": "^2.9.6",
  59 + "ladda": "1.0.6",
58 60 "pre-commit": "^1.2.2",
59 61 "pump": "^3.0.0",
60 62 "ui-bootstrap4": "^3.0.5"
... ... @@ -9,5 +9,6 @@ angular.module(&#39;focaCrearNotaPedido&#39;, [
9 9 'focaModalFlete',
10 10 'focaDirectivas',
11 11 'focaModal',
12   - 'focaModalDomicilio'
  12 + 'focaModalDomicilio',
  13 + 'angular-ladda'
13 14 ]);
src/js/controller.js
... ... @@ -17,6 +17,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
17 17 {texto: '', accion: function() {}},
18 18 {texto: '', accion: function() {}}
19 19 ];
  20 + $scope.datepickerAbierto = false;
20 21  
21 22 $scope.show = false;
22 23 $scope.cargando = true;
... ... @@ -40,7 +41,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
40 41 $scope.comprobante = Math.round(Math.random() * 1000000);
41 42  
42 43 $scope.articulosTabla = [];
43   - var idLista;
  44 + $scope.idLista = undefined;
44 45 var notaPedidoTemp = crearNotaPedidoService.getNotaPedido();
45 46 crearNotaPedidoService.getPrecioCondicion().then(
46 47 function(res) {
... ... @@ -52,7 +53,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
52 53 $scope.notaPedido = notaPedidoTemp;
53 54 $scope.notaPedido.flete = ($scope.notaPedido.flete).toString();
54 55 $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString();
55   - idLista = $scope.notaPedido.precioCondicion;
  56 + $scope.idLista = $scope.notaPedido.precioCondicion;
56 57 crearNotaPedidoService
57 58 .getArticulosByIdNotaPedido($scope.notaPedido.id).then(
58 59 function(res) {
... ... @@ -70,7 +71,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
70 71 $scope.notaPedido.fechaCarga = new Date();
71 72 $scope.notaPedido.bomba = '0';
72 73 $scope.notaPedido.flete = '0';
73   - idLista = undefined;
  74 + $scope.idLista = undefined;
74 75 }
75 76 //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO
76 77 // $scope.addNewDom = function() {
... ... @@ -101,14 +102,12 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
101 102 vendedor: $scope.notaPedido.vendedor.nombre,
102 103 idCliente: $scope.notaPedido.cliente.id,
103 104 domicilio: $scope.notaPedido.domicilio,
104   - precioCondicion: $scope.notaPedido.precioCondicion,
105 105 bomba: $scope.notaPedido.bomba,
106 106 flete: $scope.notaPedido.flete,
107 107 total: $scope.getTotal()
108 108 };
109 109 crearNotaPedidoService.crearNotaPedido(notaPedido).then(
110 110 function(data) {
111   - focaModalService.alert('Nota pedido creada');
112 111 if($scope.notaPedido.flete === 1) {
113 112 var flete = {
114 113 idNotaPedido: data.data.id,
... ... @@ -122,18 +121,28 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
122 121 }
123 122 var articulosNotaPedido = $scope.articulosTabla;
124 123 for(var i = 0; i < articulosNotaPedido.length; i++) {
125   - delete articulosNotaPedido[i].edit;
  124 + delete articulosNotaPedido[i].editCantidad;
  125 + delete articulosNotaPedido[i].editPrecio;
126 126 articulosNotaPedido[i].idNotaPedido = data.data.id;
127 127 crearNotaPedidoService
128 128 .crearArticulosParaNotaPedido(articulosNotaPedido[i]);
129 129 }
  130 + var plazos = $scope.plazosPagos;
  131 + for(var j = 0; j < plazos.length; j++) {
  132 + var json = {
  133 + idPedido: data.data.id,
  134 + dias: plazos[j].dias
  135 + };
  136 + crearNotaPedidoService.crearPlazosParaNotaPedido(json);
  137 + }
  138 + focaModalService.alert('Nota pedido creada');
130 139 $scope.limpiarPantalla();
131 140 }
132 141 );
133 142 };
134 143  
135 144 $scope.seleccionarArticulo = function() {
136   - if (idLista === undefined) {
  145 + if ($scope.idLista === undefined) {
137 146 focaModalService.alert(
138 147 'Primero seleccione una lista de precio y condicion');
139 148 return;
... ... @@ -143,7 +152,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
143 152 ariaLabelledBy: 'Busqueda de Productos',
144 153 templateUrl: 'modal-busqueda-productos.html',
145 154 controller: 'modalBusquedaProductosCtrl',
146   - resolve: { idLista: function() { return idLista; } },
  155 + resolve: { idLista: function() { return $scope.idLista; } },
147 156 size: 'lg'
148 157 }
149 158 );
... ... @@ -158,9 +167,10 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
158 167 descripcion: producto.descripcion,
159 168 item: $scope.articulosTabla.length + 1,
160 169 nombre: producto.descripcion,
161   - precio: producto.precio.toFixed(2),
  170 + precio: parseFloat(producto.precio.toFixed(2)),
162 171 costoUnitario: producto.costo,
163   - edit: false
  172 + editCantidad: false,
  173 + editPrecio: false
164 174 };
165 175 $scope.articuloACargar = newArt;
166 176 $scope.cargando = false;
... ... @@ -301,11 +311,25 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
301 311 );
302 312 modalInstance.result.then(
303 313 function(precioCondicion) {
304   - $scope.notaPedido.precioCondicion = precioCondicion.nombre;
305   - idLista = precioCondicion.idListaPrecio;
  314 + var cabecera = '';
  315 + var plazosConcat = '';
  316 + if(!Array.isArray(precioCondicion)) {
  317 + $scope.plazosPagos = precioCondicion.plazoPago;
  318 + $scope.idLista = precioCondicion.idListaPrecio;
  319 + for(var i = 0; i < precioCondicion.plazoPago.length; i++) {
  320 + plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
  321 + }
  322 + cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim();
  323 + } else { //Cuando se ingresan los plazos manualmente
  324 + $scope.idLista = -1; //-1, el modal productos busca todos los productos
  325 + $scope.plazosPagos = precioCondicion;
  326 + for(var j = 0; j < precioCondicion.length; j++) {
  327 + plazosConcat += precioCondicion[j].dias + ' ';
  328 + }
  329 + cabecera = 'Ingreso manual ' + plazosConcat.trim();
  330 + }
306 331 $scope.articulosTabla = [];
307   -
308   - addCabecera('Precios y condiciones:', precioCondicion.nombre);
  332 + addCabecera('Precios y condiciones:', cabecera);
309 333 }, function() {
310 334  
311 335 }
... ... @@ -369,6 +393,35 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
369 393 };
370 394  
371 395 addCabecera('Moneda:', moneda.DETALLE);
  396 + $scope.abrirModalCotizacion(moneda.ID);
  397 + }, function() {
  398 +
  399 + }
  400 + );
  401 + };
  402 +
  403 + $scope.abrirModalCotizacion = function(idMoneda) {
  404 + var modalInstance = $uibModal.open(
  405 + {
  406 + ariaLabelledBy: 'Busqueda de Cotización',
  407 + templateUrl: 'modal-cotizacion.html',
  408 + controller: 'focaModalCotizacionController',
  409 + size: 'lg',
  410 + resolve: {idMoneda: function() {return idMoneda;}}
  411 + }
  412 + );
  413 + modalInstance.result.then(
  414 + function(cotizacion) {
  415 + $scope.notaPedido.cotizacion = {
  416 + id: cotizacion.ID,
  417 + cotizacion: cotizacion.COTIZACION
  418 + };
  419 +
  420 + addCabecera(
  421 + 'Fecha cotizacion:',
  422 + $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
  423 + );
  424 + addCabecera('Cotizacion:', cotizacion.COTIZACION);
372 425 }, function() {
373 426  
374 427 }
... ... @@ -400,12 +453,17 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
400 453 focaModalService.alert('El valor debe ser al menos 1');
401 454 return;
402 455 }
403   - articulo.edit = false;
  456 + articulo.editCantidad = false;
  457 + articulo.editPrecio = false;
404 458 }
405 459 };
406 460  
407   - $scope.cambioEdit = function(articulo) {
408   - articulo.edit = true;
  461 + $scope.cambioEdit = function(articulo, propiedad) {
  462 + if(propiedad === 'cantidad') {
  463 + articulo.editCantidad = true;
  464 + } else if(propiedad === 'precio') {
  465 + articulo.editPrecio = true;
  466 + }
409 467 };
410 468  
411 469 $scope.limpiarFlete = function() {
... ... @@ -444,7 +502,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
444 502 };
445 503  
446 504 function addCabecera(label, valor) {
447   - var propiedad = $filter('filter')($scope.cabecera, {label: label});
  505 + var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
448 506 if(propiedad.length === 1) {
449 507 propiedad[0].valor = valor;
450 508 } else {
... ... @@ -453,7 +511,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
453 511 }
454 512  
455 513 function removeCabecera(label) {
456   - var propiedad = $filter('filter')($scope.cabecera, {label: label});
  514 + var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
457 515 if(propiedad.length === 1){
458 516 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
459 517 }
... ... @@ -42,6 +42,9 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
42 42 },
43 43 crearFlete: function(flete) {
44 44 return $http.post(route + '/flete', {flete : flete});
  45 + },
  46 + crearPlazosParaNotaPedido: function(plazos) {
  47 + return $http.post(route + '/plazo-pago/nota-pedido', plazos);
45 48 }
46 49 };
47 50 }]);
src/views/nota-pedido.html
1 1 <div class="crear-nota-pedido">
2   - <form name="formCrearNota" ng-submit="crearNotaPedido()">
  2 + <form name="formCrearNota" ng-submit="crearNotaPedido()" class="mb-0">
3 3 <div class="row">
4 4 <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2">
5 5 <div class="row p-1 panel-informativo">
... ... @@ -9,8 +9,24 @@
9 9 <h5>NOTA DE PEDIDO</h5>
10 10 </div>
11 11 <div class="col-6 col-sm-4 numero-pedido">Nº {{puntoVenta}}-{{comprobante}}</div>
12   - <div class="col-6 col-sm-4 text-right">
13   - Fecha: {{ now | date:'dd/MM/yyyy HH:mm'}}
  12 + <div class="col-6 col-sm-4 text-right crear-nota-pedido-fecha">
  13 + Fecha:
  14 + <span
  15 + ng-show="!datepickerAbierto"
  16 + ng-bind="now | date:'dd/MM/yyyy HH:mm'"
  17 + ng-click="datepickerAbierto = true"
  18 + >
  19 + </span>
  20 + <input
  21 + ng-show="datepickerAbierto"
  22 + type="date"
  23 + ng-model="now"
  24 + ng-change="datepickerAbierto = false"
  25 + ng-blur="datepickerAbierto = false"
  26 + class="form-control form-control-sm col-8 float-right"
  27 + foca-focus="datepickerAbierto"
  28 + hasta-hoy
  29 + />
14 30 </div>
15 31 </div>
16 32 <div class="row">
... ... @@ -66,7 +82,7 @@
66 82 <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2">
67 83 <!-- PC -->
68 84 <div class="row grilla-articulo align-items-end">
69   - <table class="table tabla-articulo table-striped table-sm table-dark">
  85 + <table class="table tabla-articulo table-striped table-sm table-dark mb-0">
70 86 <thead>
71 87 <tr class="d-flex">
72 88 <th class="">#</th>
... ... @@ -110,28 +126,43 @@
110 126 class="col-4"
111 127 ng-bind="articulo.descripcion"
112 128 ></td>
113   - <td class="col text-right">
  129 + <td class="col text-right">
114 130 <input
115   - ng-show="articulo.edit"
  131 + ng-show="articulo.editCantidad"
116 132 ng-model="articulo.cantidad"
117 133 class="form-control"
118 134 type="number"
119 135 min="1"
120   - foca-focus="articulo.edit"
  136 + foca-focus="articulo.editCantidad"
121 137 ng-keypress="editarArticulo($event.keyCode, articulo)"
122 138 ng-focus="selectFocus($event)"
123 139 >
124 140 <i
125 141 class="selectable"
126   - ng-click="cambioEdit(articulo)"
127   - ng-hide="articulo.edit"
  142 + ng-click="cambioEdit(articulo, 'cantidad')"
  143 + ng-hide="articulo.editCantidad"
128 144 ng-bind="articulo.cantidad">
129 145 </i>
130 146 </td>
131   - <td
132   - class="col text-right"
133   - ng-bind="articulo.precio | currency: '$'"
134   - ></td>
  147 + <td class="col text-right">
  148 + <input
  149 + ng-show="articulo.editPrecio"
  150 + ng-model="articulo.precio"
  151 + class="form-control"
  152 + type="number"
  153 + min="1"
  154 + step="0.01"
  155 + foca-focus="articulo.editPrecio"
  156 + ng-keypress="editarArticulo($event.keyCode, articulo)"
  157 + ng-focus="selectFocus($event)"
  158 + >
  159 + <i
  160 + class="selectable"
  161 + ng-click="idLista == -1 && cambioEdit(articulo, 'precio')"
  162 + ng-hide="articulo.editPrecio"
  163 + ng-bind="articulo.precio">
  164 + </i>
  165 + </td>
135 166 <td
136 167 class="col text-right"
137 168 ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'">
... ... @@ -181,8 +212,18 @@
181 212 <input
182 213 class="form-control"
183 214 ng-value="articuloACargar.precio | currency: '$'"
  215 + ng-show="idLista != -1"
184 216 readonly
185 217 >
  218 + <input
  219 + class="form-control"
  220 + type="number"
  221 + step="0.01"
  222 + ng-model="articuloACargar.precio"
  223 + esc-key="resetFilter()"
  224 + ng-keypress="agregarATabla($event.keyCode)"
  225 + ng-show="idLista == -1"
  226 + >
186 227 </td>
187 228 <td class="col text-right">
188 229 <input