Commit 1f79a6c5a650f93bbb6c48c421301b4736fdffd8

Authored by Marcelo Puebla
1 parent d0db3326b5
Exists in develop

Fix lint

src/app/modules/admin/admin.component.ts
1 import { Component, OnInit, HostListener } from '@angular/core'; 1 import { Component, OnInit, HostListener } from '@angular/core';
2 import { Router } from '@angular/router'; 2 import { Router } from '@angular/router';
3 3
4 @Component({ 4 @Component({
5 selector: 'app-admin', 5 selector: 'app-admin',
6 templateUrl: './admin.component.html', 6 templateUrl: './admin.component.html',
7 styleUrls: ['./admin.component.scss'] 7 styleUrls: ['./admin.component.scss']
8 }) 8 })
9 9
10 export class AdminComponent implements OnInit { 10 export class AdminComponent implements OnInit {
11 timerReposo: any; 11 timerReposo: any;
12 12
13 constructor( 13 constructor(
14 private router: Router, 14 private router: Router,
15 ) { } 15 ) { }
16 16
17 ngOnInit() { 17 ngOnInit() {
18 this.startTimeOutInactividad(); 18 this.startTimeOutInactividad();
19 } 19 }
20 20
21 @HostListener('document:click', ['$event']) 21 @HostListener('document:click', ['$event'])
22 22
23 documentClick(event: MouseEvent) { 23 documentClick(event: MouseEvent) {
24 if (event) { 24 if (event) {
25 this.restartTimer(); 25 this.restartTimer();
26 } 26 }
27 } 27 }
28 28
29 restartTimer() { 29 restartTimer() {
30 clearTimeout(this.timerReposo); 30 clearTimeout(this.timerReposo);
31 this.startTimeOutInactividad(); 31 this.startTimeOutInactividad();
32 } 32 }
33 33
34 startTimeOutInactividad() { 34 startTimeOutInactividad() {
35 this.timerReposo = setTimeout(() => { 35 this.timerReposo = setTimeout(() => {
36 this.router.navigate(['cancelar-compra']); 36 this.router.navigate(['cancelar-compra']);
37 }, 90000); 37 }, 90000);
38 } 38 }
39 39
40 } 40 }
41 41
src/app/modules/comanda/comanda.component.ts
1 import { Component, OnInit } from '@angular/core'; 1 import { Component, OnInit } from '@angular/core';
2 import { IComanda, IComandaDetalle, IComponente } from 'src/app/interfaces/IComanda'; 2 import { IComanda, IComandaDetalle, IComponente } from 'src/app/interfaces/IComanda';
3 import { ComandaService } from 'src/app/services/comanda/comanda.service'; 3 import { ComandaService } from 'src/app/services/comanda/comanda.service';
4 import * as _ from 'lodash'; 4 import * as _ from 'lodash';
5 5
6 @Component({ 6 @Component({
7 selector: 'app-comanda', 7 selector: 'app-comanda',
8 templateUrl: './comanda.component.html', 8 templateUrl: './comanda.component.html',
9 styleUrls: ['./comanda.component.scss'] 9 styleUrls: ['./comanda.component.scss']
10 }) 10 })
11 export class ComandaComponent implements OnInit { 11 export class ComandaComponent implements OnInit {
12 comandas: IComanda[] = []; 12 comandas: IComanda[] = [];
13 cicloTime: any; 13 cicloTime: any;
14 14
15 constructor( 15 constructor(
16 private comandaService: ComandaService, 16 private comandaService: ComandaService,
17 ) { } 17 ) { }
18 18
19 ngOnInit() { 19 ngOnInit() {
20 this.getComandas(); 20 this.getComandas();
21 this.timerGetComandas(); 21 this.timerGetComandas();
22 } 22 }
23 23
24 ngOnDestroy() { 24 OnDestroy() {
25 clearInterval(this.cicloTime); 25 clearInterval(this.cicloTime);
26 } 26 }
27 27
28 timerGetComandas() { 28 timerGetComandas() {
29 this.cicloTime = setInterval(() => { 29 this.cicloTime = setInterval(() => {
30 this.getComandas(); 30 this.getComandas();
31 }, 5000); 31 }, 5000);
32 } 32 }
33 33
34 getComandas() { 34 getComandas() {
35 this.comandaService.getAll() 35 this.comandaService.getAll()
36 .subscribe((resComandas: IComanda[]) => { 36 .subscribe((resComandas: IComanda[]) => {
37 this.addNewComandas(resComandas); 37 this.addNewComandas(resComandas);
38 }, e => console.error(e)); 38 }, e => console.error(e));
39 } 39 }
40 40
41 addNewComandas(resComandas: IComanda[]) { 41 addNewComandas(resComandas: IComanda[]) {
42 for (let j = 0; j < resComandas.length; j++) { 42 for (let j = 0; j < resComandas.length; j++) {
43 for (let i = 0; i < this.comandas.length; i++) { 43 for (const comanda of this.comandas) {
44 if (this.comandas[i].id === resComandas[j].id) { 44 if (comanda.id === resComandas[j].id) {
45 resComandas.splice(j, 1); 45 resComandas.splice(j, 1);
46 } 46 }
47 } 47 }
48 } 48 }
49 if (!resComandas.length) return; 49 if (!resComandas.length) return;
50 Array.prototype.push.apply(this.comandas, resComandas); 50 Array.prototype.push.apply(this.comandas, resComandas);
51 this.startTimersPedido(resComandas); 51 this.startTimersPedido(resComandas);
52 } 52 }
53 53
54 updateComanda(comanda: IComanda, estadoNuevo: number, observacionNueva: string) { 54 updateComanda(comanda: IComanda, estadoNuevo: number, observacionNueva: string) {
55 const data = { 55 const data = {
56 idComanda: comanda.id, 56 idComanda: comanda.id,
57 estado: estadoNuevo, 57 estado: estadoNuevo,
58 observacion: observacionNueva, 58 observacion: observacionNueva,
59 tiempoEspera: `${comanda.hoursPedido}:${comanda.secondsPedido}:${comanda.secondsPedido}`, 59 tiempoEspera: `${comanda.hoursPedido}:${comanda.secondsPedido}:${comanda.secondsPedido}`,
60 tiempoElaboracion: `${comanda.hoursElaboracion}:${comanda.secondsElaboracion}:${comanda.secondsElaboracion}`, 60 tiempoElaboracion: `${comanda.hoursElaboracion}:${comanda.secondsElaboracion}:${comanda.secondsElaboracion}`,
61 }; 61 };
62 if (data.estado === 3) { 62 if (data.estado === 3) {
63 this.comandaService.imprimirComandaCocina(parseInt(data.idComanda)) 63 this.comandaService.imprimirComandaCocina(parseInt(data.idComanda, 10))
64 .subscribe(res => { }, err => console.error(err) 64 .subscribe(res => { }, err => console.error(err)
65 ); 65 );
66 } 66 }
67 67
68 if (estadoNuevo !== 2) comanda.detalles.forEach(d => d.seeDetalle = false); 68 if (estadoNuevo !== 2) comanda.detalles.forEach(d => d.seeDetalle = false);
69 69
70 this.comandaService.update(data) 70 this.comandaService.update(data)
71 .subscribe((res: any) => { 71 .subscribe((res: any) => {
72 if (res.data) { 72 if (res.data) {
73 comanda.estado = estadoNuevo; 73 comanda.estado = estadoNuevo;
74 comanda.observacion = observacionNueva; 74 comanda.observacion = observacionNueva;
75 if (estadoNuevo === 2) { 75 if (estadoNuevo === 2) {
76 this.startTimerElaboracion(comanda); 76 this.startTimerElaboracion(comanda);
77 } else if (comanda.timerElaboracion) { 77 } else if (comanda.timerElaboracion) {
78 clearInterval(comanda.timerElaboracion); 78 clearInterval(comanda.timerElaboracion);
79 } 79 }
80 } 80 }
81 }, e => console.error(e)); 81 }, e => console.error(e));
82 } 82 }
83 83
84 rellenar(relleno, longitud) { 84 rellenar(relleno, longitud) {
85 relleno = '' + relleno; 85 relleno = '' + relleno;
86 while (relleno.length < longitud) { 86 while (relleno.length < longitud) {
87 relleno = '0' + relleno; 87 relleno = '0' + relleno;
88 } 88 }
89 return relleno; 89 return relleno;
90 } 90 }
91 91
92 toggleVerComponentes(detalle: IComandaDetalle, comanda: IComanda) { 92 toggleVerComponentes(detalle: IComandaDetalle, comanda: IComanda) {
93 detalle.seeDetalle = !detalle.seeDetalle; 93 detalle.seeDetalle = !detalle.seeDetalle;
94 } 94 }
95 95
96 hasTipo(componentes: IComponente[]) { 96 hasTipo(componentes: IComponente[]) {
97 return componentes.some(c => c.tipoArticulo === 6); 97 return componentes.some(c => c.tipoArticulo === 6);
98 } 98 }
99 99
100 //#region TIMERS 100 //#region TIMERS
101 startTimersPedido(comandas) { 101 startTimersPedido(comandas) {
102 comandas.forEach((comanda: IComanda) => { 102 comandas.forEach((comanda: IComanda) => {
103 this.comandaService.startTimerComanda(comanda, 'Pedido'); 103 this.comandaService.startTimerComanda(comanda, 'Pedido');
104 if (comanda.estado === 2) { 104 if (comanda.estado === 2) {
105 this.startTimerElaboracion(comanda); 105 this.startTimerElaboracion(comanda);
106 } 106 }
107 }); 107 });
108 } 108 }
109 109
110 startTimerElaboracion(comanda: IComanda) { 110 startTimerElaboracion(comanda: IComanda) {
111 this.comandaService.startTimerComanda(comanda, 'Elaboracion'); 111 this.comandaService.startTimerComanda(comanda, 'Elaboracion');
112 } 112 }
113 //#endregion 113 //#endregion
114 114
115 } 115 }
116 116
src/app/modules/mensaje-final/mensaje-final.component.ts
1 import { Component, OnInit } from '@angular/core'; 1 import { Component, OnInit } from '@angular/core';
2 import { ArticuloService } from 'src/app/services/articulo/articulo.service'; 2 import { ArticuloService } from 'src/app/services/articulo/articulo.service';
3 import { Router } from '@angular/router'; 3 import { Router } from '@angular/router';
4 4
5 @Component({ 5 @Component({
6 selector: 'app-mensaje-final', 6 selector: 'app-mensaje-final',
7 templateUrl: './mensaje-final.component.html', 7 templateUrl: './mensaje-final.component.html',
8 styleUrls: ['./mensaje-final.component.scss'] 8 styleUrls: ['./mensaje-final.component.scss']
9 }) 9 })
10 export class MensajeFinalComponent implements OnInit { 10 export class MensajeFinalComponent implements OnInit {
11 timer: any; 11 timer: any;
12 12
13 constructor( 13 constructor(
14 public articuloService: ArticuloService, 14 public articuloService: ArticuloService,
15 private router: Router, 15 private router: Router,
16 ) { } 16 ) { }
17 17
18 ngOnInit() { 18 ngOnInit() {
19 this.timer = setTimeout(() => { 19 this.timer = setTimeout(() => {
20 this.goToSplash(); 20 this.goToSplash();
21 }, 10000); 21 }, 10000);
22 } 22 }
23 23
24 ngOnDestroy() { 24 OnDestroy() {
25 clearTimeout(this.timer); 25 clearTimeout(this.timer);
26 } 26 }
27 27
28 goToSplash() { 28 goToSplash() {
29 this.articuloService.cleanShoppingCar(); 29 this.articuloService.cleanShoppingCar();
30 this.router.navigate(['']); 30 this.router.navigate(['']);
31 } 31 }
32 32
33 } 33 }
34 34
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
1 import { Component, OnInit } from '@angular/core'; 1 import { Component, OnInit } from '@angular/core';
2 import { BsModalRef } from 'ngx-bootstrap/modal'; 2 import { BsModalRef } from 'ngx-bootstrap/modal';
3 import { ArticuloService } from 'src/app/services/articulo/articulo.service'; 3 import { ArticuloService } from 'src/app/services/articulo/articulo.service';
4 import { IArticulo } from 'src/app/interfaces/IArticulo'; 4 import { IArticulo } from 'src/app/interfaces/IArticulo';
5 import { APP_SETTINGS } from 'src/etc/AppSettings'; 5 import { APP_SETTINGS } from 'src/etc/AppSettings';
6 import { ICategoria } from 'src/app/interfaces/ICategoria'; 6 import { ICategoria } from 'src/app/interfaces/ICategoria';
7 import { CategoriaService } from 'src/app/services/categoria/categoria.service'; 7 import { CategoriaService } from 'src/app/services/categoria/categoria.service';
8 8
9 @Component({ 9 @Component({
10 selector: 'app-seleccion-articulos', 10 selector: 'app-seleccion-articulos',
11 templateUrl: './seleccion-articulos.component.html', 11 templateUrl: './seleccion-articulos.component.html',
12 styleUrls: ['./seleccion-articulos.component.scss'] 12 styleUrls: ['./seleccion-articulos.component.scss']
13 }) 13 })
14 export class SeleccionArticulosComponent implements OnInit { 14 export class SeleccionArticulosComponent implements OnInit {
15 showSpinner = true; 15 showSpinner = true;
16 timeoutHandler: any; 16 timeoutHandler: any;
17 urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; 17 urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`;
18 articulos: IArticulo[] = []; 18 articulos: IArticulo[] = [];
19 auxArticulos: IArticulo[] = []; 19 auxArticulos: IArticulo[] = [];
20 showQuantity = 100; 20 showQuantity = 100;
21 queMostrar = 'todos'; 21 queMostrar = 'todos';
22 categoriaActive: number = null; 22 categoriaActive: number = null;
23 categorias: ICategoria[] = []; 23 categorias: ICategoria[] = [];
24 searchTerm = ''; 24 searchTerm = '';
25 ordenandoByVendidos = true; 25 ordenandoByVendidos = true;
26 allActive = true; 26 allActive = true;
27 modalRef: BsModalRef; 27 modalRef: BsModalRef;
28 total: number = 0; 28 total = 0;
29 29
30 constructor( 30 constructor(
31 public articuloService: ArticuloService, 31 public articuloService: ArticuloService,
32 private categoriaService: CategoriaService, 32 private categoriaService: CategoriaService,
33 ) { } 33 ) { }
34 34
35 ngOnInit() { 35 ngOnInit() {
36 this.getCategorias(); 36 this.getCategorias();
37 } 37 }
38 38
39 getCategorias() { 39 getCategorias() {
40 this.categoriaService.getAll() 40 this.categoriaService.getAll()
41 .subscribe((categorias: ICategoria[]) => { 41 .subscribe((categorias: ICategoria[]) => {
42 switch (this.queMostrar) { 42 switch (this.queMostrar) {
43 case 'todos': 43 case 'todos':
44 this.categorias = categorias; 44 this.categorias = categorias;
45 this.categoriaActive = 0; 45 this.categoriaActive = 0;
46 break; 46 break;
47 case 'promociones': 47 case 'promociones':
48 this.categorias = categorias; 48 this.categorias = categorias;
49 this.categoriaActive = 19; 49 this.categoriaActive = 19;
50 break; 50 break;
51 case 'ordenar': 51 case 'ordenar':
52 this.categorias = categorias.filter((categoria: ICategoria) => { 52 this.categorias = categorias.filter((categoria: ICategoria) => {
53 return categoria.ES_PEDIDO; 53 return categoria.ES_PEDIDO;
54 }); 54 });
55 this.categoriaActive = 4; 55 this.categoriaActive = 4;
56 break; 56 break;
57 default: 57 default:
58 this.categorias = categorias; 58 this.categorias = categorias;
59 this.categoriaActive = 0; 59 this.categoriaActive = 0;
60 break; 60 break;
61 } 61 }
62 !localStorage.getItem('articulos') ? 62 !localStorage.getItem('articulos') ?
63 this.getProductos() : 63 this.getProductos() :
64 this.setProductos(); 64 this.setProductos();
65 }); 65 });
66 } 66 }
67 67
68 getProductos() { 68 getProductos() {
69 this.articuloService.getAll() 69 this.articuloService.getAll()
70 .subscribe((result: IArticulo[]) => { 70 .subscribe((result: IArticulo[]) => {
71 this.articuloService.setArticulosSinImagen(result); 71 this.articuloService.setArticulosSinImagen(result);
72 if (this.queMostrar === 'ordenar') { 72 if (this.queMostrar === 'ordenar') {
73 this.categorias.forEach((categoria: ICategoria) => { 73 this.categorias.forEach((categoria: ICategoria) => {
74 const tempArticulos = result.filter((articulo: IArticulo) => { 74 const tempArticulos = result.filter((articulo: IArticulo) => {
75 return articulo.categoria_selfservice === categoria.id; 75 return articulo.categoria_selfservice === categoria.id;
76 }); 76 });
77 result = tempArticulos; 77 result = tempArticulos;
78 }); 78 });
79 } 79 }
80 localStorage.setItem('articulos', JSON.stringify(result)); 80 localStorage.setItem('articulos', JSON.stringify(result));
81 this.setProductos(); 81 this.setProductos();
82 }, (error) => { 82 }, (error) => {
83 this.showSpinner = false; 83 this.showSpinner = false;
84 console.error(error); 84 console.error(error);
85 }); 85 });
86 } 86 }
87 87
88 setProductos() { 88 setProductos() {
89 this.articulos = JSON.parse(localStorage.getItem('articulos')); 89 this.articulos = JSON.parse(localStorage.getItem('articulos'));
90 this.filterItems(); 90 this.filterItems();
91 } 91 }
92 92
93 filterItems() { 93 filterItems() {
94 if (this.categoriaActive === 0) { 94 if (this.categoriaActive === 0) {
95 this.auxArticulos = this.articulos; 95 this.auxArticulos = this.articulos;
96 return; 96 return;
97 } 97 }
98 this.auxArticulos = this.articulos.filter(x => { 98 this.auxArticulos = this.articulos.filter(x => {
99 return x.categoria_selfservice === this.categoriaActive; 99 return x.categoria_selfservice === this.categoriaActive;
100 }); 100 });
101 this.ordenar(); 101 this.ordenar();
102 } 102 }
103 103
104 ordenar() { 104 ordenar() {
105 if (this.ordenandoByVendidos) { 105 if (this.ordenandoByVendidos) {
106 this.auxArticulos.sort((a, b) => { 106 this.auxArticulos.sort((a, b) => {
107 return b.cantidadVendida - a.cantidadVendida; 107 return b.cantidadVendida - a.cantidadVendida;
108 }); 108 });
109 } 109 }
110 } 110 }
111 111
112 selectCategoria(index: number, idCategoria?: number) { 112 selectCategoria(index: number, idCategoria?: number) {
113 if (this.categoriaActive === idCategoria) return; 113 if (this.categoriaActive === idCategoria) return;
114 this.categoriaActive = idCategoria; 114 this.categoriaActive = idCategoria;
115 this.allActive = idCategoria === 0 ? true : false; 115 this.allActive = idCategoria === 0 ? true : false;
116 this.categorias.forEach((categoria, i) => { 116 this.categorias.forEach((categoria, i) => {
117 categoria.selected = index === i ? true : false; 117 categoria.selected = index === i ? true : false;
118 }); 118 });
119 this.filterItems(); 119 this.filterItems();
120 } 120 }
121 121
122 elegirArticulo(articulo: IArticulo) { 122 elegirArticulo(articulo: IArticulo) {
123 this.articuloService.getById(articulo.id) 123 this.articuloService.getById(articulo.id)
124 .subscribe((res: IArticulo) => { 124 .subscribe((res: IArticulo) => {
125 res.cantidad = 1; 125 res.cantidad = 1;
126 this.articuloService.setArticulo(res); 126 this.articuloService.setArticulo(res);
127 }, err => console.error(err)); 127 }, err => console.error(err));
128 } 128 }
129 129
130 increaseShow() { 130 increaseShow() {
131 this.showQuantity += 100; 131 this.showQuantity += 100;
132 } 132 }
133 133
134 mouseup() { 134 mouseup() {
135 if (!this.timeoutHandler) return; 135 if (!this.timeoutHandler) return;
136 clearInterval(this.timeoutHandler); 136 clearInterval(this.timeoutHandler);
137 } 137 }
138 138
139 scrollY(el: HTMLElement, value) { 139 scrollY(el: HTMLElement, value) {
140 el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); 140 el.scroll({ behavior: 'smooth', top: value + el.scrollTop });
141 this.timeoutHandler = setInterval(() => { 141 this.timeoutHandler = setInterval(() => {
142 el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); 142 el.scroll({ behavior: 'smooth', top: value + el.scrollTop });
143 }, 500); 143 }, 500);
144 } 144 }
145 145
146 scrollX(el: HTMLElement, value) { 146 scrollX(el: HTMLElement, value) {
147 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); 147 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft });
148 this.timeoutHandler = setInterval(() => { 148 this.timeoutHandler = setInterval(() => {
149 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); 149 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft });
150 }, 500); 150 }, 500);
151 } 151 }
152 } 152 }
153 153
src/app/services/articulo/articulo.service.ts
1 import { Injectable } from '@angular/core'; 1 import { Injectable } from '@angular/core';
2 import { HttpClient } from '@angular/common/http'; 2 import { HttpClient } from '@angular/common/http';
3 import { APP_SETTINGS } from '../../../etc/AppSettings'; 3 import { APP_SETTINGS } from '../../../etc/AppSettings';
4 import { IArticulo } from '../../interfaces/IArticulo'; 4 import { IArticulo } from '../../interfaces/IArticulo';
5 import { ClienteService } from '../cliente/cliente.service'; 5 import { ClienteService } from '../cliente/cliente.service';
6 import { Observable } from 'rxjs'; 6 import { Observable } from 'rxjs';
7 7
8 @Injectable() 8 @Injectable()
9 export class ArticuloService { 9 export class ArticuloService {
10 carrito: IArticulo[] = []; 10 carrito: IArticulo[] = [];
11 articuloAcargar: IArticulo; 11 articuloAcargar: IArticulo;
12 promoAcargar: IArticulo; 12 promoAcargar: IArticulo;
13 mostrar: string; 13 mostrar: string;
14 esPromoPersonalizada = false; 14 esPromoPersonalizada = false;
15 urlDeboSuite = APP_SETTINGS.apiDeboSuite; 15 urlDeboSuite = APP_SETTINGS.apiDeboSuite;
16 medioPago: number; 16 medioPago: number;
17 idComanda: number; 17 idComanda: number;
18 subTotal: number = 0; 18 subTotal = 0;
19 19
20 constructor( 20 constructor(
21 private http: HttpClient, 21 private http: HttpClient,
22 private clienteService: ClienteService, 22 private clienteService: ClienteService,
23 ) { } 23 ) { }
24 24
25 getById(id) { 25 getById(id) {
26 return this.http.get(`${this.urlDeboSuite}/articulos/${id}`); 26 return this.http.get(`${this.urlDeboSuite}/articulos/${id}`);
27 } 27 }
28 28
29 getAll() { 29 getAll() {
30 return this.http.get(`${this.urlDeboSuite}/articulos/`); 30 return this.http.get(`${this.urlDeboSuite}/articulos/`);
31 } 31 }
32 32
33 getAllWithPaginator(page: number = 1) { 33 getAllWithPaginator(page: number = 1) {
34 return this.http.get(`${this.urlDeboSuite}/articulos/${page}`); 34 return this.http.get(`${this.urlDeboSuite}/articulos/${page}`);
35 } 35 }
36 36
37 calcularTotal() { 37 calcularTotal() {
38 this.subTotal = 0; 38 this.subTotal = 0;
39 this.carrito.forEach(articulo => { 39 this.carrito.forEach(articulo => {
40 this.subTotal += (articulo.PreVen * articulo.cantidad); 40 this.subTotal += (articulo.PreVen * articulo.cantidad);
41 }); 41 });
42 } 42 }
43 43
44 setArticulo(articulo: IArticulo) { 44 setArticulo(articulo: IArticulo) {
45 for (const articuloCarrito of this.carrito) { 45 for (const articuloCarrito of this.carrito) {
46 if (articuloCarrito.id === articulo.id) { 46 if (articuloCarrito.id === articulo.id) {
47 if (articulo.PRO) break; 47 if (articulo.PRO) break;
48 articuloCarrito.cantidad++; 48 articuloCarrito.cantidad++;
49 return; 49 return;
50 } 50 }
51 } 51 }
52 this.setArticulosSinImagen([articulo]); 52 this.setArticulosSinImagen([articulo]);
53 this.carrito.unshift(articulo); 53 this.carrito.unshift(articulo);
54 this.calcularTotal(); 54 this.calcularTotal();
55 } 55 }
56 56
57 pay(dataPago: any) { 57 pay(dataPago: any) {
58 return new Observable((observer) => { 58 return new Observable((observer) => {
59 this.clienteService.getById(-1) 59 this.clienteService.getById(-1)
60 .subscribe(cliente => { 60 .subscribe(cliente => {
61 this.markArticuloInPromoAsRemoved(); 61 this.markArticuloInPromoAsRemoved();
62 this.http.post(`${this.urlDeboSuite}/comprobante/guardar/${this.medioPago}`, { 62 this.http.post(`${this.urlDeboSuite}/comprobante/guardar/${this.medioPago}`, {
63 productos: this.carrito, 63 productos: this.carrito,
64 cliente, 64 cliente,
65 origen: 'autoservicio', 65 origen: 'autoservicio',
66 codigoVendedor: 5, 66 codigoVendedor: 5,
67 puntoVenta: APP_SETTINGS.puntoVenta, 67 puntoVenta: APP_SETTINGS.puntoVenta,
68 pedidoAnombreDe: dataPago.pedidoAnombreDe, 68 pedidoAnombreDe: dataPago.pedidoAnombreDe,
69 numeroPlanilla: APP_SETTINGS.numeroPlanilla, 69 numeroPlanilla: APP_SETTINGS.numeroPlanilla,
70 }) 70 })
71 .subscribe((data) => { 71 .subscribe((data) => {
72 observer.next(data); 72 observer.next(data);
73 observer.complete(); 73 observer.complete();
74 }); 74 });
75 }); 75 });
76 }); 76 });
77 } 77 }
78 78
79 cleanShoppingCar() { 79 cleanShoppingCar() {
80 this.articuloAcargar = undefined; 80 this.articuloAcargar = undefined;
81 this.promoAcargar = undefined; 81 this.promoAcargar = undefined;
82 this.carrito = []; 82 this.carrito = [];
83 } 83 }
84 84
85 setArticulosSinImagen(articulos: IArticulo[]) { 85 setArticulosSinImagen(articulos: IArticulo[]) {
86 articulos.forEach((articulo: IArticulo) => { 86 articulos.forEach((articulo: IArticulo) => {
87 articulo.imagenes = !articulo.imagenes ? [{ imagen: 'noImage.jpg' }] : 87 articulo.imagenes = !articulo.imagenes ? [{ imagen: 'noImage.jpg' }] :
88 !articulo.imagenes.length ? [{ imagen: 'noImage.jpg' }] : articulo.imagenes; 88 !articulo.imagenes.length ? [{ imagen: 'noImage.jpg' }] : articulo.imagenes;
89 }); 89 });
90 } 90 }
91 91
92 markArticuloInPromoAsRemoved() { 92 markArticuloInPromoAsRemoved() {
93 this.carrito.forEach((articuloCarrito: IArticulo) => { 93 this.carrito.forEach((articuloCarrito: IArticulo) => {
94 if (articuloCarrito.PRO) { 94 if (articuloCarrito.PRO) {
95 articuloCarrito.productos.forEach((articulo: IArticulo) => { 95 articuloCarrito.productos.forEach((articulo: IArticulo) => {
96 if (articulo.cantidadAdicionada === 0) { 96 if (articulo.cantidadAdicionada === 0) {
97 articulo.cantidad = 0; 97 articulo.cantidad = 0;
98 articulo.importeValorExtra = 0; 98 articulo.importeValorExtra = 0;
99 } 99 }
100 }); 100 });
101 } 101 }
102 }); 102 });
103 } 103 }
104 } 104 }
105 105
src/app/services/comanda/comanda.service.ts
1 import { Injectable } from '@angular/core'; 1 import { Injectable } from '@angular/core';
2 import { HttpClient } from '@angular/common/http'; 2 import { HttpClient } from '@angular/common/http';
3 import { APP_SETTINGS } from 'src/etc/AppSettings'; 3 import { APP_SETTINGS } from 'src/etc/AppSettings';
4 import { IComanda } from 'src/app/interfaces/IComanda'; 4 import { IComanda } from 'src/app/interfaces/IComanda';
5 5
6 @Injectable({ 6 @Injectable({
7 providedIn: 'root' 7 providedIn: 'root'
8 }) 8 })
9 export class ComandaService { 9 export class ComandaService {
10 urlDeboSuite = APP_SETTINGS.apiDeboSuite; 10 urlDeboSuite = APP_SETTINGS.apiDeboSuite;
11 11
12 constructor( 12 constructor(
13 private http: HttpClient, 13 private http: HttpClient,
14 ) { } 14 ) { }
15 15
16 getPendientesEntrega() { 16 getPendientesEntrega() {
17 return this.http.get(`${this.urlDeboSuite}/comandas/pendientes-entrega`); 17 return this.http.get(`${this.urlDeboSuite}/comandas/pendientes-entrega`);
18 } 18 }
19 19
20 update(data: object) { 20 update(object: object) {
21 return this.http.post(`${this.urlDeboSuite}/comandas/update`, { data: data }); 21 return this.http.post(`${this.urlDeboSuite}/comandas/update`, { data: object });
22 } 22 }
23 23
24 getAll() { 24 getAll() {
25 return this.http.get(`${this.urlDeboSuite}/comandas`); 25 return this.http.get(`${this.urlDeboSuite}/comandas`);
26 } 26 }
27 27
28 imprimirComandaCocina(idComanda: number) { 28 imprimirComandaCocina(idComanda: number) {
29 return this.http.get(`${this.urlDeboSuite}/comandas/imprimir/${idComanda}`); 29 return this.http.get(`${this.urlDeboSuite}/comandas/imprimir/${idComanda}`);
30 } 30 }
31 31
32 startTimerComanda(comanda: IComanda, tipo: string) { 32 startTimerComanda(comanda: IComanda, tipo: string) {
33 let hours = 0; 33 let hours = 0;
34 let minutes = 0; 34 let minutes = 0;
35 let seconds = 0; 35 let seconds = 0;
36 comanda[`hours${tipo}`] = '0'; 36 comanda[`hours${tipo}`] = '0';
37 comanda[`seconds${tipo}`] = comanda[`minutes${tipo}`] = '00'; 37 comanda[`seconds${tipo}`] = comanda[`minutes${tipo}`] = '00';
38 comanda[`timer${tipo}`] = setInterval(() => { 38 comanda[`timer${tipo}`] = setInterval(() => {
39 seconds++; 39 seconds++;
40 comanda[`seconds${tipo}`] = seconds < 10 ? `0${seconds}` : seconds.toString(); 40 comanda[`seconds${tipo}`] = seconds < 10 ? `0${seconds}` : seconds.toString();
41 if (seconds === 60) { 41 if (seconds === 60) {
42 minutes++; 42 minutes++;
43 comanda[`minutes${tipo}`] = minutes < 10 ? `0${minutes}` : minutes.toString(); 43 comanda[`minutes${tipo}`] = minutes < 10 ? `0${minutes}` : minutes.toString();
44 seconds = 0; 44 seconds = 0;
45 comanda[`seconds${tipo}`] = '00'; 45 comanda[`seconds${tipo}`] = '00';
46 } 46 }
47 if (minutes === 60) { 47 if (minutes === 60) {
48 hours++; 48 hours++;
49 minutes = 0; 49 minutes = 0;
50 comanda[`hours${tipo}`] = hours.toString(); 50 comanda[`hours${tipo}`] = hours.toString();
51 comanda[`minutes${tipo}`] = '00'; 51 comanda[`minutes${tipo}`] = '00';
52 } 52 }
53 }, 1000); 53 }, 1000);
54 } 54 }
55 55
56 } 56 }
57 57