[add]: offer analysis

This commit is contained in:
VivianDee
2025-05-06 07:09:36 +01:00
parent 4c4ef909c2
commit 74066bae56
3 changed files with 41 additions and 10 deletions
+9 -2
View File
@@ -7,7 +7,7 @@ from marshmallow import ValidationError
from app.api.enums import TransactionType
from app.api.integrations import SimbrellaIntegration
from app.extensions import db
from app.models import Offer
from app.models import Offer, RACCheck
import random
@@ -57,12 +57,19 @@ class EligibilityCheckService(BaseService):
response = SimbrellaIntegration.rac_check(
customer_id = customer_id,
account_id = account_id,
transaction_id = transaction.id,
transaction_id = transaction.transaction_id,
)
# this chck for error is not valid
if response.status_code != 200:
return jsonify({"message": "RACCheck failed"}), 400
RACCheck.add_rac_check(
customer_id = customer_id,
account_id = account_id,
transaction_id = transaction.transaction_id,
data = response.data
)
offers = Offer.get_all_offers()
+6 -3
View File
@@ -8,7 +8,7 @@ from app.models.loan_charge import LoanCharge
from app.utils.logger import logger
from app.api.schemas.provide_loan import ProvideLoanSchema
from threading import Thread
from app.models import Loan, Offer, Charge , TransactionOffer
from app.models import Loan, Offer, Charge , TransactionOffer, RACCheck
from app.api.enums import LoanStatus
from app.extensions import db
from datetime import datetime, timezone
@@ -46,11 +46,14 @@ class ProvideLoanService(BaseService):
customer = Customer.is_valid_customer(customer_id)
if (ProvideLoanService.validate_account_ownership(account_id = account_id, customer_id = customer_id)):
if (ProvideLoanService.validate_account_ownership(account_id = account_id, customer_id = customer_id)):
rac_response = RACCheck.get_rac_check(customer_id = customer_id, account_id = account_id)
try:
transaction_offer, offer, eligible_amount = OfferAnalysis.get_offer(
transaction_id=transaction_id,
rac_response=None,
rac_response=rac_response,
validated_data=validated_data
)
except ValueError as ve: