mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-07 21:04:00 +02:00
brmbar.Shop.receipt_to_credit(): New method for converting receipts to credit
This commit is contained in:
parent
325033231b
commit
9c1c8d381b
1 changed files with 6 additions and 0 deletions
|
@ -75,6 +75,12 @@ class Shop:
|
|||
|
||||
return cost
|
||||
|
||||
def receipt_to_credit(self, user, credit, description):
|
||||
transaction = self._transaction(responsible = user, description = "Receipt: " + description)
|
||||
self.profits.credit(transaction, credit, user.name)
|
||||
user.credit(transaction, credit, "Credit from receipt: " + description)
|
||||
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