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

@ -62,14 +62,14 @@ def move_kot(request):
@view_config(
request_method="POST",
route_name="v1_vouchers_id",
request_param="m",
request_param="move-table",
renderer="json",
permission="Move Table",
trans=True,
)
def move_table(request):
id_ = uuid.UUID(request.matchdict["id"])
table_id = uuid.UUID(request.GET["m"])
table_id = uuid.UUID(request.json_body["table"]["id"])
request.dbsession.query(Overview).filter(Overview.voucher_id == id_).update(
{Overview.food_table_id: table_id}

View File

@ -6,14 +6,13 @@ from pyramid.view import view_config
from barker.models import SettleOption, Voucher, Settlement, Overview
from barker.models.validation_exception import ValidationError
from barker.views.voucher.show import voucher_info
@view_config(
request_method="POST",
route_name="v1_vouchers_id",
renderer="json",
request_param="r",
request_param="receive-payment",
permission="Settle Bill",
trans=False,
)

View File

@ -10,13 +10,13 @@ from barker.models import Voucher, SettleOption, Settlement, Overview
request_method="POST",
route_name="v1_vouchers_id",
renderer="json",
request_param="v",
request_param="void-bill",
permission="Void Bill",
trans=True,
)
def void_voucher(request):
id_ = uuid.UUID(request.matchdict["id"])
reason = request.GET["v"]
reason = request.json_body["reason"]
update_table = request.GET["u"]
item = request.dbsession.query(Voucher).filter(Voucher.id == id_).first()

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'))
);