transaction offer
This commit is contained in:
@@ -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
|
||||
from app.models import Loan, Offer, Charge , TransactionOffer
|
||||
from app.api.enums import LoanStatus
|
||||
from app.extensions import db
|
||||
from datetime import datetime, timezone
|
||||
@@ -47,7 +47,15 @@ class ProvideLoanService(BaseService):
|
||||
|
||||
if (ProvideLoanService.validate_account_ownership(account_id = account_id, customer_id = customer_id)):
|
||||
|
||||
offer = Offer.is_valid_offer(offer_id)
|
||||
transaction_offer = TransactionOffer.is_valid_transaction_offer(offer_id = offer_id)
|
||||
if not transaction_offer:
|
||||
logger.error(f"Invalid Transaction Offer")
|
||||
return jsonify({
|
||||
"message": "Invalid Transaction Offer."
|
||||
}), 400
|
||||
|
||||
eligible_amount = transaction_offer.eligible_amount
|
||||
offer = Offer.is_valid_offer( transaction_offer.offer_id)
|
||||
|
||||
if not offer:
|
||||
logger.error(f"Invalid Offer")
|
||||
|
||||
@@ -32,6 +32,7 @@ class SelectOfferService(BaseService):
|
||||
customer_id = validated_data.get("customerId")
|
||||
amount = validated_data.get("requestedAmount")
|
||||
product_id = validated_data.get("productId")
|
||||
offer_id = validated_data.get("offerId")
|
||||
transaction_id = validated_data.get("transactionId")
|
||||
request_id = validated_data.get("requestId")
|
||||
|
||||
|
||||
@@ -25,6 +25,13 @@ class TransactionOffer(db.Model):
|
||||
back_populates="transaction_offers",
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def is_valid_transaction_offer(cls, offer_id):
|
||||
offer = cls.query.filter_by(id=str(offer_id)).first()
|
||||
|
||||
if not offer:
|
||||
return False
|
||||
return offer
|
||||
|
||||
@classmethod
|
||||
def create_transaction_offer(cls, customer_id, transaction_id, offer_id, min_amount, max_amount, eligible_amount=None, product_id=None, tenor=None):
|
||||
|
||||
Reference in New Issue
Block a user