Customer discount with prefill discount in sales.
This commit is contained in:
31
bookie/src/app/settings/settings.service.ts
Normal file
31
bookie/src/app/settings/settings.service.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
const serviceName = 'SettingsService';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class SettingsService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
getPrefillCustomerDiscount(): Observable<boolean> {
|
||||
const url = '/api/settings/prefill-customer-discount';
|
||||
return this.http.get<{ value: boolean }>(url).pipe(
|
||||
map((x) => x.value),
|
||||
catchError(this.log.handleError(serviceName, 'getPrefillCustomerDiscount')),
|
||||
) as Observable<boolean>;
|
||||
}
|
||||
|
||||
setPrefillCustomerDiscount(value: boolean): Observable<boolean> {
|
||||
const url = '/api/settings/prefill-customer-discount';
|
||||
return this.http
|
||||
.post<{ value: boolean }>(url, { value: value })
|
||||
.pipe(
|
||||
map((x) => x.value),
|
||||
catchError(this.log.handleError(serviceName, 'setPrefillCustomerDiscount')),
|
||||
) as Observable<boolean>;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user