Partial simulation

This commit is contained in:
CHIEFSOFT\ameye
2025-06-21 10:41:53 -04:00
parent 23b352d9c3
commit 2b12e1ab0b
+52 -21
View File
@@ -2,20 +2,20 @@ from flask import request, jsonify
from marshmallow import ValidationError
from app.utils.logger import logger
from app.api.helpers.response_helper import ResponseHelper
from app.api.schemas.collect_loan import CollectLoanSchema, CollectLoanResponseSchema
from app.api.schemas.collect_loan import CollectLoanSchema, CollectLoanResponseSchema
"""
Process the CollectLoan request.
Args:
data (dict): The request data.
Returns:
tuple: JSON response and status code.
"""
class CollectLoanService:
@staticmethod
def process_request(data):
"""
Process the CollectLoan request.
Args:
data (dict): The request data.
Returns:
tuple: JSON response and status code.
"""
try:
logger.info("Processing CollectLoan request")
@@ -23,22 +23,53 @@ class CollectLoanService:
schema = CollectLoanSchema()
validated_data = schema.load(data)
amountForCollection = validated_data.get("collectAmount")
amountCollected = amountForCollection
responseDescr= "Loan Collection Successful EMULATOR"
fullDescription= "Loan collection completed successfully EMULATOR"
responseMessage= "Loan collection completed successfully EMULATOR"
if amountForCollection in [5555.0, 6666.0, 7777.0, 8888.0 , 9999.0, 22222.0] :
amountCollected = amountForCollection * 0.85
responseDescr = "Partial Loan Collection Successful EMULATOR"
fullDescription = "Partial Loan collection completed successfully EMULATOR"
responseMessage = "Partial Loan collection completed successfully EMULATOR"
# Simulated processing logic
response_data = {
"transactionId": validated_data.get("transactionId", "T002"),
"debtId": validated_data.get("debtId", "273194670"),
"customerId": validated_data.get("customerId", "CN621868"),
"accountId": validated_data.get("accountId", "2017821799"),
"productId": validated_data.get("productId", "101"),
"amountCollected": validated_data.get("collectAmount", 60000.00),
"countryId": validated_data.get("countryId", "01"),
"comment": validated_data.get("comment", "Testing CollectionLoanRequest"),
"transactionId": validated_data.get("transactionId"),
"debtId": validated_data.get("debtId"),
"customerId": validated_data.get("customerId"),
"accountId": validated_data.get("accountId"),
"productId": validated_data.get("productId"),
"amountCollected": amountCollected,
"countryId": validated_data.get("countryId"),
"comment": validated_data.get("comment", "Testing CollectionLoanRequest EMULATOR"),
"responseCode": "00",
"responseDescr": "Loan Collection Successful",
"fullDescription": "Loan collection completed successfully",
"responseMessage": "Loan collection completed successfully"
"responseDescr": responseDescr,
"fullDescription": fullDescription,
"responseMessage": responseMessage
}
# # Simulated processing logic
# response_data = {
# "transactionId": validated_data.get("transactionId", "T002"),
# "debtId": validated_data.get("debtId", "273194670"),
# "customerId": validated_data.get("customerId", "CN621868"),
# "accountId": validated_data.get("accountId", "2017821799"),
# "productId": validated_data.get("productId", "101"),
# "amountCollected": validated_data.get("collectAmount", 60000.00),
# "countryId": validated_data.get("countryId", "01"),
# "comment": validated_data.get("comment", "Testing CollectionLoanRequest"),
# "responseCode": "00",
# "responseDescr": "Loan Collection Successful",
# "fullDescription": "Loan collection completed successfully",
# "responseMessage": "Loan collection completed successfully"
# }
#
# Validate and serialize the response data
response_schema = CollectLoanResponseSchema()
result = response_schema.dump(response_data)