Refactor invoice processing fields and update related logic
- Renamed fields in the `InvoiceHeader` model from `is_updated` to `is_processed` and updated corresponding attributes in schemas, services, and frontend components. - Adjusted query filters and validation logic to reflect the new processing status. - Updated comments and documentation to ensure clarity regarding the changes in invoice status handling.
This commit is contained in:
@@ -75,15 +75,15 @@ def invoice_exists_by_id(
|
||||
return invoice
|
||||
return None
|
||||
|
||||
def invoice_updated(
|
||||
def invoice_processed(
|
||||
db: Session,
|
||||
invoice_id: str,
|
||||
tenant_id: int,
|
||||
company_id: int,
|
||||
errors: ErrorCollector,
|
||||
) -> bool:
|
||||
is_updated = (
|
||||
db.query(models.InvoiceHeader.is_updated)
|
||||
is_processed = (
|
||||
db.query(models.InvoiceHeader.is_processed)
|
||||
.filter(
|
||||
models.InvoiceHeader.id == invoice_id,
|
||||
models.InvoiceHeader.tenant_id == tenant_id,
|
||||
@@ -92,12 +92,12 @@ def invoice_updated(
|
||||
.scalar()
|
||||
)
|
||||
|
||||
if is_updated:
|
||||
if is_processed:
|
||||
errors.add_error(
|
||||
field="invoice_number",
|
||||
message=f"La factura con el número '{invoice_id}' ya ha sido actualizada y no se puede modificar.",
|
||||
solution="Capturar otro número de Factura de Importación Temporal o Desactualizar la factura.",
|
||||
code="INVOICE_UPDATED",
|
||||
code="INVOICE_processed",
|
||||
value=invoice_id,
|
||||
)
|
||||
return True
|
||||
|
||||
@@ -56,9 +56,9 @@ class InvoiceHeaderBase(BaseModel):
|
||||
)
|
||||
invoice_date: date = Field(..., description="Invoice date")
|
||||
emission_date: Optional[date] = Field(None, description="Emission date")
|
||||
is_updated: bool = Field(False, description="Status")
|
||||
updated_date: Optional[datetime] = Field(None, description="Update date")
|
||||
who_updated: Optional[str] = Field(None, max_length=20, description="Who updated")
|
||||
is_processed: bool = Field(False, description="Status")
|
||||
processed_date: Optional[datetime] = Field(None, description="Update date")
|
||||
who_processed: Optional[str] = Field(None, max_length=20, description="Who processed")
|
||||
capture_user: Optional[str] = Field(None, max_length=20, description="Capture user")
|
||||
traffic_light_status: Optional[str] = Field(
|
||||
None, max_length=50, description="Traffic light status"
|
||||
@@ -66,8 +66,8 @@ class InvoiceHeaderBase(BaseModel):
|
||||
process_log: Optional[str] = Field(
|
||||
None, max_length=300, description="Processing log"
|
||||
)
|
||||
is_updated_rec: Optional[int] = Field(None, description="Reception status")
|
||||
is_updated_rep: Optional[str] = Field(
|
||||
is_processed_rec: Optional[int] = Field(None, description="Reception status")
|
||||
is_processed_rep: Optional[str] = Field(
|
||||
None, max_length=2, description="Report status"
|
||||
)
|
||||
observation_es: Optional[str] = Field(None, description="Observations in Spanish")
|
||||
|
||||
@@ -70,7 +70,7 @@ class InvoiceService:
|
||||
# Apply filters if provided
|
||||
if filters:
|
||||
if filters.get("status") is not None:
|
||||
query = query.filter(models.InvoiceHeader.is_updated == filters["status"])
|
||||
query = query.filter(models.InvoiceHeader.is_processed == filters["status"])
|
||||
if filters.get("operation_type"):
|
||||
ot = filters["operation_type"]
|
||||
ot_val = ot.value if hasattr(ot, "value") else ot
|
||||
|
||||
@@ -292,7 +292,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
|
||||
with CoreSessionLocal() as session:
|
||||
q = (
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_updated)
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_processed)
|
||||
.filter(
|
||||
InvoiceHeader.tenant_id == tenant_id,
|
||||
InvoiceHeader.company_id == company_id,
|
||||
@@ -453,7 +453,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
company_rfc = (company.rfc or "").strip().upper() if company else ""
|
||||
|
||||
q_inv_expo = (
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_updated)
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_processed)
|
||||
.filter(
|
||||
InvoiceHeader.tenant_id == tenant_id,
|
||||
InvoiceHeader.company_id == company_id,
|
||||
@@ -628,7 +628,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
|
||||
with CoreSessionLocal() as session:
|
||||
q = (
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_updated)
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_processed)
|
||||
.filter(
|
||||
InvoiceHeader.tenant_id == tenant_id,
|
||||
InvoiceHeader.company_id == company_id,
|
||||
@@ -790,7 +790,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
with CoreSessionLocal() as session:
|
||||
# Invoice lookup: imp + TEM
|
||||
q = (
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_updated)
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_processed)
|
||||
.filter(
|
||||
InvoiceHeader.tenant_id == tenant_id,
|
||||
InvoiceHeader.company_id == company_id,
|
||||
@@ -928,7 +928,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
|
||||
with CoreSessionLocal() as session:
|
||||
q_inv = (
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_updated)
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_processed)
|
||||
.filter(
|
||||
InvoiceHeader.tenant_id == tenant_id,
|
||||
InvoiceHeader.company_id == company_id,
|
||||
@@ -1185,7 +1185,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
|
||||
with CoreSessionLocal() as session:
|
||||
q_inv = (
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_updated)
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_processed)
|
||||
.filter(
|
||||
InvoiceHeader.tenant_id == tenant_id,
|
||||
InvoiceHeader.company_id == company_id,
|
||||
@@ -1443,7 +1443,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
rfc_exception_egm = False
|
||||
|
||||
q_inv_expo = (
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_updated)
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_processed)
|
||||
.filter(
|
||||
InvoiceHeader.tenant_id == tenant_id,
|
||||
InvoiceHeader.company_id == company_id,
|
||||
@@ -1712,7 +1712,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
|
||||
with CoreSessionLocal() as session:
|
||||
q_inv = (
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_updated)
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_processed)
|
||||
.filter(
|
||||
InvoiceHeader.tenant_id == tenant_id,
|
||||
InvoiceHeader.company_id == company_id,
|
||||
@@ -1978,7 +1978,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
|
||||
with CoreSessionLocal() as session:
|
||||
q_inv = (
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_updated)
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_processed)
|
||||
.filter(
|
||||
InvoiceHeader.tenant_id == tenant_id,
|
||||
InvoiceHeader.company_id == company_id,
|
||||
@@ -2309,7 +2309,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
|
||||
with CoreSessionLocal() as session:
|
||||
q_inv = (
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_updated)
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_processed)
|
||||
.filter(
|
||||
InvoiceHeader.tenant_id == tenant_id,
|
||||
InvoiceHeader.company_id == company_id,
|
||||
@@ -2647,7 +2647,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
|
||||
with CoreSessionLocal() as session:
|
||||
q_inv = (
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_updated, InvoiceHeader.is_updated_rep)
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_processed, InvoiceHeader.is_processed_rep)
|
||||
.filter(
|
||||
InvoiceHeader.tenant_id == tenant_id,
|
||||
InvoiceHeader.company_id == company_id,
|
||||
@@ -2969,7 +2969,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
|
||||
with CoreSessionLocal() as session:
|
||||
q_inv = (
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_updated)
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_processed)
|
||||
.filter(
|
||||
InvoiceHeader.tenant_id == tenant_id,
|
||||
InvoiceHeader.company_id == company_id,
|
||||
@@ -4008,7 +4008,7 @@ def _do_insert_valid_rows(job_id: str, model_target: str, job_type_override: Opt
|
||||
|
||||
with CoreSessionLocal() as session:
|
||||
q = (
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_updated)
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_processed)
|
||||
.filter(
|
||||
InvoiceHeader.tenant_id == tenant_id,
|
||||
InvoiceHeader.company_id == company_id,
|
||||
@@ -4275,7 +4275,7 @@ def _do_insert_valid_rows(job_id: str, model_target: str, job_type_override: Opt
|
||||
|
||||
with CoreSessionLocal() as session:
|
||||
q = (
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_updated)
|
||||
session.query(InvoiceHeader.invoice_number, InvoiceHeader.id, InvoiceHeader.is_processed)
|
||||
.filter(
|
||||
InvoiceHeader.tenant_id == tenant_id,
|
||||
InvoiceHeader.company_id == company_id,
|
||||
@@ -4913,7 +4913,7 @@ 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.is_updated = True # Mark as updated
|
||||
header.is_processed = True # Mark as updated
|
||||
header.updated_date = datetime.utcnow()
|
||||
capture_user = meta.get("capture_user") or "CSV"
|
||||
header.who_updated = capture_user
|
||||
@@ -4952,7 +4952,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,
|
||||
is_updated=False,
|
||||
is_processed=False,
|
||||
system="CSV",
|
||||
capture_date=datetime.utcnow(),
|
||||
capture_user=capture_user,
|
||||
|
||||
@@ -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_updated=true)
|
||||
# Si include_cancelled=False, solo mostrar AC (is_processed=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_updated doesn't directly represent AC/NA status
|
||||
# because is_processed 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_updated = true
|
||||
NA (Not Applicable/Deactivated) = is_updated = false
|
||||
AC (Active) = is_processed = true
|
||||
NA (Not Applicable/Deactivated) = is_processed = 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_updated = true
|
||||
# NA (Not Applicable/Deactivated) = is_updated = false
|
||||
# AC (Active) = is_processed = true
|
||||
# NA (Not Applicable/Deactivated) = is_processed = false
|
||||
if not filters.include_cancelled:
|
||||
conditions.append("ih.is_updated = true")
|
||||
logger.debug("Filtering only active invoices (is_updated = true)")
|
||||
conditions.append("ih.is_processed = true")
|
||||
logger.debug("Filtering only active invoices (is_processed = 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_updated THEN 'AC' ELSE 'NA' END AS C4,
|
||||
CASE WHEN ih.is_processed 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,
|
||||
@@ -39,7 +39,7 @@ class TemporaryImportQueries:
|
||||
COALESCE(fin.exchange_rate, 0) AS C50,
|
||||
COALESCE(TO_CHAR(ih.emission_date, 'YYYYMMDD'), '') AS C51,
|
||||
COALESCE(ih.capture_user, '') AS C52,
|
||||
COALESCE(ih.who_updated, '') AS C53,
|
||||
COALESCE(ih.who_processed, '') AS C53,
|
||||
COALESCE(log.carrier_id, '') AS C54,
|
||||
COALESCE(NULLIF(CONCAT_WS(' ', log.transport_num, log.license_plate), ''), '') AS C55,
|
||||
'' AS C56,
|
||||
@@ -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_updated THEN 'AC' ELSE 'NA' END AS C4,
|
||||
CASE WHEN ih.is_processed 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,
|
||||
@@ -145,7 +145,7 @@ class TemporaryImportQueries:
|
||||
COALESCE(fin.exchange_rate, 0) AS C50,
|
||||
COALESCE(TO_CHAR(ih.emission_date, 'YYYYMMDD'), '') AS C51,
|
||||
COALESCE(ih.capture_user, '') AS C52,
|
||||
COALESCE(ih.who_updated, '') AS C53,
|
||||
COALESCE(ih.who_processed, '') AS C53,
|
||||
COALESCE(log.carrier_id, '') AS C54,
|
||||
COALESCE(NULLIF(CONCAT_WS(' ', log.transport_num, log.license_plate), ''), '') AS C55,
|
||||
'' AS C56,
|
||||
@@ -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_updated THEN 'AC' ELSE 'NA' END AS C4,
|
||||
CASE WHEN ih.is_processed 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,
|
||||
@@ -254,7 +254,7 @@ class DefinitiveImportQueries:
|
||||
COALESCE(fin.exchange_rate, 0) AS C51,
|
||||
COALESCE(TO_CHAR(ih.emission_date, 'YYYYMMDD'), '') AS C52,
|
||||
COALESCE(ih.capture_user, '') AS C53,
|
||||
COALESCE(ih.who_updated, '') AS C54,
|
||||
COALESCE(ih.who_processed, '') AS C54,
|
||||
COALESCE(NULLIF(CONCAT_WS(' ', log.transport_id, log.transport_num), ''), '') AS C56,
|
||||
'' AS C57,
|
||||
'' AS C58,
|
||||
@@ -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_updated THEN 'AC' ELSE 'NA' END AS C4,
|
||||
CASE WHEN ih.is_processed 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,
|
||||
@@ -352,7 +352,7 @@ class DefinitiveImportQueries:
|
||||
COALESCE(fin.exchange_rate, 0) AS C50,
|
||||
COALESCE(TO_CHAR(ih.emission_date, 'YYYYMMDD'), '') AS C51,
|
||||
COALESCE(ih.capture_user, '') AS C52,
|
||||
COALESCE(ih.who_updated, '') AS C53,
|
||||
COALESCE(ih.who_processed, '') AS C53,
|
||||
COALESCE(log.carrier_id, '') AS C54,
|
||||
COALESCE(NULLIF(CONCAT_WS(' ', log.transport_id, log.transport_num), ''), '') AS C55,
|
||||
'' AS C56,
|
||||
@@ -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_updated THEN 'AC' ELSE 'NA' END AS C5,
|
||||
CASE WHEN ih.is_processed 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,
|
||||
@@ -463,7 +463,7 @@ class RepairImportQueries:
|
||||
COALESCE(fin.exchange_rate, 0) AS C40,
|
||||
COALESCE(TO_CHAR(ih.emission_date, 'YYYYMMDD'), '') AS C41,
|
||||
COALESCE(ih.capture_user, '') AS C42,
|
||||
COALESCE(ih.who_updated, '') AS C43,
|
||||
COALESCE(ih.who_processed, '') AS C43,
|
||||
COALESCE(log.carrier_id, '') AS C44,
|
||||
COALESCE(log.transport_num, '') AS C45,
|
||||
COALESCE(ped.pedimento_code, '') AS C47,
|
||||
@@ -527,7 +527,7 @@ class RepairImportQueries:
|
||||
ih.invoice_number,
|
||||
COALESCE(ped.pedimento_number, ''),
|
||||
TO_CHAR(ih.invoice_date, 'YYYYMMDD'),
|
||||
CASE WHEN ih.is_updated THEN 'AC' ELSE 'NA' END,
|
||||
CASE WHEN ih.is_processed THEN 'AC' ELSE 'NA' END,
|
||||
COALESCE(ped.pedimento_code, ''),
|
||||
COALESCE(ped.regime, ''),
|
||||
COALESCE(TO_CHAR(pd.entry_date, 'YYYYMMDD'), ''),
|
||||
@@ -569,7 +569,7 @@ class RepairImportQueries:
|
||||
COALESCE(fin.exchange_rate, 0),
|
||||
COALESCE(TO_CHAR(ih.emission_date, 'YYYYMMDD'), ''),
|
||||
COALESCE(ih.capture_user, ''),
|
||||
COALESCE(ih.who_updated, ''),
|
||||
COALESCE(ih.who_processed, ''),
|
||||
COALESCE(log.carrier_id, ''),
|
||||
COALESCE(log.transport_num, ''),
|
||||
'',
|
||||
@@ -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_updated THEN 'AC' ELSE 'NA' END AS C6,
|
||||
CASE WHEN ih.is_processed 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,
|
||||
@@ -682,7 +682,7 @@ class ExportQueries:
|
||||
COALESCE(fin.exchange_rate, 0) AS C48,
|
||||
COALESCE(TO_CHAR(ih.emission_date, 'YYYYMMDD'), '') AS C49,
|
||||
COALESCE(ih.capture_user, '') AS C50,
|
||||
COALESCE(ih.who_updated, '') AS C51,
|
||||
COALESCE(ih.who_processed, '') AS C51,
|
||||
COALESCE(NULLIF(CONCAT_WS(' ', log.transport_id, log.transport_num), ''), '') AS C53,
|
||||
COALESCE(fin.value_me, 0) AS total_me,
|
||||
COALESCE(fin.value_mn, 0) AS total_mn,
|
||||
@@ -775,7 +775,7 @@ class ExportQueries:
|
||||
fin.exchange_rate AS C48, -- [47]
|
||||
ih.emission_date AS C49, -- [48]
|
||||
ih.capture_user AS C50, -- [49]
|
||||
ih.who_updated AS C51, -- [50]
|
||||
ih.who_processed AS C51, -- [50]
|
||||
'' AS C52, -- [51]
|
||||
COALESCE(NULLIF(CONCAT_WS(' ', log.transport_id, log.transport_num), ''), '') AS C53, -- [52] NumCaja
|
||||
'' AS C54, -- [53] Pedimento18
|
||||
@@ -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_updated THEN 'AC' ELSE 'NA' END AS C6,
|
||||
CASE WHEN ih.is_processed 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,
|
||||
@@ -892,7 +892,7 @@ class ExportRepairQueries:
|
||||
COALESCE(fin.exchange_rate, 0) AS C48,
|
||||
COALESCE(TO_CHAR(ih.invoice_date, 'YYYYMMDD'), '') AS C49,
|
||||
COALESCE(ih.capture_user, '') AS C50,
|
||||
COALESCE(ih.who_updated, '') AS C51,
|
||||
COALESCE(ih.who_processed, '') AS C51,
|
||||
COALESCE(log.carrier_id, '') AS C52,
|
||||
COALESCE(NULLIF(CONCAT_WS(' ', log.transport_id, log.transport_num), ''), '') AS C53,
|
||||
COALESCE(fin.value_me, 0) AS total_me,
|
||||
@@ -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_updated THEN 'AC' ELSE 'NA' END AS C6,
|
||||
CASE WHEN ih.is_processed 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,
|
||||
@@ -992,7 +992,7 @@ class ExportRepairQueries:
|
||||
COALESCE(fin.exchange_rate, 0) AS C48,
|
||||
COALESCE(TO_CHAR(ih.invoice_date, 'YYYYMMDD'), '') AS C49,
|
||||
COALESCE(ih.capture_user, '') AS C50,
|
||||
COALESCE(ih.who_updated, '') AS C51,
|
||||
COALESCE(ih.who_processed, '') AS C51,
|
||||
COALESCE(log.carrier_id, '') AS C52,
|
||||
COALESCE(NULLIF(CONCAT_WS(' ', log.transport_id, log.transport_num), ''), '') AS C53,
|
||||
'' AS C54,
|
||||
|
||||
@@ -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_updated=true)
|
||||
# Si include_cancelled=False, solo mostrar AC (is_processed=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_updated doesn't directly represent AC/NA status
|
||||
# because is_processed 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_updated=true)
|
||||
# Si include_cancelled=False, solo mostrar AC (is_processed=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_updated doesn't directly represent AC/NA status
|
||||
# because is_processed doesn't directly represent AC/NA status
|
||||
|
||||
# Provider filter
|
||||
if filters.provider:
|
||||
|
||||
Reference in New Issue
Block a user