[fix]: Max daily loan count
This commit was merged in pull request #46.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
from flask import session, jsonify
|
||||
from app.models.loan import Loan
|
||||
from app.models.transaction_offers import TransactionOffer
|
||||
from app.utils.logger import logger
|
||||
from app.api.services.base_service import BaseService
|
||||
from app.api.schemas.eligibility_check import EligibilityCheckSchema
|
||||
@@ -187,10 +186,10 @@ class EligibilityCheckService(BaseService):
|
||||
logger.error(f"Offer not found for offer_id: {offer_id} (customer_id: {customer_id})")
|
||||
return False
|
||||
|
||||
daily_count = TransactionOffer.get_daily_loan_count(customer_id, offer_id)
|
||||
daily_count = Loan.get_daily_loan_count(customer_id, offer.product_id)
|
||||
|
||||
|
||||
logger.error(f"daily_count: {daily_count}, Max: {offer.max_daily_loans}")
|
||||
logger.info(f"daily_count: {daily_count}, Max: {offer.max_daily_loans}")
|
||||
|
||||
if offer.max_daily_loans is not None and daily_count >= offer.max_daily_loans:
|
||||
return False
|
||||
|
||||
@@ -60,8 +60,10 @@ class SelectOfferService(BaseService):
|
||||
db.session.flush()
|
||||
|
||||
if amount < offer.min_amount:
|
||||
logger.error(f"The amount {amount} is less than the minimum allowed offer amount {offer.min_amount}.")
|
||||
return ResponseHelper.error(result_description="The amount is less than the minimum allowed offer amount.")
|
||||
elif amount > offer.max_amount:
|
||||
logger.error(f"The amount {amount} is greater than the minimum allowed offer amount {offer.min_amount}.")
|
||||
return ResponseHelper.error(result_description="The amount is greater than the maximum allowed offer amount.")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user