forked from brmlab/brmbar-github
brmbar v3 ItemEdit: Support for saving changes and restocking
This commit is contained in:
parent
6e7cdf0bad
commit
34bfac01d5
3 changed files with 24 additions and 5 deletions
|
@ -11,10 +11,11 @@
|
||||||
+ Use for withdrawal
|
+ Use for withdrawal
|
||||||
/ Restocking view (Stock management)
|
/ Restocking view (Stock management)
|
||||||
+ Item picker with edit button
|
+ Item picker with edit button
|
||||||
/ Item editor (name, buy price, sale price, quantity)
|
+ Item editor (name, buy price, sale price, quantity)
|
||||||
/ Item-barcode assignment
|
+ Item-barcode assignment
|
||||||
|
- Support for adding new items
|
||||||
+ Alphanumeric manual entry support
|
+ Alphanumeric manual entry support
|
||||||
- Use in item editor
|
+ Use in item editor
|
||||||
- Withdrawal for brmbar receipts
|
- Withdrawal for brmbar receipts
|
||||||
1. User responsible
|
1. User responsible
|
||||||
2. Amount and description
|
2. Amount and description
|
||||||
|
@ -28,6 +29,7 @@
|
||||||
- Delete user
|
- Delete user
|
||||||
- Forbid negative credit
|
- Forbid negative credit
|
||||||
- Stock management
|
- Stock management
|
||||||
|
- Allow overriding item barcodes
|
||||||
- Group quantity changes in a single transaction (for single receipt, many stock)
|
- Group quantity changes in a single transaction (for single receipt, many stock)
|
||||||
- Support for directly paying for stocked items from user credit
|
- Support for directly paying for stocked items from user credit
|
||||||
- Statistics
|
- Statistics
|
||||||
|
|
|
@ -106,6 +106,19 @@ class ShopAdapter(QtCore.QObject):
|
||||||
def addBarcode(self, dbid, barcode):
|
def addBarcode(self, dbid, barcode):
|
||||||
return brmbar.Account.load(db, id = dbid).add_barcode(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")
|
db = psycopg2.connect("dbname=brmbar")
|
||||||
shop = brmbar.Shop.new_with_defaults(db)
|
shop = brmbar.Shop.new_with_defaults(db)
|
||||||
currency = shop.currency
|
currency = shop.currency
|
||||||
|
|
|
@ -299,8 +299,12 @@ Item {
|
||||||
text: "Save"
|
text: "Save"
|
||||||
onButtonClick: {
|
onButtonClick: {
|
||||||
info["name"] = name
|
info["name"] = name
|
||||||
shop.saveAccount(dbid, info)
|
var res = shop.saveItem(dbid, info)
|
||||||
status_text.setStatus("Changes saved", "#ffff7c")
|
if (res.cost) {
|
||||||
|
status_text.setStatus("Restocked! Take " + res.cost + " from the money box.", "#ffff7c")
|
||||||
|
} else {
|
||||||
|
status_text.setStatus("Changes saved", "#ffff7c")
|
||||||
|
}
|
||||||
loadPage("StockMgmt")
|
loadPage("StockMgmt")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue