1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
6
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU Affero General Public License as
10
# published by the Free Software Foundation, either version 3 of the
11
# License, or (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU Affero General Public License for more details.
18
# You should have received a copy of the GNU Affero General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
24
from tools.translate import _
26
#_logger = logging.getLogger(__name__)
28
class account_coda_import(osv.osv_memory):
29
_inherit = 'account.coda.import'
31
def _match_payment_reference(self, cr, uid, st_line, coda_parsing_note, coda_statement, context=None):
32
""" check payment reference in bank statement line against payment order lines """
33
payment_line_obj = self.pool.get('payment.line')
34
coda_bank_params = coda_statement['coda_bank_params']
35
find_payment = coda_bank_params['find_payment']
38
payment_reference = st_line['payment_reference']
39
if payment_reference and find_payment and st_line['amount'] < 0:
40
payline_ids = payment_line_obj and payment_line_obj.search(cr, uid, [('name', '=', payment_reference)])
42
if len(payline_ids) == 1:
43
payline = payment_line_obj.browse(cr, uid, payline_ids[0], context=context)
44
match['payment_line_id'] = payline.id
45
st_line['partner_id'] = payline.partner_id.id
46
if payline.move_line_id:
47
st_line['reconcile'] = payline.move_line_id.id
48
st_line['account_id'] = payline.move_line_id.account_id.id
49
st_line['type'] = payline.move_line_id.account_id.type == 'receivable' and 'customer' or 'supplier'
51
err_string = _('\nThe CODA parsing detected a payment reference ambiguity while processing movement data record 2.3, seq nr %s!' \
52
'\nPlease check your Payment Gateway configuration or contact your OpenERP support channel.') % line[2:10]
55
return (err_code, err_string)
56
raise osv.except_osv(_('Error!'), err_string)
58
return st_line, coda_parsing_note, match
62
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
b'\\ No newline at end of file'