From d7fdf751b90ef5f6c24a7d509dcee81bc32c0d79 Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Sat, 10 Aug 2019 19:43:35 +0530 Subject: [PATCH] Made the voucher calls more readable --- barker/views/voucher/merge_move.py | 4 ++-- barker/views/voucher/receive_payment.py | 3 +-- barker/views/voucher/void.py | 4 ++-- bookie/src/app/sales/bills/voucher.service.ts | 11 +++++------ 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/barker/views/voucher/merge_move.py b/barker/views/voucher/merge_move.py index 3142bb8..fdc33d2 100644 --- a/barker/views/voucher/merge_move.py +++ b/barker/views/voucher/merge_move.py @@ -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} diff --git a/barker/views/voucher/receive_payment.py b/barker/views/voucher/receive_payment.py index 74f5fe0..810c0ce 100644 --- a/barker/views/voucher/receive_payment.py +++ b/barker/views/voucher/receive_payment.py @@ -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, ) diff --git a/barker/views/voucher/void.py b/barker/views/voucher/void.py index 535533d..35d6ecd 100644 --- a/barker/views/voucher/void.py +++ b/barker/views/voucher/void.py @@ -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() diff --git a/bookie/src/app/sales/bills/voucher.service.ts b/bookie/src/app/sales/bills/voucher.service.ts index 7e45cdf..90b2e5d 100644 --- a/bookie/src/app/sales/bills/voucher.service.ts +++ b/bookie/src/app/sales/bills/voucher.service.ts @@ -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 { - const options = {params: new HttpParams().set('r', "").set('u', updateTable.toString())}; + const options = {params: new HttpParams().set('receive-payment', "").set('u', updateTable.toString())}; return >this.http.post(`${url}/${id}`, amounts, options) .pipe( catchError(this.log.handleError(serviceName, 'receivePayment')) @@ -87,16 +86,16 @@ export class VoucherService { } moveTable(id: string, table: Table): Observable { - const options = {params: new HttpParams().set('m', table.id)}; - return >this.http.post(`${url}/${id}`, {}, options) + const options = {params: new HttpParams().set('move-table', '')}; + return >this.http.post(`${url}/${id}`, {table:{id: table.id}}, options) .pipe( catchError(this.log.handleError(serviceName, 'moveTable')) ); } voidBill(id: string, reason: string, updateTable: boolean): Observable { - const options = {params: new HttpParams().set('v', reason).set('u', updateTable.toString())}; - return >this.http.post(`${url}/${id}`, {}, options) + const options = {params: new HttpParams().set('void-bill', "").set('u', updateTable.toString())}; + return >this.http.post(`${url}/${id}`, {reason: reason}, options) .pipe( catchError(this.log.handleError(serviceName, 'voidBill')) );