#13: stored function for cash withdrawal transactions

This commit is contained in:
TMA 2025-04-21 17:35:03 +02:00
parent 7b11a8c954
commit e15f1646ce
2 changed files with 73 additions and 3 deletions

View file

@ -100,10 +100,16 @@ class Shop:
#self.db.commit()
def withdraw_credit(self, credit, user):
transaction = self._transaction(responsible = user, description = "BrmBar credit withdrawal for " + user.name)
self.cash.credit(transaction, credit, user.name)
user.debit(transaction, credit, "Credit withdrawal")
trn = self.db.execute_and_fetch(
"SELECT public.withdraw_credit(%s, %s, %s, %s)",
[self.cash.id, credit, user.id, user.name]
)[0]
self.db.commit()
return trn # unused
#transaction = self._transaction(responsible = user, description = "BrmBar credit withdrawal for " + user.name)
#self.cash.credit(transaction, credit, user.name)
#user.debit(transaction, credit, "Credit withdrawal")
#self.db.commit()
def transfer_credit(self, userfrom, userto, amount):
self.add_credit(amount, userto)