added loan_repayment_schedule
This commit was merged in pull request #74.
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
from .transaction_type import TransactionType
|
from .transaction_type import TransactionType
|
||||||
from .loan_status import LoanStatus
|
from .loan_status import LoanStatus
|
||||||
|
from .repayment_schedule_status import RepaymentScheduleStatus
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
class RepaymentScheduleStatus(str, Enum):
|
||||||
|
ACTIVE = "active"
|
||||||
|
PARTIALLY_PAID = "partially_paid"
|
||||||
|
REPAID = "repaid"
|
||||||
@@ -3,6 +3,7 @@ from app.extensions import db
|
|||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from sqlalchemy.sql import func
|
from sqlalchemy.sql import func
|
||||||
|
from app.api.enums.repayment_schedule_status import RepaymentScheduleStatus
|
||||||
|
|
||||||
class LoanRepaymentSchedule(db.Model):
|
class LoanRepaymentSchedule(db.Model):
|
||||||
__tablename__ = 'loan_repayment_schedules'
|
__tablename__ = 'loan_repayment_schedules'
|
||||||
@@ -51,6 +52,7 @@ class LoanRepaymentSchedule(db.Model):
|
|||||||
installment_amount=round(loan.installment_amount, 2),
|
installment_amount=round(loan.installment_amount, 2),
|
||||||
product_id = loan.product_id,
|
product_id = loan.product_id,
|
||||||
transaction_id = transaction_id,
|
transaction_id = transaction_id,
|
||||||
|
paid_status = RepaymentScheduleStatus.ACTIVE,
|
||||||
created_at=datetime.now(timezone.utc),
|
created_at=datetime.now(timezone.utc),
|
||||||
updated_at=datetime.now(timezone.utc)
|
updated_at=datetime.now(timezone.utc)
|
||||||
)
|
)
|
||||||
@@ -70,6 +72,7 @@ class LoanRepaymentSchedule(db.Model):
|
|||||||
'interestAmount': self.interest_amount,
|
'interestAmount': self.interest_amount,
|
||||||
'totalInstallment': self.total_installment,
|
'totalInstallment': self.total_installment,
|
||||||
'paid': self.paid,
|
'paid': self.paid,
|
||||||
|
'paidStatus': self.paid_status,
|
||||||
'paidAt': self.paid_at.isoformat() if self.paid_at else None
|
'paidAt': self.paid_at.isoformat() if self.paid_at else None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user