Skip to content

Commit

Permalink
Merge pull request #52 from guivaloz/guivaloz/no-definido
Browse files Browse the repository at this point in the history
Cuando el area no esta definida se manda nulo
  • Loading branch information
guivaloz authored Feb 26, 2025
2 parents 69e440d + a258b9b commit 22fc323
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
24 changes: 20 additions & 4 deletions pjecz_carina_api_key/routers/exh_exhortos.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@
exh_exhortos = APIRouter(prefix="/api/v5/exh_exhortos")


def get_autoridad_with_clave_nd(database: Annotated[Session, Depends(get_db)]) -> Autoridad:
"""Consultar la autoridad con clave ND"""
try:
return database.query(Autoridad).filter_by(clave="ND").one()
except (MultipleResultsFound, NoResultFound) as error:
raise MyAnyError("No existe la autoridad con clave ND") from error


def get_exh_area_with_clave_nd(database: Annotated[Session, Depends(get_db)]) -> ExhArea:
"""Consultar el área con clave ND"""
try:
return database.query(ExhArea).filter_by(clave="ND").one()
except (MultipleResultsFound, NoResultFound) as error:
raise MyAnyError("No existe el área con clave ND") from error


def get_exhorto_with_exhorto_origen_id(database: Annotated[Session, Depends(get_db)], exhorto_origen_id: str) -> ExhExhorto:
"""Consultar un exhorto con su exhorto_origen_id"""

Expand Down Expand Up @@ -460,11 +476,11 @@ async def recibir_exhorto_request(
# GUID/UUID... que sea único. Va a ser generado cuando se vaya a regresar el acuse con el último archivo.
folio_seguimiento = ""

# Área de recepción, 1 = NO DEFINIDO
exh_area = database.query(ExhArea).filter_by(clave="ND").first()
# Área de recepción, es NO DEFINIDO
exh_area = get_exh_area_with_clave_nd(database)

# Juzgado/Área al que se turna el Exhorto, por defecto ND
autoridad = database.query(Autoridad).filter_by(clave="ND").first()
# Juzgado/Área al que se turna el Exhorto, es NO DEFINIDO
autoridad = get_autoridad_with_clave_nd(database)

# Insertar el exhorto
exh_exhorto = ExhExhorto(
Expand Down
4 changes: 2 additions & 2 deletions pjecz_carina_api_key/routers/exh_exhortos_archivos.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ async def recibir_exhorto_archivo_request(
exh_exhorto.folio_seguimiento = generar_identificador()
exh_exhorto.respuesta_fecha_hora_recepcion = fecha_hora_recepcion
exh_exhorto.respuesta_municipio_turnado_id = 30 # Saltillo
exh_exhorto.respuesta_area_turnado_id = "ND"
exh_exhorto.respuesta_area_turnado_nombre = "NO DEFINIDO"
exh_exhorto.respuesta_area_turnado_id = None # Como el área NO esta definida se responde con nulo
exh_exhorto.respuesta_area_turnado_nombre = None # Como el área NO esta definida se responde con nulo
database.add(exh_exhorto)
database.commit()
# Y se va a elaborar el acuse
Expand Down

0 comments on commit 22fc323

Please sign in to comment.