mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-08 05:14:00 +02:00
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
|
||||
/ 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -299,8 +299,12 @@ Item {
|
|||
text: "Save"
|
||||
onButtonClick: {
|
||||
info["name"] = name
|
||||
shop.saveAccount(dbid, info)
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue