Fix: Unable to receive payment as the amountVal as always zero.

This commit is contained in:
2026-02-11 08:37:12 +00:00
parent b27a5a9211
commit e3d40d50f0
2 changed files with 24 additions and 23 deletions

View File

@ -37,8 +37,7 @@ export class BillService {
public discountAmount: Observable<number>;
public hhAmount: Observable<number>;
public taxAmount: Observable<number>;
public amount: Observable<number>;
public amountVal: number;
public amount: BehaviorSubject<number>;
public selection = new SelectionModel<string>(true, []);
private updateTable: boolean;
private allowDeactivate: boolean;
@ -47,7 +46,6 @@ export class BillService {
constructor() {
this.dataObs = new BehaviorSubject<Kot[]>([]);
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<number>(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 {

View File

@ -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, {