From f962586e3acbd6bf2fd2c9b488d9504ff05b7924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Thu, 17 Jul 2025 17:16:31 +0200 Subject: [PATCH] Ensure amount in buy_for_cash is integer. --- brmbar3/brmbar/Shop.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/brmbar3/brmbar/Shop.py b/brmbar3/brmbar/Shop.py index c219be1..fcc54be 100644 --- a/brmbar3/brmbar/Shop.py +++ b/brmbar3/brmbar/Shop.py @@ -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)