mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-07 21:04:00 +02:00
brmbar v3 ShopAdapter: Factor out acct_debt_map(), acct_inventory_map() methods
This commit is contained in:
parent
71abc6ca66
commit
5ac08ac318
1 changed files with 15 additions and 9 deletions
|
@ -13,6 +13,19 @@ class ShopAdapter(QtCore.QObject):
|
|||
def __init__(self):
|
||||
QtCore.QObject.__init__(self)
|
||||
|
||||
def acct_debt_map(self, acct):
|
||||
map = acct.__dict__.copy()
|
||||
map["balance"] = str(acct.balance())
|
||||
map["negbalance"] = str(-acct.balance())
|
||||
map["negbalance_str"] = acct.negbalance_str()
|
||||
return map
|
||||
|
||||
def acct_inventory_map(self, acct):
|
||||
buy, sell = acct.currency.rates(currency)
|
||||
map = acct.__dict__.copy()
|
||||
map["price"] = str(sell)
|
||||
return map
|
||||
|
||||
@QtCore.Slot(str, result='QVariant')
|
||||
def barcodeInput(self, barcode):
|
||||
""" Evaluate barcode received on input
|
||||
|
@ -32,16 +45,9 @@ class ShopAdapter(QtCore.QObject):
|
|||
if acct is None:
|
||||
return None
|
||||
if acct.acctype == 'debt':
|
||||
map = acct.__dict__.copy()
|
||||
map["balance"] = str(acct.balance())
|
||||
map["negbalance"] = str(-acct.balance())
|
||||
map["negbalance_str"] = acct.negbalance_str()
|
||||
return map
|
||||
return self.acct_debt_map(acct)
|
||||
elif acct.acctype == "inventory":
|
||||
buy, sell = acct.currency.rates(currency)
|
||||
map = acct.__dict__.copy()
|
||||
map["price"] = str(sell)
|
||||
return map
|
||||
return self.acct_inventory_map(acct)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue