client-barcode: Commit 6 deposits of 1.00 Euro as one deposit of 6.00 Euro (bug #203)
This commit is contained in:
parent
7046890acf
commit
53368e49ac
|
@ -261,6 +261,21 @@ class Status:
|
||||||
def commit(self):
|
def commit(self):
|
||||||
assert(self.logged_in())
|
assert(self.logged_in())
|
||||||
|
|
||||||
|
# Compress DepositCommands
|
||||||
|
dummy, initial_balance = self.transfers[0]
|
||||||
|
balance_before = initial_balance
|
||||||
|
compressed_deposit = DepositCommand(Decimal('0'))
|
||||||
|
others = list()
|
||||||
|
for (command, dummy) in list(self.transfers):
|
||||||
|
if isinstance(command, DepositCommand):
|
||||||
|
compressed_deposit.add(command)
|
||||||
|
else:
|
||||||
|
others.append((command, balance_before))
|
||||||
|
balance_before += command.difference()
|
||||||
|
if compressed_deposit.difference() != 0:
|
||||||
|
others.append((compressed_deposit, balance_before))
|
||||||
|
self.transfers = others
|
||||||
|
|
||||||
# Process command queue
|
# Process command queue
|
||||||
for (command, balance_backup) in list(self.transfers):
|
for (command, balance_backup) in list(self.transfers):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -15,6 +15,10 @@ class DepositCommand(object):
|
||||||
def difference(self):
|
def difference(self):
|
||||||
return self._difference
|
return self._difference
|
||||||
|
|
||||||
|
def add(self, deposit_command):
|
||||||
|
assert(isinstance(deposit_command, DepositCommand))
|
||||||
|
self._difference += deposit_command._difference
|
||||||
|
|
||||||
def run(self, user_name):
|
def run(self, user_name):
|
||||||
net.deposit(self._difference, net.DEPOSIT_CASH, user_name)
|
net.deposit(self._difference, net.DEPOSIT_CASH, user_name)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue