Commit ae4b8d073e7e10637ae45d795f8b66d11fd01eb4

Authored by Eric Fernandez
Exists in master

Merge branch 'develop' of http://git.focasoftware.com/npm/foca-crear-factura

src/js/controller.js
1 1 angular.module('focaCrearFactura').controller('facturaController', [
2 2 '$scope', '$uibModal', '$location', '$filter', 'crearFacturaService', '$timeout',
3 3 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService',
4   - '$localStorage',
  4 + '$localStorage', 'APP',
5 5 function (
6 6 $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService,
7   - crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage) {
  7 + crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP) {
8 8  
9 9 config();
10 10  
... ... @@ -175,7 +175,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
175 175 despachos: $scope.factura.despachos
176 176 };
177 177  
178   - crearFacturaService.guardarFactura(save).then(function(res) {
  178 + crearFacturaService.guardarFactura(save).then(function (res) {
179 179  
180 180 focaBotoneraLateralService.endGuardar(true);
181 181  
... ... @@ -183,7 +183,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
183 183  
184 184 config();
185 185  
186   - }).catch(function(err) {
  186 + }).catch(function (err) {
187 187 focaModalService.alert('Hubo un error al guardar la factura');
188 188 console.log(err);
189 189 });
... ... @@ -206,14 +206,39 @@ angular.module('focaCrearFactura').controller('facturaController', [
206 206 );
207 207 modalInstance.result.then(
208 208 function (cliente) {
209   - $scope.factura.cliente = cliente;
  209 + var modalInstance = $uibModal.open(
  210 + {
  211 + templateUrl: 'modal-estado-cuenta.html',
  212 + controller: 'focaModalEstadoCuentaController',
  213 + size: 'lg',
  214 + resolve: {
  215 + parametros: function () { return { idCliente: cliente.cod }; },
  216 + }
  217 + }
  218 + );
  219 + modalInstance.result
  220 + .then(function (data) {
210 221  
211   - $scope.$broadcast('addCabecera', {
212   - label: 'Cliente:',
213   - valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom
214   - });
  222 + $scope.factura.cliente = cliente;
215 223  
216   - $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true;
  224 + $scope.$broadcast('addCabecera', {
  225 + label: 'Cliente:',
  226 + valor: $filter('rellenarDigitos')(cliente.cod, 3) +
  227 + ' - ' + cliente.nom
  228 + });
  229 +
  230 + $filter('filter')($scope.botonera,
  231 + { label: 'Cliente' })[0].checked = true;
  232 +
  233 + $scope.$broadcast('addCabecera', {
  234 + label: 'Tipo de pago: ',
  235 + valor: data
  236 + });
  237 + })
  238 + .catch(function () {
  239 +
  240 + $scope.seleccionarCliente();
  241 + });
217 242  
218 243 }, function () {
219 244 }
... ... @@ -221,7 +246,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
221 246  
222 247 };
223 248  
224   - $scope.seleccionarVendedor = function() {
  249 + $scope.seleccionarVendedor = function () {
225 250 var parametrosModal = {
226 251 titulo: 'Bรบsqueda vendedores',
227 252 query: '/vendedor-playa',
... ... @@ -245,9 +270,9 @@ angular.module('focaCrearFactura').controller('facturaController', [
245 270 function (vendedor) {
246 271  
247 272 indicarPassword(vendedor)
248   - .then(function() {
  273 + .then(function () {
249 274 validarPlanillaVendedor(vendedor)
250   - .then(function() {
  275 + .then(function () {
251 276  
252 277 $filter('filter')($scope.botonera, {
253 278 label: 'Vendedor'
... ... @@ -256,8 +281,8 @@ angular.module('focaCrearFactura').controller('facturaController', [
256 281 $scope.$broadcast('addCabecera', {
257 282 label: 'Vendedor:',
258 283 valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) +
259   - ' - ' +
260   - vendedor.NomVen
  284 + ' - ' +
  285 + vendedor.NomVen
261 286 });
262 287  
263 288 $scope.factura.vendedor = vendedor;
... ... @@ -266,7 +291,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
266 291 })
267 292 .catch($scope.seleccionarVendedor);
268 293 })
269   - .catch(function(err) {
  294 + .catch(function (err) {
270 295 console.log(err)
271 296 });
272 297  
... ... @@ -383,14 +408,14 @@ angular.module('focaCrearFactura').controller('facturaController', [
383 408 articulo.desactivado = true;
384 409 $scope.factura.despachos.splice(index, 1);
385 410 })
386   - .catch(function() {
  411 + .catch(function () {
387 412 focaModalService.alert('Hubo un error al desasociar este despacho');
388 413 });
389 414 };
390 415  
391 416 function getProductosByPlanilla(numeroPlanilla) {
392 417  
393   - crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function(res) {
  418 + crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function (res) {
394 419  
395 420 res.data.forEach(function (producto) {
396 421  
... ... @@ -408,7 +433,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
408 433  
409 434 function crearFuncionesProductos(producto) {
410 435  
411   - $scope[nombreFuncion(producto.DetArt)] = function() {
  436 + $scope[nombreFuncion(producto.DetArt)] = function () {
412 437  
413 438 if (angular.equals($scope.factura.cliente, {})) {
414 439 focaModalService.alert('Seleccione cliente');
... ... @@ -420,7 +445,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
420 445 templateUrl: 'modal-combustibles.html',
421 446 controller: 'focaModalCombustiblesController',
422 447 resolve: {
423   - parametros: function() {
  448 + parametros: function () {
424 449 return {
425 450 despachos: producto.despachos,
426 451 nombreProducto: producto.DetArt
... ... @@ -431,7 +456,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
431 456 }
432 457 );
433 458  
434   - modalInstance.result.then(function(despacho) {
  459 + modalInstance.result.then(function (despacho) {
435 460  
436 461 var articulo = {
437 462 TIP: $scope.factura.cliente.tipoFactura,
... ... @@ -475,19 +500,19 @@ angular.module('focaCrearFactura').controller('facturaController', [
475 500 producto: despacho.PRO,
476 501 carga: despacho.CAR
477 502 })
478   - .then(function () {
479   - $scope.factura.articulosFactura.push(articulo);
480   - $scope.factura.despachos.push(despacho);
481   - })
482   - .catch(function (err) {
  503 + .then(function () {
  504 + $scope.factura.articulosFactura.push(articulo);
  505 + $scope.factura.despachos.push(despacho);
  506 + })
  507 + .catch(function (err) {
483 508  
484   - focaModalService.alert('El despacho esta en uso');
485   - });
  509 + focaModalService.alert('El despacho esta en uso');
  510 + });
486 511  
487 512 })
488   - .catch(function (err) {
489   - console.log(err);
490   - });
  513 + .catch(function (err) {
  514 + console.log(err);
  515 + });
491 516  
492 517 };
493 518 }
... ... @@ -495,7 +520,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
495 520 function nombreFuncion(string) {
496 521 var texto = 'seleccionar';
497 522 var arr = string.split(' ');
498   - arr.forEach(function(palabra) {
  523 + arr.forEach(function (palabra) {
499 524 palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1);
500 525 texto += palabra;
501 526 });
... ... @@ -504,7 +529,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
504 529  
505 530 function indicarPassword(vendedor) {
506 531  
507   - return new Promise(function(resolve, reject) {
  532 + return new Promise(function (resolve, reject) {
508 533  
509 534 focaModalService
510 535 .prompt({
... ... @@ -515,7 +540,7 @@ angular.module('focaCrearFactura').controller('facturaController', [
515 540  
516 541 if (contraseรฑa != vendedor.ClaVen.trim()) {
517 542  
518   - focaModalService.alert('Clave incorrecta').then(function() {
  543 + focaModalService.alert('Clave incorrecta').then(function () {
519 544 indicarPassword(vendedor);
520 545 });
521 546 } else {
... ... @@ -528,24 +553,24 @@ angular.module('focaCrearFactura').controller('facturaController', [
528 553  
529 554 function validarPlanillaVendedor(vendedor) {
530 555  
531   - return new Promise(function(resolve, reject) {
  556 + return new Promise(function (resolve, reject) {
532 557  
533 558 crearFacturaService
534   - .validarPlanillaVendedor(vendedor.CodVen.trim())
535   - .then(function (res) {
  559 + .validarPlanillaVendedor(vendedor.CodVen.trim())
  560 + .then(function (res) {
536 561  
537   - if (!res.data.length) {
  562 + if (!res.data.length) {
538 563  
539   - focaModalService
540   - .alert('No se encontrรณ planilla abierta para el vendedor')
541   - .then(reject);
  564 + focaModalService
  565 + .alert('No se encontrรณ planilla abierta para el vendedor')
  566 + .then(reject);
542 567  
543   - } else {
544   - resolve();
545   - }
  568 + } else {
  569 + resolve();
  570 + }
546 571  
547   - })
548   - .catch(reject);
  572 + })
  573 + .catch(reject);
549 574 });
550 575 }
551 576  
src/js/controllerEstadoCuenta.js
... ... @@ -0,0 +1,32 @@
  1 +angular.module('focaCrearFactura')
  2 + .controller('focaModalEstadoCuentaController', [
  3 + '$scope', '$uibModalInstance', 'crearFacturaService', 'parametros',
  4 + function ($scope, $uibModalInstance, crearFacturaService, parametros) {
  5 +
  6 + $scope.estadoCuenta = {
  7 + autorizado: 0.0,
  8 + extracciones: 0.0,
  9 + saldo: 0.0,
  10 + situacion: false,
  11 + facturasVencidas: 0.0
  12 + };
  13 +
  14 + init();
  15 +
  16 + function init() {
  17 + crearFacturaService.getResumenCuenta(parametros.idCliente)
  18 + .then(function (res) {
  19 + $scope.estadoCuenta = res.data;
  20 + })
  21 + .catch(function (e) { console.error(e); });
  22 + }
  23 +
  24 + $scope.elegirTipoDePago = function (tipoDePago) {
  25 + $uibModalInstance.close(tipoDePago);
  26 + };
  27 +
  28 + $scope.cancel = function () {
  29 + $uibModalInstance.dismiss('cancel');
  30 + };
  31 + }
  32 + ]);
1 1 angular.module('focaCrearFactura')
2 2 .service('crearFacturaService', ['$http', 'API_ENDPOINT',
3   - function($http, API_ENDPOINT) {
4   - var route = API_ENDPOINT.URL;
5   - return {
6   - guardarFactura: function (factura) {
7   - return $http.post(route + '/factura/guardar', factura)
8   - },
9   - getParametros: function() {
10   - return $http.get(API_ENDPOINT.URL + '/parametros/factura');
11   - },
12   - validarPlanillaVendedor: function(idVendedor) {
13   - return $http.get(route + '/turnos/validar-planilla/' + idVendedor);
14   - },
15   - getProductosByPlanilla: function (numeroPlanilla) {
16   - return $http.get(route + '/turnos/productos/' + numeroPlanilla);
17   - },
18   - setearDespachoOcupado: function (parametros) {
19   - return $http.post(route + '/turnos/despacho-en-uso', parametros);
20   - },
21   - setearDespachoDesocupado: function (parametros) {
22   - return $http.post(route + '/turnos/depacho-sin-uso', parametros);
23   - },
24   - getBotonera: function() {
25   - return [
26   - {
27   - label: 'Vendedor',
28   - image: 'vendedor.png'
29   - },
30   - {
31   - label: 'Cliente',
32   - image: 'cliente.png'
33   - },
34   - {
35   - label: 'Moneda',
36   - image: 'moneda.png'
37   - },
38   - {
39   - label: 'Observaciones',
40   - image: 'botonObservaciones.png'
41   - }
42   - ];
43   - }
44   - };
45   - }]);
  3 + function ($http, API_ENDPOINT) {
  4 + var route = API_ENDPOINT.URL;
  5 + return {
  6 + guardarFactura: function (factura) {
  7 + return $http.post(route + '/factura/guardar', factura);
  8 + },
  9 + getParametros: function () {
  10 + return $http.get(API_ENDPOINT.URL + '/parametros/factura');
  11 + },
  12 + validarPlanillaVendedor: function (idVendedor) {
  13 + return $http.get(route + '/turnos/validar-planilla/' + idVendedor);
  14 + },
  15 + getProductosByPlanilla: function (numeroPlanilla) {
  16 + return $http.get(route + '/turnos/productos/' + numeroPlanilla);
  17 + },
  18 + setearDespachoOcupado: function (parametros) {
  19 + return $http.post(route + '/turnos/despacho-en-uso', parametros);
  20 + },
  21 + setearDespachoDesocupado: function (parametros) {
  22 + return $http.post(route + '/turnos/depacho-sin-uso', parametros);
  23 + },
  24 + getResumenCuenta: function (idCliente) {
  25 + return $http.get(API_ENDPOINT + '/cliente/resumen-cuenta/' + idCliente);
  26 + },
  27 + getBotonera: function () {
  28 + return [
  29 + {
  30 + label: 'Vendedor',
  31 + image: 'vendedor.png'
  32 + },
  33 + {
  34 + label: 'Cliente',
  35 + image: 'cliente.png'
  36 + },
  37 + {
  38 + label: 'Moneda',
  39 + image: 'moneda.png'
  40 + },
  41 + {
  42 + label: 'Observaciones',
  43 + image: 'botonObservaciones.png'
  44 + }
  45 + ];
  46 + }
  47 + };
  48 + }
  49 + ]);
src/views/factura.html
... ... @@ -154,10 +154,140 @@
154 154 </tfoot>
155 155 </table>
156 156 </div>
  157 + <!-- MOBILE -->
  158 + <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">
  189 + <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>
  198 + </div>
  199 + <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>
  227 + </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>
  234 + </div>
  235 + </div>
  236 + </div>
  237 + <div class="m-auto p-1">
  238 + <button
  239 + class="btn btn-outline-light"
  240 + ng-click="quitarDespacho(key)"
  241 + >
  242 + <i class="fa fa-trash"></i>
  243 + </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>
  286 + </div>
157 287 </div>
158 288 </div>
159 289 </div>
160   - <div class="row d-md-none fixed-bottom">
  290 + <div class="row d-md-none fixed-bottom disable-selection">
161 291 <div class="w-100 bg-dark d-flex px-3 acciones-mobile">
162 292 <span class="ml-3 text-muted" ng-click="salir()">Salir</span>
163 293 <span
... ... @@ -166,7 +296,7 @@
166 296 ng-click="seleccionarFormaDePago()"
167 297 ladda="saveLoading"
168 298 data-style="expand-left"
169   - >Guardar</span>
  299 + >Pago</span>
170 300 </div>
171 301 </div>
172 302 </div>
src/views/modal-estado-cuenta.html
... ... @@ -0,0 +1,80 @@
  1 +<div class="modal-header py-1">
  2 + <div class="row w-100">
  3 + <div class="col-lg-6">
  4 + <h5 class="modal-title text-center my-1">Estado cuenta corriente</h5>
  5 + </div>
  6 + </div>
  7 +</div>
  8 +<div class="modal-body" id="modal-body">
  9 + <div class="row m-3">
  10 + <div class="col">
  11 + <div class="row mb-2">
  12 + <div class="col text-center">
  13 + <p class="m-0">Autorizado</p>
  14 + <p class="h5 m-0" ng-bind="estadoCuenta.autorizado | currency"></p>
  15 + </div>
  16 + </div>
  17 + <div class="row border-top mb-2">
  18 + <div class="col text-center">
  19 + <p class="m-0">Extracciones</p>
  20 + <p class="h5 m-0" ng-bind="estadoCuenta.extracciones | currency"></p>
  21 + </div>
  22 + </div>
  23 + <div class="row border-top mb-2">
  24 + <div class="col text-center">
  25 + <p class="m-0">Saldo</p>
  26 + <p class="h5 m-0" ng-bind="estadoCuenta.saldo | currency"></p>
  27 + </div>
  28 + </div>
  29 + <div class="row border-top">
  30 + <div class="col text-center">
  31 + <p class="m-0">Situacion</p>
  32 + <h4>
  33 + <p
  34 + ng-show="estadoCuenta.situacion"
  35 + class="badge badge-success m-0 px-3">Permitido
  36 + </p>
  37 + <p
  38 + ng-show="!estadoCuenta.situacion"
  39 + class="badge badge-danger m-0 px-3">No permitido
  40 + </p>
  41 + </h4>
  42 + </div>
  43 + </div>
  44 + <div class="row border-top mb-2">
  45 + <div class="col text-center">
  46 + <p class="m-0">Facturas Vencidas</p>
  47 + <p class="h5 m-0" ng-bind="estadoCuenta.facturasVencidas | currency"></p>
  48 + </div>
  49 + </div>
  50 + </div>
  51 + </div>
  52 + <div class="row h-25 align-items-center mx-0 botonera-secundaria">
  53 + <div class="col-6 col-sm-4 offset-sm-2">
  54 + <button
  55 + type="button"
  56 + class="btn btn-sm btn-block btn-tarjeta rounded border p-1"
  57 + ng-disabled="!estadoCuenta.situacion"
  58 + ng-click="elegirTipoDePago('Contado')"
  59 + >
  60 + <img ng-src="./img/contado.png" alt="">
  61 + <p class="m-0">Contado</p>
  62 + </button>
  63 + </div>
  64 + <div class="col-6 col-sm-4">
  65 + <button
  66 + type="button"
  67 + class="btn btn-sm btn-block btn-tarjeta rounded border p-1"
  68 + ng-disabled="!estadoCuenta.situacion"
  69 + foca-focus="true"
  70 + ng-click="elegirTipoDePago('Cuenta Corriente')"
  71 + >
  72 + <img ng-src="./img/cuentaCorriente.png" alt="">
  73 + <p class="m-0">Cta. Corriente</p>
  74 + </button>
  75 + </div>
  76 + </div>
  77 +</div>
  78 +<div class="modal-footer py-2">
  79 + <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button>
  80 +</div>
src/views/modal-seleccionar-cliente.html
... ... @@ -0,0 +1,13 @@
  1 +<div class="modal-header py-1">
  2 + <div class="row w-100">
  3 + <div class="col-lg-6">
  4 + <h5 class="modal-title my-1">Seleccione Cliente</h5>
  5 + </div>
  6 + </div>
  7 +</div>
  8 +<div class="modal-body" id="modal-body">
  9 +
  10 +</div>
  11 +<div class="modal-footer py-1">
  12 + <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button>
  13 +</div>