diff --git a/public/js/index.js b/public/js/index.js index 522f9ac1..2d9fcb1a 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -643,6 +643,7 @@ document.getElementById("addressForm").onsubmit = function (e) { const items = cart.map((item) => ({ id: item.name, quantity: item.qty, + sellQuantity: getItemSellQuantity(item.name), })); const request = { userId: user.username, diff --git a/users-api.js b/users-api.js index f9e3a793..45259faa 100644 --- a/users-api.js +++ b/users-api.js @@ -379,7 +379,7 @@ module.exports = function (app, wss, pool) { ); if (!userRow) return res.status(404).json({ ok: false, error: "User not found" }); - if (userRow.balance < price * item.quantity) + if (userRow.balance < price * (item.quantity / item.sellQuantity)) return res.status(400).json({ ok: false, error: `Insufficient balance for item ${item.id}`,