diff --git a/brmbar3/brmbar-cli.py b/brmbar3/brmbar-cli.py index 19b3a6d..d91a24b 100755 --- a/brmbar3/brmbar-cli.py +++ b/brmbar3/brmbar-cli.py @@ -36,6 +36,9 @@ Usage: brmbar-cli.py COMMAND ARGS... Launches interactive mode for performing inventory with barcode reader changecash AMT Fixes the cash and puts money difference into excess or deficit account + consolidate + Wraps up inventory + cash recounting, transferring the excess and + deficit accounts balance to the profits account and resetting them USER and ITEM may be barcodes or account ids. AMT may be both positive and negative amount (big difference to other @@ -191,6 +194,11 @@ elif sys.argv[1] == "changecash": print("New Cash is : {}".format(shop.cash.balance_str())) else: print ("No action needed amount is the same.") +elif sys.argv[1] == "consolidate": + if (len(sys.argv) != 2): + print ("Invalid number of parameters, check your parameters.") + else: + shop.consolidate() else: diff --git a/brmbar3/brmbar/Shop.py b/brmbar3/brmbar/Shop.py index 0ec4282..bf74fef 100644 --- a/brmbar3/brmbar/Shop.py +++ b/brmbar3/brmbar/Shop.py @@ -188,3 +188,17 @@ class Shop: return True else: return False + def consolidate(self): + transaction = self._transaction(description = "BrmBar inventory consolidation") + + excess_balance = self.excess.balance() + if excess_balance != 0: + print("Excess balance {} debited to profit".format(-excess_balance)) + self.excess.debit(transaction, -excess_balance, "Excess balance added to profit.") + self.profits.debit(transaction, -excess_balance, "Excess balance added to profit.") + deficit_balance = self.deficit.balance() + if deficit_balance != 0: + print("Deficit balance {} credited to profit".format(deficit_balance)) + self.deficit.credit(transaction, deficit_balance, "Deficit balance removed from profit.") + self.profits.credit(transaction, deficit_balance, "Deficit balance removed from profit.") + self.db.commit()