mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-08 21:33:59 +02:00
brmbar-cli.py: New command-line interface
For remote inspection of brmbar status and to do things too complicated and unusual for the GUI.
This commit is contained in:
parent
ff915072a0
commit
1ba8099e8e
2 changed files with 165 additions and 0 deletions
|
@ -48,6 +48,20 @@ class Shop:
|
|||
|
||||
return cost
|
||||
|
||||
def undo_sale(self, item, user, amount = 1):
|
||||
# Undo sale; rarely needed
|
||||
(buy, sell) = item.currency.rates(self.currency)
|
||||
cost = amount * sell
|
||||
profit = amount * (sell - buy)
|
||||
|
||||
transaction = self._transaction(responsible = user, description = "BrmBar sale UNDO of {}x {} to {}".format(amount, item.name, user.name))
|
||||
item.debit(transaction, amount, user.name + " (sale undo)")
|
||||
user.credit(transaction, cost, item.name + " (sale undo)")
|
||||
self.profits.credit(transaction, profit, "Margin repaid on " + item.name)
|
||||
self.db.commit()
|
||||
|
||||
return cost
|
||||
|
||||
def add_credit(self, credit, user):
|
||||
transaction = self._transaction(responsible = user, description = "BrmBar credit replenishment for " + user.name)
|
||||
self.cash.debit(transaction, credit, user.name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue