Commit d7f62d63f29bffad7b27661cdaee49e3e494bc98

Authored by Marcelo Puebla
1 parent 6ff8cc8cab
Exists in master and in 1 other branch validar_pve

Cambio de for a foreach.

src/app/components/popover-promos/popover-promos.component.ts
1 import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; 1 import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
2 import { PopoverDirective } from 'ngx-bootstrap/popover'; 2 import { PopoverDirective } from 'ngx-bootstrap/popover';
3 import { Promocion } from 'src/app/wrappers/promocion'; 3 import { Promocion } from 'src/app/wrappers/promocion';
4 import { Producto } from 'src/app/wrappers/producto'; 4 import { Producto } from 'src/app/wrappers/producto';
5 5
6 @Component({ 6 @Component({
7 selector: 'app-popover-promos', 7 selector: 'app-popover-promos',
8 templateUrl: './popover-promos.component.html', 8 templateUrl: './popover-promos.component.html',
9 styleUrls: ['./popover-promos.component.scss'] 9 styleUrls: ['./popover-promos.component.scss']
10 }) 10 })
11 export class PopoverPromosComponent implements OnInit { 11 export class PopoverPromosComponent implements OnInit {
12 12
13 @Input() popover: PopoverDirective; 13 @Input() popover: PopoverDirective;
14 @Input() popoverContent: Promocion[]; 14 @Input() popoverContent: Promocion[];
15 @Output() promoSeleccionada = new EventEmitter<Promocion>(); 15 @Output() promoSeleccionada = new EventEmitter<Promocion>();
16 16
17 constructor() { } 17 constructor() { }
18 18
19 ngOnInit() { 19 ngOnInit() {
20 } 20 }
21 21
22 hide() { 22 hide() {
23 this.popover.hide(); 23 this.popover.hide();
24 } 24 }
25 25
26 seleccionarPromo(promo: Promocion) { 26 seleccionarPromo(promo: Promocion) {
27 27
28 this.promoSeleccionada.emit(promo); 28 this.promoSeleccionada.emit(promo);
29 } 29 }
30 30
31 calcularPrecioDePromo(productos: Producto[]) { 31 calcularPrecioDePromo(productos: Producto[]) {
32 32
33 var precio = 0; 33 var precio = 0;
34 for (let i = 0; i < productos.length; i++) { 34 productos.forEach(producto => {
35 precio += productos[i].PreVen; 35 precio += producto.PreVen;
36 } 36 })
37
37 return precio; 38 return precio;
38 } 39 }
39 40
40 } 41 }
41 42