Example #1
0
 def save_preferences(self):
     common.debug("Skipping save of preferences")
Example #2
0
 def save_transaction(self, text):
     common.debug("Transaction not being saved:")
     common.debug(text)
Example #3
0
 def commit(self):
     for _, unfinished in itertools.groupby(
         self.unfinished, lambda x: str(x[2])
     ):
         unfinished = list(unfinished)
         inputs = [l for l in unfinished if l[1] < 0]
         outputs = [l for l in unfinished if l not in inputs]
         for i in inputs[:]:
             debug("Registering input %s", i)
             _, iam, ip, iac = i
             ilot = self.locate_lot(ip, iac, -iam)
             debug("Corresponding input lot located %s", ilot)
             debug("reducing lot amount by %s", iam)
             ilot.amount += iam
             debug("Detecting which lots it should output to")
             for o in outputs[:]:
                 debug("Trying lot %s", o)
                 od, oam, op, oac = o
                 toinc = min([-iam, oam])
                 debug("Must increment lot by %s", toinc)
                 try:
                     olot = self.locate_lot(op, oac)
                     debug("Located target lot %s", olot)
                     olot.dates_seen += [od]
                     olot.amount += toinc
                     debug("Lot incremented by %s", toinc)
                 except IndexError:
                     olot = Lot(ilot.number,
                                ilot.dates_seen + [od],
                                op,
                                toinc,
                                ilot.accounts_seen + [oac])
                     debug("Created new target lot %s", olot)
                     self.lots.append(olot)
                 iam += toinc
                 if toinc == oam:
                     debug("This output is spent %s", o)
                     outputs.remove(o)
                 else:
                     debug("Reducing this output for future use %s", o)
                     outputs[outputs.index(o)] = (od, oam - toinc, op, oac)
                 if iam == 0:
                     break
             if ilot.amount == 0:
                 debug("Lot reached zero, removing %s", ilot)
                 self.lots.remove(ilot)
             inputs.remove(i)
         for o in outputs[:]:
             debug("Registering output %s", o)
             od, oam, op, oac = o
             olot = Lot(self.nextnum(),
                        [od],
                        op,
                        oam,
                        [oac])
             self.lots.append(olot)
             outputs.remove(o)
         assert not inputs, inputs
         assert not outputs, outputs
     self.unfinished = []