diff --git a/brmbar3/brmbar-cli.py b/brmbar3/brmbar-cli.py index abf979f..6fce513 100755 --- a/brmbar3/brmbar-cli.py +++ b/brmbar3/brmbar-cli.py @@ -34,12 +34,8 @@ Usage: brmbar-cli.py COMMAND ARGS... Inventory recounting (fixing the number of items) inventory-interactive Launches interactive mode for performing inventory with barcode reader -! changecash +-AMT - Create a custom transaction that updates nominal cash - balance based on the actual cash balance counted - in the cash box. If you found more money than expected, - use +amt, if you found less money than expected, - use -amt. + changecash AMT + Fixes the cash and puts money difference into excess or deficit account USER and ITEM may be barcodes or account ids. AMT may be both positive and negative amount (big difference to other @@ -184,6 +180,17 @@ elif sys.argv[1] == "inventory-interactive": else: print ("No action needed amount is correct.") print("End of processing. Bye") +elif sys.argv[1] == "changecash": + if (len(sys.argv) != 3): + print ("Invalid number of parameters, check your parameters.") + else: + print("Current Cash is : {}".format(shop.cash.balance_str())) + iamt = int(sys.argv[2]) + if shop.fix_cash(amount = iamt): + print("New Cash is : {}".format(shop.cash.balance_str())) + else: + print ("No action needed amount is the same.") + else: help() diff --git a/brmbar3/brmbar/Shop.py b/brmbar3/brmbar/Shop.py index ad24563..2578d43 100644 --- a/brmbar3/brmbar/Shop.py +++ b/brmbar3/brmbar/Shop.py @@ -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 \ No newline at end of file