diff --git a/app/config.py b/app/config.py index 5845270..5c67b11 100644 --- a/app/config.py +++ b/app/config.py @@ -43,6 +43,7 @@ class Config: # SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{DATABASE_USER}:{DATABASE_PASSWORD}@{DATABASE_HOST}:{DATABASE_PORT}/{DATABASE_NAME}" SQLALCHEMY_TRACK_MODIFICATIONS = False # SQLALCHEMY_ECHO = True + OVERRIDE_COLLECTION_TRANCATION_ID = int(os.getenv("OVERRIDE_COLLECTION_TRANCATION_ID", 100)) MAIL_SERVER = os.getenv('MAIL_SERVER','smtp.zoho.com') @@ -60,7 +61,7 @@ class Config: BANK_CALL_COLLECT_LOAN_ENDPOINT = os.getenv("BANK_CALL_COLLECT_LOAN_ENDPOINT","/CollectLoan") BANK_CALL_TRANSACTION_VERIFY = os.getenv("BANK_CALL_TRANSACTION_VERIFY", "/TransactionVerify") BANK_HEALTH_CHECK_ENDPOINT = os.getenv("BANK_HEALTH_CHECK_ENDPOINT", "/system-health-check") - BANK_CALL_AUTH_ENDPOINT = os.getenv("BANK_CALL_AUTH_ENDPOINT", "/api/Auth/generate-token") + BANK_CALL_AUTH_ENDPOINT = os.getenv("BANK_CALL_AUTH_ENDPOINT", "/Auth/generate-token") BANK_GRANT_TYPE = os.getenv("BANK_GRANT_TYPE", "password") TEST_NO = os.getenv("TEST_NO", "2347038224367") diff --git a/app/helpers/collect_loan_helper.py b/app/helpers/collect_loan_helper.py index 7a1e603..369d4b2 100644 --- a/app/helpers/collect_loan_helper.py +++ b/app/helpers/collect_loan_helper.py @@ -4,9 +4,9 @@ from app.services.repayment import RepaymentService from app.services.loan import LoanService from app.helpers.response_helper import ResponseHelper from app.utils.logger import logger -from decimal import Decimal, ROUND_HALF_UP -from app.services.loan_repayment_schedule import LoanRepaymentScheduleService -from app.enums.loan_status import LoanStatus +from app.config import settings + +OVERRIDE_COLLECTION_TRANCATION_ID = settings.OVERRIDE_COLLECTION_TRANCATION_ID class CollectLoanHelper: @staticmethod @@ -27,9 +27,13 @@ class CollectLoanHelper: @staticmethod def _build_collect_loan_payload(loan_data, repayment_data, data, collectionMethod): - debtId = str(loan_data.get('debtId', "")).strip().zfill(6) - t_id = ''.join(random.choices(string.ascii_uppercase, k=22)) + logger.info(f"building CollectLoan endpoint with data: {loan_data}") + debtId = str(loan_data.get('debtId', "")).strip().zfill(6) + #this can be overridden based on config + t_id = ''.join(random.choices(string.ascii_uppercase, k=22)) + if OVERRIDE_COLLECTION_TRANCATION_ID == 100: + t_id = loan_data['transactionId'] return { "transactionId": t_id, "fbnTransactionId": loan_data['transactionId'], diff --git a/app/integrations/simbrella.py b/app/integrations/simbrella.py index 6d701bb..9a6a162 100644 --- a/app/integrations/simbrella.py +++ b/app/integrations/simbrella.py @@ -18,9 +18,8 @@ from app.services.salary import SalaryService from app.enums.loan_status import LoanStatus from app.models.loan_repayment_schedule import LoanRepaymentSchedule from decimal import Decimal, ROUND_HALF_UP -from requests.exceptions import SSLError, RequestException,Timeout +from requests.exceptions import SSLError, RequestException,Timeout,ReadTimeout, ConnectTimeout import sys -from requests.exceptions import ReadTimeout, ConnectTimeout import socket from app.helpers.collect_loan_helper import CollectLoanHelper diff --git a/app/utils/auth.py b/app/utils/auth.py index 6401cbb..34ed4fd 100644 --- a/app/utils/auth.py +++ b/app/utils/auth.py @@ -41,7 +41,7 @@ def get_headers(): except requests.exceptions.RequestException as e: logger.error(f"Failed to get auth token: {e}") - return {"error": "Authentication request failed"} + raise except ValueError as e: logger.error(f"Failed to parse auth response JSON: {e}") - return {"error": "Invalid authentication response"} + raise