[fix]: loan charges and instalment amount

This commit is contained in:
Vivian Dee
2025-04-23 18:57:22 +01:00
parent 8cfa957cc0
commit 4b92c33d5a
2 changed files with 15 additions and 8 deletions
+4
View File
@@ -52,3 +52,7 @@ class SimbrellaIntegration:
except Exception as e: except Exception as e:
logger.error(f"RACCheck API call failed: {str(e)}", exc_info=True) logger.error(f"RACCheck API call failed: {str(e)}", exc_info=True)
raise Exception(f"RACCheck API call failed: {str(e)}") raise Exception(f"RACCheck API call failed: {str(e)}")
# return httpx.Response(
# status_code=200,
# json={}
# )
+11 -8
View File
@@ -58,7 +58,7 @@ class SelectOfferService(BaseService):
logger.error(f"No charges found for offer ID {offer.id}") logger.error(f"No charges found for offer ID {offer.id}")
return jsonify({"message": "No charges found for the offer"}), 404 return jsonify({"message": "No charges found for the offer"}), 404
# logger.error(f"{loan_charges}") logger.error(f"{loan_charges}")
fees_and_dues = { fees_and_dues = {
charge.code: { charge.code: {
@@ -88,6 +88,9 @@ class SelectOfferService(BaseService):
(start_date + relativedelta(months=i + 1)).isoformat() (start_date + relativedelta(months=i + 1)).isoformat()
for i in range(tenor) for i in range(tenor)
] ]
# Calculate the installment amount
installment_amount = total_amount / tenor
offers = [ offers = [
@@ -96,15 +99,15 @@ class SelectOfferService(BaseService):
"productId": product_id, "productId": product_id,
"amount": amount, "amount": amount,
"upfrontPayment": upfront_payment, "upfrontPayment": upfront_payment,
"interestRate": 3.0, "interestRate": fees_and_dues["INTEREST"]["rate"],
"managementRate": fees_and_dues["management"]["rate"], "managementRate": fees_and_dues["MGTFEE"]["rate"],
"managementFee": fees_and_dues["management"]["fee"], "managementFee": fees_and_dues["MGTFEE"]["fee"],
"insuranceRate": fees_and_dues["insurance"]["rate"], "insuranceRate": fees_and_dues["INSURANCE"]["rate"],
"insuranceFee": fees_and_dues["insurance"]["fee"], "insuranceFee": fees_and_dues["INSURANCE"]["fee"],
"VATRate": fees_and_dues["VAT"]["rate"], "VATRate": fees_and_dues["VAT"]["rate"],
"VATAmount": fees_and_dues["VAT"]["fee"], "VATAmount": fees_and_dues["VAT"]["fee"],
"recommendedRepaymentDates": ["2022-11-30"], "recommendedRepaymentDates": recommended_repayment_dates,
"installmentAmount": recommended_repayment_dates, "installmentAmount": installment_amount,
"totalRepaymentAmount": total_amount, "totalRepaymentAmount": total_amount,
} }
] ]