Compare commits

..

2 Commits

Author SHA1 Message Date
daf57066db Quitar un 'None' 2026-03-25 18:41:32 +01:00
fbd294098d Convertir caracteres no válidos a ISO8859_1 al leer desde FactuGES 2026-03-25 18:41:20 +01:00
4 changed files with 6 additions and 4 deletions

View File

@ -17,7 +17,7 @@ def get_factuges_connection(config) -> fdb.Connection:
database=config['FACTUGES_DATABASE'],
user=config['FACTUGES_USER'],
password=config['FACTUGES_PASSWORD'],
charset='UTF8',
charset='ISO8859_1'
)
logger.info(
"Conexión a la base de datos FactuGES establecida: %s with database:%s - using user:%s",

View File

@ -17,6 +17,7 @@ from app.utils import (
normalizar_telefono_con_plus,
normalizar_url_para_insert,
tax_fraction_from_code,
text_converter,
unscale_to_decimal,
)
@ -46,7 +47,7 @@ def normalize_customer_fields(fd: Dict[str, Any]) -> Dict[str, Any]:
"is_company": config["CTE_IS_COMPANY"],
"tin": clean_tin(str(fd.get("NIF_CIF"))),
"name": fd.get("NOMBRE"),
"street": fd.get("CALLE"),
"street": text_converter(fd.get("CALLE")),
"city": fd.get("POBLACION"),
"province": fd.get("PROVINCIA"),
"postal_code": fd.get("CODIGO_POSTAL"),

View File

@ -73,7 +73,7 @@ def insert_item_and_taxes(fields) -> Dict[str, Any]:
"item_discount_amount_value": str(none_to_empty(fields.get("item_discount_amount_value"))),
"global_discount_percentage_value": str(none_to_empty(fields.get("global_discount_percentage_value"))),
"global_discount_amount_value": str(none_to_empty(fields.get("global_discount_amount_value"))),
"total_discount_amount_value": str(fields.get("total_discount_amount_value")),
"total_discount_amount_value": str(none_to_empty(fields.get("total_discount_amount_value"))),
"taxable_amount_value": str(fields.get("taxable_amount_value")),
"total_amount_value": str(fields.get("total_amount_value")),
"iva_code": str(fields.get("iva_code")),

View File

@ -1,4 +1,5 @@
import re
from app.config import logger
@ -20,7 +21,7 @@ def text_converter(texto, charset_destino='ISO8859_1', longitud_maxima=None):
try:
# Convertir el texto al charset especificado
texto_convertido = texto.encode(
charset_destino, 'ignore').decode(charset_destino)
charset_destino, 'ignore').decode("cp1252")
# Si se especifica una longitud máxima, truncar el texto
if longitud_maxima and len(texto_convertido) > longitud_maxima: