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 1 commit
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
32 changes: 32 additions & 0 deletions l10n_es_partner/gen_src/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
##############################################################################
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) All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

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

Ismael, puedes quitar el "All Rights Reserved". Es una denominación anticuada, sin efecto "mercantil", y que además, sobrepasa los 80 caracteres del PEP8.

# 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.

Esta línea puedes quitarla también, ya que su objetivo era para un generador de plantillas que sustituyera esa marca por un texto, pero no es el caso.

#
# 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
========================================================================================

1. Descargar el excel de las 'Entidades con establecimiento' de la web del
Banco de España:
http://www.bde.es/bde/es/secciones/servicios/Particulares_y_e/Registros_de_Ent/Datos_actuales/Registros_ofici_c6e37f3710fd821.html
Copy link
Member

Choose a reason for hiding this comment

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

Esto sobrepasa también los 80 caracteres del PEP8.

Copy link
Member Author

Choose a reason for hiding this comment

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

¿Cómo puedo dividir la url?

Copy link
Member

Choose a reason for hiding this comment

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

Lo que yo suelo hacer es poner la URL en un acortador (goo.gl, T.co, etc), y pegar esa URL en lugar de la completa.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok. Gracias!

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
Copy link
Member

Choose a reason for hiding this comment

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

Debes también indicar que se necesita la librería python xlrd.

Copy link
Member Author

Choose a reason for hiding this comment

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

¿Con poner:
NOTA: Necesita la librería 'xlrd'
valdría?

Copy link
Member

Choose a reason for hiding this comment

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

Sí, me parece bien. Pon librería Python, eso sí

65 changes: 65 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,65 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (c) 2014 Factor Libre S.L (http://www.factorlibre.com) All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

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

Quitar "All Rights Reserved"

# 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 = row[40].lower().replace(' ', '_').replace(u'\xf1', 'n')
output.write(' <record id="city_bank_%s" model="city.city">\n' %name)
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' %(row[7]+'. '+row[8]+', '+row[9]+' '+row[10]))
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" 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."