[add]: accountId on repayment and loan status #9
@@ -3,6 +3,7 @@ from marshmallow import Schema, fields
|
||||
# Loan Information Schema
|
||||
class LoanStatusSchema(Schema):
|
||||
transactionId = fields.Str(required=True)
|
||||
accountId = fields.Str(required=True)
|
||||
customerId = fields.Str(required=True)
|
||||
msisdn = fields.Str(required=False)
|
||||
channel = fields.Str(required=True)
|
||||
@@ -7,5 +7,6 @@ class RepaymentSchema(Schema):
|
||||
debtId = fields.Str(required=True)
|
||||
productId = fields.Str(required=True)
|
||||
transactionId = fields.Str(required=True)
|
||||
accountId = fields.Str(required=True)
|
||||
customerId = fields.Str(required=True)
|
||||
channel = fields.Str(required=True)
|
||||
|
||||
@@ -50,6 +50,7 @@ class BaseService:
|
||||
"""
|
||||
return Transaction.create_transaction(
|
||||
transaction_id = validated_data.get("transactionId"),
|
||||
customer_id = validated_data.get('customerId', None),
|
||||
account_id = validated_data.get("accountId", None),
|
||||
type = cls.TRANSACTION_TYPE,
|
||||
channel = validated_data.get("channel"),
|
||||
|
||||
@@ -13,6 +13,7 @@ class Transaction(db.Model):
|
||||
)
|
||||
transaction_id = db.Column(db.String(50), nullable=False)
|
||||
account_id = db.Column(db.String(50), nullable=True)
|
||||
customer_id = db.Column(db.String(50), nullable=True)
|
||||
type = db.Column(db.String(50), nullable=False)
|
||||
channel = db.Column(db.String(50), nullable=False)
|
||||
created_at = db.Column(db.DateTime, default=datetime.now(timezone.utc))
|
||||
@@ -22,7 +23,7 @@ class Transaction(db.Model):
|
||||
return f'<Transaction {self.id}>'
|
||||
|
||||
@classmethod
|
||||
def create_transaction(cls, transaction_id, account_id, type, channel):
|
||||
def create_transaction(cls, transaction_id, account_id, customer_id, type, channel):
|
||||
|
||||
# if cls.query.filter_by(transaction_id=transaction_id).first():
|
||||
# raise ValueError("Duplicate Transaction")
|
||||
@@ -34,6 +35,7 @@ class Transaction(db.Model):
|
||||
|
||||
transaction = cls(
|
||||
transaction_id = transaction_id,
|
||||
customer_id = customer_id,
|
||||
account_id = account_id,
|
||||
type = type,
|
||||
channel = channel
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
"""Migration on Mon Apr 14 15:15:05 UTC 2025
|
||||
|
||||
Revision ID: 783a023a477f
|
||||
Revises: f6cd1bfc8832
|
||||
Create Date: 2025-04-14 15:15:36.991148
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '783a023a477f'
|
||||
down_revision = 'f6cd1bfc8832'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('transactions', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('customer_id', sa.String(length=50), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('transactions', schema=None) as batch_op:
|
||||
batch_op.drop_column('customer_id')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user