brmbar-cli.py inventory-interactive: Try to detect mistaken barcode scan

This commit is contained in:
brmbar 2016-01-04 20:39:51 +01:00
parent edc99f1ff9
commit 6b67dd372e

View file

@ -182,16 +182,18 @@ elif sys.argv[1] == "inventory-interactive":
break break
else: else:
iacct = brmbar.Account.load_by_barcode(db, barcode) iacct = brmbar.Account.load_by_barcode(db, barcode)
amount = str(input("What is the amount of {} in reality current is {}:".format(iacct.name, iacct.balance()))) amount = str(input("What is the amount of {} in reality (expected: {} pcs):".format(iacct.name, iacct.balance())))
if amount == "": if amount == "":
break break
elif int(amount) > 10000:
print("Ignoring too high amount {}, assuming barcode was mistakenly scanned instead".format(amount))
else: else:
iamt = int(amount) iamt = int(amount)
print("Current state {} (id {}): {} pcs".format(iacct.name, iacct.id, iacct.balance())) print("Current state {} (id {}): {} pcs".format(iacct.name, iacct.id, iacct.balance()))
if shop.fix_inventory(item = iacct, amount = iamt): if shop.fix_inventory(item = iacct, amount = iamt):
print("New state {} (id {}): {} pcs".format(iacct.name, iacct.id, iacct.balance())) print("New state {} (id {}): {} pcs".format(iacct.name, iacct.id, iacct.balance()))
else: else:
print ("No action needed amount is correct.") print("No action needed, amount is correct.")
print("End of processing. Bye") print("End of processing. Bye")
elif sys.argv[1] == "changecash": elif sys.argv[1] == "changecash":
if (len(sys.argv) != 3): if (len(sys.argv) != 3):