mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-08 05:14:00 +02:00
Add missing collateral changes for Transfer
This commit is contained in:
parent
5c84bd6a8f
commit
099d775102
3 changed files with 22 additions and 3 deletions
|
@ -122,6 +122,14 @@ class ShopAdapter(QtCore.QObject):
|
|||
db.commit()
|
||||
return balance
|
||||
|
||||
@QtCore.Slot('QVariant', 'QVariant', 'QVariant', result='QVariant')
|
||||
def newTransfer(self, uidfrom, uidto, amount):
|
||||
ufrom = brmbar.Account.load(db, id=uidfrom)
|
||||
uto = brmbar.Account.load(db, id=uidto)
|
||||
shop.transfer_credit(ufrom, uto, amount = amount)
|
||||
db.commit()
|
||||
return currency.str(float(amount))
|
||||
|
||||
@QtCore.Slot('QVariant', result='QVariant')
|
||||
def balance_user(self, userid):
|
||||
user = brmbar.Account.load(db, id=userid)
|
||||
|
|
|
@ -33,6 +33,16 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
BarButton {
|
||||
x: 450
|
||||
y: 838
|
||||
width: 360
|
||||
text: "Transfer"
|
||||
onButtonClick: {
|
||||
loadPage("Transfer")
|
||||
}
|
||||
}
|
||||
|
||||
BarButton {
|
||||
id: management
|
||||
x: 855
|
||||
|
@ -50,7 +60,4 @@ Item {
|
|||
width: 1150
|
||||
text: "* Mroze a Termixy najdes v lednici *"
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -78,6 +78,10 @@ class Shop:
|
|||
user.debit(transaction, credit, "Credit withdrawal")
|
||||
self.db.commit()
|
||||
|
||||
def transfer_credit(self, userfrom, userto, amount):
|
||||
self.add_credit(amount, userto)
|
||||
self.withdraw_credit(amount, userfrom)
|
||||
|
||||
def buy_for_cash(self, item, amount = 1):
|
||||
# Buy: Currency conversion from item currency to shop currency
|
||||
(buy, sell) = item.currency.rates(self.currency)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue