Ensure amount in buy_for_cash is integer.

This commit is contained in:
Dominik Pantůček 2025-07-17 17:16:31 +02:00
parent be0b50fedd
commit f962586e3a

View file

@ -126,9 +126,12 @@ class Shop:
#self.withdraw_credit(amount, userfrom)
def buy_for_cash(self, item, amount = 1):
iamount = int(amount)
famount = float(iamount)
assert famount == amount, "amount is not integer value %s".format(amount)
cost = self.db.execute_and_fetch(
"SELECT public.buy_for_cash(%s, %s, %s, %s, %s)",
[self.cash.id, item.id, amount, self.currency.id, item.name]
[self.cash.id, item.id, iamount, self.currency.id, item.name]
)[0]
# Buy: Currency conversion from item currency to shop currency
#(buy, sell) = item.currency.rates(self.currency)