client-barcode: Split Status.commit() up into sub-functions
This commit is contained in:
parent
27962ad107
commit
156a0df88d
|
@ -267,7 +267,7 @@ class Status:
|
||||||
def commit(self):
|
def commit(self):
|
||||||
assert(self.logged_in())
|
assert(self.logged_in())
|
||||||
|
|
||||||
# Compress DepositCommands
|
def compress_deposit_commands():
|
||||||
dummy, initial_balance = self.transfers[0]
|
dummy, initial_balance = self.transfers[0]
|
||||||
balance_before = initial_balance
|
balance_before = initial_balance
|
||||||
compressed_deposit = DepositCommand(Decimal('0'))
|
compressed_deposit = DepositCommand(Decimal('0'))
|
||||||
|
@ -282,10 +282,10 @@ class Status:
|
||||||
others.append((compressed_deposit, balance_before))
|
others.append((compressed_deposit, balance_before))
|
||||||
self.transfers = others
|
self.transfers = others
|
||||||
|
|
||||||
|
def process_buy_commands_combined():
|
||||||
# Compress BuyCommands, use a single bulkbuy
|
# Compress BuyCommands, use a single bulkbuy
|
||||||
dummy, initial_balance = self.transfers[0]
|
dummy, initial_balance = self.transfers[0]
|
||||||
balance_before = initial_balance
|
balance_before = initial_balance
|
||||||
|
|
||||||
buy_commands = list()
|
buy_commands = list()
|
||||||
non_buy_commands = list()
|
non_buy_commands = list()
|
||||||
total_buy_diff = 0
|
total_buy_diff = 0
|
||||||
|
@ -305,7 +305,7 @@ class Status:
|
||||||
else:
|
else:
|
||||||
self.transfers = non_buy_commands
|
self.transfers = non_buy_commands
|
||||||
|
|
||||||
# Process remaining command queue
|
def process_commands():
|
||||||
for (command, balance_backup) in list(self.transfers):
|
for (command, balance_backup) in list(self.transfers):
|
||||||
try:
|
try:
|
||||||
command.run(self.login_name)
|
command.run(self.login_name)
|
||||||
|
@ -316,6 +316,7 @@ class Status:
|
||||||
else:
|
else:
|
||||||
self.transfers.pop(0)
|
self.transfers.pop(0)
|
||||||
|
|
||||||
|
def finish():
|
||||||
if not self.transfers:
|
if not self.transfers:
|
||||||
# Show final balance for some time
|
# Show final balance for some time
|
||||||
clear()
|
clear()
|
||||||
|
@ -324,6 +325,10 @@ class Status:
|
||||||
|
|
||||||
self.logout()
|
self.logout()
|
||||||
|
|
||||||
|
compress_deposit_commands()
|
||||||
|
process_buy_commands_combined()
|
||||||
|
process_commands()
|
||||||
|
finish()
|
||||||
|
|
||||||
def find(self, barcode):
|
def find(self, barcode):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue