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

« back to all changes in this revision

Viewing changes to l10n_es_extras/l10n_ES_remesas/wizard/csb_32.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
 
#    $Id$
11
 
#
12
 
# Corregido para instalación TinyERP estándar 4.2.0: Zikzakmedia S.L. 2008
13
 
#   Jordi Esteve <jesteve@zikzakmedia.com>
14
 
#
15
 
# Añadidas cuentas de remesas y tipos de pago. 2008
16
 
#    Pablo Rocandio <salbet@gmail.com>
17
 
#
18
 
# Rehecho de nuevo para instalación OpenERP 5.0.0 sobre account_payment_extension: Zikzakmedia S.L. 2009
19
 
#   Jordi Esteve <jesteve@zikzakmedia.com>
20
 
#
21
 
#    This program is free software: you can redistribute it and/or modify
22
 
#    it under the terms of the GNU General Public License as published by
23
 
#    the Free Software Foundation, either version 3 of the License, or
24
 
#    (at your option) any later version.
25
 
#
26
 
#    This program is distributed in the hope that it will be useful,
27
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
 
#    GNU General Public License for more details.
30
 
#
31
 
#    You should have received a copy of the GNU General Public License
32
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
33
 
#
34
 
##############################################################################
35
 
 
36
 
from datetime import datetime
37
 
from tools.translate import _
38
 
from converter import *
39
 
 
40
 
 
41
 
class csb_32:
42
 
 
43
 
    def _cabecera_fichero_32(self):
44
 
        texto = '0265'
45
 
        texto += '  '
46
 
        texto += datetime.today().strftime('%d%m%y')
47
 
        texto += digits_only( self.order.reference )[-4:]
48
 
        texto += ' '*35
49
 
        texto += digits_only( self.order.mode.bank_id.acc_number )[:8]
50
 
        texto += ' '*6
51
 
        texto += ' '*61
52
 
        texto += ' '*24
53
 
        texto += '\n'
54
 
        return texto
55
 
 
56
 
    def _cabecera_remesa_32(self, cr, context):
57
 
        # A: 
58
 
        texto = '1165'
59
 
        texto += '  '
60
 
 
61
 
        # B
62
 
        texto += datetime.today().strftime('%d%m%y')
63
 
        texto += '0001'
64
 
        texto += ' '*12
65
 
 
66
 
        # C
67
 
        texto += convert(cr, self.order.mode.cedente, 15, context) # TODO: Identificador del cedente. Qué es?
68
 
        #texto += '1' # Identificativo de efectos truncados
69
 
        #texto += ' '*21
70
 
 
71
 
        # D
72
 
        texto += digits_only( self.order.mode.bank_id.acc_number )
73
 
        texto += digits_only( self.order.mode.bank_id.acc_number )
74
 
        texto += digits_only( self.order.mode.bank_id.acc_number )
75
 
        texto += ' '*24
76
 
        texto += '\n'
77
 
        return texto
78
 
 
79
 
    def _registro_individual_i_32(self, cr, recibo, context):
80
 
        # A
81
 
        texto = '2565'
82
 
        texto += '  '
83
 
        # B
84
 
        texto += convert(cr, self.num_recibos+1, 15, context)
85
 
        texto += datetime.today().strftime('%d%m%y')
86
 
        texto += '0001'
87
 
 
88
 
        # C
89
 
        state = self.order.mode.bank_id.state_id and self.order.mode.bank_id.state_id.code or False
90
 
        texto += convert(cr, state, 2, context)
91
 
        texto += ' '*7
92
 
        texto += '  '
93
 
 
94
 
        # D
95
 
        texto += convert(cr, self.order.mode.bank_id.city, 20, context)
96
 
        texto += ' '
97
 
 
98
 
        # E
99
 
        texto += ' '*24
100
 
        texto += convert(cr, abs(recibo['amount']), 9, context)
101
 
        texto += ' '*15
102
 
        texto += datetime.strptime( recibo['ml_maturity_date'], '%Y-%m-%d').strftime('%d%m%y') 
103
 
        texto += ' '*(6+6+1+4+16)
104
 
        texto += '\n'
105
 
        return texto
106
 
 
107
 
    def _registro_individual_ii_32(self, cr, recibo, context):
108
 
        # A: Identificacion de la operacion
109
 
        texto = '2665'
110
 
        texto += '  '
111
 
 
112
 
        # B: Datos del efecto
113
 
        texto += convert(cr, self.num_recibos+1, 15, context)
114
 
        texto += '  '
115
 
        texto += '2' # Recibo
116
 
        texto += '000000'
117
 
        texto += '1' 
118
 
        # 0= Sin gastos, 1=Con gastos, 9=Orden expresa de protesto notarial
119
 
        texto += '0' 
120
 
 
121
 
        # C: Datos del efecto
122
 
        ccc = recibo['bank_id'] and recibo['bank_id'].acc_number or ''
123
 
        if ccc:
124
 
            texto += ccc[:20].zfill(20)
125
 
        else:
126
 
            texto += ' '*20
127
 
 
128
 
        # D: Datos del efecto
129
 
        texto += convert(cr, self.order.mode.partner_id.name, 34, context)
130
 
        texto += convert(cr, recibo['partner_id'].name, 34, context)
131
 
        texto += ' '*30
132
 
        texto += '\n'
133
 
        return texto
134
 
 
135
 
    def _registro_individual_iii_32(self, cr, recibo, context):
136
 
        # A: Identificacion de la operacion
137
 
        texto = '2765'
138
 
        texto += '  '
139
 
        
140
 
        # B: Datos del efecto
141
 
        texto += convert(cr, self.num_recibos+1, 15, context)
142
 
        texto += '  '
143
 
        addresses = self.pool.get('res.partner').address_get(self.cr, self.uid, [recibo['partner_id'].id] )
144
 
        #if not addresses:
145
 
        #    print "NO ADDRESSES"
146
 
        address = self.pool.get('res.partner.address').browse(self.cr, self.uid, addresses['default'], self.context)
147
 
        texto += convert( cr, address.street, 34, context )
148
 
        texto += convert( cr, address.zip, 5, context )
149
 
        texto += convert( cr, address.city, 20, context )
150
 
        texto += convert( cr, address.state_id and address.state_id.code or False, 2, context )
151
 
        texto += '0'*7
152
 
 
153
 
        # C: Datos del efecto
154
 
        vat = recibo['partner_id'].vat and recibo['partner_id'].vat[2:] or False
155
 
        texto += convert(cr, vat, 9, context)
156
 
        texto += ' '*50
157
 
        texto += '\n'
158
 
        return texto
159
 
 
160
 
    def _registro_fin_remesa_32(self, cr, context):
161
 
        # A: Identificación de la operación
162
 
        texto = '7165'
163
 
        texto += '  '
164
 
 
165
 
        # B: Control de duplicidades
166
 
        texto += datetime.today().strftime('%d%m%y')
167
 
        texto += '0001'
168
 
        texto += ' '*(6+6)
169
 
 
170
 
        # C: Libre
171
 
        texto += ' '*37
172
 
 
173
 
        # D: Acumuladores de importe
174
 
        texto += ' '*10
175
 
        texto += convert( cr, -self.order.total, 10, context )
176
 
        texto += ' '*(10+6+7+6+6+6)
177
 
 
178
 
        # E: Controles de lectura de fichero
179
 
        texto += ' '*5
180
 
        texto += convert(cr, (self.num_recibos*3) + 2, 7, context)
181
 
        texto += convert(cr, self.num_recibos, 6, context)
182
 
        texto += ' '*6
183
 
        texto += '\n'
184
 
        return texto
185
 
 
186
 
    def _registro_fin_fichero_32(self, cr, context):
187
 
        # A: Identificación de la operación
188
 
        texto = '9865'
189
 
        texto += '  '
190
 
    
191
 
        # B: Libre
192
 
        texto += ' '*22
193
 
 
194
 
        # C: Libre
195
 
        texto += ' '*37
196
 
 
197
 
        # D: Acumuladores de importes
198
 
        texto += ' '*10
199
 
        texto += convert( cr, -self.order.total, 10, context )
200
 
        texto += ' '*(10+6+7+6+6+6)
201
 
 
202
 
        # E: Controles de lectura del fichero
203
 
        texto += '00001'
204
 
        texto += convert(cr, (self.num_recibos*3) + 3, 7, context)
205
 
        texto += convert(cr, self.num_recibos, 6, context)
206
 
        texto += ' '*6
207
 
        texto += '\n'
208
 
        return texto
209
 
 
210
 
    def create_file(self, pool, cr, uid, order, lines, context):
211
 
        self.pool = pool
212
 
        self.cr = cr
213
 
        self.uid = uid
214
 
        self.order = order
215
 
        self.context = context
216
 
 
217
 
        txt_remesa = ''
218
 
        self.num_recibos = 0
219
 
        self.num_lineas_opc = 0
220
 
 
221
 
        txt_remesa += self._cabecera_fichero_32()
222
 
        txt_remesa += self._cabecera_remesa_32(cr, context)
223
 
        for recibo in lines:
224
 
            txt_remesa += self._registro_individual_i_32(cr, recibo, context)
225
 
            txt_remesa += self._registro_individual_ii_32(cr, recibo, context)
226
 
            txt_remesa += self._registro_individual_iii_32(cr, recibo, context)
227
 
            self.num_recibos = self.num_recibos + 1
228
 
        txt_remesa += self._registro_fin_remesa_32(cr, context)
229
 
        txt_remesa += self._registro_fin_fichero_32(cr, context)
230
 
        return txt_remesa
231
 
 
232
 
 
233
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: