diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f2d39a8f..fbad3e54 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,6 @@ repos: rev: v0.6.9 hooks: - id: ruff - args: [ --fix ] - id: ruff-format - repo: https://github.com/astral-sh/uv-pre-commit rev: 0.4.18 diff --git a/app/routers/applications.py b/app/routers/applications.py index c8a45eb9..d110a91a 100644 --- a/app/routers/applications.py +++ b/app/routers/applications.py @@ -96,23 +96,30 @@ async def approve_application( :return: The approved application with its associated relations. """ with rollback_on_error(session): - # Check if all keys present in an instance of UpdateDataField exist and have truthy values in - # the application's `secop_data_verification`. - app_secop_dict = application.secop_data_verification.copy() - fields = list(parsers.UpdateDataField().model_dump().keys()) - not_validated_fields = [key for key in fields if key not in app_secop_dict or not app_secop_dict[key]] - if not_validated_fields: - raise HTTPException( - status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, - detail=_("Some borrower data field are not verified"), - ) + # If the lender has an external onboarding system the fields and documents verification is not required- + if not application.lender.external_onboarding_url: + # Check if all keys present in an instance of UpdateDataField exist and have truthy values in + # the application's `secop_data_verification`. + app_secop_dict = application.secop_data_verification.copy() + fields = list(parsers.UpdateDataField().model_dump().keys()) + not_validated_fields = [key for key in fields if key not in app_secop_dict or not app_secop_dict[key]] + if not_validated_fields: + raise HTTPException( + status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + detail=_("Some borrower data field are not verified"), + ) - # Check all documents are verified. - not_validated_documents = [doc.type for doc in application.borrower_documents if not doc.verified] - if not_validated_documents: + # Check all documents are verified. + not_validated_documents = [doc.type for doc in application.borrower_documents if not doc.verified] + if not_validated_documents: + raise HTTPException( + status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + detail=_("Some documents are not verified"), + ) + if not payload.disbursed_final_amount: raise HTTPException( status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, - detail=_("Some documents are not verified"), + detail=_("The disbursed final amount information is required for approving the application"), ) # Approve the application. @@ -460,6 +467,14 @@ async def email_borrower( :raises HTTPException: If there's an error in sending the email to the borrower. """ with rollback_on_error(session): + if application.lender.external_onboarding_url: + raise HTTPException( + status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + detail=_( + "The lender has an external onboarding system so no information can be requested from the " + "borrower through Credere" + ), + ) application.status = models.ApplicationStatus.INFORMATION_REQUESTED application.information_requested_at = datetime.now(application.created_at.tzinfo) application.pending_documents = True diff --git a/email_templates/test.html b/email_templates/test.html deleted file mode 100644 index e7e22a66..00000000 --- a/email_templates/test.html +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - Oportunidad de acceso a crédito por ser adjudicatario de contrato - estatal - - - -
- -
- -
- -
La aplicación ha sido completada
-
-

Hola, {{AWARD_SUPPLIER_NAME}},

-
-
- {{LENDER_NAME}} -

Tu solicitud de crédito fue recibida por la institución financiera

-
-
-

- ¿Cuál es el último paso? -

-
-
-

- La insitución financiera que escogiste require de un proceso de onboarding en sus sistemas, por favor completa el último paso completando el proceso de formalización con {{LENDER_NAME}} haciendo click en el siguiente botón. -

-
-
-
- - Finalizar mi aplicación con {{LENDER_NAME}} - -
-
- -
-

- Apenas completes tu aplicación a través de este botón 👆, la institución financiera será informada y se comunicará contigo a la mayor brevedad posible. -

-
-
-

- Muchas gracias por confiar en Credere. -

-
-
- - -
-
-
- - - - - -
-
- Con el apoyo de -
-
- -
-
- Esta herramienta está financiada por Strive Community, una iniciativa - filantrópica global lanzada por el Centro para el crecimiento inclusivo - de Mastercard y Caribou Digital, cuyo objetivo es apoyar a 5 millones de - pequeñas empresas en todo el mundo para desarrollar resiliencia y - crecer. -
- - - - - - -
- - - - - - - - - - - -
-

- Copyright 2023 Open Contracting Partnership. All rights reserved. -

-
- -