From 3f16378ed042432fc84fedb8849a0f30b3af3e6f Mon Sep 17 00:00:00 2001 From: hreyes Date: Wed, 18 Mar 2026 15:49:47 -0600 Subject: [PATCH] feature/fix-invoice-status --- backend/api/v1/modules/a76/layouts_csv/facturas/tasks.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/api/v1/modules/a76/layouts_csv/facturas/tasks.py b/backend/api/v1/modules/a76/layouts_csv/facturas/tasks.py index 6f43ab11..03a1751c 100644 --- a/backend/api/v1/modules/a76/layouts_csv/facturas/tasks.py +++ b/backend/api/v1/modules/a76/layouts_csv/facturas/tasks.py @@ -4487,6 +4487,7 @@ def _do_insert_valid_rows(job_id: str, model_target: str, job_type_override: Opt InvoiceFinancials, InvoiceLogistics, InvoiceSalesDetails, + InvoiceStatus, OperationType, TransportType, WeightUnit, @@ -4925,7 +4926,10 @@ def _do_insert_valid_rows(job_id: str, model_target: str, job_type_override: Opt header = existing_header header.invoice_date = invoice_date header.operation_type = op_type_value - header.status = True # Mark as updated + # CSV import only captures data; "processed" is set by the manual/import processing flow. + # Legacy CSV imports may have persisted booleans ('True'/'False') into status. + if header.status not in (InvoiceStatus.PENDING, InvoiceStatus.PROCESSED, InvoiceStatus.REVERSED): + header.status = InvoiceStatus.PENDING header.updated_date = datetime.utcnow() capture_user = meta.get("capture_user") or "CSV" header.who_processed = capture_user @@ -4964,7 +4968,7 @@ def _do_insert_valid_rows(job_id: str, model_target: str, job_type_override: Opt invoice_number=invoice_number, invoice_date=invoice_date, operation_type=op_type_value, - status=False, + status=InvoiceStatus.PENDING, system="CSV", capture_date=datetime.utcnow(), capture_user=capture_user,