Refactor invoice status terminology and update related logic
- Renamed 'is_processed' fields to 'status' in the InvoiceHeader model and updated corresponding attributes in schemas, services, and frontend components for consistency. - Adjusted query filters and validation logic to reflect the new 'status' terminology. - Updated comments and documentation to clarify changes in invoice status handling.
This commit is contained in:
@@ -70,7 +70,7 @@ class DefinitiveImportService:
|
||||
estatus = row[3] # C4 - Estatus (AC o NA)
|
||||
|
||||
# Filtrar facturas según include_cancelled
|
||||
# Si include_cancelled=False, solo mostrar AC (is_processed=true)
|
||||
# Si include_cancelled=False, solo mostrar AC (status=true)
|
||||
# Si include_cancelled=True, mostrar todas (AC y NA)
|
||||
if not filters.include_cancelled and estatus != 'AC':
|
||||
continue
|
||||
@@ -345,7 +345,7 @@ class DefinitiveImportService:
|
||||
where_conditions.append(f"pd.payment_date >= TO_DATE('{filters.start_date}', 'YYYYMMDD') AND pd.payment_date <= TO_DATE('{filters.end_date}', 'YYYYMMDD')")
|
||||
|
||||
# Note: Status filter applied at Python level after CASE WHEN in SELECT
|
||||
# because is_processed doesn't directly represent AC/NA status
|
||||
# because status doesn't directly represent AC/NA status
|
||||
|
||||
# Provider filter
|
||||
if filters.provider:
|
||||
|
||||
@@ -326,8 +326,8 @@ class ExportService:
|
||||
Build WHERE clause for export query.
|
||||
|
||||
IMPORTANT: Returns conditions WITHOUT the WHERE keyword (already in base query)
|
||||
AC (Active) = is_processed = true
|
||||
NA (Not Applicable/Deactivated) = is_processed = false
|
||||
AC (Active) = status = true
|
||||
NA (Not Applicable/Deactivated) = status = false
|
||||
"""
|
||||
conditions = []
|
||||
|
||||
@@ -344,11 +344,11 @@ class ExportService:
|
||||
|
||||
# CRITICAL VALIDATION: AC/NA status filter
|
||||
# If include_cancelled is False (checkbox unchecked), only show AC invoices
|
||||
# AC (Active) = is_processed = true
|
||||
# NA (Not Applicable/Deactivated) = is_processed = false
|
||||
# AC (Active) = status = true
|
||||
# NA (Not Applicable/Deactivated) = status = false
|
||||
if not filters.include_cancelled:
|
||||
conditions.append("ih.is_processed = true")
|
||||
logger.debug("Filtering only active invoices (is_processed = true)")
|
||||
conditions.append("ih.status = true")
|
||||
logger.debug("Filtering only active invoices (status = true)")
|
||||
else:
|
||||
logger.debug("Including cancelled invoices (include_cancelled = true)")
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class TemporaryImportQueries:
|
||||
ih.invoice_number AS C1,
|
||||
COALESCE(ped.pedimento_number, '') AS C2,
|
||||
TO_CHAR(ih.invoice_date, 'YYYYMMDD') AS C3,
|
||||
CASE WHEN ih.is_processed THEN 'AC' ELSE 'NA' END AS C4,
|
||||
CASE WHEN ih.status THEN 'AC' ELSE 'NA' END AS C4,
|
||||
COALESCE(ped.pedimento_code, '') AS C5,
|
||||
COALESCE(ped.regime, '') AS C10,
|
||||
COALESCE(TO_CHAR(pd.entry_date, 'YYYYMMDD'), '') AS C11,
|
||||
@@ -92,7 +92,7 @@ class TemporaryImportQueries:
|
||||
ih.invoice_number AS C1,
|
||||
COALESCE(ped.pedimento_number, '') AS C2,
|
||||
TO_CHAR(ih.invoice_date, 'YYYYMMDD') AS C3,
|
||||
CASE WHEN ih.is_processed THEN 'AC' ELSE 'NA' END AS C4,
|
||||
CASE WHEN ih.status THEN 'AC' ELSE 'NA' END AS C4,
|
||||
COALESCE(ped.pedimento_code, '') AS C5,
|
||||
COALESCE(fin.value_me, 0) AS C6,
|
||||
COALESCE(fin.value_mn, 0) AS C7,
|
||||
@@ -230,7 +230,7 @@ class DefinitiveImportQueries:
|
||||
ih.invoice_number AS C1,
|
||||
COALESCE(ped.pedimento_number, '') AS C2,
|
||||
TO_CHAR(ih.invoice_date, 'YYYYMMDD') AS C3,
|
||||
CASE WHEN ih.is_processed THEN 'AC' ELSE 'NA' END AS C4,
|
||||
CASE WHEN ih.status THEN 'AC' ELSE 'NA' END AS C4,
|
||||
COALESCE(ped.pedimento_code, '') AS C5,
|
||||
COALESCE(ped.regime, '') AS C10,
|
||||
COALESCE(TO_CHAR(pd.entry_date, 'YYYYMMDD'), '') AS C11,
|
||||
@@ -299,7 +299,7 @@ class DefinitiveImportQueries:
|
||||
ih.invoice_number AS C1,
|
||||
COALESCE(ped.pedimento_number, '') AS C2,
|
||||
TO_CHAR(ih.invoice_date, 'YYYYMMDD') AS C3,
|
||||
CASE WHEN ih.is_processed THEN 'AC' ELSE 'NA' END AS C4,
|
||||
CASE WHEN ih.status THEN 'AC' ELSE 'NA' END AS C4,
|
||||
COALESCE(ped.pedimento_code, '') AS C5,
|
||||
COALESCE(fin.value_me, 0) AS C6,
|
||||
COALESCE(fin.value_mn, 0) AS C7,
|
||||
@@ -446,7 +446,7 @@ class RepairImportQueries:
|
||||
ih.invoice_number AS C2,
|
||||
COALESCE(ped.pedimento_number, '') AS C3,
|
||||
TO_CHAR(ih.invoice_date, 'YYYYMMDD') AS C4,
|
||||
CASE WHEN ih.is_processed THEN 'AC' ELSE 'NA' END AS C5,
|
||||
CASE WHEN ih.status THEN 'AC' ELSE 'NA' END AS C5,
|
||||
COALESCE(ped.pedimento_code, '') AS C6,
|
||||
COALESCE(ped.regime, '') AS C7,
|
||||
COALESCE(TO_CHAR(pd.payment_date, 'YYYYMMDD'), '') AS C9,
|
||||
@@ -527,7 +527,7 @@ class RepairImportQueries:
|
||||
ih.invoice_number,
|
||||
COALESCE(ped.pedimento_number, ''),
|
||||
TO_CHAR(ih.invoice_date, 'YYYYMMDD'),
|
||||
CASE WHEN ih.is_processed THEN 'AC' ELSE 'NA' END,
|
||||
CASE WHEN ih.status THEN 'AC' ELSE 'NA' END,
|
||||
COALESCE(ped.pedimento_code, ''),
|
||||
COALESCE(ped.regime, ''),
|
||||
COALESCE(TO_CHAR(pd.entry_date, 'YYYYMMDD'), ''),
|
||||
@@ -664,7 +664,7 @@ class ExportQueries:
|
||||
ih.invoice_number AS C1,
|
||||
COALESCE(ped.pedimento_number, '') AS C2,
|
||||
TO_CHAR(ih.invoice_date, 'YYYYMMDD') AS C3,
|
||||
CASE WHEN ih.is_processed THEN 'AC' ELSE 'NA' END AS C6,
|
||||
CASE WHEN ih.status THEN 'AC' ELSE 'NA' END AS C6,
|
||||
COALESCE(ped.pedimento_code, '') AS C7,
|
||||
COALESCE(ped.regime, '') AS C8,
|
||||
COALESCE(TO_CHAR(pd.end_date, 'YYYYMMDD'), TO_CHAR(pd.payment_date, 'YYYYMMDD'), '') AS C10,
|
||||
@@ -874,7 +874,7 @@ class ExportRepairQueries:
|
||||
ih.invoice_number AS C1,
|
||||
COALESCE(ped.pedimento_number, '') AS C2,
|
||||
TO_CHAR(ih.invoice_date, 'YYYYMMDD') AS C3,
|
||||
CASE WHEN ih.is_processed THEN 'AC' ELSE 'NA' END AS C6,
|
||||
CASE WHEN ih.status THEN 'AC' ELSE 'NA' END AS C6,
|
||||
COALESCE(ped.pedimento_code, '') AS C7,
|
||||
COALESCE(ped.regime, '') AS C8,
|
||||
COALESCE(TO_CHAR(pd.payment_date, 'YYYYMMDD'), '') AS C11,
|
||||
@@ -943,7 +943,7 @@ class ExportRepairQueries:
|
||||
TO_CHAR(ih.invoice_date, 'YYYYMMDD') AS C3,
|
||||
COALESCE(fin.value_me, 0) AS C4,
|
||||
COALESCE(fin.value_mn, 0) AS C5,
|
||||
CASE WHEN ih.is_processed THEN 'AC' ELSE 'NA' END AS C6,
|
||||
CASE WHEN ih.status THEN 'AC' ELSE 'NA' END AS C6,
|
||||
COALESCE(ped.pedimento_code, '') AS C7,
|
||||
COALESCE(ped.regime, '') AS C8,
|
||||
COALESCE(TO_CHAR(pd.entry_date, 'YYYYMMDD'), '') AS C9,
|
||||
|
||||
@@ -74,7 +74,7 @@ class RepairImportService:
|
||||
estatus = row[3] # C5 - Estatus (AC o NA)
|
||||
|
||||
# Filtrar facturas según include_cancelled
|
||||
# Si include_cancelled=False, solo mostrar AC (is_processed=true)
|
||||
# Si include_cancelled=False, solo mostrar AC (status=true)
|
||||
# Si include_cancelled=True, mostrar todas (AC y NA)
|
||||
if not filters.include_cancelled and estatus != 'AC':
|
||||
continue
|
||||
@@ -355,7 +355,7 @@ class RepairImportService:
|
||||
where_conditions.append(f"pd.payment_date >= TO_DATE('{filters.start_date}', 'YYYYMMDD') AND pd.payment_date <= TO_DATE('{filters.end_date}', 'YYYYMMDD')")
|
||||
|
||||
# Note: Status filter applied at Python level after CASE WHEN in SELECT
|
||||
# because is_processed doesn't directly represent AC/NA status
|
||||
# because status doesn't directly represent AC/NA status
|
||||
|
||||
# Provider filter
|
||||
if filters.provider:
|
||||
|
||||
@@ -70,7 +70,7 @@ class TemporaryImportService:
|
||||
estatus = row[3] # C4 - Estatus (AC o NA)
|
||||
|
||||
# Filtrar facturas según include_cancelled
|
||||
# Si include_cancelled=False, solo mostrar AC (is_processed=true)
|
||||
# Si include_cancelled=False, solo mostrar AC (status=true)
|
||||
# Si include_cancelled=True, mostrar todas (AC y NA)
|
||||
if not filters.include_cancelled and estatus != 'AC':
|
||||
continue
|
||||
@@ -421,7 +421,7 @@ class TemporaryImportService:
|
||||
where_conditions.append(f"pd.payment_date >= TO_DATE('{filters.start_date}', 'YYYYMMDD') AND pd.payment_date <= TO_DATE('{filters.end_date}', 'YYYYMMDD')")
|
||||
|
||||
# Note: Status filter applied at Python level after CASE WHEN in SELECT
|
||||
# because is_processed doesn't directly represent AC/NA status
|
||||
# because status doesn't directly represent AC/NA status
|
||||
|
||||
# Provider filter
|
||||
if filters.provider:
|
||||
|
||||
Reference in New Issue
Block a user