Compare commits

..

1 Commits

Author SHA1 Message Date
VivianDee e5b2d6e7b6 Update provide_loan.py 2025-11-11 07:15:21 +01:00
3 changed files with 11 additions and 12 deletions
+2 -7
View File
@@ -180,7 +180,7 @@ class OfferAnalysis:
if real_eligible_amount < original_transaction_offer.min_amount:
logger.error(f"Max eligible amount ({real_eligible_amount}) is less than the minimum offer amount ({original_transaction_offer.min_amount}).")
raise ValueError("You are not eligible for a loan at this time - Minimum amount not met.")
raise ValueError("You are not eligible for a loan at this time.")
# if real_eligible_amount < 100:
# logger.error(f"Max eligible amount ({real_eligible_amount}) is less than the minimum offer amount ({original_transaction_offer.min_amount}).")
@@ -225,8 +225,7 @@ class OfferAnalysis:
if approved_amount < offer.min_amount:
logger.error(f"Max eligible amount ({approved_amount}) is less than the minimum offer amount ({offer.min_amount}).")
continue
# raise ValueError("You are not eligible for a loan at this time.")
raise ValueError("You are not eligible for a loan at this time.")
# if approved_amount < 100:
# logger.error(f"Max eligible amount ({approved_amount}) is less than the minimum offer amount ({offer.min_amount}).")
@@ -256,8 +255,4 @@ class OfferAnalysis:
"tenor": offer.tenor
})
if not eligible_offers:
logger.error("No eligible offers found for customer: {customer_id} - Minimum amount not met")
raise ValueError("You are not eligible for a loan at this time - Minimum amount not met")
return eligible_offers
+6 -2
View File
@@ -18,6 +18,7 @@ from app.api.integrations import EventServiceIntegration
from app.models import LoanRepaymentSchedule
from app.api.services.offer_analysis import OfferAnalysis
from app.api.helpers.response_helper import ResponseHelper
from datetime import datetime
class ProvideLoanService(BaseService):
TRANSACTION_TYPE = TransactionType.PROVIDE_LOAN
@@ -113,9 +114,12 @@ class ProvideLoanService(BaseService):
management = charges["management"]
insurance = charges["insurance"]
vat = charges["vat"]
# Generate Loan Reference
loan_ref = f"SIM{datetime.now().strftime('%Y%m%d%H%M%S%f')}"
padded_id = str(transaction_id).zfill(12)
loan_ref = f"{padded_id}{channel}{offer.product_id}"
# padded_id = str(transaction_id).zfill(12)
# loan_ref = f"{padded_id}{channel}{offer.product_id}"
# Save the loan details
+3 -3
View File
@@ -47,11 +47,11 @@ class Customer(db.Model):
@classmethod
def create_customer(cls, id, msisdn, country_code, account_id, account_type='savings'):
if cls.query.filter_by(id=id).first():
raise ValueError("Customer ID '{id}' already exists.")
raise ValueError("Customer already exists")
elif Account.query.filter_by(id=account_id).first():
raise ValueError(f"Account ID '{account_id}' already exists.")
raise ValueError("Account already exists")
elif cls.query.filter_by(msisdn=msisdn).first():
raise ValueError("MSISDN '{msisdn}' already exists")
raise ValueError("msisdn already exists")
# Create the customer
customer = cls(