diff --git a/brmbar3/TODO b/brmbar3/TODO index 0fb1e8f..d6cfb37 100644 --- a/brmbar3/TODO +++ b/brmbar3/TODO @@ -11,10 +11,11 @@ + Use for withdrawal / Restocking view (Stock management) + Item picker with edit button - / Item editor (name, buy price, sale price, quantity) - / Item-barcode assignment + + Item editor (name, buy price, sale price, quantity) + + Item-barcode assignment + - Support for adding new items + Alphanumeric manual entry support - - Use in item editor + + Use in item editor - Withdrawal for brmbar receipts 1. User responsible 2. Amount and description @@ -28,6 +29,7 @@ - Delete user - Forbid negative credit - Stock management + - Allow overriding item barcodes - Group quantity changes in a single transaction (for single receipt, many stock) - Support for directly paying for stocked items from user credit - Statistics diff --git a/brmbar3/brmbar-gui-qt4.py b/brmbar3/brmbar-gui-qt4.py index cb89f19..381a51f 100755 --- a/brmbar3/brmbar-gui-qt4.py +++ b/brmbar3/brmbar-gui-qt4.py @@ -106,6 +106,19 @@ class ShopAdapter(QtCore.QObject): def addBarcode(self, dbid, barcode): return brmbar.Account.load(db, id = dbid).add_barcode(barcode) + @QtCore.Slot('QVariant', 'QVariant', result='QVariant') + def saveItem(self, dbid, invmap): + acct = brmbar.Account.load(db, id = dbid) + buy, sell = acct.currency.rates(currency) + if (sell != invmap["price"]): + acct.currency.update_sell_rate(currency, invmap["price"]) + if (buy != invmap["buy_price"]): + acct.currency.update_buy_rate(currency, invmap["buy_price"]) + cost = "" + if (acct.balance() < int(invmap["balance"])): + cost = shop.buy_for_cash(acct, invmap["balance"] - acct.balance()) + return { "dbid": dbid, "cost": currency.str(cost) } + db = psycopg2.connect("dbname=brmbar") shop = brmbar.Shop.new_with_defaults(db) currency = shop.currency diff --git a/brmbar3/brmbar-gui-qt4/ItemEdit.qml b/brmbar3/brmbar-gui-qt4/ItemEdit.qml index 6c1d5ca..6e3d24e 100644 --- a/brmbar3/brmbar-gui-qt4/ItemEdit.qml +++ b/brmbar3/brmbar-gui-qt4/ItemEdit.qml @@ -299,8 +299,12 @@ Item { text: "Save" onButtonClick: { info["name"] = name - shop.saveAccount(dbid, info) - status_text.setStatus("Changes saved", "#ffff7c") + var res = shop.saveItem(dbid, info) + if (res.cost) { + status_text.setStatus("Restocked! Take " + res.cost + " from the money box.", "#ffff7c") + } else { + status_text.setStatus("Changes saved", "#ffff7c") + } loadPage("StockMgmt") } }