[add]: transaction fix

This commit is contained in:
VivianDee
2025-04-11 13:15:56 +01:00
parent 8a018545ec
commit e69335cb71
6 changed files with 44 additions and 21 deletions
+1 -2
View File
@@ -50,8 +50,7 @@ class BaseService:
"""
return Transaction.create_transaction(
transaction_id = validated_data.get("transactionId"),
ref_id = validated_data.get("refId") or validated_data.get("accountId"),
ref_model = validated_data.get("refModel", "account"),
account_id = validated_data.get("accountId", None),
type = cls.TRANSACTION_TYPE,
channel = validated_data.get("channel"),
)
-5
View File
@@ -35,11 +35,6 @@ class LoanStatusService(BaseService):
# Get loans
loans = [loan.to_dict() for loan in customer.loans]
validated_data['refId'] = customer.id
validated_data['refModel'] = "customer"
transaction = LoanStatusService.log_transaction(validated_data = validated_data)
if not transaction:
-4
View File
@@ -51,10 +51,6 @@ class ProvideLoanService(BaseService):
"message": "Failed to save loan details."
}), 400
db.session.flush()
validated_data['refId'] = loan.id
validated_data['refModel'] = "loan"
# Log Transaction
transaction = ProvideLoanService.log_transaction(validated_data = validated_data)
+1 -5
View File
@@ -47,11 +47,7 @@ class RepaymentService(BaseService):
return jsonify({
"message": "Failed to save repayment details."
}), 400
db.session.flush()
validated_data['refId'] = repayment.id
validated_data['refModel'] = "repayment"
#Update Loan status
Loan.update_status(loan_id = loan_id, status = LoanStatus.REPAID)