def _default_lines(self):
'Return the larger list of lines which can be reconciled'
currency = self.show.account.company.currency
chunk = config.getint('account', 'reconciliation_chunk', default=10)
# Combination is exponential so it must be limited to small number
default = []
for lines in grouped_slice(self._all_lines(), chunk):
lines = list(lines)
best = None
for n in xrange(len(lines), 1, -1):
for comb_lines in combinations(lines, n):
amount = sum((l.debit - l.credit) for l in comb_lines)
if currency.is_zero(amount):
best = [l.id for l in comb_lines]
break
if best:
break
if best:
default.extend(best)
return default
评论列表
文章目录