Fix: Edge cases where backend and frontend totals are off and you cannot settle the bill.
This commit is contained in:
@@ -37,25 +37,36 @@ export class BillService {
|
||||
|
||||
public grossAmount = computed(() =>
|
||||
this.math.halfRoundEven(
|
||||
this.data().reduce((t, k) => k.inventories.reduce((a, c) => a + c.price * c.quantity, 0) + t, 0),
|
||||
this.data().reduce(
|
||||
(t, k) => k.inventories.filter((c) => !c.parentId).reduce((a, c) => a + c.price * c.quantity, 0) + t,
|
||||
0,
|
||||
),
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
public hhAmount = computed(() =>
|
||||
this.math.halfRoundEven(
|
||||
this.data().reduce(
|
||||
(t, k) => k.inventories.reduce((a, c) => a + (c.isHappyHour ? c.price : 0) * c.quantity, 0) + t,
|
||||
(t, k) =>
|
||||
k.inventories.filter((c) => !c.parentId).reduce((a, c) => a + (c.isHappyHour ? c.price : 0) * c.quantity, 0) +
|
||||
t,
|
||||
0,
|
||||
),
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
public discountAmount = computed(() =>
|
||||
this.math.halfRoundEven(
|
||||
this.data().reduce(
|
||||
(t, k) => k.inventories.reduce((a, c) => a + (c.isHappyHour ? 0 : c.price) * c.quantity * c.discount, 0) + t,
|
||||
(t, k) =>
|
||||
k.inventories
|
||||
.filter((c) => !c.parentId)
|
||||
.reduce((a, c) => a + (c.isHappyHour ? 0 : c.price) * c.quantity * c.discount, 0) + t,
|
||||
0,
|
||||
),
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -63,16 +74,36 @@ export class BillService {
|
||||
this.math.halfRoundEven(
|
||||
this.data().reduce(
|
||||
(t, k) =>
|
||||
k.inventories.reduce(
|
||||
(a, c) => a + (c.isHappyHour ? 0 : c.price) * c.quantity * (1 - c.discount) * c.taxRate,
|
||||
0,
|
||||
) + t,
|
||||
k.inventories
|
||||
.filter((c) => !c.parentId)
|
||||
.reduce((a, c) => a + (c.isHappyHour ? 0 : c.price) * c.quantity * (1 - c.discount) * c.taxRate, 0) + t,
|
||||
0,
|
||||
),
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
public amount = computed(() =>
|
||||
this.math.halfRoundEven(
|
||||
this.data().reduce(
|
||||
(t, k) =>
|
||||
k.inventories
|
||||
.filter((c) => !c.parentId)
|
||||
.reduce(
|
||||
(a, c) =>
|
||||
a +
|
||||
this.math.halfRoundEven(
|
||||
(c.isHappyHour ? 0 : c.price) * c.quantity * (1 - c.discount) * (1 + c.taxRate),
|
||||
2,
|
||||
),
|
||||
0,
|
||||
) + t,
|
||||
0,
|
||||
),
|
||||
0,
|
||||
),
|
||||
);
|
||||
|
||||
public amount = computed(() => this.grossAmount() - this.discountAmount() + this.taxAmount());
|
||||
public selection = new SelectionModel<string>(true, []);
|
||||
private updateTable = signal<boolean>(true);
|
||||
private allowDeactivate = signal<boolean>(false);
|
||||
|
||||
Reference in New Issue
Block a user