Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] l10n_es_partner: Añadido script para actualizar info bancos #90

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions l10n_es_partner/gen_src/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
##############################################################################
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ponle por favor extensión .rst para que GitHub lo reconozca, ahora que tenemos esa opción, y habrá que quitar la cabecera de la licencia.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He puesto la extensión .rst y quitado la cabecera.

#
# OpenERP, Open Source Management Solution
# Copyright (c) 2014 Factor Libre S.L (http://www.factorlibre.com)
# Ismael Calvo <ismael.calvo@factorlibre.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

Utilidad para generar el archivo de bancos apartir de la información del Banco
==============================================================================
de España
=========

NOTA: Necesita la librería python 'xlrd'

1. Descargar el excel de las 'Entidades con establecimiento' de la web del
Banco de España:
http://goo.gl/EPfcR5
2. Mover el archivo descargado 'REGBANESP_CONESTAB_A.XLS' a la carpeta gen_src
3. Ejecutar:
python gen_data_banks.py
4. Se generará un archivo data_banks.xml en la carpeta wizard que sustituirá el
anterior
79 changes: 79 additions & 0 deletions l10n_es_partner/gen_src/gen_data_banks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (c) 2014 Factor Libre S.L (http://www.factorlibre.com)
# Ismael Calvo <ismael.calvo@factorlibre.com>
# $Id$
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eliminar

#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from xlrd import open_workbook
import codecs

if __name__ == "__main__":
# Abre el archivo que contine la información de los bancos
book = False
try:
book = open_workbook('REGBANESP_CONESTAB_A.XLS')
except IOError:
print "Archivo REGBANESP_CONESTAB_A.XLS no encontrado."

if book:
sheet = book.sheet_by_index(0)

# Prepara el archivo resultante
output = codecs.open("../wizard/data_banks.xml", mode='w',
encoding='utf-8')
output.write("<?xml version='1.0' encoding='UTF-8'?>\n")
output.write("<openerp>\n")
output.write(" <data noupdate='1'>\n")

# Genera los nuevos registros de los bancos
for row_index in range(1, sheet.nrows):
row = sheet.row_values(row_index)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hay que pasar las líneas que sean de bancos ya no vigentes. Hay una columna que indica algo así como fecha de baja o similar que lo indica.

Copy link
Sponsor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pedro, el problema es que si partimos de datos de bancos antiguos, podemos tener un problema con las cuentas viejas, dado que si mantenemos la opción de que "reconozca" el SWIFT del banco viejo dará error en la remesa al rechazarlo el banco.

¿Lo quieres crear como inactivo? No entiendo muy bien el uso de esto, la verdad :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Es que hay bancos muy muy antiguos. Me sigue quedando la duda de si los BIC viejos siguen activos. También dijimos que hay bancos que ya empiezan a no admitir los números de cuenta viejos, por lo que no sé si tiene sentido mantener esos bancos viejos. De todas formas, como mínimo habrá que purgar aquellos que no tengan BIC en el fichero.

Copy link
Sponsor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El problema es que no se ha seguido un criterio común, hay bancos que dieron cuentas nuevas a sus clientes y otros que ha permitido continuar con las antiguas (como Banesto). Pero creemos ver un patrón en el fichero, dado que si tiene SWIFT informado parece que es que sigue vigente, aunque en la línea ponga que está de baja, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfecto, por lo menos podemos aplicar ese criterio de filtro.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He incluido solo los bancos que tienen BIC. Además relleno el campo bic que no sé por qué no lo puse.

name = "city_bank_" + row[40].lower().replace(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Llámalo res_bank_ algo mejor. Además, habría que buscar si hay alguna columna id más corta que el nombre. El BIC podría ser una buena opción.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Estoy viendo que para mantener la compatibilidad con la lista antigua, hay que dejar ese nombre corto, pero lo que tienes que hacer es sustituir los puntos y espacios por cadena vacía, no un _. Una "cagada" de la anterior exportación fue no sustituir también las comas, pero bueno, no parece que esté afectando.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corregido.

' ', '_').replace(u'\xf1', 'n')
street = row[7] + '. ' + row[8] + ', ' + row[9] + ' ' + row[10]
output.write(' <record id="%s" model="city.city">\n' % name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El modelo no es city.city, sino res.bank.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corregido.

output.write(' <field name="name">%s<field/>\n' % (
row[40]))
output.write(' <field name="lname">%s<field/>\n' % (
row[4]))
output.write(' <field name="code">%s<field/>\n' % (
row[1]))
output.write(' <field name="vat">%s<field/>\n' % (
row[6]))
output.write(' <field name="street">%s<field/>\n' % (
street))
output.write(' <field name="city">%s<field/>\n' % (
row[12]))
output.write(' <field name="zip">%s<field/>\n' % (
row[11]))
output.write(' <field name="phone">'
'%s<field/>\n' % row[16])
output.write(' <field name="fax">%s<field/>\n' % (
row[18]))
output.write(' <field eval="1" name="active"/>\n')
output.write(' <field name="state"'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No se debe hardcodear la provincia. Tendrás que poner una tabla de equivalencia.

' ref="l10n_es_topynyms.ES28"/>\n')
output.write(' <field name="country_id"'
' ref="base.es"/>\n')
output.write(' </record>\n')
output.write(" </data>\n")
output.write("</openerp>\n")

output.close()
print "data_banks.xml generado correctamente."