1
# -*- encoding: utf-8 -*-
2
##############################################################################
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>
12
# Corregido para instalación TinyERP estándar 4.2.0: Zikzakmedia S.L. 2008
13
# Jordi Esteve <jesteve@zikzakmedia.com>
15
# Añadidas cuentas de remesas y tipos de pago. 2008
16
# Pablo Rocandio <salbet@gmail.com>
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>
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.
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.
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/>.
34
##############################################################################
36
from datetime import datetime
37
from tools.translate import _
38
from converter import *
43
def _cabecera_fichero_32(self):
46
texto += datetime.today().strftime('%d%m%y')
47
texto += digits_only( self.order.reference )[-4:]
49
texto += digits_only( self.order.mode.bank_id.acc_number )[:8]
56
def _cabecera_remesa_32(self, cr, context):
62
texto += datetime.today().strftime('%d%m%y')
67
texto += convert(cr, self.order.mode.cedente, 15, context) # TODO: Identificador del cedente. Qué es?
68
#texto += '1' # Identificativo de efectos truncados
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 )
79
def _registro_individual_i_32(self, cr, recibo, context):
84
texto += convert(cr, self.num_recibos+1, 15, context)
85
texto += datetime.today().strftime('%d%m%y')
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)
95
texto += convert(cr, self.order.mode.bank_id.city, 20, context)
100
texto += convert(cr, abs(recibo['amount']), 9, context)
102
texto += datetime.strptime( recibo['ml_maturity_date'], '%Y-%m-%d').strftime('%d%m%y')
103
texto += ' '*(6+6+1+4+16)
107
def _registro_individual_ii_32(self, cr, recibo, context):
108
# A: Identificacion de la operacion
112
# B: Datos del efecto
113
texto += convert(cr, self.num_recibos+1, 15, context)
115
texto += '2' # Recibo
118
# 0= Sin gastos, 1=Con gastos, 9=Orden expresa de protesto notarial
121
# C: Datos del efecto
122
ccc = recibo['bank_id'] and recibo['bank_id'].acc_number or ''
124
texto += ccc[:20].zfill(20)
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)
135
def _registro_individual_iii_32(self, cr, recibo, context):
136
# A: Identificacion de la operacion
140
# B: Datos del efecto
141
texto += convert(cr, self.num_recibos+1, 15, context)
143
addresses = self.pool.get('res.partner').address_get(self.cr, self.uid, [recibo['partner_id'].id] )
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 )
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)
160
def _registro_fin_remesa_32(self, cr, context):
161
# A: Identificación de la operación
165
# B: Control de duplicidades
166
texto += datetime.today().strftime('%d%m%y')
173
# D: Acumuladores de importe
175
texto += convert( cr, -self.order.total, 10, context )
176
texto += ' '*(10+6+7+6+6+6)
178
# E: Controles de lectura de fichero
180
texto += convert(cr, (self.num_recibos*3) + 2, 7, context)
181
texto += convert(cr, self.num_recibos, 6, context)
186
def _registro_fin_fichero_32(self, cr, context):
187
# A: Identificación de la operación
197
# D: Acumuladores de importes
199
texto += convert( cr, -self.order.total, 10, context )
200
texto += ' '*(10+6+7+6+6+6)
202
# E: Controles de lectura del fichero
204
texto += convert(cr, (self.num_recibos*3) + 3, 7, context)
205
texto += convert(cr, self.num_recibos, 6, context)
210
def create_file(self, pool, cr, uid, order, lines, context):
215
self.context = context
219
self.num_lineas_opc = 0
221
txt_remesa += self._cabecera_fichero_32()
222
txt_remesa += self._cabecera_remesa_32(cr, context)
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)
233
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: