Refactor invoice status handling to use 'processed' terminology
- Renamed instances of 'invoice_updated' to 'invoice_processed' across various modules to improve clarity and consistency in invoice status management. - Updated validation and processing logic to reflect the new terminology, ensuring that all references are aligned with the recent changes in the invoice processing model. - Adjusted related functions and validation checks to maintain functionality and accuracy in invoice processing workflows.
This commit is contained in:
@@ -21,7 +21,7 @@ from sqlalchemy.orm import Session, joinedload
|
||||
|
||||
from api.v1.modules.a76.invoices.common.common_validators import (
|
||||
invoice_exists_by_id,
|
||||
invoice_updated,
|
||||
invoice_processed,
|
||||
)
|
||||
from core.exceptions import ErrorCollector
|
||||
from .imports.validators.create import validate_create as validate_create_import
|
||||
@@ -343,7 +343,7 @@ class ItemService:
|
||||
|
||||
if not invoice:
|
||||
errors.raise_if_errors("Error al encontra la factura para el item")
|
||||
if not invoice_updated(db, item_data.invoice_id, tenant_id, company_id, errors):
|
||||
if not invoice_processed(db, item_data.invoice_id, tenant_id, company_id, errors):
|
||||
errors.raise_if_errors("Error al crear el item - la factura ya fue actualizada, no se pueden agregar items")
|
||||
|
||||
# Lock invoice and calculate line number
|
||||
|
||||
@@ -302,11 +302,11 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
)
|
||||
rows_inv = q.all()
|
||||
invoice_id_by_number: Dict[str, int] = {}
|
||||
invoice_updated_by_number: Dict[str, bool] = {}
|
||||
invoice_processed_by_number: Dict[str, bool] = {}
|
||||
for num, iid, is_upd in rows_inv:
|
||||
if num:
|
||||
invoice_id_by_number[str(num).strip()] = iid
|
||||
invoice_updated_by_number[str(num).strip()] = bool(is_upd)
|
||||
invoice_processed_by_number[str(num).strip()] = bool(is_upd)
|
||||
|
||||
partida_max_series: Dict[Tuple[str, str], int] = {}
|
||||
q_qty = (
|
||||
@@ -389,7 +389,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
autonumerar=autonumerar,
|
||||
validar_series_exception=validar_series_exception,
|
||||
invoice_id_by_number=invoice_id_by_number,
|
||||
invoice_updated_by_number=invoice_updated_by_number,
|
||||
invoice_processed_by_number=invoice_processed_by_number,
|
||||
partida_max_series=partida_max_series,
|
||||
csv_series_count_so_far=csv_series_count_so_far,
|
||||
existing_series_keys=existing_series_keys,
|
||||
@@ -461,11 +461,11 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
)
|
||||
)
|
||||
invoice_id_by_number: Dict[str, int] = {}
|
||||
invoice_updated_by_number: Dict[str, bool] = {}
|
||||
invoice_processed_by_number: Dict[str, bool] = {}
|
||||
for num, iid, is_upd in q_inv_expo.all():
|
||||
if num:
|
||||
invoice_id_by_number[str(num).strip()] = iid
|
||||
invoice_updated_by_number[str(num).strip()] = bool(is_upd)
|
||||
invoice_processed_by_number[str(num).strip()] = bool(is_upd)
|
||||
|
||||
partida_max_series: Dict[Tuple[str, str], int] = {}
|
||||
q_qty = (
|
||||
@@ -565,7 +565,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
autonumerar=autonumerar,
|
||||
validar_series_exception=validar_series_exception,
|
||||
invoice_id_by_number=invoice_id_by_number,
|
||||
invoice_updated_by_number=invoice_updated_by_number,
|
||||
invoice_processed_by_number=invoice_processed_by_number,
|
||||
rfc_exception_updated=rfc_exception_updated,
|
||||
partida_max_series=partida_max_series,
|
||||
csv_series_count_so_far=csv_series_count_so_far,
|
||||
@@ -638,11 +638,11 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
)
|
||||
rows_inv = q.all()
|
||||
invoice_id_by_number: Dict[str, int] = {}
|
||||
invoice_updated_by_number: Dict[str, bool] = {}
|
||||
invoice_processed_by_number: Dict[str, bool] = {}
|
||||
for num, iid, is_upd in rows_inv:
|
||||
if num:
|
||||
invoice_id_by_number[str(num).strip()] = iid
|
||||
invoice_updated_by_number[str(num).strip()] = bool(is_upd)
|
||||
invoice_processed_by_number[str(num).strip()] = bool(is_upd)
|
||||
|
||||
partida_max_series: Dict[Tuple[str, str], int] = {}
|
||||
q_qty = (
|
||||
@@ -725,7 +725,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
autonumerar=autonumerar,
|
||||
validar_series_exception=validar_series_exception,
|
||||
invoice_id_by_number=invoice_id_by_number,
|
||||
invoice_updated_by_number=invoice_updated_by_number,
|
||||
invoice_processed_by_number=invoice_processed_by_number,
|
||||
partida_max_series=partida_max_series,
|
||||
csv_series_count_so_far=csv_series_count_so_far,
|
||||
existing_series_keys=existing_series_keys,
|
||||
@@ -800,11 +800,11 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
)
|
||||
rows_inv = q.all()
|
||||
invoice_id_by_number: Dict[str, int] = {}
|
||||
invoice_updated_by_number: Dict[str, bool] = {}
|
||||
invoice_processed_by_number: Dict[str, bool] = {}
|
||||
for num, iid, is_upd in rows_inv:
|
||||
if num:
|
||||
invoice_id_by_number[str(num).strip()] = iid
|
||||
invoice_updated_by_number[str(num).strip()] = bool(is_upd)
|
||||
invoice_processed_by_number[str(num).strip()] = bool(is_upd)
|
||||
|
||||
# Existing series keys: (invoice_number, linea_factura, linea_serie)
|
||||
existing_series_keys: Set[Tuple[str, str, str]] = set()
|
||||
@@ -862,7 +862,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
autonumerar=autonumerar,
|
||||
validar_series_exception=validar_series_exception,
|
||||
invoice_id_by_number=invoice_id_by_number,
|
||||
invoice_updated_by_number=invoice_updated_by_number,
|
||||
invoice_processed_by_number=invoice_processed_by_number,
|
||||
existing_series_keys=existing_series_keys,
|
||||
existing_series_data=existing_series_data,
|
||||
warnings=warnings_list,
|
||||
@@ -937,11 +937,11 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
)
|
||||
)
|
||||
invoice_id_by_number: Dict[str, int] = {}
|
||||
invoice_updated_by_number: Dict[str, bool] = {}
|
||||
invoice_processed_by_number: Dict[str, bool] = {}
|
||||
for num, iid, is_upd in q_inv.all():
|
||||
if num:
|
||||
invoice_id_by_number[str(num).strip()] = iid
|
||||
invoice_updated_by_number[str(num).strip()] = bool(is_upd)
|
||||
invoice_processed_by_number[str(num).strip()] = bool(is_upd)
|
||||
|
||||
existing_line_keys_by_invoice: Dict[str, Set[str]] = {}
|
||||
q_li = (
|
||||
@@ -1104,7 +1104,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
calcular_costo_en_base_a_total=calcular_costo_en_base_a_total,
|
||||
validar_decimales_pza=validar_decimales_pza,
|
||||
invoice_id_by_number=invoice_id_by_number,
|
||||
invoice_updated_by_number=invoice_updated_by_number,
|
||||
invoice_processed_by_number=invoice_processed_by_number,
|
||||
rfc_exception_updated=rfc_exception_updated,
|
||||
existing_line_keys_by_invoice=existing_line_keys_by_invoice,
|
||||
line_counts_csv=line_counts_csv,
|
||||
@@ -1194,11 +1194,11 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
)
|
||||
)
|
||||
invoice_id_by_number: Dict[str, int] = {}
|
||||
invoice_updated_by_number: Dict[str, bool] = {}
|
||||
invoice_processed_by_number: Dict[str, bool] = {}
|
||||
for num, iid, is_upd in q_inv.all():
|
||||
if num:
|
||||
invoice_id_by_number[str(num).strip()] = iid
|
||||
invoice_updated_by_number[str(num).strip()] = bool(is_upd)
|
||||
invoice_processed_by_number[str(num).strip()] = bool(is_upd)
|
||||
|
||||
existing_line_keys_by_invoice: Dict[str, Set[str]] = {}
|
||||
q_li = (
|
||||
@@ -1363,7 +1363,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
calcular_costo_en_base_a_total=calcular_costo_en_base_a_total,
|
||||
validar_decimales_pza=validar_decimales_pza,
|
||||
invoice_id_by_number=invoice_id_by_number,
|
||||
invoice_updated_by_number=invoice_updated_by_number,
|
||||
invoice_processed_by_number=invoice_processed_by_number,
|
||||
rfc_exception_updated=rfc_exception_updated,
|
||||
existing_line_keys_by_invoice=existing_line_keys_by_invoice,
|
||||
line_counts_csv=line_counts_csv,
|
||||
@@ -1451,11 +1451,11 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
)
|
||||
)
|
||||
invoice_id_by_number: Dict[str, int] = {}
|
||||
invoice_updated_by_number: Dict[str, bool] = {}
|
||||
invoice_processed_by_number: Dict[str, bool] = {}
|
||||
for num, iid, is_upd in q_inv_expo.all():
|
||||
if num:
|
||||
invoice_id_by_number[str(num).strip()] = iid
|
||||
invoice_updated_by_number[str(num).strip()] = bool(is_upd)
|
||||
invoice_processed_by_number[str(num).strip()] = bool(is_upd)
|
||||
|
||||
existing_line_keys_by_invoice: Dict[str, Set[str]] = {}
|
||||
q_li_expo = (
|
||||
@@ -1630,7 +1630,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
actualizar=actualizar,
|
||||
levantar_subpartidas=levantar_subpartidas,
|
||||
invoice_id_by_number=invoice_id_by_number,
|
||||
invoice_updated_by_number=invoice_updated_by_number,
|
||||
invoice_processed_by_number=invoice_processed_by_number,
|
||||
rfc_exception_updated=rfc_exception_updated,
|
||||
existing_line_keys_by_invoice=existing_line_keys_by_invoice,
|
||||
line_counts_csv=line_counts_csv,
|
||||
@@ -1721,11 +1721,11 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
)
|
||||
)
|
||||
invoice_id_by_number: Dict[str, int] = {}
|
||||
invoice_updated_by_number: Dict[str, bool] = {}
|
||||
invoice_processed_by_number: Dict[str, bool] = {}
|
||||
for num, iid, is_upd in q_inv.all():
|
||||
if num:
|
||||
invoice_id_by_number[str(num).strip()] = iid
|
||||
invoice_updated_by_number[str(num).strip()] = bool(is_upd)
|
||||
invoice_processed_by_number[str(num).strip()] = bool(is_upd)
|
||||
|
||||
existing_line_keys_by_invoice: Dict[str, Set[str]] = {}
|
||||
q_li = (
|
||||
@@ -1890,7 +1890,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
calcular_costo_en_base_a_total=calcular_costo_en_base_a_total,
|
||||
validar_decimales_pza=validar_decimales_pza,
|
||||
invoice_id_by_number=invoice_id_by_number,
|
||||
invoice_updated_by_number=invoice_updated_by_number,
|
||||
invoice_processed_by_number=invoice_processed_by_number,
|
||||
rfc_exception_updated=rfc_exception_updated,
|
||||
existing_line_keys_by_invoice=existing_line_keys_by_invoice,
|
||||
line_counts_csv=line_counts_csv,
|
||||
@@ -1987,12 +1987,12 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
)
|
||||
)
|
||||
invoice_exists_by_number: Dict[str, bool] = {}
|
||||
invoice_updated_by_number: Dict[str, bool] = {}
|
||||
invoice_processed_by_number: Dict[str, bool] = {}
|
||||
for num, iid, is_upd in q_inv.all():
|
||||
if num:
|
||||
n = str(num).strip()
|
||||
invoice_exists_by_number[n] = True
|
||||
invoice_updated_by_number[n] = bool(is_upd)
|
||||
invoice_processed_by_number[n] = bool(is_upd)
|
||||
|
||||
pedimento_data_by_key: Dict[str, List[Dict[str, Any]]] = {}
|
||||
for p in (
|
||||
@@ -2211,7 +2211,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
i,
|
||||
actualizar=actualizar,
|
||||
invoice_exists_by_number=invoice_exists_by_number,
|
||||
invoice_updated_by_number=invoice_updated_by_number,
|
||||
invoice_processed_by_number=invoice_processed_by_number,
|
||||
pedimento_data_by_key=pedimento_data_by_key,
|
||||
remesa_por_pedimento_bd=remesa_por_pedimento_bd,
|
||||
remesa_por_pedimento_csv=remesa_por_pedimento_csv,
|
||||
@@ -2318,12 +2318,12 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
)
|
||||
)
|
||||
invoice_exists_by_number = {}
|
||||
invoice_updated_by_number = {}
|
||||
invoice_processed_by_number = {}
|
||||
for num, iid, is_upd in q_inv.all():
|
||||
if num:
|
||||
n = str(num).strip()
|
||||
invoice_exists_by_number[n] = True
|
||||
invoice_updated_by_number[n] = bool(is_upd)
|
||||
invoice_processed_by_number[n] = bool(is_upd)
|
||||
|
||||
pedimento_data_by_key = {}
|
||||
for p in (
|
||||
@@ -2545,7 +2545,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
i,
|
||||
actualizar=actualizar,
|
||||
invoice_exists_by_number=invoice_exists_by_number,
|
||||
invoice_updated_by_number=invoice_updated_by_number,
|
||||
invoice_processed_by_number=invoice_processed_by_number,
|
||||
pedimento_data_by_key=pedimento_data_by_key,
|
||||
remesa_por_pedimento_bd=remesa_por_pedimento_bd,
|
||||
remesa_por_pedimento_csv=remesa_por_pedimento_csv,
|
||||
@@ -2655,13 +2655,13 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
)
|
||||
)
|
||||
invoice_exists_by_number = {}
|
||||
invoice_updated_by_number = {}
|
||||
invoice_processed_by_number = {}
|
||||
invoice_in_report_by_number = {}
|
||||
for num, iid, is_upd, is_rep in q_inv.all():
|
||||
if num:
|
||||
n = str(num).strip()
|
||||
invoice_exists_by_number[n] = True
|
||||
invoice_updated_by_number[n] = bool(is_upd)
|
||||
invoice_processed_by_number[n] = bool(is_upd)
|
||||
invoice_in_report_by_number[n] = bool(is_rep) if is_rep is not None else False
|
||||
|
||||
if cambio_regimen:
|
||||
@@ -2902,7 +2902,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
cambio_regimen=cambio_regimen,
|
||||
tipo_factura=tipo_factura,
|
||||
invoice_exists_by_number=invoice_exists_by_number,
|
||||
invoice_updated_by_number=invoice_updated_by_number,
|
||||
invoice_processed_by_number=invoice_processed_by_number,
|
||||
invoice_in_report_by_number=invoice_in_report_by_number,
|
||||
pedimento_data_by_key=pedimento_data_by_key,
|
||||
remesa_por_pedimento_bd=remesa_por_pedimento_bd,
|
||||
@@ -2978,12 +2978,12 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
)
|
||||
)
|
||||
invoice_exists_by_number = {}
|
||||
invoice_updated_by_number = {}
|
||||
invoice_processed_by_number = {}
|
||||
for num, iid, is_upd in q_inv.all():
|
||||
if num:
|
||||
n = str(num).strip()
|
||||
invoice_exists_by_number[n] = True
|
||||
invoice_updated_by_number[n] = bool(is_upd)
|
||||
invoice_processed_by_number[n] = bool(is_upd)
|
||||
|
||||
valid_provider_ids = set()
|
||||
valid_sold_to_ids = set()
|
||||
@@ -3093,7 +3093,7 @@ def _do_scan_file(job_id: str, model_target: str, config: Optional[str] = None,
|
||||
i,
|
||||
actualizar=actualizar,
|
||||
invoice_exists_by_number=invoice_exists_by_number,
|
||||
invoice_updated_by_number=invoice_updated_by_number,
|
||||
invoice_processed_by_number=invoice_processed_by_number,
|
||||
valid_provider_ids=valid_provider_ids,
|
||||
valid_sold_to_ids=valid_sold_to_ids,
|
||||
valid_shipped_to_ids=valid_shipped_to_ids,
|
||||
@@ -4018,11 +4018,11 @@ def _do_insert_valid_rows(job_id: str, model_target: str, job_type_override: Opt
|
||||
)
|
||||
rows_inv = q.all()
|
||||
invoice_id_by_number: Dict[str, int] = {}
|
||||
invoice_updated_by_number: Dict[str, bool] = {}
|
||||
invoice_processed_by_number: Dict[str, bool] = {}
|
||||
for num, iid, is_upd in rows_inv:
|
||||
if num:
|
||||
invoice_id_by_number[str(num).strip()] = iid
|
||||
invoice_updated_by_number[str(num).strip()] = bool(is_upd)
|
||||
invoice_processed_by_number[str(num).strip()] = bool(is_upd)
|
||||
|
||||
partida_max_series = {}
|
||||
q_qty = (
|
||||
@@ -4104,7 +4104,7 @@ def _do_insert_valid_rows(job_id: str, model_target: str, job_type_override: Opt
|
||||
autonumerar=autonumerar,
|
||||
validar_series_exception=validar_series_exception,
|
||||
invoice_id_by_number=invoice_id_by_number,
|
||||
invoice_updated_by_number=invoice_updated_by_number,
|
||||
invoice_processed_by_number=invoice_processed_by_number,
|
||||
partida_max_series=partida_max_series,
|
||||
csv_series_count_so_far=csv_series_count_so_far,
|
||||
existing_series_keys=existing_series_keys,
|
||||
@@ -4285,11 +4285,11 @@ def _do_insert_valid_rows(job_id: str, model_target: str, job_type_override: Opt
|
||||
)
|
||||
rows_inv = q.all()
|
||||
invoice_id_by_number: Dict[str, int] = {}
|
||||
invoice_updated_by_number: Dict[str, bool] = {}
|
||||
invoice_processed_by_number: Dict[str, bool] = {}
|
||||
for num, iid, is_upd in rows_inv:
|
||||
if num:
|
||||
invoice_id_by_number[str(num).strip()] = iid
|
||||
invoice_updated_by_number[str(num).strip()] = bool(is_upd)
|
||||
invoice_processed_by_number[str(num).strip()] = bool(is_upd)
|
||||
|
||||
existing_series_keys: Set[Tuple[str, str, str]] = set()
|
||||
existing_series_data: Dict[Tuple[str, str, str], Dict[str, Any]] = {}
|
||||
@@ -4349,7 +4349,7 @@ def _do_insert_valid_rows(job_id: str, model_target: str, job_type_override: Opt
|
||||
autonumerar=autonumerar,
|
||||
validar_series_exception=validar_series_exception,
|
||||
invoice_id_by_number=invoice_id_by_number,
|
||||
invoice_updated_by_number=invoice_updated_by_number,
|
||||
invoice_processed_by_number=invoice_processed_by_number,
|
||||
existing_series_keys=existing_series_keys,
|
||||
existing_series_data=existing_series_data,
|
||||
warnings=None,
|
||||
|
||||
@@ -173,7 +173,7 @@ def validate_row_encabezados_cmex(
|
||||
line_num: int,
|
||||
actualizar: bool,
|
||||
invoice_exists_by_number: Dict[str, bool],
|
||||
invoice_updated_by_number: Dict[str, bool],
|
||||
invoice_processed_by_number: Dict[str, bool],
|
||||
valid_provider_ids: Set[int],
|
||||
valid_sold_to_ids: Set[int],
|
||||
valid_shipped_to_ids: Set[int],
|
||||
@@ -203,7 +203,7 @@ def validate_row_encabezados_cmex(
|
||||
"Error: (Col.C) La columna de Número de Factura está vacía y no se pueden hacer las validaciones.",
|
||||
)
|
||||
|
||||
if invoice_updated_by_number.get(factura.strip(), False):
|
||||
if invoice_processed_by_number.get(factura.strip(), False):
|
||||
return _err(
|
||||
line_num,
|
||||
"NUMERO FACTURA",
|
||||
|
||||
@@ -307,7 +307,7 @@ def validate_row_encabezados_expo(
|
||||
cambio_regimen: bool,
|
||||
tipo_factura: str,
|
||||
invoice_exists_by_number: Dict[str, bool],
|
||||
invoice_updated_by_number: Dict[str, bool],
|
||||
invoice_processed_by_number: Dict[str, bool],
|
||||
remesa_por_pedimento_bd: Dict[str, Set[int]],
|
||||
remesa_por_pedimento_csv: Dict[str, Dict[int, str]],
|
||||
valid_provider_ids: Set[int],
|
||||
@@ -348,7 +348,7 @@ def validate_row_encabezados_expo(
|
||||
"Error: (Col.C) La columna de Número de Factura está vacía y no se pueden hacer las validaciones.",
|
||||
)
|
||||
|
||||
if invoice_updated_by_number.get(factura.strip(), False):
|
||||
if invoice_processed_by_number.get(factura.strip(), False):
|
||||
return _err(
|
||||
line_num,
|
||||
"NUMERO FACTURA",
|
||||
|
||||
@@ -225,7 +225,7 @@ def validate_row_encabezados_impo_def(
|
||||
line_num: int,
|
||||
actualizar: bool,
|
||||
invoice_exists_by_number: Dict[str, bool],
|
||||
invoice_updated_by_number: Dict[str, bool],
|
||||
invoice_processed_by_number: Dict[str, bool],
|
||||
pedimento_data_by_key: Dict[str, List[Dict[str, Any]]],
|
||||
remesa_por_pedimento_bd: Dict[str, Set[int]],
|
||||
remesa_por_pedimento_csv: Dict[str, Dict[int, str]],
|
||||
@@ -266,7 +266,7 @@ def validate_row_encabezados_impo_def(
|
||||
"Error: (Col.C) La columna de Número de Factura está vacía y no se pueden hacer las validaciones.",
|
||||
)
|
||||
|
||||
if invoice_updated_by_number.get(factura.strip(), False):
|
||||
if invoice_processed_by_number.get(factura.strip(), False):
|
||||
return _err(
|
||||
line_num,
|
||||
"NUMERO FACTURA",
|
||||
|
||||
@@ -514,7 +514,7 @@ def validate_row_encabezados_impo_temp(
|
||||
line_num: int,
|
||||
actualizar: bool,
|
||||
invoice_exists_by_number: Dict[str, bool],
|
||||
invoice_updated_by_number: Dict[str, bool],
|
||||
invoice_processed_by_number: Dict[str, bool],
|
||||
pedimento_data_by_key: Dict[str, List[Dict[str, Any]]],
|
||||
remesa_por_pedimento_bd: Dict[str, Set[int]],
|
||||
remesa_por_pedimento_csv: Dict[str, Dict[int, str]],
|
||||
@@ -549,7 +549,7 @@ def validate_row_encabezados_impo_temp(
|
||||
if not factura:
|
||||
return _err(line_num, "NUMERO FACTURA", "Error: (Col.C) La columna de Número de Factura está vacía y no se pueden hacer las validaciones.")
|
||||
|
||||
if invoice_updated_by_number.get(factura.strip(), False):
|
||||
if invoice_processed_by_number.get(factura.strip(), False):
|
||||
return _err(
|
||||
line_num,
|
||||
"NUMERO FACTURA",
|
||||
|
||||
@@ -73,12 +73,12 @@ def _check_factura_expo_existe(
|
||||
def _check_factura_expo_no_actualizada(
|
||||
invoice_number: str,
|
||||
line_num: int,
|
||||
invoice_updated_by_number: Dict[str, bool],
|
||||
invoice_processed_by_number: Dict[str, bool],
|
||||
rfc_exception_updated: Set[str],
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
if invoice_number in rfc_exception_updated:
|
||||
return None
|
||||
if invoice_updated_by_number.get(invoice_number, False):
|
||||
if invoice_processed_by_number.get(invoice_number, False):
|
||||
return _err(
|
||||
line_num,
|
||||
"NUMERO FACTURA EXPO",
|
||||
@@ -453,7 +453,7 @@ def validate_row_partidas_expo(
|
||||
actualizar: bool,
|
||||
levantar_subpartidas: bool,
|
||||
invoice_id_by_number: Dict[str, int],
|
||||
invoice_updated_by_number: Dict[str, bool],
|
||||
invoice_processed_by_number: Dict[str, bool],
|
||||
rfc_exception_updated: Set[str],
|
||||
existing_line_keys_by_invoice: Dict[str, Set[str]],
|
||||
line_counts_csv: Dict[Tuple[str, str], int],
|
||||
@@ -488,7 +488,7 @@ def validate_row_partidas_expo(
|
||||
return err
|
||||
|
||||
err = _check_factura_expo_no_actualizada(
|
||||
factura_expo, line_num, invoice_updated_by_number, rfc_exception_updated
|
||||
factura_expo, line_num, invoice_processed_by_number, rfc_exception_updated
|
||||
)
|
||||
if err:
|
||||
return err
|
||||
|
||||
@@ -52,7 +52,7 @@ def validate_row_partidas_impo_def(
|
||||
calcular_costo_en_base_a_total: bool,
|
||||
validar_decimales_pza: bool,
|
||||
invoice_id_by_number: Dict[str, int],
|
||||
invoice_updated_by_number: Dict[str, bool],
|
||||
invoice_processed_by_number: Dict[str, bool],
|
||||
rfc_exception_updated: Set[str],
|
||||
existing_line_keys_by_invoice: Dict[str, Set[str]],
|
||||
line_counts_csv: Dict[Tuple[str, str], int],
|
||||
@@ -94,7 +94,7 @@ def validate_row_partidas_impo_def(
|
||||
return err
|
||||
|
||||
err = _check_factura_no_actualizada(
|
||||
invoice_number, line_num, invoice_updated_by_number, rfc_exception_updated
|
||||
invoice_number, line_num, invoice_processed_by_number, rfc_exception_updated
|
||||
)
|
||||
if err:
|
||||
return err
|
||||
|
||||
@@ -74,12 +74,12 @@ def _check_factura_existe(
|
||||
def _check_factura_no_actualizada(
|
||||
invoice_number: str,
|
||||
line_num: int,
|
||||
invoice_updated_by_number: Dict[str, bool],
|
||||
invoice_processed_by_number: Dict[str, bool],
|
||||
rfc_exception_updated: Set[str],
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
if invoice_number in rfc_exception_updated:
|
||||
return None
|
||||
if invoice_updated_by_number.get(invoice_number, False):
|
||||
if invoice_processed_by_number.get(invoice_number, False):
|
||||
return {
|
||||
"line": line_num,
|
||||
"col": "NUMERO FACTURA",
|
||||
@@ -398,7 +398,7 @@ def validate_row_partidas_impo_temp(
|
||||
calcular_costo_en_base_a_total: bool,
|
||||
validar_decimales_pza: bool,
|
||||
invoice_id_by_number: Dict[str, int],
|
||||
invoice_updated_by_number: Dict[str, bool],
|
||||
invoice_processed_by_number: Dict[str, bool],
|
||||
rfc_exception_updated: Set[str],
|
||||
existing_line_keys_by_invoice: Dict[str, Set[str]],
|
||||
line_counts_csv: Dict[Tuple[str, str], int],
|
||||
@@ -438,7 +438,7 @@ def validate_row_partidas_impo_temp(
|
||||
return err
|
||||
|
||||
err = _check_factura_no_actualizada(
|
||||
invoice_number, line_num, invoice_updated_by_number, rfc_exception_updated
|
||||
invoice_number, line_num, invoice_processed_by_number, rfc_exception_updated
|
||||
)
|
||||
if err:
|
||||
return err
|
||||
|
||||
@@ -68,13 +68,13 @@ def _check_factura_existe_expo(
|
||||
def _check_factura_no_actualizada_expo(
|
||||
invoice_number: str,
|
||||
line_num: int,
|
||||
invoice_updated_by_number: Dict[str, bool],
|
||||
invoice_processed_by_number: Dict[str, bool],
|
||||
rfc_exception_updated: Set[str],
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""Si factura ya actualizada (Estatus AC) no se pueden hacer cambios; excepción por RFC (ej. EGM0303257J1)."""
|
||||
if invoice_number in rfc_exception_updated:
|
||||
return None
|
||||
if invoice_updated_by_number.get(invoice_number, False):
|
||||
if invoice_processed_by_number.get(invoice_number, False):
|
||||
return {
|
||||
"line": line_num,
|
||||
"col": "NUMERO FACTURA",
|
||||
@@ -175,7 +175,7 @@ def validate_row_series_expo(
|
||||
autonumerar: bool,
|
||||
validar_series_exception: bool,
|
||||
invoice_id_by_number: Dict[str, int],
|
||||
invoice_updated_by_number: Dict[str, bool],
|
||||
invoice_processed_by_number: Dict[str, bool],
|
||||
rfc_exception_updated: Set[str],
|
||||
partida_max_series: Dict[Tuple[str, str], int],
|
||||
csv_series_count_so_far: Dict[Tuple[str, str], int],
|
||||
@@ -207,7 +207,7 @@ def validate_row_series_expo(
|
||||
return err
|
||||
|
||||
err = _check_factura_no_actualizada_expo(
|
||||
invoice_number, line_num, invoice_updated_by_number, rfc_exception_updated
|
||||
invoice_number, line_num, invoice_processed_by_number, rfc_exception_updated
|
||||
)
|
||||
if err:
|
||||
return err
|
||||
|
||||
@@ -47,11 +47,11 @@ def _check_factura_existe_def(
|
||||
def _check_factura_no_actualizada_def(
|
||||
invoice_number: str,
|
||||
line_num: int,
|
||||
invoice_updated_by_number: Dict[str, bool],
|
||||
invoice_processed_by_number: Dict[str, bool],
|
||||
catalog_label: str = "Importación Definitiva",
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""Si factura ya actualizada (Estatus AC) no se pueden hacer cambios. Mensaje según catalog_label."""
|
||||
if invoice_updated_by_number.get(invoice_number, False):
|
||||
if invoice_processed_by_number.get(invoice_number, False):
|
||||
return {
|
||||
"line": line_num,
|
||||
"col": "NUMERO FACTURA",
|
||||
@@ -220,7 +220,7 @@ def validate_row_series_impo_def(
|
||||
autonumerar: bool,
|
||||
validar_series_exception: bool,
|
||||
invoice_id_by_number: Dict[str, int],
|
||||
invoice_updated_by_number: Dict[str, bool],
|
||||
invoice_processed_by_number: Dict[str, bool],
|
||||
partida_max_series: Dict[Tuple[str, str], int],
|
||||
csv_series_count_so_far: Dict[Tuple[str, str], int],
|
||||
existing_series_keys: Set[Tuple[str, str, str]],
|
||||
@@ -250,7 +250,7 @@ def validate_row_series_impo_def(
|
||||
if err:
|
||||
return err
|
||||
|
||||
err = _check_factura_no_actualizada_def(invoice_number, line_num, invoice_updated_by_number, catalog_label)
|
||||
err = _check_factura_no_actualizada_def(invoice_number, line_num, invoice_processed_by_number, catalog_label)
|
||||
if err:
|
||||
return err
|
||||
|
||||
|
||||
@@ -77,10 +77,10 @@ def _check_factura_existe(
|
||||
def _check_factura_no_actualizada(
|
||||
invoice_number: str,
|
||||
line_num: int,
|
||||
invoice_updated_by_number: Dict[str, bool],
|
||||
invoice_processed_by_number: Dict[str, bool],
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""Si factura ya actualizada (Estatus AC) no se pueden hacer cambios."""
|
||||
if invoice_updated_by_number.get(invoice_number, False):
|
||||
if invoice_processed_by_number.get(invoice_number, False):
|
||||
return {
|
||||
"line": line_num,
|
||||
"col": "NUMERO FACTURA",
|
||||
@@ -261,7 +261,7 @@ def validate_row_series_impo_temp(
|
||||
autonumerar: bool,
|
||||
validar_series_exception: bool,
|
||||
invoice_id_by_number: Dict[str, int],
|
||||
invoice_updated_by_number: Dict[str, bool],
|
||||
invoice_processed_by_number: Dict[str, bool],
|
||||
existing_series_keys: Set[Tuple[str, str, str]],
|
||||
existing_series_data: Optional[Dict[Tuple[str, str, str], Dict[str, Any]]],
|
||||
warnings: Optional[List[Dict[str, Any]]] = None,
|
||||
@@ -290,7 +290,7 @@ def validate_row_series_impo_temp(
|
||||
return err
|
||||
|
||||
# Factura no actualizada
|
||||
err = _check_factura_no_actualizada(invoice_number, line_num, invoice_updated_by_number)
|
||||
err = _check_factura_no_actualizada(invoice_number, line_num, invoice_processed_by_number)
|
||||
if err:
|
||||
return err
|
||||
|
||||
|
||||
Reference in New Issue
Block a user