~openerp-spain-team/openerp-spain/6.0-git

« back to all changes in this revision

Viewing changes to l10n_es_remesas/wizard/csb_34.py

  • Committer: Borja L.S.
  • Date: 2010-10-18 10:04:25 UTC
  • Revision ID: git-v1:271c47a993616dbba60585d48b8b98d603199d93
[REF] *: Refactorización para portar a 6.0 - Paso 1.

- Se han renombrado los módulos para usar la nomenclatura propuesta
  por OpenERP: l10n_es para el módulo base de localización (plan de 
  cuentas), l10n_es_* para el resto de módulos.

- Se eliminan los módulos extra_addons/* que deberían moverse a 
  los extra-addons genéricos (no son específicos de España).

- Se renombran los __terp__.py por __openerp__.py

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
#    Copyright (c) 2006 ACYSOS S.L. (http://acysos.com) All Rights Reserved.
 
6
#                       Pedro Tarrafeta <pedro@acysos.com>
 
7
#    Copyright (c) 2008 Pablo Rocandio. All Rights Reserved.
 
8
#    Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
 
9
#                       Jordi Esteve <jesteve@zikzakmedia.com>
 
10
#    Copyright (c) 2009 NaN (http://www.nan-tic.com) All Rights Reserved.
 
11
#                       Albert Cervera i Areny <albert@nan-tic.com>
 
12
#    $Id$
 
13
#
 
14
# Corregido para instalación TinyERP estándar 4.2.0: Zikzakmedia S.L. 2008
 
15
#   Jordi Esteve <jesteve@zikzakmedia.com>
 
16
#
 
17
# Añadidas cuentas de remesas y tipos de pago. 2008
 
18
#    Pablo Rocandio <salbet@gmail.com>
 
19
#
 
20
# Rehecho de nuevo para instalación OpenERP 5.0.0 sobre account_payment_extension: Zikzakmedia S.L. 2009
 
21
#   Jordi Esteve <jesteve@zikzakmedia.com>
 
22
#
 
23
#    This program is free software: you can redistribute it and/or modify
 
24
#    it under the terms of the GNU General Public License as published by
 
25
#    the Free Software Foundation, either version 3 of the License, or
 
26
#    (at your option) any later version.
 
27
#
 
28
#    This program is distributed in the hope that it will be useful,
 
29
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
30
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
31
#    GNU General Public License for more details.
 
32
#
 
33
#    You should have received a copy of the GNU General Public License
 
34
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
35
#
 
36
##############################################################################
 
37
 
 
38
from datetime import datetime
 
39
from tools.translate import _
 
40
from converter import *
 
41
 
 
42
class csb_34:
 
43
    def _start_34(self, cr, context):
 
44
        return convert(cr, self.order.mode.bank_id.partner_id.vat[2:] + self.order.mode.sufijo, 12, context)
 
45
 
 
46
    def _cabecera_ordenante_34(self, cr, uid, context):
 
47
        today = datetime.today().strftime('%d%m%y')
 
48
 
 
49
        text = ''
 
50
 
 
51
        # Primer tipo
 
52
        text += '0362'
 
53
        text += self._start_34(cr, context)
 
54
        text += 12*' '
 
55
        text += '001'
 
56
        text += today
 
57
        if self.order.date_planned:
 
58
            planned = datetime.strptime(self.order.date_planned, '%Y-%m-%d')
 
59
            text += planned.strftime('%d%m%y')
 
60
        else:
 
61
            text += today
 
62
        #text += self.convert(self.order.mode.nombre, 40)
 
63
        text += convert_bank_account(cr, self.order.mode.bank_id.acc_number, self.order.mode.partner_id.name, context)
 
64
        text += '0'
 
65
        text += 8*' '
 
66
        text += '\n'
 
67
 
 
68
        # Segundo Tipo 
 
69
        text += '0362'
 
70
        text += self._start_34(cr, context)
 
71
        text += 12*' '
 
72
        text += '002'
 
73
        text += convert(cr, self.order.mode.bank_id.partner_id.name, 36, context)
 
74
        text += 5*' '
 
75
        text += '\n'
 
76
 
 
77
        # Tercer Tipo 
 
78
        text += '0362'
 
79
        text += self._start_34(cr, context)
 
80
        text += 12*' '
 
81
        text += '003'
 
82
        # Direccion
 
83
        address_id = self.pool.get('res.partner').address_get(cr, uid, [self.order.mode.bank_id.partner_id.id], ['invoice'])['invoice']
 
84
        if not address_id:
 
85
            raise Log( _('User error:\n\nCompany %s has no invoicing address.') % address_id )
 
86
 
 
87
        street = self.pool.get('res.partner.address').read(cr, uid, [address_id], ['street'], context)[0]['street']
 
88
        text += convert(cr, street, 36, context)
 
89
        text += 5*' '
 
90
        text += '\n'
 
91
 
 
92
        # Cuarto Tipo 
 
93
        text += '0362'
 
94
        text += self._start_34(cr, context)
 
95
        text += 12*' '
 
96
        text += '004'
 
97
        text += convert(cr, self.order.mode.bank_id.street, 36, context)
 
98
        text += 5*' '
 
99
        text += '\n'
 
100
        return text
 
101
 
 
102
    def _cabecera_nacionales_34(self, cr, uid, context):
 
103
        text = '0456'
 
104
        text += self._start_34(cr, context)
 
105
        text += 12*' '
 
106
        text += 3*' '
 
107
        text += 41*' '
 
108
        text += '\n'
 
109
        return text
 
110
 
 
111
    def _detalle_nacionales_34(self, cr, uid, recibo, context):
 
112
        # Primer Registro
 
113
        text = ''
 
114
        text += '0656'
 
115
        text += self._start_34(cr, context)
 
116
        text += convert(cr, recibo['partner_id'].vat, 12, context)
 
117
        text += '010'
 
118
        text += convert(cr, recibo['amount'], 12, context)
 
119
        #text += convert_bank_account(cr, recibo['bank_id'].acc_number, recibo['partner_id'].name, context)
 
120
        ccc = recibo['bank_id'] and recibo['bank_id'].acc_number or ''
 
121
        ccc = digits_only(ccc)
 
122
        text += ccc[:20].zfill(20)
 
123
        text += '1'
 
124
        text += '9' # Otros conceptos (ni Nomina ni Pension)
 
125
        text += '1'
 
126
        text += 6*' '
 
127
        text += '\n'
 
128
 
 
129
        # Segundo Registro
 
130
        text += '0656'
 
131
        text += self._start_34(cr, context)
 
132
        text += convert(cr, recibo['partner_id'].vat, 12, context)
 
133
        text += '011'
 
134
        text += convert(cr, recibo['partner_id'].name, 36, context)
 
135
        text += 5*' '
 
136
        text += '\n'
 
137
        return text
 
138
 
 
139
    def _totales_nacionales_34(self, cr, uid, context):
 
140
        text = '0856'
 
141
        text += self._start_34(cr, context)
 
142
        text += 12*' '
 
143
        text += 3*' '
 
144
        text += convert(cr, self.order.total, 12, context)
 
145
        text += convert(cr, self.payment_line_count, 8, context)
 
146
        text += convert(cr, 1 + (self.payment_line_count * 2) + 1, 10, context)
 
147
        text += 6*' '
 
148
        text += 5*' '
 
149
        text += '\n'
 
150
        return text
 
151
 
 
152
    def _total_general_34(self, cr, uid, context):
 
153
        text = '0962'
 
154
        text += self._start_34(cr, context)
 
155
        text += 12*' '
 
156
        text += 3*' '
 
157
        text += convert(cr, self.order.total, 12, context)
 
158
        text += convert(cr, self.payment_line_count, 8, context)
 
159
        text += convert(cr, 4 + 1 + (self.payment_line_count * 2 ) + 1 + 1, 10, context)
 
160
        text += 6*' '
 
161
        text += 5*' '
 
162
        text += '\n'
 
163
        return text
 
164
 
 
165
    def create_file(self, pool, cr, uid, order, lines, context):
 
166
        self.pool = pool
 
167
        self.order = order
 
168
        self.context = context
 
169
 
 
170
        self.payment_line_count = 0
 
171
        self.record_count = 0
 
172
 
 
173
        file = ''
 
174
        file += self._cabecera_ordenante_34(cr, uid, context)
 
175
        file += self._cabecera_nacionales_34(cr, uid, context)
 
176
        for recibo in lines:
 
177
            file += self._detalle_nacionales_34(cr, uid, recibo, context)
 
178
            self.payment_line_count += 1
 
179
            self.record_count += 2
 
180
        file += self._totales_nacionales_34(cr, uid, context)
 
181
        self.record_count += 1
 
182
        file += self._total_general_34(cr, uid, context)
 
183
        return file
 
184
 
 
185
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: