1
0

[fix]: Repayment schedule model

This commit is contained in:
VivianDee
2025-04-25 15:10:07 +01:00
parent c216c55928
commit ddbabcaca9
3 changed files with 43 additions and 8 deletions
+2 -2
View File
@@ -19,9 +19,9 @@ class LoanRepaymentSchedule(db.Model):
loan = relationship(
"Loan",
primaryjoin="LoanCharge.loan_id == Loan.id",
primaryjoin="LoanRepaymentSchedule.loan_id == Loan.id",
foreign_keys=[loan_id],
back_populates="loan_charges",
back_populates="loan_repayment_schedules",
)
@classmethod
@@ -33,12 +33,6 @@ def upgrade():
existing_type=sa.NUMERIC(precision=10, scale=2),
type_=sa.Float(),
existing_nullable=True)
with op.batch_alter_table('loans', schema=None) as batch_op:
batch_op.add_column(sa.Column('upfront_fee', sa.Float(), nullable=True))
batch_op.add_column(sa.Column('repayment_amount', sa.Float(), nullable=True))
batch_op.add_column(sa.Column('installment_amount', sa.Float(), nullable=True))
# ### end Alembic commands ###
@@ -0,0 +1,41 @@
"""Migration on Fri Apr 25 14:02:01 UTC 2025
Revision ID: 2cf0c177ca02
Revises: 1b2339f43824
Create Date: 2025-04-25 14:02:42.244146
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '2cf0c177ca02'
down_revision = '1b2339f43824'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('loan_repayment_schedules',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('loan_id', sa.Integer(), nullable=False),
sa.Column('installment_number', sa.Integer(), nullable=False),
sa.Column('due_date', sa.DateTime(), nullable=False),
sa.Column('principal_amount', sa.Float(), nullable=True),
sa.Column('interest_amount', sa.Float(), nullable=True),
sa.Column('total_installment', sa.Float(), nullable=True),
sa.Column('paid', sa.Boolean(), nullable=True),
sa.Column('paid_at', sa.DateTime(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('loan_repayment_schedules')
# ### end Alembic commands ###