Commit 6b637fa3788f8814f47693f4ad9f7c055cb514b1
Exists in
master
Merge branch 'master' of git.focasoftware.com:angular/autoservicio
# Conflicts: # src/app/services/producto.service.ts
Showing
4 changed files
Show diff stats
src/app/services/cliente.service.spec.ts
... | ... | @@ -0,0 +1,12 @@ |
1 | +import { TestBed } from '@angular/core/testing'; | |
2 | + | |
3 | +import { ClienteService } from './cliente.service'; | |
4 | + | |
5 | +describe('ClienteService', () => { | |
6 | + beforeEach(() => TestBed.configureTestingModule({})); | |
7 | + | |
8 | + it('should be created', () => { | |
9 | + const service: ClienteService = TestBed.get(ClienteService); | |
10 | + expect(service).toBeTruthy(); | |
11 | + }); | |
12 | +}); |
src/app/services/cliente.service.ts
... | ... | @@ -0,0 +1,17 @@ |
1 | +import { Injectable } from '@angular/core'; | |
2 | +import { HttpClient } from '@angular/common/http'; | |
3 | +import { appSettings } from "src/etc/AppSettings"; | |
4 | + | |
5 | +@Injectable({ | |
6 | + providedIn: 'root' | |
7 | +}) | |
8 | +export class ClienteService { | |
9 | + | |
10 | + private url = appSettings.apiClientes | |
11 | + | |
12 | + constructor(private http: HttpClient) { } | |
13 | + | |
14 | + getClienteById(id: number) { | |
15 | + return this.http.get(`${this.url}/get/${id}`); | |
16 | + } | |
17 | +} |
src/app/services/producto.service.ts
... | ... | @@ -3,6 +3,7 @@ import { HttpClient } from '@angular/common/http'; |
3 | 3 | import { Observable } from 'rxjs'; |
4 | 4 | import { appSettings } from 'src/etc/AppSettings'; |
5 | 5 | import { Producto } from '../wrappers/producto'; |
6 | +import { ClienteService } from './cliente.service'; | |
6 | 7 | |
7 | 8 | @Injectable({ |
8 | 9 | providedIn: 'root' |
... | ... | @@ -15,7 +16,7 @@ export class ProductoService { |
15 | 16 | mostrar: string; |
16 | 17 | esPromoPersonalizada: boolean = false; |
17 | 18 | |
18 | - constructor(private http: HttpClient) { } | |
19 | + constructor(private http: HttpClient, private clienteService: ClienteService) { } | |
19 | 20 | |
20 | 21 | getProductoById(id): Observable<any> { |
21 | 22 | |
... | ... | @@ -80,8 +81,20 @@ export class ProductoService { |
80 | 81 | } |
81 | 82 | |
82 | 83 | pagar(medioPago: string) { |
83 | - return this.http.post(`${appSettings.apiUrl}/comprobante/guardar/${medioPago}`, { | |
84 | - productos: this.productos | |
84 | + | |
85 | + return new Observable((observer) => { | |
86 | + | |
87 | + this.clienteService.getClienteById(-1).subscribe(cliente => { | |
88 | + | |
89 | + this.http.post(`${appSettings.apiUrl}/comprobante/guardar/${medioPago}`, { | |
90 | + productos: this.productos, | |
91 | + cliente: cliente | |
92 | + }).subscribe((data) => { | |
93 | + | |
94 | + observer.next(data); | |
95 | + observer.complete(); | |
96 | + }); | |
97 | + }); | |
85 | 98 | }); |
86 | 99 | } |
87 | 100 |
src/etc/AppSettings ejemplo.ts