From d53699a2422b5e8a253dc4026f919eb6a7424313 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 3 Aug 2026 14:13:37 +0200 Subject: [PATCH] =?UTF-8?q?Adaptaci=C3=B3n=20a=20v0.10.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/settings.py | 6 ++++++ app/db/normalizations.py | 9 +++++++-- app/db/sync_invoices_factuges.py | 6 +++--- app/db/sync_invoices_factuges_REST_API.py | 2 +- app/utils/payloads_factuges.py | 11 ++++++++++- enviroment/dev.env | 7 +++++++ scripts/stack.rodax.env | 1 + setup.cfg | 2 +- 8 files changed, 36 insertions(+), 8 deletions(-) diff --git a/app/config/settings.py b/app/config/settings.py index 73d8026..b0fb61f 100644 --- a/app/config/settings.py +++ b/app/config/settings.py @@ -75,6 +75,12 @@ def load_config() -> Dict[str, Any]: "CTE_IS_COMPANY": _required("CTE_IS_COMPANY"), "CTE_SYNC_RESULT_OK": _required("CTE_SYNC_RESULT_OK"), "CTE_SYNC_RESULT_FAIL": _required("CTE_SYNC_RESULT_FAIL"), + "CTE_TAX_MODE": _required("CTE_TAX_MODE"), # single + "CTE_DEFAULT_IVA_CODE": _required("CTE_DEFAULT_IVA_CODE"), + "CTE_USES_EQUIVALENCE_SURCHARGE": _required("CTE_USES_EQUIVALENCE_SURCHARGE"), + "CTE_DEFAULT_REC_CODE": os.getenv("CTE_DEFAULT_REC_CODE"), + "CTE_USES_RETENTION": _required("CTE_USES_RETENTION"), + "CTE_DEFAULT_RETENTION_CODE": os.getenv("CTE_DEFAULT_RETENTION_CODE"), # Verifactu (requeridas) "VERIFACTU_BASE_URL": _required("VERIFACTU_BASE_URL"), diff --git a/app/db/normalizations.py b/app/db/normalizations.py index b9f4c7f..673b56c 100644 --- a/app/db/normalizations.py +++ b/app/db/normalizations.py @@ -97,14 +97,19 @@ def normalize_header_invoice_fields(fd: Dict[str, Any]) -> Dict[str, Any]: "is_proforma": config["CTE_IS_PROFORMA"], "status": config["CTE_STATUS_INVOICE"], - # + "tax_mode": config['CTE_TAX_MODE'], + "default_iva_code": config['CTE_DEFAULT_IVA_CODE'], + "uses_equivalence_surcharge": config['CTE_USES_EQUIVALENCE_SURCHARGE'], + "default_rec_code": config['CTE_DEFAULT_REC_CODE'], + "uses_retention": config['CTE_USES_RETENTION'], + "default_retention_code": config['CTE_DEFAULT_RETENTION_CODE'], "series": config['CTE_SERIE'], "factuges_id": int(fd['ID_FACTURA']), "reference": fd['REFERENCIA'], # Se asigna la fecha de la subida que es cuando se va a presentar a la AEAT - "invoice_date": date.today().strftime("%Y-%m-%d"), + "proforma_date": date.today().strftime("%Y-%m-%d"), "operation_date": str(fd['FECHA_FACTURA']), "description": textwrap.shorten( f"{str(fd['REFERENCIA'])} - {str(fd.get('NOMBRE')) or ''}", width=50, placeholder="…"), diff --git a/app/db/sync_invoices_factuges.py b/app/db/sync_invoices_factuges.py index cd732b0..8aaadd1 100644 --- a/app/db/sync_invoices_factuges.py +++ b/app/db/sync_invoices_factuges.py @@ -272,7 +272,7 @@ def insert_invoice_header( "Inserting invoice %s %s %s %s %s", invoice_id, hif.get("reference"), - hif.get("invoice_date"), + hif.get("proforma_date"), hif.get("operation_date"), config["CTE_STATUS_INVOICE"], ) @@ -285,7 +285,7 @@ def insert_invoice_header( hif.get("is_proforma"), hif.get("series"), hif.get("reference"), - hif.get("invoice_date"), + hif.get("proforma_date"), hif.get("operation_date"), hif.get("description"), hif.get("notes"), @@ -326,7 +326,7 @@ def insert_verifactu_record( "Inserting verifactu record %s %s %s", id, hif.get("reference"), - hif.get("invoice_date"), + hif.get("proforma_date"), ) cur.execute( # type: ignore SQL.INSERT_VERIFACTU_RECORD, diff --git a/app/db/sync_invoices_factuges_REST_API.py b/app/db/sync_invoices_factuges_REST_API.py index 5d5ffe2..e1f7dc3 100644 --- a/app/db/sync_invoices_factuges_REST_API.py +++ b/app/db/sync_invoices_factuges_REST_API.py @@ -258,7 +258,7 @@ def insert_verifactu_record( "Inserting verifactu record %s %s %s", id, hif.get("reference"), - hif.get("invoice_date"), + hif.get("proforma_date"), ) cur.execute( # type: ignore SQL.INSERT_VERIFACTU_RECORD, diff --git a/app/utils/payloads_factuges.py b/app/utils/payloads_factuges.py index 25f09de..05955bf 100644 --- a/app/utils/payloads_factuges.py +++ b/app/utils/payloads_factuges.py @@ -22,7 +22,7 @@ def create_invoice_header( "series": hif.get("series"), "reference": hif.get("reference"), "description": hif.get("description"), - "invoice_date": hif.get("invoice_date"), + "proforma_date": hif.get("proforma_date"), "operation_date": hif.get("operation_date"), "notes": none_to_empty(hif.get("notes")), "language_code": cf.get("language_code"), @@ -36,6 +36,15 @@ def create_invoice_header( "payment_method_id": str(payment_method_id), "payment_method_description": payment_method_description, + "tax_config": { + "tax_mode": hif.get("tax_mode"), + "default_iva_code": hif.get("default_iva_code"), + "uses_equivalence_surcharge": hif.get("uses_equivalence_surcharge"), + "default_rec_code": hif.get("default_rec_code"), + "uses_retention": hif.get("uses_retention"), + "default_retention_code": hif.get("default_retention_code"), + }, + "customer": { "is_company": cf["is_company"], "name": cf["name"], diff --git a/enviroment/dev.env b/enviroment/dev.env index 0002ed5..26a6744 100644 --- a/enviroment/dev.env +++ b/enviroment/dev.env @@ -22,7 +22,14 @@ FACTUGES_USER = sysdba FACTUGES_PASSWORD = masterkey CTE_COMPANY_ID = '5e4dc5b3-96b9-4968-9490-14bd032fec5f' VERIFACTU_API_KEY = vf_test_ei8WYAvEq5dhSdEyQVjgCS8NZaNpEK2BljSHSUXf+Y0= + CTE_SERIE = 'F25/' +CTE_TAX_MODE = 'single' +CTE_DEFAULT_IVA_CODE = "iva_21" +CTE_USES_EQUIVALENCE_SURCHARGE = 0 +CTE_USES_RETENTION = 0 + + #DESARROLLO ACANA #FACTUGES_HOST = 192.168.0.109 diff --git a/scripts/stack.rodax.env b/scripts/stack.rodax.env index aacf262..80cf1a0 100644 --- a/scripts/stack.rodax.env +++ b/scripts/stack.rodax.env @@ -24,6 +24,7 @@ CTE_STATUS_VERIFACTU = 'Pendiente' CTE_LANGUAGE_CODE = 'es' CTE_COUNTRY_CODE = 'es' CTE_IS_COMPANY = 1 +CTE_TAX_MODE = 'single' CTE_SYNC_RESULT_OK = 1 CTE_SYNC_RESULT_FAIL = 2 diff --git a/setup.cfg b/setup.cfg index 38ed8d1..d0f5705 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = factuges-sync -version = 0.3.0 +version = 0.3.1 description = ETL job to sync data from legacy DB to MariaDB author = Rodax Software author_email = info@rodax-software.com