Loan repayment fix & save loan details #5
@@ -43,10 +43,9 @@ class ProvideLoanService(BaseService):
|
||||
}), 400
|
||||
|
||||
# Save the loan details
|
||||
loan_id = f"loan_{transaction.id}"
|
||||
loan_id = f"loan_{transaction_id}"
|
||||
|
||||
loan = Loan.create_loan(
|
||||
id=loan_id,
|
||||
customer_id=customer_id,
|
||||
account_id=account_id,
|
||||
offer_id=validated_data.get('offerId'),
|
||||
|
||||
+6
-3
@@ -7,7 +7,11 @@ from app.models.account import Account
|
||||
class Loan(db.Model):
|
||||
__tablename__ = 'loans'
|
||||
|
||||
id = db.Column(db.String(50), primary_key=True)
|
||||
id = db.Column(
|
||||
db.Integer,
|
||||
primary_key=True,
|
||||
autoincrement=True,
|
||||
)
|
||||
customer_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)
|
||||
@@ -18,7 +22,7 @@ class Loan(db.Model):
|
||||
|
||||
|
||||
@classmethod
|
||||
def create_loan(cls, id, customer_id, account_id, offer_id, principal_amount, status='pending'):
|
||||
def create_loan(cls, customer_id, account_id, offer_id, principal_amount, status='pending'):
|
||||
|
||||
# Check if customer exists
|
||||
is_valid = Customer.is_valid_customer(customer_id)
|
||||
@@ -33,7 +37,6 @@ class Loan(db.Model):
|
||||
|
||||
# Create and save the loan
|
||||
loan = cls(
|
||||
id=id,
|
||||
customer_id=customer_id,
|
||||
account_id=account_id,
|
||||
offer_id=offer_id,
|
||||
|
||||
Reference in New Issue
Block a user