~ressu/+junk/account_banking_patu

« back to all changes in this revision

Viewing changes to account_banking_nl_clieop/account_banking_nl_clieop.py

  • Committer: Sami Haahtinen
  • Date: 2010-08-02 11:19:59 UTC
  • Revision ID: ressu@ressukka.net-20100802111959-7bdrj9t13eg4g0oj
split repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
##############################################################################
2
 
#
3
 
#    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
4
 
#    All Rights Reserved
5
 
#
6
 
#    This program is free software: you can redistribute it and/or modify
7
 
#    it under the terms of the GNU General Public License as published by
8
 
#    the Free Software Foundation, either version 3 of the License, or
9
 
#    (at your option) any later version.
10
 
#
11
 
#    This program is distributed in the hope that it will be useful,
12
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
#    GNU General Public License for more details.
15
 
#
16
 
#    You should have received a copy of the GNU General Public License
17
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
#
19
 
##############################################################################
20
 
 
21
 
from osv import osv, fields
22
 
from datetime import date
23
 
from tools.translate import _
24
 
 
25
 
class payment_order(osv.osv):
26
 
    '''
27
 
    Attach export_clieop wizard to payment order and allow traceability
28
 
    '''
29
 
    _inherit = 'payment.order'
30
 
    def get_wizard(self, type):
31
 
        if type in ['CLIEOPPAY', 'CLIEOPINC', 'CLIEOPSAL']:
32
 
            return self._module, 'wizard_account_banking_export_clieop'
33
 
        return super(payment_order, self).get_wizard(type)
34
 
payment_order()
35
 
 
36
 
class clieop_export(osv.osv):
37
 
    '''ClieOp3 Export'''
38
 
    _name = 'banking.export.clieop'
39
 
    _description = __doc__
40
 
 
41
 
    _columns = {
42
 
        'payment_order_ids':
43
 
            fields.text('Payment Orders'),
44
 
        'testcode':
45
 
            fields.selection([('T', _('Yes')), ('P', _('No'))],
46
 
                             'Test Run', readonly=True),
47
 
        'daynumber':
48
 
            fields.integer('ClieOp Transaction nr of the Day', readonly=True),
49
 
        'duplicates':
50
 
            fields.integer('Number of Duplicates', readonly=True),
51
 
        'prefered_date':
52
 
            fields.date('Prefered Processing Date',readonly=True),
53
 
        'no_transactions':
54
 
            fields.integer('Number of Transactions', readonly=True),
55
 
        'check_no_accounts':
56
 
            fields.char('Check Number Accounts', size=5, readonly=True),
57
 
        'total_amount':
58
 
            fields.float('Total Amount', readonly=True),
59
 
        'identification':
60
 
            fields.char('Identification', size=6, readonly=True, select=True),
61
 
        'filetype':
62
 
            fields.selection([
63
 
                ('CREDBET', 'Payment Batch'),
64
 
                ('SALARIS', 'Salary Payment Batch'),
65
 
                ('INCASSO', 'Direct Debit Batch'),
66
 
                ], 'File Type', size=7, readonly=True, select=True),
67
 
        'date_generated':
68
 
            fields.datetime('Generation Date', readonly=True, select=True),
69
 
        'file':
70
 
            fields.binary('ClieOp File', readonly=True),
71
 
        'state':
72
 
            fields.selection([
73
 
                ('draft', 'Draft'),
74
 
                ('sent', 'Sent'),
75
 
                ('done', 'Reconciled'),
76
 
            ], 'State', readonly=True),
77
 
    }
78
 
    def _get_daynr(self, cursor, uid, ids, context):
79
 
        '''
80
 
        Return highest day number
81
 
        '''
82
 
        last = cursor.execute('SELECT max(daynumber) '
83
 
                              'FROM banking_export_clieop '
84
 
                              'WHERE date_generated = "%s"' % 
85
 
                              date.today().strftime('%Y-%m-%d')
86
 
                             ).fetchone()
87
 
        if last:
88
 
            return int(last) +1
89
 
        return 1
90
 
 
91
 
    _defaults = {
92
 
        'date_generated': lambda *a: date.today().strftime('%Y-%m-%d'),
93
 
        'duplicates': lambda *a: 1,
94
 
        'state': lambda *a: 'draft',
95
 
        'daynumber': _get_daynr,
96
 
    }
97
 
clieop_export()
98
 
 
99
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: