Fix: Unable to receive payment as the amountVal as always zero.
This commit is contained in:
@ -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 {
|
||||
|
||||
@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user