From e3d40d50f050e75a33919db6d91438f44760b898 Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Wed, 11 Feb 2026 08:37:12 +0000 Subject: [PATCH] Fix: Unable to receive payment as the amountVal as always zero. --- bookie/src/app/sales/bill.service.ts | 45 ++++++++++--------- .../app/sales/home/sales-home.component.ts | 2 +- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/bookie/src/app/sales/bill.service.ts b/bookie/src/app/sales/bill.service.ts index 2c78bbb6..d661ed44 100644 --- a/bookie/src/app/sales/bill.service.ts +++ b/bookie/src/app/sales/bill.service.ts @@ -37,8 +37,7 @@ export class BillService { public discountAmount: Observable; public hhAmount: Observable; public taxAmount: Observable; - public amount: Observable; - public amountVal: number; + public amount: BehaviorSubject; public selection = new SelectionModel(true, []); private updateTable: boolean; private allowDeactivate: boolean; @@ -47,7 +46,6 @@ export class BillService { constructor() { this.dataObs = new BehaviorSubject([]); - this.amountVal = 0; this.updateTable = true; this.allowDeactivate = false; @@ -97,25 +95,28 @@ export class BillService { }), ); - this.amount = this.dataObs.pipe( - map((kots: Kot[]) => { - return this.math.halfRoundEven( - kots.reduce( - (t, k) => - k.inventories.reduce( - (a, c) => - a + - this.math.halfRoundEven( - (c.isHappyHour ? 0 : c.price) * c.quantity * (1 - c.discount) * (1 + c.taxRate), - 2, - ), - 0, - ) + t, - 0, - ), - ); - }), - ); + this.amount = new BehaviorSubject(0); + this.dataObs + .pipe( + map((kots: Kot[]) => { + return this.math.halfRoundEven( + kots.reduce( + (t, k) => + k.inventories.reduce( + (a, c) => + a + + this.math.halfRoundEven( + (c.isHappyHour ? 0 : c.price) * c.quantity * (1 - c.discount) * (1 + c.taxRate), + 2, + ), + 0, + ) + t, + 0, + ), + ); + }), + ) + .subscribe((value) => this.amount.next(value)); } displayBill(): void { diff --git a/bookie/src/app/sales/home/sales-home.component.ts b/bookie/src/app/sales/home/sales-home.component.ts index 2b149fbb..b6b2f8e6 100644 --- a/bookie/src/app/sales/home/sales-home.component.ts +++ b/bookie/src/app/sales/home/sales-home.component.ts @@ -195,7 +195,7 @@ export class SalesHomeComponent { if (!this.receivePaymentAllowed()) { return; } - const amount = this.bs.amountVal; + const amount = this.bs.amount.value; const type = this.bs.bill.voucherType; this.dialog .open(ReceivePaymentComponent, {