mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-07 21:04:00 +02:00
brmbar-cli.py inventory-interactive: Tidy up code
This commit is contained in:
parent
6b67dd372e
commit
2bbb46d4ea
1 changed files with 15 additions and 14 deletions
|
@ -174,27 +174,26 @@ elif sys.argv[1] == "inventory":
|
||||||
elif sys.argv[1] == "inventory-interactive":
|
elif sys.argv[1] == "inventory-interactive":
|
||||||
print("Inventory interactive mode. To exit interactive mode just enter empty barcode")
|
print("Inventory interactive mode. To exit interactive mode just enter empty barcode")
|
||||||
|
|
||||||
keep_entering = True
|
while True:
|
||||||
while keep_entering:
|
|
||||||
barcode = str(input("Enter barcode:"))
|
barcode = str(input("Enter barcode:"))
|
||||||
fuckyou = input("fuckyou")
|
fuckyou = input("fuckyou")
|
||||||
if barcode == "":
|
if barcode == "":
|
||||||
break
|
break
|
||||||
|
iacct = brmbar.Account.load_by_barcode(db, barcode)
|
||||||
|
amount = str(input("What is the amount of {} in reality (expected: {} pcs):".format(iacct.name, iacct.balance())))
|
||||||
|
if amount == "":
|
||||||
|
break
|
||||||
|
elif int(amount) > 10000:
|
||||||
|
print("Ignoring too high amount {}, assuming barcode was mistakenly scanned instead".format(amount))
|
||||||
else:
|
else:
|
||||||
iacct = brmbar.Account.load_by_barcode(db, barcode)
|
iamt = int(amount)
|
||||||
amount = str(input("What is the amount of {} in reality (expected: {} pcs):".format(iacct.name, iacct.balance())))
|
print("Current state {} (id {}): {} pcs".format(iacct.name, iacct.id, iacct.balance()))
|
||||||
if amount == "":
|
if shop.fix_inventory(item = iacct, amount = iamt):
|
||||||
break
|
print("New state {} (id {}): {} pcs".format(iacct.name, iacct.id, iacct.balance()))
|
||||||
elif int(amount) > 10000:
|
|
||||||
print("Ignoring too high amount {}, assuming barcode was mistakenly scanned instead".format(amount))
|
|
||||||
else:
|
else:
|
||||||
iamt = int(amount)
|
print("No action needed, amount is correct.")
|
||||||
print("Current state {} (id {}): {} pcs".format(iacct.name, iacct.id, iacct.balance()))
|
|
||||||
if shop.fix_inventory(item = iacct, amount = iamt):
|
|
||||||
print("New state {} (id {}): {} pcs".format(iacct.name, iacct.id, iacct.balance()))
|
|
||||||
else:
|
|
||||||
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):
|
||||||
print ("Invalid number of parameters, check your parameters.")
|
print ("Invalid number of parameters, check your parameters.")
|
||||||
|
@ -205,11 +204,13 @@ elif sys.argv[1] == "changecash":
|
||||||
print("New Cash is : {}".format(shop.cash.balance_str()))
|
print("New Cash is : {}".format(shop.cash.balance_str()))
|
||||||
else:
|
else:
|
||||||
print ("No action needed amount is the same.")
|
print ("No action needed amount is the same.")
|
||||||
|
|
||||||
elif sys.argv[1] == "consolidate":
|
elif sys.argv[1] == "consolidate":
|
||||||
if (len(sys.argv) != 2):
|
if (len(sys.argv) != 2):
|
||||||
print ("Invalid number of parameters, check your parameters.")
|
print ("Invalid number of parameters, check your parameters.")
|
||||||
else:
|
else:
|
||||||
shop.consolidate()
|
shop.consolidate()
|
||||||
|
|
||||||
elif sys.argv[1] == "restock":
|
elif sys.argv[1] == "restock":
|
||||||
if (len(sys.argv) != 4):
|
if (len(sys.argv) != 4):
|
||||||
print ("Invalid number of parameters, check your parameters.")
|
print ("Invalid number of parameters, check your parameters.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue