diff --git a/backend/api/v1/modules/a76/invoices/imports/process/sub_process/review_classes.py b/backend/api/v1/modules/a76/invoices/imports/process/sub_process/review_classes.py index db009bd6..935bbca3 100644 --- a/backend/api/v1/modules/a76/invoices/imports/process/sub_process/review_classes.py +++ b/backend/api/v1/modules/a76/invoices/imports/process/sub_process/review_classes.py @@ -138,7 +138,7 @@ def review_classes( 3a. If no class errors: validate fractions for ALL lines. 3b. If class errors exist: add a CLASE error per invalid line and validate fractions only for those lines. - 4. If the invoice has not been reviewed by the company, flag lines whose + 4. If invoice logistics does not mark equipment_reviewed, flag lines whose class requires physical review (Class.physical_review == 1). """ # 1. Lines whose class is not assigned / not found in the catalog @@ -178,7 +178,7 @@ def review_classes( _validate_line_fraction(db, line, errors) # 4. Physical review check - if not invoice.compliance_mx.was_reviewed_by_company: + if not (invoice.logistics and invoice.logistics.equipment_reviewed): review_required_lines = ( db.query(LineItem) .join(Class, LineItem.class_id == Class.id) @@ -201,7 +201,7 @@ def review_classes( ), solution=[ f"Revisar el Equipo de la Partida: {line.line_number} " - "y Asignar Como Revisado a Nivel Factura." + "y marcar Equipo revisado en Continuación (logística) a nivel factura." ], code="CLASE", ) diff --git a/backend/tests/fixtures/builders.py b/backend/tests/fixtures/builders.py index 6486d36b..15cf6800 100644 --- a/backend/tests/fixtures/builders.py +++ b/backend/tests/fixtures/builders.py @@ -343,6 +343,7 @@ def create_import_invoice_with_line( tenant_id=tenant_id, company_id=company_id, weight_type="kgs", + equipment_reviewed=True, ) db.add(invoice) db.flush() @@ -413,6 +414,7 @@ def create_export_invoice_with_line( tenant_id=tenant_id, company_id=company_id, weight_type="kgs", + equipment_reviewed=True, ) db.add(invoice) db.flush()