~taktik/openobject-addons/hui-extra-6.1

« back to all changes in this revision

Viewing changes to account_coda_pain/wizard/account_coda_import.py

  • Committer: Luc De Meyer
  • Date: 2014-03-12 19:53:31 UTC
  • Revision ID: luc.demeyer@noviat.com-20140312195331-lxqjtcbxg9h5dd7e
update accounting modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    OpenERP, Open Source Management Solution
 
5
#
 
6
#    Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
 
7
#
 
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.
 
12
#
 
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.
 
17
#
 
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/>.
 
20
#
 
21
##############################################################################
 
22
 
 
23
from osv import osv
 
24
from tools.translate import _
 
25
#import logging
 
26
#_logger = logging.getLogger(__name__)
 
27
 
 
28
class account_coda_import(osv.osv_memory):
 
29
    _inherit = 'account.coda.import'
 
30
 
 
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']
 
36
        match={}
 
37
        
 
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)])
 
41
            if payline_ids:
 
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' 
 
50
                else:
 
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]                   
 
53
                    err_code = 'R2007'
 
54
                    if self.batch:
 
55
                        return (err_code, err_string)
 
56
                    raise osv.except_osv(_('Error!'), err_string)    
 
57
 
 
58
        return st_line, coda_parsing_note, match
 
59
        
 
60
account_coda_import()
 
61
        
 
62
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
 
b'\\ No newline at end of file'