mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-07 21:04:00 +02:00
brmbar.Shop.withdraw_credit(): New method analogous to add_credit()
This commit is contained in:
parent
f261fe5ea5
commit
eda6eaf9e4
1 changed files with 6 additions and 0 deletions
|
@ -57,6 +57,12 @@ class Shop:
|
|||
user.credit(transaction, credit, "Credit replenishment")
|
||||
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")
|
||||
self.db.commit()
|
||||
|
||||
def _transaction(self, responsible = None, description = None):
|
||||
with closing(self.db.cursor()) as cur:
|
||||
cur.execute("INSERT INTO transactions (responsible, description) VALUES (%s, %s) RETURNING id",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue