Commit fb598a4469f95ab54bbd71daf586c0b27875cf20

Authored by Marcelo Puebla
1 parent aad68e973a
Exists in develop

Add

Mensaje de error con articulos en carrito sin stock
src/app/modules/carrito/carrito.component.html
1 <div class="h-92 bg-white fade-in-left"> 1 <div class="h-92 bg-white fade-in-left">
2 <!-- PUBLICIDADES --> 2 <!-- PUBLICIDADES -->
3 <app-header-publicidad></app-header-publicidad> 3 <app-header-publicidad></app-header-publicidad>
4 4
5 <div class="h-75 carrito-content" #carritoContent> 5 <div class="h-75 carrito-content" #carritoContent>
6 <!-- CABECERA --> 6 <!-- CABECERA -->
7 <div class="row mx-3 h-auto border border-primary rounded-sm"> 7 <div class="row mx-3 h-auto border border-primary rounded-sm">
8 <div class="col-12 px-0 py-2 align-self-center"> 8 <div class="col-12 px-0 py-2 align-self-center">
9 <div class="px-3"> 9 <div class="px-3">
10 <p class="h6 text-truncate">ESTE ES TÚ CARRITO DE COMPRAS</p> 10 <p class="h6 text-truncate">ESTE ES TÚ CARRITO DE COMPRAS</p>
11 </div> 11 </div>
12 </div> 12 </div>
13 </div> 13 </div>
14 14
15 <!-- CARRITO --> 15 <!-- CARRITO -->
16 <div 16 <div
17 class="row mx-2 mt-4 h-80 h-lg-60 align-content-start scroll-y-visible" 17 class="row mx-2 mt-4 h-80 h-lg-60 align-content-start scroll-y-visible"
18 (scroll)="scrollEvent($event)"> 18 (scroll)="scrollEvent($event)">
19 <!-- MENSAJE DE ADVERTENCIA --> 19 <!-- MENSAJE DE ADVERTENCIA -->
20 <div class="col-10 align-self-center alert alert-primary" *ngIf="!articuloService.carrito.length"> 20 <div class="col-10 align-self-center alert alert-primary" *ngIf="!articuloService.carrito.length">
21 <p class="h5 text-center">No hay artículos en el carrito</p> 21 <p class="h5 text-center">No hay artículos en el carrito</p>
22 </div> 22 </div>
23 <!-- ARTICULOS --> 23 <!-- ARTICULOS -->
24 <div 24 <div
25 class="col-12 col-xl-6 p-2 h-50 h-md-25 h-xl-40 text-center text-truncate carrito-articulo" 25 class="col-12 col-xl-6 p-2 h-50 h-md-25 h-xl-40 text-center text-truncate carrito-articulo"
26 [ngClass]="{'media-pantalla': carritoContent.classList.contains('media-pantalla')}" 26 [ngClass]="{'media-pantalla': carritoContent.classList.contains('media-pantalla')}"
27 *ngFor="let articulo of articuloService.carrito; let i = index;" 27 *ngFor="let articulo of articuloService.carrito; let i = index;"
28 @EnterLeaveX> 28 @EnterLeaveX>
29 <!-- ARTICULO --> 29 <!-- ARTICULO -->
30 <div class="h-100 border border-primary rounded-sm"> 30 <div class="h-100 border border-primary rounded-sm">
31 <div class="row align-items-center mx-0 h-100"> 31 <div class="row align-items-center mx-0 h-100">
32 <!-- NOMBRE E IMAGEN --> 32 <!-- NOMBRE E IMAGEN -->
33 <div class="col-6 col-md-3 h-50 h-md-100 border-right border-primary"> 33 <div class="col-6 col-md-3 h-50 h-md-100 border-right border-primary">
34 <img 34 <img
35 draggable="false" 35 draggable="false"
36 ondragstart="return false;" 36 ondragstart="return false;"
37 (contextmenu)="false" 37 (contextmenu)="false"
38 class="d-none d-md-block mx-auto h-55 rounded-sm shadow-sm" 38 class="d-none d-md-block mx-auto h-55 rounded-sm shadow-sm"
39 src="{{urlImagenes}}{{articulo.imagenes[0].imagen}}" 39 src="{{urlImagenes}}{{articulo.imagenes[0].imagen}}"
40 onerror="this.src='assets/img/imagen-no-encontrada.jpg'"> 40 onerror="this.src='assets/img/imagen-no-encontrada.jpg'">
41 <div class="row mx-0 h-100 h-md-45"> 41 <div class="row mx-0 h-100 h-md-45">
42 <p class="col px-0 text-primary carrito-text-desc align-self-center"> 42 <p class="col px-0 text-primary carrito-text-desc align-self-center">
43 <small>{{articulo.MKT_DESC ? articulo.MKT_DESC.toUpperCase() : articulo.DetArt.toUpperCase()}}</small> 43 <small>{{articulo.MKT_DESC ? articulo.MKT_DESC.toUpperCase() : articulo.DetArt.toUpperCase()}}</small>
44 </p> 44 </p>
45 </div> 45 </div>
46 </div> 46 </div>
47 <!-- CANTIDAD --> 47 <!-- CANTIDAD -->
48 <div class="col-6 col-md-3 h-50 h-md-100 border-right border-primary"> 48 <div class="col-6 col-md-3 h-50 h-md-100 border-right border-primary">
49 <p class="h-40"><small>CANT</small></p> 49 <p class="h-40"><small>CANT</small></p>
50 <app-articulo-cantidad [articulo]="articulo"></app-articulo-cantidad> 50 <app-articulo-cantidad [articulo]="articulo"></app-articulo-cantidad>
51 </div> 51 </div>
52 <!-- PRECIO --> 52 <!-- PRECIO -->
53 <div class="col-6 col-md-3 h-50 h-md-100 border-right border-primary"> 53 <div class="col-6 col-md-3 h-50 h-md-100 border-right border-primary">
54 <p class="h-40"><small>PRECIO</small></p> 54 <p class="h-40"><small>PRECIO</small></p>
55 <div class="py-1 badge-pill bg-dark text-white"> 55 <div class="py-1 badge-pill bg-dark text-white">
56 <p><small>{{articulo.PreVen | currency}}</small></p> 56 <p><small>{{articulo.PreVen | currency}}</small></p>
57 </div> 57 </div>
58 </div> 58 </div>
59 <!-- ELIMINAR --> 59 <!-- ELIMINAR -->
60 <div class="col-6 col-md-3 align-self-center"> 60 <div class="col-6 col-md-3 align-self-center">
61 <div class="row mx-0 justify-content-center"> 61 <div class="row mx-0 justify-content-center">
62 <div 62 <div
63 class="col-auto px-3 py-1 btn-effect bg-primary badge-pill text-white" 63 class="col-auto px-3 py-1 btn-effect bg-primary badge-pill text-white"
64 (click)="deleteArticulo(i)"> 64 (click)="deleteArticulo(i)">
65 <span> 65 <span>
66 <small class="pr-2">ELIMINAR</small> 66 <small class="pr-2">ELIMINAR</small>
67 <img 67 <img
68 draggable="false" 68 draggable="false"
69 ondragstart="return false;" 69 ondragstart="return false;"
70 (contextmenu)="false" 70 (contextmenu)="false"
71 class="icon-20 rotate-45" 71 class="icon-20 rotate-45"
72 src="assets/img/mas-blanco.svg"> 72 src="assets/img/mas-blanco.svg">
73 </span> 73 </span>
74 </div> 74 </div>
75 </div> 75 </div>
76 </div> 76 </div>
77 </div> 77 </div>
78 </div> 78 </div>
79 </div> 79 </div>
80 </div> 80 </div>
81 <!-- TOTAL --> 81 <!-- TOTAL -->
82 <div class="row mx-3 mt-2 h-auto justify-content-end"> 82 <div class="row mx-3 mt-2 h-auto justify-content-end">
83 <div class="col-auto font-weight-bold align-self-center text-primary py-2 h3">TOTAL</div> 83 <div class="col-auto font-weight-bold align-self-center text-primary py-2 h3">TOTAL</div>
84 <div class="col-auto align-self-center bg-primary badge-pill"> 84 <div class="col-auto align-self-center bg-primary badge-pill">
85 <p class="text-center font-weight-bold text-white py-2 h3 px-2">{{articuloService.total | currency}}</p> 85 <p class="text-center font-weight-bold text-white py-2 h3 px-2">{{articuloService.total | currency}}</p>
86 </div> 86 </div>
87 </div> 87 </div>
88 <!-- CONTINUAR --> 88 <!-- CONTINUAR -->
89 <div 89 <div
90 *ngIf="articuloService.carrito.length" 90 *ngIf="articuloService.carrito.length"
91 class="row mx-3 mt-4 h-auto justify-content-end"> 91 class="row mx-3 mt-4 h-auto justify-content-end">
92 <div 92 <div
93 class="col-auto py-2 px-3 align-self-center btn-effect bg-primary badge-pill text-white" 93 class="col-auto py-2 px-3 align-self-center btn-effect bg-primary badge-pill text-white"
94 [routerLink]="['/forma-pago']"> 94 (click)="validateCarrito()">
95 <span> 95 <span>
96 <small class="pr-2">CONTINUAR</small> 96 <small class="pr-2">CONTINUAR</small>
97 <img 97 <img
98 draggable="false" 98 draggable="false"
99 ondragstart="return false;" 99 ondragstart="return false;"
100 (contextmenu)="false" 100 (contextmenu)="false"
101 class="icon-20" 101 class="icon-20"
102 src="assets/img/ir.svg"> 102 src="assets/img/ir.svg">
103 </span> 103 </span>
104 </div> 104 </div>
105 </div> 105 </div>
106 </div> 106 </div>
107 107
108 </div> 108 </div>
109 109
src/app/modules/carrito/carrito.component.ts
1 import { Component, OnInit, OnDestroy, HostListener } from '@angular/core'; 1 import { Component, OnInit, OnDestroy, HostListener } from '@angular/core';
2 import { Location } from '@angular/common'; 2 import { Location } from '@angular/common';
3 import { ArticuloService } from 'src/app/services/articulo/articulo.service'; 3 import { ArticuloService } from 'src/app/services/articulo/articulo.service';
4 import { APP_SETTINGS } from 'src/etc/AppSettings'; 4 import { APP_SETTINGS } from 'src/etc/AppSettings';
5 import { Router } from '@angular/router'; 5 import { Router } from '@angular/router';
6 import { BsModalRef } from 'ngx-bootstrap/modal/public_api'; 6 import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
7 import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; 7 import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service';
8 import { ANIMATIONS } from 'src/app/utils/animations'; 8 import { ANIMATIONS } from 'src/app/utils/animations';
9 import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component';
10 import { ErrorStockComponent } from 'src/app/shared/error-stock/error-stock.component';
9 11
10 @Component({ 12 @Component({
11 selector: 'app-carrito', 13 selector: 'app-carrito',
12 templateUrl: './carrito.component.html', 14 templateUrl: './carrito.component.html',
13 styleUrls: ['./carrito.component.scss'], 15 styleUrls: ['./carrito.component.scss'],
14 animations: [ANIMATIONS.EnterLeaveX] 16 animations: [ANIMATIONS.EnterLeaveX]
15 }) 17 })
16 export class CarritoComponent implements OnInit, OnDestroy { 18 export class CarritoComponent implements OnInit, OnDestroy {
17 urlImagenes = `${APP_SETTINGS.apiImagenes}/imagenes/`; 19 urlImagenes = `${APP_SETTINGS.apiImagenes}/imagenes/`;
18 maxCantidad = 50; 20 maxCantidad = 50;
19 modalRef: BsModalRef; 21 modalRef: BsModalRef;
20 22
21 constructor( 23 constructor(
22 public articuloService: ArticuloService, 24 public articuloService: ArticuloService,
23 private location: Location, 25 private location: Location,
24 private router: Router, 26 private router: Router,
25 private inactiveScreen: InactiveScreenService, 27 private inactiveScreen: InactiveScreenService,
28 private modalService: BsModalService
26 ) { } 29 ) { }
27 30
28 ngOnInit() { 31 ngOnInit() {
29 if (!this.articuloService.carrito.length) { 32 if (!this.articuloService.carrito.length) {
30 this.router.navigate(['']); 33 this.router.navigate(['']);
31 return; 34 return;
32 } 35 }
33 this.mediaPantalla(); 36 this.mediaPantalla();
34 } 37 }
35 38
36 ngOnDestroy() { 39 ngOnDestroy() {
37 if (this.modalRef) this.modalRef.hide(); 40 if (this.modalRef) this.modalRef.hide();
38 } 41 }
39 42
40 deleteArticulo(index: number) { 43 deleteArticulo(index: number) {
41 this.articuloService.deleteArticulo(index); 44 this.articuloService.deleteArticulo(index);
42 } 45 }
43 46
47 validateCarrito() {
48 const res = this.articuloService.validateCarrito()
49 if (res.valid) {
50 this.router.navigate(['forma-pago']);
51 } else {
52 this.modalService.show(
53 ErrorStockComponent,
54 {
55 initialState: { articulo: res.articulo },
56 class: 'modal-dialog-centered'
57 });
58 }
59 }
60
44 goBack() { 61 goBack() {
45 this.location.back(); 62 this.location.back();
46 } 63 }
47 64
48 @HostListener('document:click', ['$event']) 65 @HostListener('document:click', ['$event'])
49 eventListener(event: Event) { 66 eventListener(event: Event) {
50 clearTimeout(this.inactiveScreen.timerReposo); 67 clearTimeout(this.inactiveScreen.timerReposo);
51 this.inactiveScreen.startTimeOutInactividad(); 68 this.inactiveScreen.startTimeOutInactividad();
52 } 69 }
53 70
54 @HostListener('scroll', ['$event']) 71 @HostListener('scroll', ['$event'])
55 scrollEvent(event: Event) { 72 scrollEvent(event: Event) {
56 clearTimeout(this.inactiveScreen.timerReposo); 73 clearTimeout(this.inactiveScreen.timerReposo);
57 this.inactiveScreen.startTimeOutInactividad(); 74 this.inactiveScreen.startTimeOutInactividad();
58 } 75 }
59 76
60 mediaPantalla() { 77 mediaPantalla() {
61 if ($('body').hasClass('media-pantalla')) { 78 if ($('body').hasClass('media-pantalla')) {
62 $(`.carrito-content`).addClass('media-pantalla').addBack('media-pantalla'); 79 $(`.carrito-content`).addClass('media-pantalla').addBack('media-pantalla');
63 } 80 }
64 } 81 }
65 } 82 }
66 83
src/app/modules/carrito/carrito.module.ts
1 import { NgModule } from '@angular/core'; 1 import { NgModule } from '@angular/core';
2 import { CommonModule } from '@angular/common'; 2 import { CommonModule } from '@angular/common';
3 3
4 import { CarritoRoutingModule } from './carrito-routing.module'; 4 import { CarritoRoutingModule } from './carrito-routing.module';
5 import { CarritoComponent } from './carrito.component'; 5 import { CarritoComponent } from './carrito.component';
6 import { SeleccionArticulosModule } from '../seleccion-articulos/seleccion-articulos.module'; 6 import { SeleccionArticulosModule } from '../seleccion-articulos/seleccion-articulos.module';
7 import { SharedModule } from '../shared/shared.module'; 7 import { SharedModule } from '../shared/shared.module';
8 import { ErrorStockComponent } from 'src/app/shared/error-stock/error-stock.component';
8 9
9 @NgModule({ 10 @NgModule({
10 declarations: [CarritoComponent], 11 declarations: [
12 CarritoComponent,
13 ErrorStockComponent
14 ],
11 imports: [ 15 imports: [
12 CommonModule, 16 CommonModule,
13 CarritoRoutingModule, 17 CarritoRoutingModule,
14 SeleccionArticulosModule, 18 SeleccionArticulosModule,
15 SharedModule, 19 SharedModule,
16 ] 20 ],
21 entryComponents: [ErrorStockComponent]
17 }) 22 })
18 export class CarritoModule { } 23 export class CarritoModule { }
19 24
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 total = 0; 18 total = 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 substractCant(articulo: IArticulo) { 37 substractCant(articulo: IArticulo) {
38 if (articulo.cantidad === 1) return; 38 if (articulo.cantidad === 1) return;
39 articulo.cantidad--; 39 articulo.cantidad--;
40 this.calcularTotal(); 40 this.calcularTotal();
41 } 41 }
42 42
43 addCant(articulo: IArticulo) { 43 addCant(articulo: IArticulo) {
44 articulo.cantidad++; 44 articulo.cantidad++;
45 this.calcularTotal(); 45 this.calcularTotal();
46 } 46 }
47 47
48 calcularTotal() { 48 calcularTotal() {
49 this.total = 0; 49 this.total = 0;
50 this.carrito.forEach(articulo => { 50 this.carrito.forEach(articulo => {
51 this.total += (articulo.PreVen * articulo.cantidad); 51 this.total += (articulo.PreVen * articulo.cantidad);
52 }); 52 });
53 } 53 }
54 54
55 setArticulo(articulo: IArticulo) { 55 setArticulo(articulo: IArticulo) {
56 articulo.cantidad = 1; 56 articulo.cantidad = 1;
57 for (const articuloCarrito of this.carrito) { 57 for (const articuloCarrito of this.carrito) {
58 if (articuloCarrito.id === articulo.id) { 58 if (articuloCarrito.id === articulo.id) {
59 if (!articuloCarrito.productos) break; 59 if (!articuloCarrito.productos) break;
60 let samePromo = false; 60 let samePromo = false;
61 articuloCarrito.productos.forEach((a, i) => { 61 articuloCarrito.productos.forEach((a, i) => {
62 samePromo = (a.id === articulo.productos[i].id); 62 samePromo = (a.id === articulo.productos[i].id);
63 }); 63 });
64 if (!samePromo) break; 64 if (!samePromo) break;
65 this.addCant(articuloCarrito); 65 this.addCant(articuloCarrito);
66 return; 66 return;
67 } 67 }
68 } 68 }
69 this.setArticulosSinImagen([articulo]); 69 this.setArticulosSinImagen([articulo]);
70 this.carrito.unshift(articulo); 70 this.carrito.unshift(articulo);
71 this.calcularTotal(); 71 this.calcularTotal();
72 } 72 }
73 73
74 deleteArticulo(index: number) { 74 deleteArticulo(index: number) {
75 this.carrito.splice(index, 1); 75 this.carrito.splice(index, 1);
76 this.calcularTotal(); 76 this.calcularTotal();
77 } 77 }
78 78
79 pay(dataPago: any) { 79 pay(dataPago: any) {
80 return new Observable((observer) => { 80 return new Observable((observer) => {
81 this.clienteService.getById(-1) 81 this.clienteService.getById(-1)
82 .subscribe(cliente => { 82 .subscribe(cliente => {
83 this.markArticuloInPromoAsRemoved(); 83 this.markArticuloInPromoAsRemoved();
84 this.http.post(`${this.urlDeboSuite}/comprobante/guardar/${this.medioPago}`, { 84 this.http.post(`${this.urlDeboSuite}/comprobante/guardar/${this.medioPago}`, {
85 productos: this.carrito, 85 productos: this.carrito,
86 cliente, 86 cliente,
87 origen: 'autoservicio', 87 origen: 'autoservicio',
88 codigoVendedor: 5, 88 codigoVendedor: 5,
89 puntoVenta: APP_SETTINGS.puntoVenta, 89 puntoVenta: APP_SETTINGS.puntoVenta,
90 pedidoAnombreDe: dataPago.pedidoAnombreDe, 90 pedidoAnombreDe: dataPago.pedidoAnombreDe,
91 numeroPlanilla: APP_SETTINGS.numeroPlanilla, 91 numeroPlanilla: APP_SETTINGS.numeroPlanilla,
92 pedidoParaLlevar: localStorage.getItem('pedidoParaLlevar'), 92 pedidoParaLlevar: localStorage.getItem('pedidoParaLlevar'),
93 terminal: APP_SETTINGS.terminal, 93 terminal: APP_SETTINGS.terminal,
94 contactLess: dataPago.contactLess === 'true' ? true : false, 94 contactLess: dataPago.contactLess === 'true' ? true : false,
95 }) 95 })
96 .subscribe((data) => { 96 .subscribe((data) => {
97 observer.next(data); 97 observer.next(data);
98 observer.complete(); 98 observer.complete();
99 }, err => { 99 }, err => {
100 observer.error(err); 100 observer.error(err);
101 observer.complete(); 101 observer.complete();
102 }); 102 });
103 }); 103 });
104 }); 104 });
105 } 105 }
106 106
107 validateCarrito() {
108 for (const articulo of this.carrito) {
109 if (articulo.productos) {
110 for (const a of articulo.productos) {
111 if (a.ExiVta - (a.cantidad * articulo.cantidad) < 0) return { valid: false, articulo };
112 }
113 } else if (articulo.ExiVta - articulo.cantidad < 0) return { valid: false, articulo };
114 }
115 return { valid: true };
116 }
117
107 cleanShoppingCar() { 118 cleanShoppingCar() {
108 this.articuloAcargar = undefined; 119 this.articuloAcargar = undefined;
109 this.promoAcargar = undefined; 120 this.promoAcargar = undefined;
110 this.carrito = []; 121 this.carrito = [];
111 this.calcularTotal(); 122 this.calcularTotal();
112 } 123 }
113 124
114 setArticulosSinImagen(articulos: IArticulo[]) { 125 setArticulosSinImagen(articulos: IArticulo[]) {
115 articulos.forEach((articulo: IArticulo) => { 126 articulos.forEach((articulo: IArticulo) => {
116 articulo.imagenes = !articulo.imagenes ? [{ imagen: 'noImage.jpg' }] : 127 articulo.imagenes = !articulo.imagenes ? [{ imagen: 'noImage.jpg' }] :
117 !articulo.imagenes.length ? [{ imagen: 'noImage.jpg' }] : articulo.imagenes; 128 !articulo.imagenes.length ? [{ imagen: 'noImage.jpg' }] : articulo.imagenes;
118 }); 129 });
119 } 130 }
120 131
121 markArticuloInPromoAsRemoved() { 132 markArticuloInPromoAsRemoved() {
122 this.carrito.forEach((articuloCarrito: IArticulo) => { 133 this.carrito.forEach((articuloCarrito: IArticulo) => {
123 if (articuloCarrito.PRO) { 134 if (articuloCarrito.PRO) {
124 articuloCarrito.productos.forEach((articulo: IArticulo) => { 135 articuloCarrito.productos.forEach((articulo: IArticulo) => {
125 if (articulo.cantidadAdicionada === 0) { 136 if (articulo.cantidadAdicionada === 0) {
126 articulo.cantidad = 0; 137 articulo.cantidad = 0;
127 articulo.importeValorExtra = 0; 138 articulo.importeValorExtra = 0;
128 } 139 }
129 }); 140 });
130 } 141 }
131 }); 142 });
132 } 143 }
133 144
134 changeArticulo(articuloToChange: IArticulo, articuloData: any) { 145 changeArticulo(articuloToChange: IArticulo, articuloData: any) {
135 articuloToChange.CODA = articuloData.CodArt; 146 articuloToChange.CODA = articuloData.CodArt;
136 articuloToChange.CodArt = articuloData.CodArt; 147 articuloToChange.CodArt = articuloData.CodArt;
137 articuloToChange.SECA = articuloData.CodSec; 148 articuloToChange.SECA = articuloData.CodSec;
138 articuloToChange.CodSec = articuloData.CodSec; 149 articuloToChange.CodSec = articuloData.CodSec;
139 articuloToChange.PreVen = articuloData.PreVen; 150 articuloToChange.PreVen = articuloData.PreVen;
140 articuloToChange.id = articuloData.id; 151 articuloToChange.id = articuloData.id;
141 articuloToChange.DET_LAR = articuloData.DET_LAR; 152 articuloToChange.DET_LAR = articuloData.DET_LAR;
142 articuloToChange.DetArt = articuloData.DetArt; 153 articuloToChange.DetArt = articuloData.DetArt;
143 articuloToChange.MKT_DESC = articuloData.MKT_DESC; 154 articuloToChange.MKT_DESC = articuloData.MKT_DESC;
144 } 155 }
145 } 156 }
146 157
src/app/shared/error-stock/error-stock.component.html
File was created 1 <div class="bg-primary text-center rounded">
2 <div class="modal-body">
3 <p class="h4 text-white text-center mx-3 mb-3">El articulo {{articulo.MKT_DESC}} no tiene stock</p>
4 <div
5 class="m-0 h4 d-inline-block py-2 btn-effect bg-white badge-pill"
6 (click)="modalRef.hide()">
7 Aceptar
8 </div>
9 </div>
10 </div>
11
src/app/shared/error-stock/error-stock.component.scss
src/app/shared/error-stock/error-stock.component.spec.ts
File was created 1 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2
3 import { ErrorStockComponent } from './error-stock.component';
4
5 describe('ErrorStockComponent', () => {
6 let component: ErrorStockComponent;
7 let fixture: ComponentFixture<ErrorStockComponent>;
8
9 beforeEach(async(() => {
10 TestBed.configureTestingModule({
11 declarations: [ ErrorStockComponent ]
12 })
13 .compileComponents();
14 }));
15
16 beforeEach(() => {
17 fixture = TestBed.createComponent(ErrorStockComponent);
18 component = fixture.componentInstance;
19 fixture.detectChanges();
20 });
21
22 it('should create', () => {
23 expect(component).toBeTruthy();
24 });
25 });
26
src/app/shared/error-stock/error-stock.component.ts
File was created 1 import { Component, OnInit } from '@angular/core';
2 import { BsModalRef } from 'ngx-bootstrap/modal';
3 import { IArticulo } from 'src/app/interfaces/IArticulo';
4
5 @Component({
6 selector: 'app-error-stock',
7 templateUrl: './error-stock.component.html',
8 styleUrls: ['./error-stock.component.scss']
9 })
10 export class ErrorStockComponent implements OnInit {
11 articulo: IArticulo;
12
13 constructor(
14 private modalRef: BsModalRef,
15 ) { }
16
17 ngOnInit() { }
18
19 }
20