4
4
# OpenERP, Open Source Management Solution
6
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
6
# Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved.
8
8
# This program is free software: you can redistribute it and/or modify
9
9
# it under the terms of the GNU Affero General Public License as
13
13
# This program is distributed in the hope that it will be useful,
14
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
16
# GNU Affero General Public License for more details.
18
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/>.
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
21
##############################################################################
24
from tools.translate import _
26
#_logger = logging.getLogger(__name__)
28
class account_coda_import(osv.osv_memory):
23
from openerp.osv import orm
24
from openerp.tools.translate import _
27
class account_coda_import(orm.TransientModel):
29
28
_inherit = 'account.coda.import'
30
def _st_line_hook(self, cr, uid, coda_bank_params, line, st_line_vals, context=None):
31
if line.get('payment_line_id'):
32
st_line_vals['payment_line_id'] = line['payment_line_id']
33
return super(account_coda_import, self)._st_line_hook(cr, uid, coda_bank_params, line, st_line_vals, context=context)
31
35
def _match_payment_reference(self, cr, uid, st_line, coda_parsing_note, coda_statement, context=None):
32
36
""" check payment reference in bank statement line against payment order lines """
33
37
payment_line_obj = self.pool.get('payment.line')
34
38
coda_bank_params = coda_statement['coda_bank_params']
35
39
find_payment = coda_bank_params['find_payment']
38
42
payment_reference = st_line['payment_reference']
39
43
if payment_reference and find_payment and st_line['amount'] < 0:
40
44
payline_ids = payment_line_obj and payment_line_obj.search(cr, uid, [('name', '=', payment_reference)])
42
46
if len(payline_ids) == 1:
43
47
payline = payment_line_obj.browse(cr, uid, payline_ids[0], context=context)
44
48
match['payment_line_id'] = payline.id
49
st_line['payment_line_id'] = payline.id
45
50
st_line['partner_id'] = payline.partner_id.id
46
51
if payline.move_line_id:
47
52
st_line['reconcile'] = payline.move_line_id.id
48
53
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'
54
st_line['type'] = payline.move_line_id.account_id.type == 'receivable' and 'customer' or 'supplier'
51
56
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]
57
'\nPlease check your Payment Gateway configuration or contact your OpenERP support channel.') % line[2:10]
55
60
return (err_code, err_string)
56
raise osv.except_osv(_('Error!'), err_string)
61
raise orm.except_orm(_('Error!'), err_string)
58
63
return st_line, coda_parsing_note, match
62
65
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
b'\\ No newline at end of file'