Commit 0b977744143a58515257f815b86966a388a241f0

Authored by Eric Fernandez
Exists in master and in 1 other branch validar_pve

Merge branch 'master' into 'master'

Master(mpuebla)

See merge request !62
src/app/components/busqueda-productos/busqueda-productos.component.ts
1 import { Component, OnInit, EventEmitter } from '@angular/core'; 1 import { Component, OnInit, EventEmitter } from '@angular/core';
2 import { ProductoService } from 'src/app/services/producto.service'; 2 import { ProductoService } from 'src/app/services/producto.service';
3 import { Producto } from 'src/app/wrappers/producto'; 3 import { Producto } from 'src/app/wrappers/producto';
4 import { Categoria } from 'src/app/wrappers/categoria'; 4 import { Categoria } from 'src/app/wrappers/categoria';
5 import { appSettings } from 'src/etc/AppSettings'; 5 import { appSettings } from 'src/etc/AppSettings';
6 import { Router } from '@angular/router'; 6 import { Router } from '@angular/router';
7 7
8 @Component({ 8 @Component({
9 selector: 'app-busqueda-productos', 9 selector: 'app-busqueda-productos',
10 templateUrl: './busqueda-productos.component.html', 10 templateUrl: './busqueda-productos.component.html',
11 styleUrls: ['./busqueda-productos.component.scss'] 11 styleUrls: ['./busqueda-productos.component.scss']
12 }) 12 })
13 export class BusquedaProductosComponent implements OnInit { 13 export class BusquedaProductosComponent implements OnInit {
14 14
15 private productos: Producto[] = []; 15 private productos: Producto[] = [];
16 private auxProductos: Producto[] = []; 16 private auxProductos: Producto[] = [];
17 private searchTerm: string = ''; 17 private searchTerm: string = '';
18 private categoriaActive: number = null; 18 private categoriaActive: number = null;
19 private showSpinner: boolean = true; 19 private showSpinner: boolean = true;
20 private queMostrar: string = 'todo'; 20 private queMostrar: string = 'todo';
21 private apiUrl: string = appSettings.apiUrl; 21 private apiUrl: string = appSettings.apiUrl;
22 private categorias: Categoria[] = []; 22 private categorias: Categoria[] = [];
23 private blurFocus = new EventEmitter(); 23 private blurFocus = new EventEmitter();
24 24
25 constructor( 25 constructor(
26 private productoService: ProductoService, 26 private productoService: ProductoService,
27 private router: Router) { } 27 private router: Router) { }
28 28
29 ngOnInit() { 29 ngOnInit() {
30 30
31 this.queMostrar = this.productoService.mostrar; 31 this.queMostrar = this.productoService.mostrar;
32 32
33 this.productoService.getCategorias() 33 this.productoService.getCategorias()
34 .subscribe((categorias: Categoria[]) => { 34 .subscribe((categorias: Categoria[]) => {
35 35
36 switch (this.queMostrar) { 36 switch (this.queMostrar) {
37 case 'todos': 37 case 'todos':
38 this.categorias = categorias; 38 this.categorias = categorias;
39 this.categoriaActive = 0; 39 this.categoriaActive = 0;
40 break; 40 break;
41 case 'promociones': 41 case 'promociones':
42 this.categorias = categorias; 42 this.categorias = categorias;
43 this.categoriaActive = 1; 43 this.categoriaActive = 1;
44 break; 44 break;
45 case 'ordenar': 45 case 'ordenar':
46 46
47 this.categorias = categorias.filter((categoria: Categoria) => { 47 this.categorias = categorias.filter((categoria: Categoria) => {
48 return categoria.ES_PEDIDO; 48 return categoria.ES_PEDIDO;
49 }); 49 });
50 50
51 this.categoriaActive = 0; 51 this.categoriaActive = 0;
52 52
53 break; 53 break;
54 default: 54 default:
55 break; 55 break;
56 } 56 }
57 57
58 }); 58 });
59 59
60 this.productoService.productoAcargar = undefined; 60 this.productoService.productoAcargar = undefined;
61 this.productoService.getAll() 61 this.productoService.getAll()
62 .subscribe((data: Producto[]) => { 62 .subscribe((data: Producto[]) => {
63 63
64 this.setProductosSinImagen(data);
65
64 if (this.queMostrar == 'ordenar') { 66 if (this.queMostrar == 'ordenar') {
65 67
66 this.categorias.forEach((categoria: Categoria) => { 68 this.categorias.forEach((categoria: Categoria) => {
67 69
68 let tempProductos = data.filter((producto: Producto) => { 70 let tempProductos = data.filter((producto: Producto) => {
69 return producto.categoria_selfservice == categoria.id; 71 return producto.categoria_selfservice == categoria.id;
70 }); 72 });
71 73
72 this.productos = this.productos.concat(tempProductos); 74 this.productos = this.productos.concat(tempProductos);
73 75
74 }); 76 });
75 } else { 77 } else {
76 this.productos = data; 78 this.productos = data;
77 } 79 }
78 this.filterItems(); 80 this.filterItems();
79 }, (error) => { 81 }, (error) => {
80 this.showSpinner = false; 82 this.showSpinner = false;
81 console.error(error); 83 console.error(error);
82 }); 84 });
83 } 85 }
84 86
85 filterItems() { 87 filterItems() {
86 88
87 this.auxProductos = this.productos.filter(x => { 89 this.auxProductos = this.productos.filter(x => {
88 if (this.categoriaActive === 0) { 90 if (this.categoriaActive === 0) {
89 return x.DET_LAR.toLowerCase().includes(this.searchTerm.toLowerCase()); 91 return x.DET_LAR.toLowerCase().includes(this.searchTerm.toLowerCase());
90 } 92 }
91 else { 93 else {
92 return x.DET_LAR.toLowerCase().includes(this.searchTerm.toLowerCase()) && 94 return x.DET_LAR.toLowerCase().includes(this.searchTerm.toLowerCase()) &&
93 x.categoria_selfservice === this.categoriaActive; 95 x.categoria_selfservice === this.categoriaActive;
94 } 96 }
95 }); 97 });
96 98
97 } 99 }
98 100
99 agregarAlCarrito(producto: Producto) { 101 agregarAlCarrito(producto: Producto) {
100 102
101 producto.cantidad = 1; 103 producto.cantidad = 1;
102 this.productoService.productos.push(producto); 104 this.productoService.productos.push(producto);
103 } 105 }
104 106
105 lostBlur() { 107 lostBlur() {
106 this.blurFocus.emit(); 108 this.blurFocus.emit();
107 } 109 }
108 110
109 private elegirProducto(producto: Producto) { 111 private elegirProducto(producto: Producto) {
110 112
111 if (producto.PRO) { 113 if (producto.PRO) {
112 114
113 let imagenes = producto.imagenes; 115 let imagenes = producto.imagenes;
114 this.productoService.getPromocionByCodigos(producto.CodSec, producto.CodArt) 116 this.productoService.getPromocionByCodigos(producto.CodSec, producto.CodArt)
115 .subscribe(res => { 117 .subscribe(res => {
116 118
117 this.productoService.productoAcargar = res[0]; 119 this.productoService.productoAcargar = res[0];
118 this.productoService.productoAcargar.imagenes = imagenes; 120 this.productoService.productoAcargar.imagenes = imagenes;
119 this.router.navigate(['inicio']); 121 this.router.navigate(['inicio']);
120 }, 122 },
121 error => { console.error(error); } 123 error => { console.error(error); }
122 ); 124 );
123 } else { 125 } else {
124 126
125 this.productoService.productoAcargar = producto; 127 this.productoService.productoAcargar = producto;
126 this.router.navigate(['inicio']); 128 this.router.navigate(['inicio']);
127 } 129 }
128 130
129 } 131 }
132
133 private setProductosSinImagen(productos: Producto[]) {
134
135 productos.forEach((producto: Producto) => {
136 producto.imagenes = producto.imagenes.length == 0 ?
137 [{ imagen: 'noImage.jpg' }] : producto.imagenes;
138 })
139 }
130 } 140 }
131 141
src/app/components/inicio/inicio.component.ts
1 import { Component, OnInit, ViewChild, HostListener, AfterViewInit } from '@angular/core'; 1 import { Component, OnInit, ViewChild, HostListener, AfterViewInit } from '@angular/core';
2 import { PopoverDirective } from 'ngx-bootstrap'; 2 import { PopoverDirective } from 'ngx-bootstrap';
3 import { appSettings } from 'src/etc/AppSettings'; 3 import { appSettings } from 'src/etc/AppSettings';
4 import { Router } from '@angular/router'; 4 import { Router } from '@angular/router';
5 import { ProductoService } from 'src/app/services/producto.service'; 5 import { ProductoService } from 'src/app/services/producto.service';
6 import { Producto } from 'src/app/wrappers/producto'; 6 import { Producto } from 'src/app/wrappers/producto';
7 import { Sinonimo } from 'src/app/wrappers/sinonimo'; 7 import { Sinonimo } from 'src/app/wrappers/sinonimo';
8 8
9 @Component({ 9 @Component({
10 selector: 'app-inicio', 10 selector: 'app-inicio',
11 templateUrl: './inicio.component.html', 11 templateUrl: './inicio.component.html',
12 styleUrls: ['./inicio.component.scss'] 12 styleUrls: ['./inicio.component.scss']
13 }) 13 })
14 export class InicioComponent implements OnInit, AfterViewInit { 14 export class InicioComponent implements OnInit, AfterViewInit {
15 15
16 private tienePromo = false; 16 private tienePromo = false;
17 private productoEsPromo = false; 17 private productoEsPromo = false;
18 private busqueda: string = ''; 18 private busqueda: string = '';
19 private productoAcargar: Producto; 19 private productoAcargar: Producto;
20 private promoAcargar: Producto; 20 private promoAcargar: Producto;
21 private productos: Producto[] = []; 21 private productos: Producto[] = [];
22 private promociones: Producto[] = []; 22 private promociones: Producto[] = [];
23 private sinonimos: Sinonimo[] = []; 23 private sinonimos: Sinonimo[] = [];
24 private apiUrl: string = appSettings.apiUrl; 24 private apiUrl: string = appSettings.apiUrl;
25 25
26 @ViewChild('pop', { static: false }) popoverDirective: PopoverDirective; 26 @ViewChild('pop', { static: false }) popoverDirective: PopoverDirective;
27 27
28 @HostListener('document:keypress', ["$event"]) catchInput(e: KeyboardEvent) { 28 @HostListener('document:keypress', ["$event"]) catchInput(e: KeyboardEvent) {
29 29
30 if (e.keyCode == 13) { 30 if (e.keyCode == 13) {
31 this.buscarByCodigoBarras(this.busqueda); 31 this.buscarByCodigoBarras(this.busqueda);
32 this.busqueda = ''; 32 this.busqueda = '';
33 } else { 33 } else {
34 this.busqueda += e.key; 34 this.busqueda += e.key;
35 } 35 }
36 36
37 }; 37 };
38 38
39 constructor( 39 constructor(
40 private router: Router, 40 private router: Router,
41 private productoService: ProductoService 41 private productoService: ProductoService
42 ) { } 42 ) { }
43 43
44 ngOnInit() { 44 ngOnInit() {
45 45
46 this.productoAcargar = this.productoService.productoAcargar; 46 this.productoAcargar = this.productoService.productoAcargar;
47 this.getProductos(); 47 this.getProductos();
48 } 48 }
49 49
50 ngAfterViewInit() { 50 ngAfterViewInit() {
51 51
52 setTimeout(() => { 52 setTimeout(() => {
53 if (!this.productoAcargar) return; 53 if (!this.productoAcargar) return;
54 54
55 if (this.productoAcargar.PRO) { 55 if (this.productoAcargar.PRO) {
56 this.promociones.push(this.productoAcargar); 56 this.promociones.push(this.productoAcargar);
57 this.promoSeleccionada(this.productoAcargar, true); 57 this.promoSeleccionada(this.productoAcargar, true);
58 } 58 }
59 else { 59 else {
60 this.getPromociones(); 60 this.getPromociones();
61 } 61 }
62 }) 62 })
63 } 63 }
64 64
65 getProductos() { 65 getProductos() {
66 66
67 this.productoService.getAll() 67 this.productoService.getAll()
68 .subscribe((productos: Producto[]) => { 68 .subscribe((productos: Producto[]) => {
69 this.productos = productos; 69 this.productos = productos;
70 }); 70 });
71 } 71 }
72 72
73 getPromociones() { 73 getPromociones() {
74 74
75 var sector = this.productoAcargar.CodSec; 75 var sector = this.productoAcargar.CodSec;
76 var codigo = this.productoAcargar.CodArt; 76 var codigo = this.productoAcargar.CodArt;
77 this.productoService.getPromociones(sector, codigo) 77 this.productoService.getPromociones(sector, codigo)
78 .subscribe((res: Producto[]) => { 78 .subscribe((res: Producto[]) => {
79 79
80 if (res.length === 0) { 80 if (res.length === 0) {
81 81
82 this.productoAcargar.cantidad = 1; 82 this.productoAcargar.cantidad = 1;
83 this.productoService.productos.push(this.productoAcargar); 83 this.productoService.setProductos(this.productoAcargar);
84 this.productoAcargar = this.productoService.productoAcargar = undefined; 84 this.productoAcargar = this.productoService.productoAcargar = undefined;
85 } else { 85 } else {
86 86
87 this.promociones = res; 87 this.promociones = res;
88 this.popoverDirective.show(); 88 this.popoverDirective.show();
89 } 89 }
90 }, error => { console.error(error); }) 90 }, error => { console.error(error); })
91 } 91 }
92 92
93 confirmarProducto() { 93 confirmarProducto() {
94 94
95 var producto = this.promoAcargar ? this.promoAcargar : this.productoAcargar; 95 var producto = this.promoAcargar ? this.promoAcargar : this.productoAcargar;
96 producto.cantidad = 1; 96 producto.cantidad = 1;
97 this.productoService.productos.push(producto); 97 this.productoService.setProductos(producto);
98 this.productoService.productoAcargar = this.promoAcargar = this.productoAcargar = undefined; 98 this.productoService.productoAcargar = this.promoAcargar = this.productoAcargar = undefined;
99 this.promociones = []; 99 this.promociones = [];
100 this.popoverDirective.hide(); 100 this.popoverDirective.hide();
101 } 101 }
102 102
103 promoSeleccionada($event: Producto, showPopover: boolean) { 103 promoSeleccionada($event: Producto, showPopover: boolean) {
104 104
105 this.productoService.getProductoById($event.id) 105 this.productoService.getProductoById($event.id)
106 .subscribe((res: Producto) => { 106 .subscribe((res: Producto) => {
107 107
108 $event.imagenes = res.imagenes.length == 0 ? [{ imagen: 'noImage.jpg' }] : res.imagenes; 108 $event.imagenes = res.imagenes.length == 0 ? [{ imagen: 'noImage.jpg' }] : res.imagenes;
109 this.promoAcargar = $event; 109 this.promoAcargar = $event;
110 110
111 if ($event.tieneSinonimos) { 111 if ($event.tieneSinonimos) {
112 this.getSinonimos(this.promoAcargar.CodSec, this.promoAcargar.CodArt); 112 this.getSinonimos(this.promoAcargar.CodSec, this.promoAcargar.CodArt);
113 } else if (showPopover) { 113 } else if (showPopover) {
114 this.popoverDirective.show(); 114 this.popoverDirective.show();
115 } else { 115 } else {
116 this.popoverDirective.hide(); 116 this.popoverDirective.hide();
117 } 117 }
118 118
119 }, 119 },
120 error => { console.log(error); }) 120 error => { console.log(error); })
121 } 121 }
122 122
123 getSinonimos(sector, codigo) { 123 getSinonimos(sector, codigo) {
124 124
125 this.productoService.getPromocionSinonimos(sector, codigo) 125 this.productoService.getPromocionSinonimos(sector, codigo)
126 .subscribe((res: Sinonimo[]) => { 126 .subscribe((res: Sinonimo[]) => {
127 127
128 res.forEach(sinonimo => { 128 res.forEach(sinonimo => {
129 129
130 sinonimo.cantidad = 0; 130 sinonimo.cantidad = 0;
131 this.promoAcargar.productos.forEach(productoPromo => { 131 this.promoAcargar.productos.forEach(productoPromo => {
132 132
133 sinonimo.productos.forEach(productoSinonimo => { 133 sinonimo.productos.forEach(productoSinonimo => {
134 134
135 if (productoSinonimo.id === productoPromo.id) { 135 if (productoSinonimo.id === productoPromo.id) {
136 productoSinonimo.cantidad = productoPromo.cantidad; 136 productoSinonimo.cantidad = productoPromo.cantidad;
137 sinonimo.cantidad += productoPromo.cantidad; 137 sinonimo.cantidad += productoPromo.cantidad;
138 } 138 }
139 }) 139 })
140 }) 140 })
141 }) 141 })
142 this.sinonimos = res; 142 this.sinonimos = res;
143 (this.sinonimos.length > 0) ? this.popoverDirective.show() : this.popoverDirective.hide(); 143 (this.sinonimos.length > 0) ? this.popoverDirective.show() : this.popoverDirective.hide();
144 }) 144 })
145 } 145 }
146 146
147 productosPersonalizados($event: Producto[]) { 147 productosPersonalizados($event: Producto[]) {
148 148
149 var productosPersonalizados = $event; 149 var productosPersonalizados = $event;
150 150
151 this.promoAcargar.productos.forEach(productoPromo => { 151 this.promoAcargar.productos.forEach(productoPromo => {
152 152
153 if (!productoPromo.idSinonimo) productosPersonalizados.push(productoPromo); 153 if (!productoPromo.idSinonimo) productosPersonalizados.push(productoPromo);
154 }) 154 })
155 155
156 this.promoAcargar.productos = productosPersonalizados; 156 this.promoAcargar.productos = productosPersonalizados;
157 this.confirmarProducto(); 157 this.confirmarProducto();
158 } 158 }
159 159
160 buscarByCodigoBarras(busqueda) { 160 buscarByCodigoBarras(busqueda) {
161 161
162 let producto = this.productos.filter(producto => { 162 let producto = this.productos.filter(producto => {
163 return producto.codigoBarra == busqueda; 163 return producto.codigoBarra == busqueda;
164 }); 164 });
165 165
166 if (producto.length) { 166 if (producto.length) {
167 167
168 this.productoAcargar = producto[0]; 168 this.productoAcargar = producto[0];
169 this.getPromociones(); 169 this.getPromociones();
170 170
171 } else { 171 } else {
172 alert('No se encuentra el producto'); 172 alert('No se encuentra el producto');
173 } 173 }
174 174
175 } 175 }
176 176
177 irBusquedaProductos(value) { 177 irBusquedaProductos(value) {
178 178
179 this.productoService.mostrar = value; 179 this.productoService.mostrar = value;
180 this.router.navigate(['busqueda-productos']); 180 this.router.navigate(['busqueda-productos']);
181 } 181 }
182 182
183 deshacerCarga() { 183 deshacerCarga() {
184 184
185 if (this.sinonimos.length > 0) { 185 if (this.sinonimos.length > 0) {
186 this.sinonimos = []; 186 this.sinonimos = [];
187 this.popoverDirective.hide(); 187 this.popoverDirective.hide();
188 } 188 }
189 189
190 if (this.promoAcargar) { 190 if (this.promoAcargar) {
191 this.promoAcargar = undefined; 191 this.promoAcargar = undefined;
192 if (this.productoAcargar.PRO) { 192 if (this.productoAcargar.PRO) {
193 this.productoAcargar = undefined; 193 this.productoAcargar = undefined;
194 this.promociones = []; 194 this.promociones = [];
195 this.popoverDirective.hide(); 195 this.popoverDirective.hide();
196 } else { 196 } else {
197 this.popoverDirective.show(); 197 this.popoverDirective.show();
198 } 198 }
199 } else { 199 } else {
200 this.productoAcargar = undefined; 200 this.productoAcargar = undefined;
201 this.promociones = []; 201 this.promociones = [];
202 this.popoverDirective.hide(); 202 this.popoverDirective.hide();
203 } 203 }
204 } 204 }
205 205
206 } 206 }
207 207
src/app/services/producto.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 { Observable } from 'rxjs'; 3 import { Observable } from 'rxjs';
4 import { appSettings } from 'src/etc/AppSettings'; 4 import { appSettings } from 'src/etc/AppSettings';
5 import { Producto } from '../wrappers/producto'; 5 import { Producto } from '../wrappers/producto';
6 6
7 @Injectable({ 7 @Injectable({
8 providedIn: 'root' 8 providedIn: 'root'
9 }) 9 })
10 export class ProductoService { 10 export class ProductoService {
11 11
12 productos: Producto[] = []; 12 productos: Producto[] = [];
13 productoAcargar: Producto; 13 productoAcargar: Producto;
14 promoAcargar: Producto; 14 promoAcargar: Producto;
15 mostrar: string; 15 mostrar: string;
16 16
17 constructor(private http: HttpClient) { } 17 constructor(private http: HttpClient) { }
18 18
19 getProductoById(id): Observable<any> { 19 getProductoById(id): Observable<any> {
20 20
21 return this.http.get(`${appSettings.apiUrl}/articulos/${id}`); 21 return this.http.get(`${appSettings.apiUrl}/articulos/${id}`);
22 } 22 }
23 23
24 getAll(): Observable<any> { 24 getAll(): Observable<any> {
25 25
26 return this.http.get(`${appSettings.apiUrl}/articulos`); 26 return this.http.get(`${appSettings.apiUrl}/articulos`);
27 } 27 }
28 28
29 setProductos(producto: Producto) { 29 setProductos(producto: Producto) {
30 30
31 for (let i = 0; i < this.productos.length; i++) {
32
33 if (this.productos[i].id === producto.id) {
34
35 if (producto.PRO) {
36 if (this.promosIdenticas(this.productos[i], producto)) {
37 this.productos[i].cantidad++;
38 return;
39 } else {
40 break;
41 }
42 }
43 this.productos[i].cantidad++;
44 return;
45 }
46 }
47
31 this.productos.push(producto); 48 this.productos.push(producto);
32 } 49 }
33 50
34 getPromocionByCodigos(sector, codigo): Observable<any> { 51 getPromocionByCodigos(sector, codigo): Observable<any> {
35 52
36 var url = `${appSettings.apiUrl}/promociones/by-codigos/${sector}/${codigo}`; 53 var url = `${appSettings.apiUrl}/promociones/by-codigos/${sector}/${codigo}`;
37 // var url = `${appSettings.apiUrl}/promociones/by-codigos/${2}/${7}`; 54 // var url = `${appSettings.apiUrl}/promociones/by-codigos/${2}/${7}`;
38 return this.http.get(url); 55 return this.http.get(url);
39 } 56 }
40 57
41 getPromociones(sector, codigo): Observable<any> { 58 getPromociones(sector, codigo): Observable<any> {
42 59
43 var url = `${appSettings.apiUrl}/promociones/incluir-articulo/${sector}/${codigo}`; 60 var url = `${appSettings.apiUrl}/promociones/incluir-articulo/${sector}/${codigo}`;
44 // var url = `${appSettings.apiUrl}/promociones/incluir-articulo/${2}/${1306}`; 61 // var url = `${appSettings.apiUrl}/promociones/incluir-articulo/${2}/${1306}`;
45 return this.http.get(url); 62 return this.http.get(url);
46 } 63 }
47 64
48 getPromocionSinonimos(sector, codigo): Observable<any> { 65 getPromocionSinonimos(sector, codigo): Observable<any> {
49 66
50 var url = `${appSettings.apiUrl}/sinonimos/promo/${sector}/${codigo}`; 67 var url = `${appSettings.apiUrl}/sinonimos/promo/${sector}/${codigo}`;
51 // var url = `${appSettings.apiUrl}/sinonimos/promo/${2}/${7}`; 68 // var url = `${appSettings.apiUrl}/sinonimos/promo/${2}/${7}`;
52 return this.http.get(url); 69 return this.http.get(url);
53 } 70 }
54 71
55 updateImages(body): Observable<any> { 72 updateImages(body): Observable<any> {
56 return this.http.post(`${appSettings.apiUrl}/imagenes/guardar`, body); 73 return this.http.post(`${appSettings.apiUrl}/imagenes/guardar`, body);
57 } 74 }
58 75
59 getCategorias() { 76 getCategorias() {
60 return this.http.get(`${appSettings.apiUrl}/categorias`); 77 return this.http.get(`${appSettings.apiUrl}/categorias`);
61 } 78 }
62 79
63 pagar() { 80 pagar() {
64 return this.http.post(`${appSettings.apiUrl}/comprobante/guardar`, { 81 return this.http.post(`${appSettings.apiUrl}/comprobante/guardar`, {
65 productos: this.productos 82 productos: this.productos
66 }); 83 });
67 } 84 }
68 85
86 private promosIdenticas(promoEnCarrito: Producto, promo: Producto) {
87
88 var sonIdenticas = true;
89 var productosPromoCarrito = promoEnCarrito.productos;
90 var productosPromoAcargar = promo.productos;
91
92 if (productosPromoCarrito.length !== productosPromoAcargar.length) {
93 return false;
94 }
95
96 for (let i = 0; i < productosPromoCarrito.length; i++) {
97
98 if (productosPromoCarrito[i].id !== productosPromoAcargar[i].id) {
99 return false;
100 }
101 }
102
103 return sonIdenticas;
104 }
105
69 } 106 }
70 107