Commit 1cbb6ed28588197f0365c043a7b970be62f13b4b

Authored by Marcelo Puebla
1 parent 07193a22b4
Exists in master

Cambio en servicio pagar, agregado get cliente por ID.

src/app/components/confirmacion-carrito/confirmacion-carrito.component.html
... ... @@ -156,7 +156,7 @@
156 156 <!-- EFECTIVO -->
157 157 <div
158 158 class="row card-effect card-forma-pago mx-1 my-3 rounded-sm shadow-sm bg-white"
159   - (click)="pagar('efectivo')">
  159 + (click)="pagar(1)">
160 160 <div class="col-7 text-center my-auto px-2">
161 161 <span class="h5 font-weight-bold">Efectivo</span>
162 162 </div>
... ... @@ -182,7 +182,7 @@
182 182 <!-- QR -->
183 183 <div
184 184 class="row card-effect card-forma-pago mx-1 my-3 rounded-sm shadow-sm bg-white"
185   - (click)="pagar('electronico')">
  185 + (click)="pagar(9)">
186 186 <div class="col-7 text-center my-auto px-2">
187 187 <span class="h5 font-weight-bold">Pago Electrónico</span>
188 188 </div>
src/app/components/confirmacion-carrito/confirmacion-carrito.component.ts
... ... @@ -75,34 +75,37 @@ export class ConfirmacionCarritoComponent implements OnInit, OnDestroy {
75 75 }
76 76  
77 77 //#region METODOS PARA LA FORMA DE PAGO
78   - pagar(medioPago: string) {
  78 + pagar(medioPago: number) {
79 79  
80   - if (medioPago == 'electronico') {
  80 + if (medioPago === 9) {
81 81  
82 82 this.verQR = true;
83 83 }
84 84  
85   - this.subscribePago = this.productoService.pagar(medioPago)
86   - .subscribe(() => {
  85 + this.productoService.getClienteById(-1)
  86 + .subscribe(cliente => {
  87 + this.subscribePago = this.productoService.pagar(medioPago, cliente)
  88 + .subscribe(() => {
87 89  
88   - clearTimeout(this.timerReposo);
  90 + clearTimeout(this.timerReposo);
89 91  
90   - if (medioPago == 'efectivo') {
  92 + if (medioPago === 1) {
91 93  
92   - this.compraConEfectivofinalizada = true;
93   - } else if (medioPago == 'electronico') {
  94 + this.compraConEfectivofinalizada = true;
  95 + } else if (medioPago === 9) {
94 96  
95   - this.compraConQRfinalizada = true;
96   - }
  97 + this.compraConQRfinalizada = true;
  98 + }
97 99  
98   - setTimeout(() => {
  100 + setTimeout(() => {
99 101  
100   - this.router.navigate(['mensaje-final']);
101   - }, 10000);
102   - }, err => {
103   - console.log(err);
104   - alert('algo salió mal');
105   - })
  102 + this.router.navigate(['mensaje-final']);
  103 + }, 10000);
  104 + }, err => {
  105 + console.log(err);
  106 + alert('algo salió mal');
  107 + })
  108 + }, console.error)
106 109 }
107 110 //#endregion
108 111  
src/app/services/producto.service.ts
... ... @@ -79,9 +79,18 @@ export class ProductoService {
79 79 return this.http.get(`${appSettings.apiUrl}/categorias`);
80 80 }
81 81  
82   - pagar(medioPago: string) {
  82 + getClienteById(id: number = -1): Observable<any> {
  83 +
  84 + let apiClientes = 'http://10.231.45.220:1515/clientes';
  85 + return this.http.get(`${apiClientes}/get/${id}`);
  86 + }
  87 +
  88 + pagar(medioPago: number, cliente: any) {
  89 +
83 90 return this.http.post(`${appSettings.apiUrl}/comprobante/guardar/${medioPago}`, {
84   - productos: this.productos
  91 + productos: this.productos,
  92 + cliente: cliente,
  93 + origen: 'autoservicio',
85 94 });
86 95 }
87 96