Deduplicated the settle options function for save/update/void/receive payment

Ported:
  Void
  Receive payment
This commit is contained in:
2020-09-24 08:47:09 +05:30
parent 6c06271315
commit 578385f866
11 changed files with 164 additions and 130 deletions

View File

@ -76,19 +76,24 @@ export class VoucherService {
}
}
receivePayment(id: string, amounts: { id: number; name: string; amount: number }[], name: string, updateTable: boolean): Observable<boolean> {
const options = {params: new HttpParams().set('receive-payment', '').set('u', updateTable.toString())};
receivePayment(
id: string,
amounts: { id: number; name: string; amount: number }[],
name: string,
updateTable: boolean
): Observable<boolean> {
const options = {params: new HttpParams().set('u', updateTable.toString())};
return <Observable<boolean>>this.http.post<boolean>(
`${url}/${id}`, {name: name, amounts: amounts}, options
`${url}/receive-payment/${id}`, {name: name, amounts: amounts}, options
).pipe(
catchError(this.log.handleError(serviceName, 'receivePayment'))
);
}
voidBill(id: string, reason: string, updateTable: boolean): Observable<boolean> {
const options = {params: new HttpParams().set('void-bill', '').set('u', updateTable.toString())};
const options = {params: new HttpParams().set('reason', reason).set('u', updateTable.toString())};
return <Observable<boolean>>this.http.post<boolean>(
`${url}/${id}`, {reason: reason}, options
`${url}/void-bill/${id}`, {}, options
).pipe(
catchError(this.log.handleError(serviceName, 'voidBill'))
);