Loan status fix
This commit is contained in:
+12
-17
@@ -50,34 +50,29 @@ class Repayment(db.Model):
|
||||
|
||||
@classmethod
|
||||
def create_repayment(cls, repayment_data):
|
||||
logger.info(f"create_repayment data: {repayment_data}")
|
||||
|
||||
try:
|
||||
logger.info(f"repayment_data-LoanStatus- data: {repayment_data['LoanStatus']}")
|
||||
except Exception as e:
|
||||
logger.error(f"Bad data LoanStatus 777777 error: {e}")
|
||||
llogger.info(f"LoanStatus 2222222 data: {repayment_data.LoanStatus}")
|
||||
|
||||
|
||||
|
||||
if repayment_data["LoanStatus"] not in [LoanStatus.ACTIVE, LoanStatus.START_REPAY]:
|
||||
raise ValueError(f"Repayment cannot be processed. Loan status: ({repayment_data["LoanStatus"]})")
|
||||
raise ValueError(f"Repayment cannot be processed. Loan status: ({repayment_data['LoanStatus']})")
|
||||
|
||||
repayment = cls(
|
||||
customer_id=repayment_data.customerId,
|
||||
loan_id=repayment_data.loanId,
|
||||
product_id=repayment_data.productId,
|
||||
transaction_id=repayment_data.transactionId,
|
||||
customer_id=repayment_data["customerId"],
|
||||
loan_id=repayment_data["loanId"],
|
||||
product_id=repayment_data["productId"],
|
||||
transaction_id=repayment_data["transactionId"],
|
||||
created_at=datetime.now(timezone.utc),
|
||||
updated_at=datetime.now(timezone.utc),
|
||||
initiated_by= repayment_data.initiated_by
|
||||
initiated_by= repayment_data["initiatedBy"],
|
||||
salary_amount=repayment_data["salaryAmount"]
|
||||
)
|
||||
|
||||
try:
|
||||
db.session.add(repayment)
|
||||
except IntegrityError as err:
|
||||
db.session.commit()
|
||||
logger.info("Repayment record committed.")
|
||||
return repayment
|
||||
except InqtegrityError as err:
|
||||
logger.error(f"Database integrity error: {err}")
|
||||
return repayment
|
||||
return [q]
|
||||
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user