~akretion-team/banking-addons/70-fully-handle-payment-types

« back to all changes in this revision

Viewing changes to account_banking_payment/model/banking_import_transaction.py

  • Committer: Raphaël Valyi
  • Date: 2014-03-21 19:12:47 UTC
  • mfrom: (225.1.11 7.0)
  • Revision ID: rvalyi@gmail.com-20140321191247-zqytcf091nlbxboo
[MERGE] merged HEAD into current feature branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
116
116
        '''
117
117
        # TODO: Not sure what side effects are created when payments are done
118
118
        # for credited customer invoices, which will be matched later on too.
 
119
 
 
120
        def bank_match(account, partner_bank):
 
121
            """
 
122
            Returns whether a given account number is equivalent to a
 
123
            partner bank in the database. We simply call the search method,
 
124
            which checks IBAN, domestic and disregards from spaces in IBANs.
 
125
 
 
126
            :param account: string representation of a bank account number
 
127
            :param partner_bank: browse record of model res.partner.bank
 
128
            """
 
129
            return partner_bank.id in self.pool['res.partner.bank'].search(
 
130
                cr, uid, [('acc_number', '=', account)])
 
131
 
119
132
        digits = dp.get_precision('Account')(cr)[1]
120
133
        candidates = [
121
 
            x for x in payment_lines
122
 
            if x.communication == trans.reference 
123
 
            and round(x.amount, digits) == -round(
124
 
                trans.statement_line_id.amount, digits)
125
 
            and trans.remote_account in (x.bank_id.acc_number,
126
 
                                         x.bank_id.acc_number_domestic)
 
134
            line for line in payment_lines
 
135
            if (line.communication == trans.reference 
 
136
                and round(line.amount, digits) == -round(
 
137
                    trans.statement_line_id.amount, digits)
 
138
                and bank_match(trans.remote_account, line.bank_id))
127
139
            ]
128
140
        if len(candidates) == 1:
129
141
            candidate = candidates[0]