mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-08 05:14:00 +02:00
Added support for cashchange command
This commit is contained in:
parent
06e1e15b7e
commit
0528a50769
2 changed files with 32 additions and 6 deletions
|
@ -163,5 +163,24 @@ class Shop:
|
|||
self.deficit.debit(transaction, buy_total, "Inventory fix deficit " + item.name)
|
||||
self.db.commit()
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
def fix_cash(self, amount):
|
||||
amount_in_reality = amount
|
||||
amount_in_system = self.cash.balance()
|
||||
|
||||
diff = abs(amount_in_reality - amount_in_system)
|
||||
if amount_in_reality > amount_in_system:
|
||||
transaction = self._transaction(description = "BrmBar cash inventory fix of {} in system to {} in reality".format(amount_in_system, amount_in_reality))
|
||||
self.cash.debit(transaction, diff, "Inventory fix excess")
|
||||
self.excess.credit(transaction, diff, "Inventory cash fix excess.")
|
||||
self.db.commit()
|
||||
return True
|
||||
elif amount_in_reality < amount_in_system:
|
||||
transaction = self._transaction(description = "BrmBar cash inventory fix of {} in system to {} in reality".format(amount_in_system, amount_in_reality))
|
||||
self.cash.credit(transaction, diff, "Inventory fix deficit")
|
||||
self.deficit.debit(transaction, diff, "Inventory fix deficit.")
|
||||
self.db.commit()
|
||||
return True
|
||||
else:
|
||||
return False
|
Loading…
Add table
Add a link
Reference in a new issue