Commit da32f0d613d31a6b990a19aa140d47d5ce9ba935

Authored by Marcelo Puebla
Exists in develop

Merge branch 'develop' into 'develop'

Develop

See merge request !26
src/app/modules/pedidos-salientes/pedidos-salientes.component.html
1 <div class="row mt-2 justify-content-center h-15"> 1 <div class="row mt-2 justify-content-center h-15">
2 <div class="col-3 col-lg-2"> 2 <div class="col-3 col-lg-2">
3 <img 3 <img
4 draggable="false" 4 draggable="false"
5 ondragstart="return false;" 5 ondragstart="return false;"
6 (contextmenu)="false" 6 (contextmenu)="false"
7 class="w-60 h-auto d-block mx-auto" 7 class="w-60 h-auto d-block mx-auto"
8 src="../../../assets/img/logo-spot.svg"> 8 src="../../../assets/img/logo-spot.svg">
9 </div> 9 </div>
10 </div> 10 </div>
11 <div class="row mt-n5 mx-0 justify-content-around h-75"> 11 <div class="row mt-n5 mx-0 justify-content-around h-75">
12 <div class="col-5 col-md-6 col-lg-3 h-100"> 12 <div class="col-5 col-md-6 col-lg-3 h-100">
13 <div class="p-3 bg-white text-center shadow-lg rounded h-100"> 13 <div class="p-3 bg-white text-center shadow-lg rounded h-100">
14 <h5 class="pt-3">ESTAMOS</h5> 14 <h5 class="pt-3">ESTAMOS</h5>
15 <h3 class="font-weight-bold text-secondary">preparando</h3> 15 <h3 class="font-weight-bold text-secondary">preparando</h3>
16 <h5>TU PEDIDO</h5> 16 <h5>TU PEDIDO</h5>
17 <div 17 <div
18 *ngFor="let pedido of pedidosPendientes; let i = index" 18 *ngFor="let pedido of pedidosPendientes; let i = index"
19 [hidden]="i == 0 || i > 4" 19 [hidden]="i == 0 || i > 4"
20 class="font-weight-bold mb-2 text-muted"> 20 class="font-weight-bold mb-2 text-muted">
21 <h1 class="display-4">{{rellenar(pedido.id.toString().slice(1), 2)}}</h1> 21 <h1 class="display-4">{{rellenar(pedido.id.toString().slice(1), 3)}}</h1>
22 </div> 22 </div>
23 </div> 23 </div>
24 </div> 24 </div>
25 <div class="col-5 col-md-6 col-lg-3 h-100"> 25 <div class="col-5 col-md-6 col-lg-3 h-100">
26 <div class="p-3 bg-white shadow-lg rounded text-center h-100"> 26 <div class="p-3 bg-white shadow-lg rounded text-center h-100">
27 <h5 class="pt-3">LISTO PARA</h5> 27 <h5 class="pt-3">LISTO PARA</h5>
28 <h3 class="font-weight-bold text-primary">retirar</h3> 28 <h3 class="font-weight-bold text-primary">retirar</h3>
29 <div *ngIf="pedidoFinalizado.length"> 29 <div *ngIf="pedidoFinalizado.length">
30 <h1 class="display-1 mt-4 text-primary mb-0">{{rellenar(pedidoFinalizado[0].id.toString().slice(1), 2)}}</h1> 30 <h1 class="display-1 mt-4 text-primary mb-0">{{rellenar(pedidoFinalizado[0].id.toString().slice(1), 3)}}</h1>
31 <hr class="line mt-0"> 31 <hr class="line mt-0">
32 </div> 32 </div>
33 <h3 class="font-weight-bold text-info mt-4">¡Que lo disfrutes!</h3> 33 <h3 class="font-weight-bold text-info mt-4">¡Que lo disfrutes!</h3>
34 </div> 34 </div>
35 </div> 35 </div>
36 </div> 36 </div>
37 37
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 = 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;
48 articuloCarrito.cantidad++; 47 articuloCarrito.cantidad++;
48 this.calcularTotal();
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 }