Blacked and isorted the python files

Prettied and eslinted the typescript/html files
This commit is contained in:
2020-10-11 10:56:29 +05:30
parent b31db593c2
commit d677cfb1ea
505 changed files with 7560 additions and 5650 deletions

View File

@ -1,14 +1,13 @@
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/internal/Observable';
import { catchError } from 'rxjs/operators';
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';
const httpOptions = {
headers: new HttpHeaders({'Content-Type': 'application/json'})
};
import { Bill } from './bill';
import { PrintType } from './print-type';
const url = '/api/voucher';
const urlMoveTable = '/api/move-table';
@ -16,17 +15,16 @@ const urlMoveKot = '/api/move-kot';
const urlSplitBill = '/api/split-bill';
const serviceName = 'VoucherService';
@Injectable({providedIn: 'root'})
@Injectable({ providedIn: 'root' })
export class VoucherService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {
}
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
get(id: string): Observable<Bill> {
return <Observable<Bill>>this.http.get<Bill>(`${url}/from-id/${id}`)
.pipe(
catchError(this.log.handleError(serviceName, `get id=${id}`))
);
return <Observable<Bill>>(
this.http
.get<Bill>(`${url}/from-id/${id}`)
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`)))
);
}
getFromTable(tableId: string, voucherId: string, guestId: string): Observable<Bill> {
@ -38,128 +36,164 @@ export class VoucherService {
params = params.set('g', guestId);
}
return <Observable<Bill>>this.http.get<Bill>(`${url}/from-table/${tableId}`, {params: params})
return <Observable<Bill>>this.http
.get<Bill>(`${url}/from-table/${tableId}`, { params })
.pipe(
catchError(this.log.handleError(
serviceName,
`getFromTable tableId=${tableId} voucherId=${voucherId} guestId=${guestId}`
))
catchError(
this.log.handleError(
serviceName,
`getFromTable tableId=${tableId} voucherId=${voucherId} guestId=${guestId}`,
),
),
);
}
save(voucher: Bill, printType: PrintType, guest_book_id: string, updateTable: boolean): Observable<boolean> {
const options = {params: new HttpParams().set('p', printType).set('u', updateTable.toString())};
if (guest_book_id !== null) {
options.params = options.params.set('g', guest_book_id);
}
return <Observable<boolean>>this.http.post<boolean>(`${url}/save`, voucher, options)
.pipe(
catchError(this.log.handleError(serviceName, 'save'))
);
save(
voucher: Bill,
printType: PrintType,
guest_book_id: string,
updateTable: boolean,
): Observable<boolean> {
const options = {
params: new HttpParams().set('p', printType).set('u', updateTable.toString()),
};
if (guest_book_id !== null) {
options.params = options.params.set('g', guest_book_id);
}
return <Observable<boolean>>(
this.http
.post<boolean>(`${url}/save`, voucher, options)
.pipe(catchError(this.log.handleError(serviceName, 'save')))
);
}
update(voucher: Bill, printType: PrintType, guest_book_id: string, updateTable: boolean): Observable<boolean> {
const options = {params: new HttpParams().set('p', printType).set('u', updateTable.toString())};
if (guest_book_id !== null) {
options.params = options.params.set('g', guest_book_id);
}
return <Observable<boolean>>this.http.put<boolean>(`${url}/update/${voucher.id}`, voucher, options)
.pipe(
catchError(this.log.handleError(serviceName, 'update'))
);
update(
voucher: Bill,
printType: PrintType,
guest_book_id: string,
updateTable: boolean,
): Observable<boolean> {
const options = {
params: new HttpParams().set('p', printType).set('u', updateTable.toString()),
};
if (guest_book_id !== null) {
options.params = options.params.set('g', guest_book_id);
}
return <Observable<boolean>>(
this.http
.put<boolean>(`${url}/update/${voucher.id}`, voucher, options)
.pipe(catchError(this.log.handleError(serviceName, 'update')))
);
}
change(voucher: Bill, printType: PrintType, guest_book_id: string, updateTable: boolean): Observable<boolean> {
const options = {params: new HttpParams().set('u', updateTable.toString())};
if (guest_book_id !== null) {
options.params = options.params.set('g', guest_book_id);
}
return <Observable<boolean>>this.http.put<boolean>(`${url}/change/${voucher.id}`, voucher, options)
.pipe(
catchError(this.log.handleError(serviceName, 'change'))
);
change(
voucher: Bill,
printType: PrintType,
guest_book_id: string,
updateTable: boolean,
): Observable<boolean> {
const options = { params: new HttpParams().set('u', updateTable.toString()) };
if (guest_book_id !== null) {
options.params = options.params.set('g', guest_book_id);
}
return <Observable<boolean>>(
this.http
.put<boolean>(`${url}/change/${voucher.id}`, voucher, options)
.pipe(catchError(this.log.handleError(serviceName, 'change')))
);
}
saveOrUpdate(voucher: Bill, printType: PrintType, guest_book_id: string, updateTable: boolean): Observable<boolean> {
saveOrUpdate(
voucher: Bill,
printType: PrintType,
guest_book_id: string,
updateTable: boolean,
): Observable<boolean> {
if (!voucher.id) {
return this.save(voucher, printType, guest_book_id, updateTable);
} else if (voucher.voucherType === PrintType.Kot) {
return this.update(voucher, printType, guest_book_id, updateTable);
} else {
return this.change(voucher, printType, guest_book_id, updateTable);
}
if (voucher.voucherType === PrintType.Kot) {
return this.update(voucher, printType, guest_book_id, updateTable);
}
return this.change(voucher, printType, guest_book_id, updateTable);
}
receivePayment(
id: string,
amounts: { id: number; name: string; amount: number }[],
name: string,
updateTable: boolean
updateTable: boolean,
): Observable<boolean> {
const options = {params: new HttpParams().set('u', updateTable.toString())};
return <Observable<boolean>>this.http.post<boolean>(
`${url}/receive-payment/${id}`, {name: name, amounts: amounts}, options
).pipe(
catchError(this.log.handleError(serviceName, 'receivePayment'))
const options = { params: new HttpParams().set('u', updateTable.toString()) };
return <Observable<boolean>>(
this.http
.post<boolean>(`${url}/receive-payment/${id}`, { name, amounts }, options)
.pipe(catchError(this.log.handleError(serviceName, 'receivePayment')))
);
}
voidBill(id: string, reason: string, updateTable: boolean): Observable<boolean> {
const options = {params: new HttpParams().set('reason', reason).set('u', updateTable.toString())};
return <Observable<boolean>>this.http.post<boolean>(
`${url}/void-bill/${id}`, {}, options
).pipe(
catchError(this.log.handleError(serviceName, 'voidBill'))
const options = {
params: new HttpParams().set('reason', reason).set('u', updateTable.toString()),
};
return <Observable<boolean>>(
this.http
.post<boolean>(`${url}/void-bill/${id}`, {}, options)
.pipe(catchError(this.log.handleError(serviceName, 'voidBill')))
);
}
moveTable(id: string, table: Table): Observable<boolean> {
return <Observable<boolean>>this.http.post<boolean>(`${urlMoveTable}/move`, {
voucherId: id,
tableId: table.id
}).pipe(
catchError(this.log.handleError(serviceName, 'moveTable'))
);
return <Observable<boolean>>this.http
.post<boolean>(`${urlMoveTable}/move`, {
voucherId: id,
tableId: table.id,
})
.pipe(catchError(this.log.handleError(serviceName, 'moveTable')));
}
mergeTable(id: string, table: Table): Observable<boolean> {
return <Observable<boolean>>this.http.post<boolean>(`${urlMoveTable}/merge`, {
voucherId: id,
tableId: table.id,
newVoucherId: table.voucherId
}).pipe(
catchError(this.log.handleError(serviceName, 'mergeTable'))
);
return <Observable<boolean>>this.http
.post<boolean>(`${urlMoveTable}/merge`, {
voucherId: id,
tableId: table.id,
newVoucherId: table.voucherId,
})
.pipe(catchError(this.log.handleError(serviceName, 'mergeTable')));
}
moveKotToNewTable(id: string, kotId: string, table: Table): Observable<boolean> {
return <Observable<boolean>>this.http.post<boolean>(`${urlMoveKot}/move`, {
voucherId: id,
kotId: kotId,
tableId: table.id
}).pipe(
catchError(this.log.handleError(serviceName, 'moveKotToNewTable'))
);
return <Observable<boolean>>this.http
.post<boolean>(`${urlMoveKot}/move`, {
voucherId: id,
kotId,
tableId: table.id,
})
.pipe(catchError(this.log.handleError(serviceName, 'moveKotToNewTable')));
}
mergeKotWithOldBill(id: string, kotId: string, table: Table): Observable<boolean> {
return <Observable<boolean>>this.http.post<boolean>(`${urlMoveKot}/merge`, {
voucherId: id,
kotId: kotId,
tableId: table.id,
newVoucherId: table.voucherId
}).pipe(
catchError(this.log.handleError(serviceName, 'mergeKotWithOldBill'))
);
return <Observable<boolean>>this.http
.post<boolean>(`${urlMoveKot}/merge`, {
voucherId: id,
kotId,
tableId: table.id,
newVoucherId: table.voucherId,
})
.pipe(catchError(this.log.handleError(serviceName, 'mergeKotWithOldBill')));
}
splitBill(id: string, inventoriesToMove: string[], table: Table) {
const options = {params: new HttpParams().set('u', 'true')};
return <Observable<boolean>>this.http.post<boolean>(`${urlSplitBill}/${id}`, {
inventories: inventoriesToMove,
tableId: table.id
}, options).pipe(
catchError(this.log.handleError(serviceName, 'splitBill'))
);
const options = { params: new HttpParams().set('u', 'true') };
return <Observable<boolean>>this.http
.post<boolean>(
`${urlSplitBill}/${id}`,
{
inventories: inventoriesToMove,
tableId: table.id,
},
options,
)
.pipe(catchError(this.log.handleError(serviceName, 'splitBill')));
}
}