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 discountAmount: Observable<number>;
|
||||||
public hhAmount: Observable<number>;
|
public hhAmount: Observable<number>;
|
||||||
public taxAmount: Observable<number>;
|
public taxAmount: Observable<number>;
|
||||||
public amount: Observable<number>;
|
public amount: BehaviorSubject<number>;
|
||||||
public amountVal: number;
|
|
||||||
public selection = new SelectionModel<string>(true, []);
|
public selection = new SelectionModel<string>(true, []);
|
||||||
private updateTable: boolean;
|
private updateTable: boolean;
|
||||||
private allowDeactivate: boolean;
|
private allowDeactivate: boolean;
|
||||||
@ -47,7 +46,6 @@ export class BillService {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.dataObs = new BehaviorSubject<Kot[]>([]);
|
this.dataObs = new BehaviorSubject<Kot[]>([]);
|
||||||
this.amountVal = 0;
|
|
||||||
this.updateTable = true;
|
this.updateTable = true;
|
||||||
this.allowDeactivate = false;
|
this.allowDeactivate = false;
|
||||||
|
|
||||||
@ -97,25 +95,28 @@ export class BillService {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.amount = this.dataObs.pipe(
|
this.amount = new BehaviorSubject<number>(0);
|
||||||
map((kots: Kot[]) => {
|
this.dataObs
|
||||||
return this.math.halfRoundEven(
|
.pipe(
|
||||||
kots.reduce(
|
map((kots: Kot[]) => {
|
||||||
(t, k) =>
|
return this.math.halfRoundEven(
|
||||||
k.inventories.reduce(
|
kots.reduce(
|
||||||
(a, c) =>
|
(t, k) =>
|
||||||
a +
|
k.inventories.reduce(
|
||||||
this.math.halfRoundEven(
|
(a, c) =>
|
||||||
(c.isHappyHour ? 0 : c.price) * c.quantity * (1 - c.discount) * (1 + c.taxRate),
|
a +
|
||||||
2,
|
this.math.halfRoundEven(
|
||||||
),
|
(c.isHappyHour ? 0 : c.price) * c.quantity * (1 - c.discount) * (1 + c.taxRate),
|
||||||
0,
|
2,
|
||||||
) + t,
|
),
|
||||||
0,
|
0,
|
||||||
),
|
) + t,
|
||||||
);
|
0,
|
||||||
}),
|
),
|
||||||
);
|
);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.subscribe((value) => this.amount.next(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
displayBill(): void {
|
displayBill(): void {
|
||||||
|
|||||||
@ -195,7 +195,7 @@ export class SalesHomeComponent {
|
|||||||
if (!this.receivePaymentAllowed()) {
|
if (!this.receivePaymentAllowed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const amount = this.bs.amountVal;
|
const amount = this.bs.amount.value;
|
||||||
const type = this.bs.bill.voucherType;
|
const type = this.bs.bill.voucherType;
|
||||||
this.dialog
|
this.dialog
|
||||||
.open(ReceivePaymentComponent, {
|
.open(ReceivePaymentComponent, {
|
||||||
|
|||||||
Reference in New Issue
Block a user