mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-08 05:14:00 +02:00
brmbar v3 Withdraw: New view for user withdrawal of previously added money
This commit is contained in:
parent
eda6eaf9e4
commit
83735fec98
4 changed files with 128 additions and 5 deletions
|
@ -2,17 +2,17 @@
|
||||||
+ Stock management link
|
+ Stock management link
|
||||||
+ User management link
|
+ User management link
|
||||||
+ Bilance overview (Cash, Profit, Credit total)
|
+ Bilance overview (Cash, Profit, Credit total)
|
||||||
/ Item picker from list (only items with non-zero quantities)
|
+ Item picker from list
|
||||||
/ User management
|
+ User management
|
||||||
+ List of users
|
+ List of users
|
||||||
- Withdrawal of user credit
|
+ Withdrawal of user credit
|
||||||
- Numerical manual entry support
|
- Numerical manual entry support
|
||||||
- Use for credit charge
|
- Use for credit charge
|
||||||
- Use for withdrawal
|
- Use for withdrawal
|
||||||
- Alphanumeric manual entry support
|
- Alphanumeric manual entry support
|
||||||
- Use in item editor
|
- Use in item editor
|
||||||
- Restocking view (Stock management)
|
- Restocking view (Stock management)
|
||||||
- Item picker with edit button
|
- Item picker with edit button (only items with non-zero quantities)
|
||||||
- Item editor (name, barcode, buy price, sale price, quantity)
|
- Item editor (name, barcode, buy price, sale price, quantity)
|
||||||
- Group quantity changes in a single transaction
|
- Group quantity changes in a single transaction
|
||||||
- Withdrawal for brmbar receipts
|
- Withdrawal for brmbar receipts
|
||||||
|
|
|
@ -67,6 +67,12 @@ class ShopAdapter(QtCore.QObject):
|
||||||
shop.add_credit(credit = credit, user = user)
|
shop.add_credit(credit = credit, user = user)
|
||||||
return user.negbalance_str()
|
return user.negbalance_str()
|
||||||
|
|
||||||
|
@QtCore.Slot('QVariant', 'QVariant', result='QVariant')
|
||||||
|
def withdrawCredit(self, credit, userid):
|
||||||
|
user = brmbar.Account.load(db, id = userid)
|
||||||
|
shop.withdraw_credit(credit = credit, user = user)
|
||||||
|
return user.negbalance_str()
|
||||||
|
|
||||||
@QtCore.Slot(result='QVariant')
|
@QtCore.Slot(result='QVariant')
|
||||||
def balance_cash(self):
|
def balance_cash(self):
|
||||||
return shop.cash.balance_str()
|
return shop.cash.balance_str()
|
||||||
|
|
|
@ -24,7 +24,8 @@ Item {
|
||||||
loadPageByAcct(acct)
|
loadPageByAcct(acct)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
loadPage("UserEdit", { name: acct["name"], dbid: acct["id"], negbalance: acct["negbalance"] })
|
/* TODO: This should be UserEdit when implemented. */
|
||||||
|
loadPage("Withdraw", { name: acct["name"], dbid: acct["id"], negbalance: acct["negbalance"] })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +68,9 @@ Item {
|
||||||
height: 68
|
height: 68
|
||||||
text: "Withdraw"
|
text: "Withdraw"
|
||||||
fontSize: 34
|
fontSize: 34
|
||||||
|
onButtonClick: {
|
||||||
|
loadPage("Withdraw", { username: modelData.name, userdbid: modelData.id })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
model: user_list_model
|
model: user_list_model
|
||||||
|
|
113
brmbar3/brmbar-gui-qt4/Withdraw.qml
Normal file
113
brmbar3/brmbar-gui-qt4/Withdraw.qml
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
|
||||||
|
import QtQuick 1.1
|
||||||
|
import QtQuick 1.0
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: page
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
property variant username: ""
|
||||||
|
property variant userdbid: ""
|
||||||
|
property variant amount: ""
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: item_name
|
||||||
|
x: 65
|
||||||
|
y: 156
|
||||||
|
width: 537
|
||||||
|
height: 160
|
||||||
|
color: "#ffffff"
|
||||||
|
text: parent.username ? parent.username : "Credit withdrawal"
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
font.pointSize: 44
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: text3
|
||||||
|
x: 611
|
||||||
|
y: 156
|
||||||
|
height: 160
|
||||||
|
width: 348
|
||||||
|
color: "#ffff7c"
|
||||||
|
text: parent.amount ? "-" + parent.amount : ""
|
||||||
|
horizontalAlignment: Text.AlignRight
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
font.pointSize: 90
|
||||||
|
}
|
||||||
|
|
||||||
|
BarTextHint {
|
||||||
|
x: 65
|
||||||
|
y: 430
|
||||||
|
hint_goal: parent.amount ? (parent.username ? "Withdraw amount?" : "Withdraw:") : "Withdraw:"
|
||||||
|
hint_action: !(parent.amount && parent.userdbid) ? "Scan barcode now" : ""
|
||||||
|
}
|
||||||
|
|
||||||
|
BarcodeInput {
|
||||||
|
color: "#00ff00" /* just for debugging */
|
||||||
|
onAccepted: {
|
||||||
|
var acct = shop.barcodeInput(text)
|
||||||
|
text = ""
|
||||||
|
if (typeof(acct) == "undefined" || (parent.username && acct.acctype != "recharge") || (parent.amount && acct.acctype != "debt")) {
|
||||||
|
status_text.setStatus("Unknown barcode", "#ff4444")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (acct.acctype == "debt") {
|
||||||
|
username = acct.name
|
||||||
|
userdbid = acct.id
|
||||||
|
} else {
|
||||||
|
amount = acct.amount
|
||||||
|
}
|
||||||
|
/* if (username && amount) {
|
||||||
|
parent.withdrawCredit()
|
||||||
|
} */ /* Always ask for confirmation. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BarButton {
|
||||||
|
id: withdraw_button
|
||||||
|
x: 65
|
||||||
|
y: 582
|
||||||
|
width: 360
|
||||||
|
text: "Withdraw"
|
||||||
|
fontSize: 44
|
||||||
|
visible: parent.amount && parent.userdbid
|
||||||
|
onButtonClick: {
|
||||||
|
parent.withdrawCredit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BarButton {
|
||||||
|
id: cancel
|
||||||
|
x: 599
|
||||||
|
y: 582
|
||||||
|
width: 360
|
||||||
|
text: "Cancel"
|
||||||
|
onButtonClick: {
|
||||||
|
status_text.setStatus("Withdrawal cancelled", "#ff4444")
|
||||||
|
loadPage("UserMgmt") /* TODO better "back" navigation? */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: text1
|
||||||
|
x: 112
|
||||||
|
y: 333
|
||||||
|
width: 800
|
||||||
|
height: 80
|
||||||
|
color: "#ffffff"
|
||||||
|
text: "Take "+amount+" Kč from the money box now."
|
||||||
|
visible: amount ? true : false
|
||||||
|
anchors.horizontalCenterOffset: 0
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
font.pointSize: 36
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
function withdrawCredit() {
|
||||||
|
var balance = shop.withdrawCredit(amount, userdbid)
|
||||||
|
status_text.setStatus("Withdrawn! "+username+"'s credit is "+balance+".", "#ffff7c")
|
||||||
|
loadPage("MainPage")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue