added catch for 404
This commit was merged in pull request #35.
This commit is contained in:
@@ -2,6 +2,8 @@ from app.extensions import db
|
||||
from datetime import datetime, timezone
|
||||
from app.utils.logger import logger
|
||||
from app.enums.loan_status import LoanStatus
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
|
||||
|
||||
class Repayment(db.Model):
|
||||
__tablename__ = "repayments"
|
||||
@@ -51,7 +53,7 @@ class Repayment(db.Model):
|
||||
@classmethod
|
||||
def create_repayment(cls, repayment_data):
|
||||
|
||||
if repayment_data["LoanStatus"] not in [LoanStatus.ACTIVE, LoanStatus.START_REPAY]:
|
||||
if repayment_data["LoanStatus"] not in [LoanStatus.ACTIVE, LoanStatus.START_REPAY,LoanStatus.ACTIVE_PARTIAL]:
|
||||
raise ValueError(f"Repayment cannot be processed. Loan status: ({repayment_data['LoanStatus']})")
|
||||
|
||||
repayment = cls(
|
||||
@@ -70,9 +72,9 @@ class Repayment(db.Model):
|
||||
db.session.commit()
|
||||
logger.info("Repayment record committed.")
|
||||
return repayment
|
||||
except InqtegrityError as err:
|
||||
except IntegrityError as err:
|
||||
logger.error(f"Database integrity error: {err}")
|
||||
return [q]
|
||||
return {"error": "Integrity error", "details": str(err)}
|
||||
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user