[fix]: Removed out product and lien amount
This commit is contained in:
@@ -8,8 +8,8 @@ class ProvideLoanSchema(Schema):
|
|||||||
customerId = fields.Str(required=True)
|
customerId = fields.Str(required=True)
|
||||||
accountId = fields.Str(required=True)
|
accountId = fields.Str(required=True)
|
||||||
msisdn = fields.Str(required=False)
|
msisdn = fields.Str(required=False)
|
||||||
productId = fields.Str(required=True)
|
# productId = fields.Str(required=True)
|
||||||
lienAmount = fields.Float(required=True)
|
# lienAmount = fields.Float(required=True)
|
||||||
requestedAmount = fields.Float(required=True)
|
requestedAmount = fields.Float(required=True)
|
||||||
collectionType = fields.Int(required=True)
|
collectionType = fields.Int(required=True)
|
||||||
offerId = fields.Int(required=True)
|
offerId = fields.Int(required=True)
|
||||||
|
|||||||
@@ -42,14 +42,14 @@ class ProvideLoanService(BaseService):
|
|||||||
"message": "Failed to log transaction."
|
"message": "Failed to log transaction."
|
||||||
}), 400
|
}), 400
|
||||||
|
|
||||||
# Save the loan details here
|
# Save the loan details
|
||||||
loan_id = f"loan_{transaction.id}"
|
loan_id = f"loan_{transaction.id}"
|
||||||
|
|
||||||
loan = Loan.create_loan(
|
loan = Loan.create_loan(
|
||||||
id=loan_id,
|
id=loan_id,
|
||||||
customer_id=customer_id,
|
customer_id=customer_id,
|
||||||
account_id=account_id,
|
account_id=account_id,
|
||||||
product_id=validated_data.get('productId'),
|
offer_id=validated_data.get('offerId'),
|
||||||
principal_amount=validated_data.get('requestedAmount'),
|
principal_amount=validated_data.get('requestedAmount'),
|
||||||
status="active"
|
status="active"
|
||||||
)
|
)
|
||||||
|
|||||||
+4
-3
@@ -10,7 +10,7 @@ class Loan(db.Model):
|
|||||||
id = db.Column(db.String(50), primary_key=True)
|
id = db.Column(db.String(50), primary_key=True)
|
||||||
customer_id = db.Column(db.String(50), nullable=False)
|
customer_id = db.Column(db.String(50), nullable=False)
|
||||||
account_id = db.Column(db.String(50), nullable=False)
|
account_id = db.Column(db.String(50), nullable=False)
|
||||||
product_id = db.Column(db.String(20), nullable=False)
|
offer_id = db.Column(db.String(20), nullable=False)
|
||||||
principal_amount = db.Column(db.Float, nullable=False)
|
principal_amount = db.Column(db.Float, nullable=False)
|
||||||
status = db.Column(db.String(20), default='pending')
|
status = db.Column(db.String(20), default='pending')
|
||||||
created_at = db.Column(db.DateTime, default=datetime.now(timezone.utc))
|
created_at = db.Column(db.DateTime, default=datetime.now(timezone.utc))
|
||||||
@@ -18,7 +18,7 @@ class Loan(db.Model):
|
|||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_loan(cls, id, customer_id, account_id, product_id, principal_amount, status='pending'):
|
def create_loan(cls, id, customer_id, account_id, offer_id, principal_amount, 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)
|
||||||
@@ -30,12 +30,13 @@ class Loan(db.Model):
|
|||||||
# if has_active_loans:
|
# if has_active_loans:
|
||||||
# raise ValueError("Customer has active loans")
|
# raise ValueError("Customer has active loans")
|
||||||
|
|
||||||
|
|
||||||
# Create and save the loan
|
# Create and save the loan
|
||||||
loan = cls(
|
loan = cls(
|
||||||
id=id,
|
id=id,
|
||||||
customer_id=customer_id,
|
customer_id=customer_id,
|
||||||
account_id=account_id,
|
account_id=account_id,
|
||||||
product_id=product_id,
|
offer_id=offer_id,
|
||||||
principal_amount=principal_amount,
|
principal_amount=principal_amount,
|
||||||
status=status
|
status=status
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,15 +21,6 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "3451342"
|
"example": "3451342"
|
||||||
},
|
},
|
||||||
"productId": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "101"
|
|
||||||
},
|
|
||||||
"lienAmount": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "decimal",
|
|
||||||
"example": 400
|
|
||||||
},
|
|
||||||
"requestedAmount": {
|
"requestedAmount": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"format": "decimal",
|
"format": "decimal",
|
||||||
|
|||||||
Reference in New Issue
Block a user