Se deshabilito la creacion de facturas de exportacion
This commit is contained in:
@@ -112,27 +112,20 @@ def validate_common(
|
||||
return # Stop here if pedimento not found
|
||||
|
||||
if not invoice.compliance_mx.is_regime_change:
|
||||
# Validar que el tipo de operación del pedimento coincida con el de la factura
|
||||
# Nota: Para UPDATES, operation_type puede ser None. En ese caso usamos el del pedimento (asumimos que es correcto)
|
||||
# o podríamos buscarlo en existing_invoice si tuviéramos acceso aquí.
|
||||
current_operation = invoice.operation_type or pedimento.operation_type
|
||||
|
||||
if pedimento.operation_type != current_operation:
|
||||
operation_labels = {"imp": "Importación", "exp": "Exportación"}
|
||||
expected_label = operation_labels.get(current_operation, current_operation)
|
||||
# Validar que el pedimento sea de importación (hardcoded restriction)
|
||||
if pedimento.operation_type != "imp":
|
||||
errors.add_error(
|
||||
field="compliance_mx.pedimento_id",
|
||||
message=f"El Pedimento seleccionado no corresponde a una {expected_label}.",
|
||||
solution=[f"Selecciona un Pedimento de {expected_label}"],
|
||||
message="El Pedimento seleccionado no corresponde a una Importación.",
|
||||
solution=["Selecciona un Pedimento de Importación"],
|
||||
code="INVALID_OPERATION_TYPE",
|
||||
value=pedimento.operation_type,
|
||||
)
|
||||
else:
|
||||
# Validar regímenes incompatibles
|
||||
export_only_regimes = ["EXD", "ETE", "ETR"]
|
||||
import_only_regimes = ["IMD"] # Usualmente IMD es solo importación definitiva
|
||||
|
||||
if current_operation == "imp" and pedimento.regime in export_only_regimes:
|
||||
if pedimento.regime in export_only_regimes:
|
||||
errors.add_error(
|
||||
field="compliance_mx.pedimento_id",
|
||||
message="El Pedimento seleccionado corresponde a una Exportación, no a una Importación.",
|
||||
@@ -140,14 +133,6 @@ def validate_common(
|
||||
code="INVALID_REGIME",
|
||||
value=pedimento.regime,
|
||||
)
|
||||
elif current_operation == "exp" and pedimento.regime in import_only_regimes:
|
||||
errors.add_error(
|
||||
field="compliance_mx.pedimento_id",
|
||||
message="El Pedimento seleccionado corresponde a una Importación, no a una Exportación.",
|
||||
solution=["Selecciona un Pedimento de Exportación"],
|
||||
code="INVALID_REGIME",
|
||||
value=pedimento.regime,
|
||||
)
|
||||
|
||||
# Validar que el tipo de documento coincida con el régimen del pedimento
|
||||
# NOTA: Solo validamos si no hay errores previos y si document_type está presente
|
||||
|
||||
Reference in New Issue
Block a user