[update]: Loan Charge model
This commit is contained in:
@@ -33,6 +33,11 @@ class ProvideLoanService(BaseService):
|
|||||||
request_id = validated_data.get('requestId')
|
request_id = validated_data.get('requestId')
|
||||||
collection_type = validated_data.get('collectionType')
|
collection_type = validated_data.get('collectionType')
|
||||||
transaction_id = validated_data.get('transactionId')
|
transaction_id = validated_data.get('transactionId')
|
||||||
|
offer_id = validated_data.get('offerId')
|
||||||
|
product_id = validated_data.get('productrId')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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)):
|
||||||
|
|
||||||
@@ -50,7 +55,8 @@ class ProvideLoanService(BaseService):
|
|||||||
loan = Loan.create_loan(
|
loan = Loan.create_loan(
|
||||||
customer_id = customer_id,
|
customer_id = customer_id,
|
||||||
account_id = account_id,
|
account_id = account_id,
|
||||||
offer_id = validated_data.get('offerId'),
|
offer_id = offer_id,
|
||||||
|
product_id = product_id,
|
||||||
collection_type = collection_type,
|
collection_type = collection_type,
|
||||||
transaction_id = validated_data.get('transactionId'),
|
transaction_id = validated_data.get('transactionId'),
|
||||||
initial_loan_amount = validated_data.get('requestedAmount'),
|
initial_loan_amount = validated_data.get('requestedAmount'),
|
||||||
|
|||||||
+2
-1
@@ -19,6 +19,7 @@ class Loan(db.Model):
|
|||||||
transaction_id = db.Column(db.String(50), nullable=True)
|
transaction_id = db.Column(db.String(50), nullable=True)
|
||||||
account_id = db.Column(db.String(50), nullable=False)
|
account_id = db.Column(db.String(50), nullable=False)
|
||||||
offer_id = db.Column(db.String(20), nullable=False)
|
offer_id = db.Column(db.String(20), nullable=False)
|
||||||
|
product_id = db.Column(db.String(20), nullable=False)
|
||||||
collection_type = db.Column(db.String(20), nullable=True)
|
collection_type = db.Column(db.String(20), nullable=True)
|
||||||
current_loan_amount = db.Column(db.Float, nullable=True)
|
current_loan_amount = db.Column(db.Float, nullable=True)
|
||||||
initial_loan_amount = db.Column(db.Float, nullable=False)
|
initial_loan_amount = db.Column(db.Float, nullable=False)
|
||||||
@@ -44,7 +45,7 @@ class Loan(db.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_loan(cls, customer_id, account_id, offer_id, initial_loan_amount, collection_type, transaction_id, status='pending'):
|
def create_loan(cls, customer_id, account_id, offer_id, product_id, initial_loan_amount, collection_type, transaction_id, status='pending'):
|
||||||
|
|
||||||
# Check if customer exists
|
# Check if customer exists
|
||||||
is_valid = Customer.is_valid_customer(customer_id)
|
is_valid = Customer.is_valid_customer(customer_id)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class LoanCharge(db.Model):
|
|||||||
amount = db.Column(db.Float, default=0.0)
|
amount = db.Column(db.Float, default=0.0)
|
||||||
percent = db.Column(db.Float, default=0.0)
|
percent = db.Column(db.Float, default=0.0)
|
||||||
description = db.Column(db.Text, nullable=True)
|
description = db.Column(db.Text, nullable=True)
|
||||||
due_date = db.Column(db.DateTime, nullable=False)
|
due = db.Column(db.Integer, nullable=False)
|
||||||
created_at = db.Column(db.DateTime, default=datetime.now(timezone.utc))
|
created_at = db.Column(db.DateTime, default=datetime.now(timezone.utc))
|
||||||
updated_at = db.Column(db.DateTime, default=datetime.now(timezone.utc), onupdate=datetime.now(timezone.utc))
|
updated_at = db.Column(db.DateTime, default=datetime.now(timezone.utc), onupdate=datetime.now(timezone.utc))
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ class LoanCharge(db.Model):
|
|||||||
'amount': self.amount,
|
'amount': self.amount,
|
||||||
'percent': self.percent,
|
'percent': self.percent,
|
||||||
'description': self.description,
|
'description': self.description,
|
||||||
'dueDate': self.due_date.isoformat() if self.due_date else None,
|
'due': self.due,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user