[fix]: Loan min amount check #35

Merged
ameye merged 1 commits from loan_min_amount into master 2025-05-21 14:58:49 +00:00
3 changed files with 12 additions and 0 deletions
+4
View File
@@ -63,6 +63,10 @@ class OfferAnalysis:
logger.info(f"sum_active_loans === > {sum_active_loans}")
real_eligible_amount = original_loan.eligible_amount - sum_active_loans
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.")
transaction_offer = TransactionOffer.create_transaction_offer(
customer_id=customer_id,
transaction_id=transaction_id,
+4
View File
@@ -60,6 +60,10 @@ class ProvideLoanService(BaseService):
except ValueError as ve:
logger.error(str(ve))
return ResponseHelper.error(result_description=str(ve))
if(amount < transaction_offer.min_amount):
return ResponseHelper.error(result_description="The amount is less than the minimum allowed transaction amount.")
# transaction_offer_id = int(offer_id[5:]) # The last part is int
+4
View File
@@ -59,6 +59,10 @@ class SelectOfferService(BaseService):
db.session.flush()
if(amount < offer.min_amount):
return ResponseHelper.error(result_description="The amount is less than the minimum allowed offer amount.")
charges = SelectOfferService.calculate_charges(offer, amount)
upfront_payment = charges["upfront_payment"]
total_amount = charges["total_amount"]