Made the voucher calls more readable

This commit is contained in:
Amritanshu
2019-08-10 19:43:35 +05:30
parent 40a958a935
commit d7fdf751b9
4 changed files with 10 additions and 12 deletions

View File

@ -5,7 +5,6 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { ErrorLoggerService } from '../../core/error-logger.service';
import { Bill, PrintType } from './bill';
import { Table } from "../../core/table";
import {ObjectUnsubscribedError} from "rxjs";
const httpOptions = {
headers: new HttpHeaders({'Content-Type': 'application/json'})
@ -79,7 +78,7 @@ export class VoucherService {
}
receivePayment(id: string, amounts: { id: string; name: string; amount: number }[], updateTable: boolean): Observable<boolean> {
const options = {params: new HttpParams().set('r', "").set('u', updateTable.toString())};
const options = {params: new HttpParams().set('receive-payment', "").set('u', updateTable.toString())};
return <Observable<boolean>>this.http.post<boolean>(`${url}/${id}`, amounts, options)
.pipe(
catchError(this.log.handleError(serviceName, 'receivePayment'))
@ -87,16 +86,16 @@ export class VoucherService {
}
moveTable(id: string, table: Table): Observable<boolean> {
const options = {params: new HttpParams().set('m', table.id)};
return <Observable<boolean>>this.http.post<boolean>(`${url}/${id}`, {}, options)
const options = {params: new HttpParams().set('move-table', '')};
return <Observable<boolean>>this.http.post<boolean>(`${url}/${id}`, {table:{id: table.id}}, options)
.pipe(
catchError(this.log.handleError(serviceName, 'moveTable'))
);
}
voidBill(id: string, reason: string, updateTable: boolean): Observable<boolean> {
const options = {params: new HttpParams().set('v', reason).set('u', updateTable.toString())};
return <Observable<boolean>>this.http.post<boolean>(`${url}/${id}`, {}, options)
const options = {params: new HttpParams().set('void-bill', "").set('u', updateTable.toString())};
return <Observable<boolean>>this.http.post<boolean>(`${url}/${id}`, {reason: reason}, options)
.pipe(
catchError(this.log.handleError(serviceName, 'voidBill'))
);