[add]: account_id to loan status and repayment

This commit is contained in:
VivianDee
2025-04-14 15:26:46 +01:00
parent 6476b62d3c
commit 482a860bd2
4 changed files with 52 additions and 29 deletions
+7
View File
@@ -32,6 +32,9 @@ class LoanStatusService(BaseService):
customer_id = validated_data.get('customerId') customer_id = validated_data.get('customerId')
customer = Customer.get_customer(customer_id) customer = Customer.get_customer(customer_id)
transactionId = validated_data.get('transactionId') transactionId = validated_data.get('transactionId')
account_id = validated_data.get('accountId')
if(LoanStatusService.validate_account_ownership(account_id = account_id, customer_id = customer_id)):
# Get loans # Get loans
loans = [loan.to_dict() for loan in customer.loans if loan.status == LoanStatus.ACTIVE] loans = [loan.to_dict() for loan in customer.loans if loan.status == LoanStatus.ACTIVE]
@@ -43,6 +46,10 @@ class LoanStatusService(BaseService):
return jsonify({ return jsonify({
"message": "Failed to log transaction." "message": "Failed to log transaction."
}), 400 }), 400
else:
return jsonify({
"message": "Invalid Customer or Account"
}), 400
# loans = [ # loans = [
+9 -1
View File
@@ -2,6 +2,7 @@ from flask import request, jsonify
from marshmallow import ValidationError from marshmallow import ValidationError
from app.api.enums.loan_status import LoanStatus from app.api.enums.loan_status import LoanStatus
from app.models import Repayment from app.models import Repayment
from app.models.customer import Customer
from app.models.loan import Loan from app.models.loan import Loan
from app.utils.logger import logger from app.utils.logger import logger
from app.api.schemas.repayment import RepaymentSchema from app.api.schemas.repayment import RepaymentSchema
@@ -31,8 +32,10 @@ class RepaymentService(BaseService):
request_id = validated_data.get('requestId') request_id = validated_data.get('requestId')
loan_id = validated_data.get('debtId') loan_id = validated_data.get('debtId')
product_id = validated_data.get('productId') product_id = validated_data.get('productId')
account_id = validated_data.get('accountId')
customer = Customer.get_customer(customer_id)
if(RepaymentService.validate_account_ownership(account_id = account_id, customer_id = customer_id)):
# Save the repayment details # Save the repayment details
repayment = Repayment.create_repayment( repayment = Repayment.create_repayment(
@@ -59,6 +62,11 @@ class RepaymentService(BaseService):
return jsonify({ return jsonify({
"message": "Failed to log transaction." "message": "Failed to log transaction."
}), 400 }), 400
else:
return jsonify({
"message": "Invalid Customer or Account"
}), 400
# Simulated processing logic # Simulated processing logic
@@ -16,6 +16,10 @@
"channel": { "channel": {
"type": "string", "type": "string",
"example": "USSD" "example": "USSD"
},
"accountId": {
"type": "string",
"example": "ACN8263457"
} }
}, },
"xml": { "xml": {
@@ -24,6 +24,10 @@
"channel": { "channel": {
"type": "string", "type": "string",
"example": "USSD" "example": "USSD"
},
"accountId": {
"type": "string",
"example": "ACN8263457"
} }
}, },
"xml": { "xml": {