Compare commits
2 Commits
ef315b1479
...
daf57066db
| Author | SHA1 | Date | |
|---|---|---|---|
| daf57066db | |||
| fbd294098d |
@ -17,7 +17,7 @@ def get_factuges_connection(config) -> fdb.Connection:
|
|||||||
database=config['FACTUGES_DATABASE'],
|
database=config['FACTUGES_DATABASE'],
|
||||||
user=config['FACTUGES_USER'],
|
user=config['FACTUGES_USER'],
|
||||||
password=config['FACTUGES_PASSWORD'],
|
password=config['FACTUGES_PASSWORD'],
|
||||||
charset='UTF8',
|
charset='ISO8859_1'
|
||||||
)
|
)
|
||||||
logger.info(
|
logger.info(
|
||||||
"Conexión a la base de datos FactuGES establecida: %s with database:%s - using user:%s",
|
"Conexión a la base de datos FactuGES establecida: %s with database:%s - using user:%s",
|
||||||
|
|||||||
@ -17,6 +17,7 @@ from app.utils import (
|
|||||||
normalizar_telefono_con_plus,
|
normalizar_telefono_con_plus,
|
||||||
normalizar_url_para_insert,
|
normalizar_url_para_insert,
|
||||||
tax_fraction_from_code,
|
tax_fraction_from_code,
|
||||||
|
text_converter,
|
||||||
unscale_to_decimal,
|
unscale_to_decimal,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ def normalize_customer_fields(fd: Dict[str, Any]) -> Dict[str, Any]:
|
|||||||
"is_company": config["CTE_IS_COMPANY"],
|
"is_company": config["CTE_IS_COMPANY"],
|
||||||
"tin": clean_tin(str(fd.get("NIF_CIF"))),
|
"tin": clean_tin(str(fd.get("NIF_CIF"))),
|
||||||
"name": fd.get("NOMBRE"),
|
"name": fd.get("NOMBRE"),
|
||||||
"street": fd.get("CALLE"),
|
"street": text_converter(fd.get("CALLE")),
|
||||||
"city": fd.get("POBLACION"),
|
"city": fd.get("POBLACION"),
|
||||||
"province": fd.get("PROVINCIA"),
|
"province": fd.get("PROVINCIA"),
|
||||||
"postal_code": fd.get("CODIGO_POSTAL"),
|
"postal_code": fd.get("CODIGO_POSTAL"),
|
||||||
|
|||||||
@ -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"))),
|
"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_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"))),
|
"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")),
|
"taxable_amount_value": str(fields.get("taxable_amount_value")),
|
||||||
"total_amount_value": str(fields.get("total_amount_value")),
|
"total_amount_value": str(fields.get("total_amount_value")),
|
||||||
"iva_code": str(fields.get("iva_code")),
|
"iva_code": str(fields.get("iva_code")),
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from app.config import logger
|
from app.config import logger
|
||||||
|
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ def text_converter(texto, charset_destino='ISO8859_1', longitud_maxima=None):
|
|||||||
try:
|
try:
|
||||||
# Convertir el texto al charset especificado
|
# Convertir el texto al charset especificado
|
||||||
texto_convertido = texto.encode(
|
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
|
# Si se especifica una longitud máxima, truncar el texto
|
||||||
if longitud_maxima and len(texto_convertido) > longitud_maxima:
|
if longitud_maxima and len(texto_convertido) > longitud_maxima:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user