Browse Source

client-barcode: Commit 6 deposits of 1.00 Euro as one deposit of 6.00 Euro (bug #203)

master
Sebastian Pipping 11 years ago
parent
commit
53368e49ac
  1. 15
      client-barcode/freitagskasse.py
  2. 4
      client-barcode/freitagslib/commands.py

15
client-barcode/freitagskasse.py

@ -261,6 +261,21 @@ class Status: @@ -261,6 +261,21 @@ class Status:
def commit(self):
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
for (command, balance_backup) in list(self.transfers):
try:

4
client-barcode/freitagslib/commands.py

@ -15,6 +15,10 @@ class DepositCommand(object): @@ -15,6 +15,10 @@ class DepositCommand(object):
def difference(self):
return self._difference
def add(self, deposit_command):
assert(isinstance(deposit_command, DepositCommand))
self._difference += deposit_command._difference
def run(self, user_name):
net.deposit(self._difference, net.DEPOSIT_CASH, user_name)

Loading…
Cancel
Save