move.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:health-mosconi 作者: GNUHealth-Mosconi 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号