forked from brmlab/brmbar-github
brmbar-cli: restock by EAN (for automated restocking)
This commit is contained in:
parent
f061cc7f7b
commit
a1c37cb695
2 changed files with 10 additions and 4 deletions
|
@ -97,6 +97,12 @@ def load_item(inp):
|
||||||
exit(1)
|
exit(1)
|
||||||
return acct
|
return acct
|
||||||
|
|
||||||
|
def load_item_by_barcode(inp):
|
||||||
|
acct = brmbar.Account.load_by_barcode(db, inp)
|
||||||
|
if acct.acctype != "inventory":
|
||||||
|
print("Bad EAN " + inp + " type " + acct.acctype, file=sys.stderr)
|
||||||
|
exit(1)
|
||||||
|
return acct
|
||||||
|
|
||||||
db = Database.Database("dbname=brmbar")
|
db = Database.Database("dbname=brmbar")
|
||||||
shop = brmbar.Shop.new_with_defaults(db)
|
shop = brmbar.Shop.new_with_defaults(db)
|
||||||
|
@ -245,16 +251,16 @@ elif sys.argv[1] == "consolidate":
|
||||||
else:
|
else:
|
||||||
shop.consolidate()
|
shop.consolidate()
|
||||||
|
|
||||||
elif sys.argv[1] == "restock":
|
elif sys.argv[1] in {"restock", "restock_ean"}:
|
||||||
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.")
|
||||||
else:
|
else:
|
||||||
iacct = load_item(sys.argv[2])
|
iacct = (load_item if sys.argv[1] == "restock" else load_item_by_barcode)(sys.argv[2])
|
||||||
oldbal = iacct.balance()
|
oldbal = iacct.balance()
|
||||||
amt = int(sys.argv[3])
|
amt = int(sys.argv[3])
|
||||||
cash = shop.buy_for_cash(iacct, amt);
|
cash = shop.buy_for_cash(iacct, amt);
|
||||||
print("Old amount {}, increased by {}, take {} from cashbox".format(oldbal, amt, cash))
|
print("Old amount {}, increased by {}, take {} from cashbox".format(oldbal, amt, cash))
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
help()
|
help()
|
||||||
|
|
|
@ -13,6 +13,6 @@ if [ ! -z "$RES" ]; then
|
||||||
if [ -z "$WINNER" ]; then
|
if [ -z "$WINNER" ]; then
|
||||||
WINNER="anonymous hunter"
|
WINNER="anonymous hunter"
|
||||||
fi
|
fi
|
||||||
echo "Brmlab cleanup bounty was claimed by $WINNER! Thanks!"|ssh jenda@fry.hrach.eu
|
echo "Brmlab cleanup bounty was claimed by $WINNER! Thanks!"|ssh -p 110 jenda@coralmyn.hrach.eu
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue