Skip to content

Commit

Permalink
bug: amount subzero
Browse files Browse the repository at this point in the history
  • Loading branch information
Xziy committed Aug 4, 2024
1 parent 067ca93 commit 01dd38d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions models/Order.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ let Model = {
else {
dishObj = dish;
}
if (amount < 0)
throw `Amount is subzero [${amount}]`;
// TODO: In core you can add any amount dish, only in checkout it should show which not allowed
if (dishObj.balance !== -1) {
if (amount > dishObj.balance) {
Expand Down
2 changes: 2 additions & 0 deletions models/Order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ let Model = {
dishObj = dish;
}

if (amount < 0) throw `Amount is subzero [${amount}]`

// TODO: In core you can add any amount dish, only in checkout it should show which not allowed
if (dishObj.balance !== -1) {
Expand Down Expand Up @@ -598,6 +599,7 @@ let Model = {
},

async setCount(criteria: CriteriaQuery<Order>, dish: OrderDish, amount: number): Promise<void> {

await emitter.emit.apply(emitter, ["core:order-before-set-count", ...arguments]);
const _dish = dish.dish as Dish;
if (_dish.balance !== -1)
Expand Down

0 comments on commit 01dd38d

Please sign in to comment.