Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c4d7db5c59 | |||
| d359532775 | |||
| 2b12e1ab0b | |||
| 23b352d9c3 |
@@ -2,7 +2,7 @@ from marshmallow import Schema, fields
|
||||
|
||||
class DisbursementSchema(Schema):
|
||||
transactionId = fields.Str(required=False, allow_none=True)
|
||||
fbnTransactionId = fields.Str(required=False, allow_none=True)
|
||||
FbnTransactionId = fields.Str(required=False, allow_none=True)
|
||||
debtId = fields.Str(required=False, allow_none=True)
|
||||
customerId = fields.Str(required=False, allow_none=True)
|
||||
accountId = fields.Str(required=False, allow_none=True)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -25,53 +25,66 @@ class RACCheckService:
|
||||
schema = RACCheckSchema()
|
||||
validated_data = schema.load(data)
|
||||
|
||||
# Simulated RAC check logic — create racResponse manually or via logic
|
||||
# rac_response = {
|
||||
# "hasSalaryAccount": True,
|
||||
# "bvnValidated": True,
|
||||
# "creditBureauCheck": False,
|
||||
# "crmsCheck": True,
|
||||
# "accountStatus": True,
|
||||
# "hasLien": False,
|
||||
# "noBouncedCheck": True,
|
||||
# "isWhitelisted": True,
|
||||
# "hasPastDueLoan": False
|
||||
# }
|
||||
customer_id = validated_data["customerId"]
|
||||
is_valid = not (
|
||||
int(customer_id[-1]) in [2, 7, 9]
|
||||
)
|
||||
|
||||
|
||||
try:
|
||||
salary_count = int(str(customer_id)[-1]) + 1
|
||||
if salary_count < 1 or salary_count > 6:
|
||||
salary_count = 3
|
||||
except ValueError:
|
||||
salary_count = 3
|
||||
|
||||
salary_payments = {}
|
||||
total_salary = 0
|
||||
|
||||
for i in range(1, salary_count + 1):
|
||||
salary = ((salary_count + i ) * 7919) % 200000 + 10000
|
||||
salary_payments[f"salarypaymenT_{i}"] = salary
|
||||
total_salary += salary
|
||||
|
||||
average_salary = total_salary // salary_count if salary_count > 0 else 0
|
||||
|
||||
|
||||
rac_response = {
|
||||
"procesS_DATE": datetime.strptime("2025-06-05", "%Y-%m-%d").date(),
|
||||
"ciF_ID": "416405737",
|
||||
"customeR_id": "7032744",
|
||||
"customeR_id": customer_id,
|
||||
"salaccT_1": "4142904114",
|
||||
"alerT_PHONE": "2348039301606",
|
||||
"averagE_SALARY": 5000,
|
||||
"averagE_SALARY": average_salary,
|
||||
"loaN_OUSTANDING_BAL": 0,
|
||||
"emi": 1000,
|
||||
"eliG_AMT": 25000,
|
||||
"rule1_45day_sal": True,
|
||||
"rule2_2m_sal": True,
|
||||
"rule3_no_bounced_check": True,
|
||||
"rule4_current_loan_payments": True,
|
||||
"rule5_no_past_due_fadv_loan": True,
|
||||
"rule6_no_past_due_other_loan": True,
|
||||
"rule7_consistent_salary_amount": True,
|
||||
"rule8_whitelisted": True,
|
||||
"rule9_regular_account": True,
|
||||
"rule10_bvn_validation": True,
|
||||
"rule11_CRC_no_delinquency": True,
|
||||
"rule12_CRMS_no_delinquency": True,
|
||||
"rule13_BVN_ignore": True,
|
||||
"rule14_no_lien": True,
|
||||
"rule15_null_ignore": True,
|
||||
"overalL_ELIG": True,
|
||||
"salarypaymenT_1": 180000,
|
||||
"salarypaymenT_2": 50000,
|
||||
"salarypaymenT_3": 70000,
|
||||
"salarypaymenT_4": 0,
|
||||
"salarypaymenT_5": 0,
|
||||
"salarypaymenT_6": 0
|
||||
"rule1_45day_sal": is_valid,
|
||||
"rule2_2m_sal": is_valid,
|
||||
"rule3_no_bounced_check": is_valid,
|
||||
"rule4_current_loan_payments": True if is_valid is False else is_valid,
|
||||
"rule5_no_past_due_fadv_loan": is_valid,
|
||||
"rule6_no_past_due_other_loan": is_valid,
|
||||
"rule7_consistent_salary_amount": is_valid,
|
||||
"rule8_whitelisted": True if is_valid is False else is_valid,
|
||||
"rule9_regular_account": True if is_valid is False else is_valid,
|
||||
"rule10_bvn_validation": is_valid,
|
||||
"rule11_CRC_no_delinquency": is_valid,
|
||||
"rule12_CRMS_no_delinquency": True if is_valid is False else is_valid,
|
||||
"rule13_BVN_ignore": is_valid,
|
||||
"rule14_no_lien": is_valid,
|
||||
"rule15_null_ignore": True if is_valid is False else is_valid,
|
||||
"overalL_ELIG": is_valid
|
||||
# "salarypaymenT_1": 180000,
|
||||
# "salarypaymenT_2": 50000,
|
||||
# "salarypaymenT_3": 70000,
|
||||
# "salarypaymenT_4": 0,
|
||||
# "salarypaymenT_5": 0,
|
||||
# "salarypaymenT_6": 0
|
||||
}
|
||||
|
||||
rac_response.update(salary_payments)
|
||||
|
||||
|
||||
full_response = {
|
||||
"transactionId": validated_data["transactionId"],
|
||||
|
||||
Reference in New Issue
Block a user