diff --git a/.idea/digifi-BankToProductCore.iml b/.idea/digifi-BankToProductCore.iml
index ae45667..c956989 100644
--- a/.idea/digifi-BankToProductCore.iml
+++ b/.idea/digifi-BankToProductCore.iml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index 9402635..0000000
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index a6218fe..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index 140eb7a..0bc8e59 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -17,12 +17,6 @@ EXPOSE 5000
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0
-#RUN chmod +x scripts/entrypoint.sh
-#
-#ENTRYPOINT ["scripts/entrypoint.sh"]
-
-CMD ["sh", "-c", \
- "echo 'Starting Gunicorn server...' && \
- exec gunicorn -w 4 -b 0.0.0.0:5000 wsgi:wsgi_app"]
-
+RUN chmod +x scripts/entrypoint.sh
+ENTRYPOINT ["scripts/entrypoint.sh"]
\ No newline at end of file
diff --git a/JUNK/fd58e10e4968_update_offers.py b/JUNK/fd58e10e4968_update_offers.py
new file mode 100644
index 0000000..eb2d52b
--- /dev/null
+++ b/JUNK/fd58e10e4968_update_offers.py
@@ -0,0 +1,75 @@
+"""Update Offers
+
+Revision ID: fd58e10e4968
+Revises:
+Create Date: 2025-03-28 15:47:35.620664
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'fd58e10e4968'
+down_revision = None
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.create_table('accounts',
+ sa.Column('id', sa.String(length=50), nullable=False),
+ sa.Column('customer_id', sa.String(length=50), nullable=False),
+ sa.Column('account_type', sa.String(length=50), nullable=True),
+ sa.Column('status', sa.String(length=20), nullable=True),
+ sa.Column('lien_amount', sa.Float(), nullable=True),
+ sa.Column('created_at', sa.DateTime(), nullable=True),
+ sa.Column('updated_at', sa.DateTime(), nullable=True),
+ sa.PrimaryKeyConstraint('id')
+ )
+ op.create_table('customers',
+ sa.Column('id', sa.String(length=50), nullable=False),
+ sa.Column('msisdn', sa.String(length=20), nullable=False),
+ sa.Column('country_code', sa.String(length=3), nullable=False),
+ sa.Column('created_at', sa.DateTime(), nullable=True),
+ sa.Column('updated_at', sa.DateTime(), nullable=True),
+ sa.PrimaryKeyConstraint('id'),
+ sa.UniqueConstraint('msisdn')
+ )
+ op.create_table('loans',
+ sa.Column('id', sa.String(length=50), nullable=False),
+ sa.Column('customer_id', sa.String(length=50), nullable=False),
+ sa.Column('account_id', sa.String(length=50), nullable=False),
+ sa.Column('product_id', sa.String(length=20), nullable=False),
+ sa.Column('principal_amount', sa.Float(), nullable=False),
+ sa.Column('status', sa.String(length=20), nullable=True),
+ sa.Column('created_at', sa.DateTime(), nullable=True),
+ sa.Column('updated_at', sa.DateTime(), nullable=True),
+ sa.PrimaryKeyConstraint('id')
+ )
+ op.create_table('transactions',
+ sa.Column('id', sa.String(length=50), nullable=False),
+ sa.Column('account_id', sa.String(length=50), nullable=False),
+ sa.Column('type', sa.String(length=50), nullable=False),
+ sa.Column('amount', sa.Float(), nullable=False),
+ sa.Column('status', sa.String(length=20), nullable=True),
+ sa.Column('created_at', sa.DateTime(), nullable=True),
+ sa.Column('updated_at', sa.DateTime(), nullable=True),
+ sa.PrimaryKeyConstraint('id')
+ )
+ op.drop_table('test')
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.create_table('test',
+ sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
+ sa.Column('name', sa.VARCHAR(length=125), autoincrement=False, nullable=True)
+ )
+ op.drop_table('transactions')
+ op.drop_table('loans')
+ op.drop_table('customers')
+ op.drop_table('accounts')
+ # ### end Alembic commands ###
diff --git a/app/api/enums/loan_status.py b/app/api/enums/loan_status.py
index fa9f0c5..b707c54 100644
--- a/app/api/enums/loan_status.py
+++ b/app/api/enums/loan_status.py
@@ -3,6 +3,5 @@ from enum import Enum
class LoanStatus(str, Enum):
PENDING = "pending"
ACTIVE = "active"
- ACTIVE_PARTIAL = "active_partial"
START_REPAY = "start_repay"
REPAID = "repaid"
\ No newline at end of file
diff --git a/app/api/helpers/response_helper.py b/app/api/helpers/response_helper.py
index 2380c61..d2158f0 100644
--- a/app/api/helpers/response_helper.py
+++ b/app/api/helpers/response_helper.py
@@ -26,7 +26,7 @@ class ResponseHelper:
@staticmethod
def success(
result_description: str = "Successful",
- result_code: str = "0",
+ result_code: str = "00",
data: Optional[Dict[str, Any]] = None
) -> Dict[str, Any]:
return ResponseHelper.build_response(result_code, result_description, data)
diff --git a/app/api/routes/routes.py b/app/api/routes/routes.py
index d4eb7ef..73e7154 100644
--- a/app/api/routes/routes.py
+++ b/app/api/routes/routes.py
@@ -1,6 +1,5 @@
from flask import Blueprint, request, jsonify, send_from_directory
from app.api.services import (
- LoginService,
EligibilityCheckService,
SelectOfferService,
ProvideLoanService,
@@ -43,15 +42,6 @@ def serve_paths(filename):
swagger_dir = os.path.join("swagger")
return send_from_directory(swagger_dir, filename)
-# EligibilityCheck Endpoint
-@api.route("/Login", methods=["POST"])
-@jwt_required()
-def merms_login():
- data = request.get_json()
- # logger.info(f"EligibilityCheck request received: {data}")
- response = LoginService.process_request(data)
- return response
-
# EligibilityCheck Endpoint
@api.route("/EligibilityCheck", methods=["POST"])
diff --git a/app/api/schemas/login.py b/app/api/schemas/login.py
deleted file mode 100644
index fd74cb0..0000000
--- a/app/api/schemas/login.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from marshmallow import Schema, fields
-
-class LoginSchema(Schema):
- username = fields.Str(required=True)
- password = fields.Str(required=True)
diff --git a/app/api/services/__init__.py b/app/api/services/__init__.py
index 4d4c307..15278db 100644
--- a/app/api/services/__init__.py
+++ b/app/api/services/__init__.py
@@ -7,4 +7,3 @@ from app.api.services.customer_consent import CustomerConsentService
from app.api.services.notification_callback import NotificationCallbackService
from app.api.services.authorization import AuthorizationService
from app.api.services.offer_analysis import OfferAnalysis
-from app.api.services.login import LoginService
\ No newline at end of file
diff --git a/app/api/services/login.py b/app/api/services/login.py
deleted file mode 100644
index f947ac9..0000000
--- a/app/api/services/login.py
+++ /dev/null
@@ -1,137 +0,0 @@
-from flask import session, jsonify
-from app.models.loan import Loan
-from app.utils.logger import logger
-from app.api.services.base_service import BaseService
-from app.api.schemas.eligibility_check import EligibilityCheckSchema
-from marshmallow import ValidationError
-from app.api.enums import TransactionType
-from app.api.integrations import SimbrellaIntegration
-from app.extensions import db
-from app.models import Offer, RACCheck, Members
-from app.api.services.offer_analysis import OfferAnalysis
-from app.api.helpers.response_helper import ResponseHelper
-from werkzeug.security import generate_password_hash, check_password_hash
-from app.api.schemas.login import LoginSchema
-import datetime
-import jwt
-import random
-from app.config import Config
-
-
-class LoginService(BaseService):
-
- @staticmethod
- def process_request(data):
- """
- Process the Login request.
-
- Args:
- data (dict): The request data.
-
- Returns:
- dict: A standardized response.
- """
- try:
- with db.session.begin():
-
- validated_data = LoginService.validate_data(data, LoginSchema())
- username = validated_data.get('username')
- password = validated_data.get('password')
-
- member = Members.get_member_by_username(username)
- # pass22 = generate_password_hash(password)
- # logger.info("Password generated = > {}".format(pass22) )
-
- pass_check = check_password_hash(member.password, password)
- logger.info("Password check: {}".format(pass_check))
- if not member or not pass_check:
- invalid_data = {
- "error_message": "invalid username or password",
- "message_key": "invalid_username_or_password",
- }
- return ResponseHelper.success(data=invalid_data)
-
- user_data = {}
- user_data["id"] = member.id,
- user_data["member_id"]= member.id,
- user_data["uid"] = str(member.uid),
-
- user_token = jwt.encode(
- {"user": user_data, 'exp' : datetime.datetime.utcnow() + datetime.timedelta(minutes=3330)},
- Config.JWT_SECRET_KEY,
- algorithm="HS256"
- )
-
- # Simulate processing
- response_data = {
- "member_id": member.id,
- "uid": str(member.uid),
- "username": member.username,
- "account_name": member.account_name,
- "firstname":member.firstname,
- "lastname": member.lastname,
- "room": member.uid,
- "token": user_token
- }
-
- # user = {}
- # user_data = {}
- # user_data["id"] = result_data["member_id"]
- # user_data["member_id"] =result_data["member_id"]
- # user_data["uid"] = result_data["uid"]
-
- # token should expire after 24 hrs
- # user["token"] = jwt.encode(
- # {"user": user_data, 'exp' : datetime.datetime.utcnow() + datetime.timedelta(minutes=3330)},
- # Config.JWT_SECRET_KEY,
- # algorithm="HS256"
- # )
- # user["room"] = result_data["uid"]
- # response_data = {
- # "message": "Successfully fetched auth token",
- # "data": user_data
- # }
-
- return ResponseHelper.success(data=response_data)
-
- except ValidationError as err:
-
- logger.error(f"Validation Error: {getattr(err, 'messages', str(err))}")
- db.session.rollback()
- return ResponseHelper.unprocessable_entity(result_description="Validation exception")
-
- except ValueError as err:
- logger.error(f"{getattr(err, 'messages', str(err))}")
- db.session.rollback()
- return ResponseHelper.error(result_description=str(err))
-
- except Exception as e:
- logger.error(f"An error occurred: {str(e)}", exc_info=True)
- db.session.rollback()
- return ResponseHelper.internal_server_error()
-
- @staticmethod
- def check_loan_limits(customer_id):
- """
- Checks if a customer has exceeded the loan limits for given offer.
- """
- loan = Loan.get_customer_last_loan(customer_id)
-
- if not loan:
- return True
-
- offer_id = loan.offer_id[:5]
-
- offer = Offer.get_offer_by_id(offer_id)
- if not offer:
- logger.error(f"Offer not found for offer_id: {offer_id} (customer_id: {customer_id})")
- return False
-
- daily_count = Loan.get_daily_loan_count(customer_id, offer.product_id)
-
- logger.info(f"daily_count: {daily_count}, Max: {offer.max_daily_loans}")
-
- if offer.max_daily_loans is not None and daily_count >= offer.max_daily_loans:
- return False
-
- return True
diff --git a/app/config.py b/app/config.py
index a589cb3..564d58e 100644
--- a/app/config.py
+++ b/app/config.py
@@ -3,7 +3,6 @@ from datetime import timedelta
class Config:
"""Base configuration for Flask app"""
- JWT_SECRET_KEY = os.getenv("JWT_SECRET_KEY", "")
SWAGGER_URL = os.getenv("SWAGGER_URL", "/documentation")
API_URL = os.getenv("API_URL", "/swagger.json")
@@ -16,7 +15,7 @@ class Config:
DATABASE_USER = os.environ.get("DATABASE_USER")
DATABASE_PASSWORD = os.environ.get("DATABASE_PASSWORD")
DATABASE_HOST = os.environ.get("DATABASE_HOST")
- DATABASE_PORT = os.environ.get("DATABASE_PORT", 5432)
+ DATABASE_PORT = os.environ.get("DATABASE_PORT", 10532)
DATABASE_NAME = os.environ.get("DATABASE_NAME")
# Database Connection
diff --git a/app/models/__init__.py b/app/models/__init__.py
index 3d980b1..6331244 100644
--- a/app/models/__init__.py
+++ b/app/models/__init__.py
@@ -11,8 +11,6 @@ from .loan_repayment_schedule import LoanRepaymentSchedule
from .transaction_offers import TransactionOffer
from .repayments_data import RepaymentsData
from .salary import Salary
-from .members import Members
-
-__all__ = ['Members','Customer', 'Account', 'Loan', 'Transaction', 'Repayment', 'LoanCharge', 'Offer', 'Charge', 'RACCheck', 'LoanRepaymentSchedule', 'TransactionOffer', 'RepaymentsData', 'Salary']
\ No newline at end of file
+__all__ = ['Customer', 'Account', 'Loan', 'Transaction', 'Repayment', 'LoanCharge', 'Offer', 'Charge', 'RACCheck', 'LoanRepaymentSchedule', 'TransactionOffer', 'RepaymentsData', 'Salary']
\ No newline at end of file
diff --git a/app/models/members.py b/app/models/members.py
deleted file mode 100644
index 2be4047..0000000
--- a/app/models/members.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from datetime import datetime, timezone
-from app.extensions import db
-from sqlalchemy.sql import func
-
-
-class Members(db.Model):
- __tablename__ = 'members'
-
- id = db.Column(db.Integer, primary_key=True, autoincrement=True)
- uid = db.Column(db.String(150), nullable=False)
- username = db.Column(db.String(25), nullable=False)
- password = db.Column(db.String(100), nullable=True)
- loc = db.Column(db.String(20), nullable=True)
- status = db.Column(db.Integer, default=1)
- added = db.Column(db.DateTime(timezone=False), server_default=func.now())
- updated = db.Column(db.DateTime(timezone=False), server_default=func.now(), onupdate=func.now())
- email = db.Column(db.String(100), nullable=False)
- account_name = db.Column(db.String(100), nullable=True)
- firstname = db.Column(db.String(25), nullable=False)
- lastname = db.Column(db.String(100), nullable=True)
-
- def to_dict(self):
- return {
- "id": self.id,
- "uid": self.uid,
- "username": self.account_id,
- "account_id": self.username,
- "password": self.password,
- "loc": self.loc,
- "status": self.status,
- "added": self.added.isoformat() if self.added else None,
- "updated": self.updated.isoformat() if self.updated else None,
- "email": self.email,
- "account_name": self.account_name,
- "firstname": self.firstname,
- "lastname": self.lastname
- }
-
- def __repr__(self):
- return f''
-
- @classmethod
- def get_member_by_username(cls, username):
- """
- Return an offer by its ID.
- """
- member = cls.query.filter_by(username=str(username)).first()
-
- if not member:
- raise ValueError(f"Username = {username} not found")
- return member
\ No newline at end of file
diff --git a/app/swagger/digifi_swagger.json b/app/swagger/digifi_swagger.json
index 65a3414..436abcf 100644
--- a/app/swagger/digifi_swagger.json
+++ b/app/swagger/digifi_swagger.json
@@ -1,8 +1,8 @@
{
"openapi": "3.0.3",
"info": {
- "title": "Swagger MERM Core - OpenAPI 3.0",
- "description": "This is MERMS Backend Server with the OpenAPI 3.0 specification. \n\n\nSome useful links:\n- [Product Page](https://www.mermsemr.com/)\n- [Dev Product Web](https://panel.mermsemr.com/)",
+ "title": "Swagger Bank Channel to Simbrella FirstAdvance - OpenAPI 3.0",
+ "description": "This is a Simbrella FirstAdvance Backend Server with the OpenAPI 3.0 specification. \n\n\nSome useful links:\n- [Web Simulated Demo Page](https://digifi-salaryloan.chiefsoft.net/)\n- [Web Management Support Portal](https://digifi-office.chiefsoft.net/auth/login)",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"email": "support@chiefsoft.com"
@@ -15,13 +15,13 @@
},
"servers": [
{
- "url": "http://localhost:14700"
+ "url": "http://localhost:4500"
},
{
- "url": "https://devapi.mermsemr.com"
+ "url": "http://api.dev.simbrellang.net:4500"
},
{
- "url": "https://api.mermsemr.com"
+ "url": "https://api.dev.simbrellang.net"
}
],
"tags": [
@@ -30,7 +30,7 @@
"description": "This feature will be used for authorizing customers.",
"externalDocs": {
"description": "Find out more",
- "url": "https://www.mermsemr.com"
+ "url": "https://www.simbrellang.net"
}
},
{
@@ -38,23 +38,47 @@
"description": "This feature will be used for refreshing authorized customers.",
"externalDocs": {
"description": "Find out more",
- "url": "https://www.mermsemr.com"
+ "url": "https://www.simbrellang.net"
}
},
{
- "name": "Login",
- "description": "User Login",
+ "name": "EligibilityCheck",
+ "description": "Eligibility Check Request",
"externalDocs": {
"description": "Find out more",
- "url": "https://www.mermsemr.com"
+ "url": "https://www.simbrellang.net"
}
},
{
- "name": "Register",
- "description": "Register a new user.",
+ "name": "SelectOffer",
+ "description": "This method is used the send the offer the customer selected to Simbrella.",
"externalDocs": {
"description": "Find out more",
- "url": "https://www.mermsemr.com"
+ "url": "https://www.simbrellang.net"
+ }
+ },
+ {
+ "name": "ProvideLoan",
+ "description": "Provide Loan Request.",
+ "externalDocs": {
+ "description": "Find out more",
+ "url": "https://www.simbrellang.net"
+ }
+ },
+ {
+ "name": "LoanStatus",
+ "description": "Loan Information Request.",
+ "externalDocs": {
+ "description": "Find out more",
+ "url": "https://www.simbrellang.net"
+ }
+ },
+ {
+ "name": "Repayment",
+ "description": "Repayment Request.",
+ "externalDocs": {
+ "description": "Find out more",
+ "url": "https://www.simbrellang.net"
}
}
],
@@ -65,26 +89,59 @@
"/AuthorizeRefresh": {
"$ref": "swagger/paths/AuthorizeRefresh.json"
},
- "/Login": {
- "$ref": "swagger/paths/Login.json"
+ "/EligibilityCheck": {
+ "$ref": "swagger/paths/EligibilityCheck.json"
},
- "/Register": {
+ "/SelectOffer": {
"$ref": "swagger/paths/SelectOffer.json"
+ },
+ "/ProvideLoan": {
+ "$ref": "swagger/paths/ProvideLoan.json"
+ },
+ "/LoanStatus": {
+ "$ref": "swagger/paths/LoanStatus.json"
+ },
+ "/Repayment": {
+ "$ref": "swagger/paths/Repayment.json"
}
},
"components": {
"schemas": {
- "Login": {
- "$ref": "swagger/schemas/LoginRequest.json"
+ "EligibilityCheckRequest": {
+ "$ref": "swagger/schemas/EligibilityCheckRequest.json"
},
- "LoginResponse": {
- "$ref": "swagger/schemas/LoginResponse.json"
+ "EligibilityCheckResponse": {
+ "$ref": "swagger/schemas/EligibilityCheckResponse.json"
},
- "Register": {
+ "SelectOfferRequest": {
"$ref": "swagger/schemas/SelectOfferRequest.json"
},
- "RegisterResponse": {
- "$ref": "swagger/schemas/RegisterResponse.json"
+ "SelectOfferResponse": {
+ "$ref": "swagger/schemas/SelectOfferResponse.json"
+ },
+ "LoanStatusRequest": {
+ "$ref": "swagger/schemas/LoanStatusRequest.json"
+ },
+ "LoanStatusResponse": {
+ "$ref": "swagger/schemas/LoanStatusResponse.json"
+ },
+ "RepaymentRequest": {
+ "$ref": "swagger/schemas/RepaymentRequest.json"
+ },
+ "RepaymentResponse": {
+ "$ref": "swagger/schemas/RepaymentResponse.json"
+ },
+ "CustomerConsentRequest": {
+ "$ref": "swagger/schemas/CustomerConsentRequest.json"
+ },
+ "CustomerConsentResponse": {
+ "$ref": "swagger/schemas/CustomerConsentResponse.json"
+ },
+ "NotificationCallbackRequest": {
+ "$ref": "swagger/schemas/NotificationCallbackRequest.json"
+ },
+ "NotificationCallbackResponse": {
+ "$ref": "swagger/schemas/NotificationCallbackResponse.json"
},
"ApiResponse": {
"$ref": "swagger/schemas/ApiResponse.json"
diff --git a/app/swagger/paths/Login.json b/app/swagger/paths/Login.json
deleted file mode 100644
index fe2c681..0000000
--- a/app/swagger/paths/Login.json
+++ /dev/null
@@ -1,57 +0,0 @@
-{
- "post": {
- "tags": [
- "Login"
- ],
- "summary": "Start the process - initiate steps to eligibility RAC Checks ",
- "description": "Initiate Login Request",
- "operationId": "startLogin",
- "requestBody": {
- "description": "Post JSON to conduct eligibility tests",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "../schemas/LoginRequest.json"
- }
- },
- "application/xml": {
- "schema": {
- "$ref": "../schemas/LoginRequest.json"
- }
- },
- "application/x-www-form-urlencoded": {
- "schema": {
- "$ref": "../schemas/LoginRequest.json"
- }
- }
- },
- "required": true
- },
- "responses": {
- "200": {
- "description": "Successful operation",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "../schemas/LoginResponse.json"
- }
- },
- "application/xml": {
- "schema": {
- "$ref": "../schemas/LoginResponse.json"
- }
- }
- }
- },
- "400": {
- "description": "Invalid request"
- },
- "422": {
- "description": "Validation exception"
- },
- "500": {
- "description": "Internal server error"
- }
- }
- }
-}
\ No newline at end of file
diff --git a/app/swagger/schemas/LoginRequest.json b/app/swagger/schemas/LoginRequest.json
deleted file mode 100644
index 7922cfa..0000000
--- a/app/swagger/schemas/LoginRequest.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "type": "object",
- "properties": {
- "username": {
- "type": "string",
- "example": "testaccount"
- },
- "password": {
- "type": "string",
- "example": "merms.user.panel"
- }
- },
- "xml": {
- "name": "LoginRequest"
- }
-}
\ No newline at end of file
diff --git a/app/swagger/schemas/LoginResponse.json b/app/swagger/schemas/LoginResponse.json
deleted file mode 100644
index 5c659a2..0000000
--- a/app/swagger/schemas/LoginResponse.json
+++ /dev/null
@@ -1,49 +0,0 @@
-{
- "type": "object",
- "properties": {
- "member_id": {
- "type": "string",
- "example": "200"
- },
- "uid": {
- "type": "string",
- "example": "8888-999998-9999"
- },
- "username": {
- "type": "string",
- "example": "username"
- },
- "account_name": {
- "type": "string",
- "example": "account_name"
- },
- "firstname": {
- "type": "string",
- "example": "firstname"
- },
- "lastname": {
- "type": "string",
- "example": "lastname"
- },
- "room": {
- "type": "string",
- "example": "room"
- },
- "token": {
- "type": "string",
- "example": "username"
- },
- "resultDescription": {
- "type": "string",
- "example": "Successful"
- },
- "resultCode": {
- "type": "string",
- "example": "00"
- }
- },
- "xml": {
- "name": "LoginResponse"
- }
-}
-
diff --git a/docker-compose.yml b/docker-compose.yml
index d74b463..ef41164 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,10 +1,10 @@
services:
- merms-backend-core:
+ digifi-bank-to-product-core:
build: .
env_file:
- .env
ports:
- - "${APP_PORT:-14703}:5000"
+ - "${APP_PORT:-4500}:5000"
environment:
- FLASK_APP=${FLASK_APP}
- FLASK_ENV=${FLASK_ENV}
diff --git a/entrypoint.sh b/entrypoint.sh
deleted file mode 100644
index 8c7018a..0000000
--- a/entrypoint.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-echo "Running DB migrations..."
-flask db upgrade
-
-echo "Starting Gunicorn server..."
-exec gunicorn -w 4 -b 0.0.0.0:5000 wsgi:wsgi_app
diff --git a/migrations/versions/0acd553309a1_migration_on_tue_jun_10_08_41_00_wat_.py b/migrations/versions/0acd553309a1_migration_on_tue_jun_10_08_41_00_wat_.py
new file mode 100644
index 0000000..b9ca93d
--- /dev/null
+++ b/migrations/versions/0acd553309a1_migration_on_tue_jun_10_08_41_00_wat_.py
@@ -0,0 +1,35 @@
+"""Migration on Tue Jun 10 08:41:00 WAT 2025
+
+Revision ID: 0acd553309a1
+Revises: 45790fd659fb
+Create Date: 2025-06-10 08:41:45.222513
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '0acd553309a1'
+down_revision = '45790fd659fb'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.create_table('repayments_data',
+ sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
+ sa.Column('transaction_id', sa.String(length=50), nullable=False),
+ sa.Column('added_date', sa.DateTime(timezone=True), nullable=False),
+ sa.Column('response_code', sa.String(length=10), nullable=True),
+ sa.Column('response_descr', sa.String(length=255), nullable=True),
+ sa.PrimaryKeyConstraint('id')
+ )
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_table('repayments_data')
+ # ### end Alembic commands ###
diff --git a/migrations/versions/1340e7e578b9_migration_on_thu_apr_10_21_50_01_utc_.py b/migrations/versions/1340e7e578b9_migration_on_thu_apr_10_21_50_01_utc_.py
new file mode 100644
index 0000000..92e0eef
--- /dev/null
+++ b/migrations/versions/1340e7e578b9_migration_on_thu_apr_10_21_50_01_utc_.py
@@ -0,0 +1,32 @@
+"""Migration on Thu Apr 10 21:50:01 UTC 2025
+
+Revision ID: 1340e7e578b9
+Revises: b8f6fd76ead8
+Create Date: 2025-04-10 21:50:32.113149
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '1340e7e578b9'
+down_revision = 'b8f6fd76ead8'
+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('ref_model', 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('ref_model')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/1696ee63c28a_.py b/migrations/versions/1696ee63c28a_.py
new file mode 100644
index 0000000..ddbe1fa
--- /dev/null
+++ b/migrations/versions/1696ee63c28a_.py
@@ -0,0 +1,52 @@
+"""empty message
+
+Revision ID: 1696ee63c28a
+Revises: b54422fb31e0
+Create Date: 2025-06-18 12:28:23.942143
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '1696ee63c28a'
+down_revision = 'b54422fb31e0'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.create_table('salaries',
+ sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
+ sa.Column('customer_id', sa.String(length=50), nullable=False),
+ sa.Column('account_type', sa.String(length=50), nullable=True),
+ sa.Column('status', sa.String(length=20), nullable=True),
+ sa.Column('amount', sa.Float(), nullable=False),
+ sa.Column('salary_date', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
+ sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
+ sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
+ sa.PrimaryKeyConstraint('id')
+ )
+ with op.batch_alter_table('repayments', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('initiated_by', sa.String(length=50), nullable=True))
+ batch_op.add_column(sa.Column('salary_amount', sa.Float(), nullable=True))
+
+ with op.batch_alter_table('repayments_data', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('balance', sa.Float(), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('repayments_data', schema=None) as batch_op:
+ batch_op.drop_column('balance')
+
+ with op.batch_alter_table('repayments', schema=None) as batch_op:
+ batch_op.drop_column('salary_amount')
+ batch_op.drop_column('initiated_by')
+
+ op.drop_table('salaries')
+ # ### end Alembic commands ###
diff --git a/migrations/versions/173ea45db189_migration_on_sat_may_10_09_54_34_utc_.py b/migrations/versions/173ea45db189_migration_on_sat_may_10_09_54_34_utc_.py
new file mode 100644
index 0000000..0c3686b
--- /dev/null
+++ b/migrations/versions/173ea45db189_migration_on_sat_may_10_09_54_34_utc_.py
@@ -0,0 +1,32 @@
+"""Migration on Sat May 10 09:54:34 UTC 2025
+
+Revision ID: 173ea45db189
+Revises: 3105abd795d4
+Create Date: 2025-05-10 09:54:39.380499
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '173ea45db189'
+down_revision = '3105abd795d4'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('transaction_offers', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('original_transaction', sa.String(length=50), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('transaction_offers', schema=None) as batch_op:
+ batch_op.drop_column('original_transaction')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/1b2339f43824_migration_on_thu_apr_24_17_42_25_utc_.py b/migrations/versions/1b2339f43824_migration_on_thu_apr_24_17_42_25_utc_.py
new file mode 100644
index 0000000..c66d8a4
--- /dev/null
+++ b/migrations/versions/1b2339f43824_migration_on_thu_apr_24_17_42_25_utc_.py
@@ -0,0 +1,53 @@
+"""Migration on Thu Apr 24 17:42:25 UTC 2025
+
+Revision ID: 1b2339f43824
+Revises: de9ad96ba34e
+Create Date: 2025-04-24 17:43:09.589626
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '1b2339f43824'
+down_revision = 'de9ad96ba34e'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.create_table('rac_checks',
+ sa.Column('id', sa.String(), nullable=False),
+ sa.Column('transaction_id', sa.String(length=50), nullable=False),
+ sa.Column('customer_id', sa.String(), nullable=False),
+ sa.Column('account_id', sa.String(), nullable=False),
+ sa.Column('rac_response', sa.JSON(), nullable=False),
+ sa.Column('created_at', sa.DateTime(), nullable=True),
+ sa.Column('updated_at', sa.DateTime(), nullable=True),
+ sa.PrimaryKeyConstraint('id')
+ )
+ with op.batch_alter_table('loan_charges', schema=None) as batch_op:
+ batch_op.alter_column('amount',
+ existing_type=sa.NUMERIC(precision=10, scale=2),
+ type_=sa.Float(),
+ existing_nullable=True)
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.drop_column('installment_amount')
+ batch_op.drop_column('repayment_amount')
+ batch_op.drop_column('upfront_fee')
+
+ with op.batch_alter_table('loan_charges', schema=None) as batch_op:
+ batch_op.alter_column('amount',
+ existing_type=sa.Float(),
+ type_=sa.NUMERIC(precision=10, scale=2),
+ existing_nullable=True)
+
+ op.drop_table('rac_checks')
+ # ### end Alembic commands ###
diff --git a/migrations/versions/287ecb02d3d7_migration_on_wed_apr_16_18_35_18_utc_.py b/migrations/versions/287ecb02d3d7_migration_on_wed_apr_16_18_35_18_utc_.py
new file mode 100644
index 0000000..583c616
--- /dev/null
+++ b/migrations/versions/287ecb02d3d7_migration_on_wed_apr_16_18_35_18_utc_.py
@@ -0,0 +1,32 @@
+"""Migration on Wed Apr 16 18:35:18 UTC 2025
+
+Revision ID: 287ecb02d3d7
+Revises: a4847b997191
+Create Date: 2025-04-16 18:36:04.632791
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '287ecb02d3d7'
+down_revision = 'a4847b997191'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loan_charges', schema=None) as batch_op:
+ batch_op.drop_column('transaction_id')
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loan_charges', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('transaction_id', sa.VARCHAR(length=50), autoincrement=False, nullable=True))
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/2a45dd99c9cb_migration_on_fri_apr_25_15_01_00_utc_.py b/migrations/versions/2a45dd99c9cb_migration_on_fri_apr_25_15_01_00_utc_.py
new file mode 100644
index 0000000..7b388b5
--- /dev/null
+++ b/migrations/versions/2a45dd99c9cb_migration_on_fri_apr_25_15_01_00_utc_.py
@@ -0,0 +1,42 @@
+"""Migration on Fri Apr 25 15:01:00 UTC 2025
+
+Revision ID: 2a45dd99c9cb
+Revises: 2cf0c177ca02
+Create Date: 2025-04-25 15:01:51.129681
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '2a45dd99c9cb'
+down_revision = '2cf0c177ca02'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loan_repayment_schedules', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('product_id', sa.String(length=20), nullable=True))
+ batch_op.add_column(sa.Column('installment_amount', sa.Float(), nullable=True))
+ batch_op.add_column(sa.Column('total_repayment_amount', sa.Float(), nullable=True))
+ batch_op.drop_column('principal_amount')
+ batch_op.drop_column('interest_amount')
+ batch_op.drop_column('total_installment')
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loan_repayment_schedules', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('total_installment', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True))
+ batch_op.add_column(sa.Column('interest_amount', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True))
+ batch_op.add_column(sa.Column('principal_amount', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True))
+ batch_op.drop_column('total_repayment_amount')
+ batch_op.drop_column('installment_amount')
+ batch_op.drop_column('product_id')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/2cf0c177ca02_migration_on_fri_apr_25_14_02_01_utc_.py b/migrations/versions/2cf0c177ca02_migration_on_fri_apr_25_14_02_01_utc_.py
new file mode 100644
index 0000000..6876ba6
--- /dev/null
+++ b/migrations/versions/2cf0c177ca02_migration_on_fri_apr_25_14_02_01_utc_.py
@@ -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 ###
diff --git a/migrations/versions/2eee4157505f_.py b/migrations/versions/2eee4157505f_.py
new file mode 100644
index 0000000..427b545
--- /dev/null
+++ b/migrations/versions/2eee4157505f_.py
@@ -0,0 +1,250 @@
+"""empty message
+
+Revision ID: 2eee4157505f
+Revises: 565bc3d0ba6e
+Create Date: 2025-05-16 13:24:41.914400
+
+"""
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects import postgresql
+
+# revision identifiers, used by Alembic.
+revision = '2eee4157505f'
+down_revision = '565bc3d0ba6e'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('accounts', schema=None) as batch_op:
+ batch_op.alter_column('created_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+ batch_op.alter_column('updated_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+
+ with op.batch_alter_table('charges', schema=None) as batch_op:
+ batch_op.alter_column('created_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+ batch_op.alter_column('updated_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+
+ with op.batch_alter_table('customers', schema=None) as batch_op:
+ batch_op.alter_column('created_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+ batch_op.alter_column('updated_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+
+ with op.batch_alter_table('loan_charges', schema=None) as batch_op:
+ batch_op.alter_column('created_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+ batch_op.alter_column('updated_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+
+ with op.batch_alter_table('loan_repayment_schedules', schema=None) as batch_op:
+ batch_op.alter_column('created_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+ batch_op.alter_column('updated_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.alter_column('created_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+ batch_op.alter_column('updated_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+
+ with op.batch_alter_table('offers', schema=None) as batch_op:
+ batch_op.alter_column('created_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+ batch_op.alter_column('updated_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+
+ with op.batch_alter_table('rac_checks', schema=None) as batch_op:
+ batch_op.alter_column('created_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+ batch_op.alter_column('updated_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+
+ with op.batch_alter_table('repayments', schema=None) as batch_op:
+ batch_op.alter_column('created_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+ batch_op.alter_column('updated_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+
+ with op.batch_alter_table('transaction_offers', schema=None) as batch_op:
+ batch_op.alter_column('created_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+ batch_op.alter_column('updated_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True)
+
+ with op.batch_alter_table('transactions', schema=None) as batch_op:
+ batch_op.alter_column('created_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True,
+ existing_server_default=sa.text('now()'))
+ batch_op.alter_column('updated_at',
+ existing_type=postgresql.TIMESTAMP(),
+ type_=sa.DateTime(timezone=True),
+ existing_nullable=True,
+ existing_server_default=sa.text('now()'))
+
+ # ### 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.alter_column('updated_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True,
+ existing_server_default=sa.text('now()'))
+ batch_op.alter_column('created_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True,
+ existing_server_default=sa.text('now()'))
+
+ with op.batch_alter_table('transaction_offers', schema=None) as batch_op:
+ batch_op.alter_column('updated_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+ batch_op.alter_column('created_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+
+ with op.batch_alter_table('repayments', schema=None) as batch_op:
+ batch_op.alter_column('updated_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+ batch_op.alter_column('created_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+
+ with op.batch_alter_table('rac_checks', schema=None) as batch_op:
+ batch_op.alter_column('updated_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+ batch_op.alter_column('created_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+
+ with op.batch_alter_table('offers', schema=None) as batch_op:
+ batch_op.alter_column('updated_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+ batch_op.alter_column('created_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.alter_column('updated_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+ batch_op.alter_column('created_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+
+ with op.batch_alter_table('loan_repayment_schedules', schema=None) as batch_op:
+ batch_op.alter_column('updated_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+ batch_op.alter_column('created_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+
+ with op.batch_alter_table('loan_charges', schema=None) as batch_op:
+ batch_op.alter_column('updated_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+ batch_op.alter_column('created_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+
+ with op.batch_alter_table('customers', schema=None) as batch_op:
+ batch_op.alter_column('updated_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+ batch_op.alter_column('created_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+
+ with op.batch_alter_table('charges', schema=None) as batch_op:
+ batch_op.alter_column('updated_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+ batch_op.alter_column('created_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+
+ with op.batch_alter_table('accounts', schema=None) as batch_op:
+ batch_op.alter_column('updated_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+ batch_op.alter_column('created_at',
+ existing_type=sa.DateTime(timezone=True),
+ type_=postgresql.TIMESTAMP(),
+ existing_nullable=True)
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/3105abd795d4_.py b/migrations/versions/3105abd795d4_.py
new file mode 100644
index 0000000..c6ae0da
--- /dev/null
+++ b/migrations/versions/3105abd795d4_.py
@@ -0,0 +1,52 @@
+"""empty message
+
+Revision ID: 3105abd795d4
+Revises: 95a52be203c4
+Create Date: 2025-05-07 11:44:18.483694
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '3105abd795d4'
+down_revision = '95a52be203c4'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('rac_checks', schema=None) as batch_op:
+ # Step 1: Drop the default value
+ batch_op.alter_column('id',
+ server_default=None,
+ existing_type=sa.VARCHAR(),
+ existing_nullable=False
+ )
+
+ with op.batch_alter_table('rac_checks', schema=None) as batch_op:
+ # Step 2: Change the column type
+ batch_op.alter_column('id',
+ existing_type=sa.VARCHAR(),
+ type_=sa.Integer(),
+ existing_nullable=False,
+ autoincrement=True,
+ postgresql_using='id::integer'
+ )
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('rac_checks', schema=None) as batch_op:
+ batch_op.alter_column('id',
+ existing_type=sa.Integer(),
+ type_=sa.VARCHAR(),
+ existing_nullable=False,
+ autoincrement=True,
+ existing_server_default=sa.text("''::character varying"))
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/38acee611d55_migration_for_mloan_table.py b/migrations/versions/38acee611d55_migration_for_mloan_table.py
new file mode 100644
index 0000000..cb327d3
--- /dev/null
+++ b/migrations/versions/38acee611d55_migration_for_mloan_table.py
@@ -0,0 +1,32 @@
+"""Migration for mloan table
+
+Revision ID: 38acee611d55
+Revises: f1e83a993034
+Create Date: 2025-04-30 09:55:30.552838
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '38acee611d55'
+down_revision = 'f1e83a993034'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('tenor', sa.Integer(), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.drop_column('tenor')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/45790fd659fb_.py b/migrations/versions/45790fd659fb_.py
new file mode 100644
index 0000000..2895b4f
--- /dev/null
+++ b/migrations/versions/45790fd659fb_.py
@@ -0,0 +1,54 @@
+"""empty message
+
+Revision ID: 45790fd659fb
+Revises: b3a5e10bc77e
+Create Date: 2025-06-04 12:37:48.180736
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '45790fd659fb'
+down_revision = 'b3a5e10bc77e'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('disburse_result', sa.String(length=10), nullable=True))
+ batch_op.add_column(sa.Column('disburse_description', sa.String(length=100), nullable=True))
+ batch_op.add_column(sa.Column('verify_result', sa.String(length=10), nullable=True))
+ batch_op.add_column(sa.Column('verify_description', sa.String(length=100), nullable=True))
+
+ with op.batch_alter_table('repayments', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('repay_date', sa.DateTime(), nullable=True))
+ batch_op.add_column(sa.Column('repay_result', sa.String(length=10), nullable=True))
+ batch_op.add_column(sa.Column('repay_description', sa.String(length=100), nullable=True))
+ batch_op.add_column(sa.Column('verify_date', sa.DateTime(), nullable=True))
+ batch_op.add_column(sa.Column('verify_result', sa.String(length=10), nullable=True))
+ batch_op.add_column(sa.Column('verify_description', sa.String(length=100), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('repayments', schema=None) as batch_op:
+ batch_op.drop_column('verify_description')
+ batch_op.drop_column('verify_result')
+ batch_op.drop_column('verify_date')
+ batch_op.drop_column('repay_description')
+ batch_op.drop_column('repay_result')
+ batch_op.drop_column('repay_date')
+
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.drop_column('verify_description')
+ batch_op.drop_column('verify_result')
+ batch_op.drop_column('disburse_description')
+ batch_op.drop_column('disburse_result')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/565bc3d0ba6e_migration_on_sat_may_10_12_54_52_utc_.py b/migrations/versions/565bc3d0ba6e_migration_on_sat_may_10_12_54_52_utc_.py
new file mode 100644
index 0000000..91895f2
--- /dev/null
+++ b/migrations/versions/565bc3d0ba6e_migration_on_sat_may_10_12_54_52_utc_.py
@@ -0,0 +1,34 @@
+"""Migration on Sat May 10 12:54:52 UTC 2025
+
+Revision ID: 565bc3d0ba6e
+Revises: 173ea45db189
+Create Date: 2025-05-10 12:54:56.683215
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '565bc3d0ba6e'
+down_revision = '173ea45db189'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('disburse_date', sa.DateTime(), nullable=True))
+ batch_op.add_column(sa.Column('disburse_verify', sa.DateTime(), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.drop_column('disburse_verify')
+ batch_op.drop_column('disburse_date')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/610b7e9d15a6_migration_on_fri_apr_11_14_15_19_utc_.py b/migrations/versions/610b7e9d15a6_migration_on_fri_apr_11_14_15_19_utc_.py
new file mode 100644
index 0000000..ab24390
--- /dev/null
+++ b/migrations/versions/610b7e9d15a6_migration_on_fri_apr_11_14_15_19_utc_.py
@@ -0,0 +1,32 @@
+"""Migration on Fri Apr 11 14:15:19 UTC 2025
+
+Revision ID: 610b7e9d15a6
+Revises: 9bb0367eb486
+Create Date: 2025-04-11 14:16:12.533227
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '610b7e9d15a6'
+down_revision = '9bb0367eb486'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('transaction_id', sa.String(length=50), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.drop_column('transaction_id')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/783a023a477f_migration_on_mon_apr_14_15_15_05_utc_.py b/migrations/versions/783a023a477f_migration_on_mon_apr_14_15_15_05_utc_.py
new file mode 100644
index 0000000..7308758
--- /dev/null
+++ b/migrations/versions/783a023a477f_migration_on_mon_apr_14_15_15_05_utc_.py
@@ -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 ###
diff --git a/migrations/versions/7a0caf83d5be_.py b/migrations/versions/7a0caf83d5be_.py
new file mode 100644
index 0000000..190e4f4
--- /dev/null
+++ b/migrations/versions/7a0caf83d5be_.py
@@ -0,0 +1,34 @@
+"""empty message
+
+Revision ID: 7a0caf83d5be
+Revises: 1696ee63c28a
+Create Date: 2025-06-19 04:35:23.660261
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '7a0caf83d5be'
+down_revision = '1696ee63c28a'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('salaries', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('account_id', sa.String(length=50), nullable=True))
+ batch_op.drop_column('account_type')
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('salaries', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('account_type', sa.VARCHAR(length=50), autoincrement=False, nullable=True))
+ batch_op.drop_column('account_id')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/86e701febdda_.py b/migrations/versions/86e701febdda_.py
new file mode 100644
index 0000000..5f54178
--- /dev/null
+++ b/migrations/versions/86e701febdda_.py
@@ -0,0 +1,41 @@
+"""empty message
+
+Revision ID: 86e701febdda
+Revises: eb99c7fb9e09
+Create Date: 2025-04-29 07:59:33.305967
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '86e701febdda'
+down_revision = 'eb99c7fb9e09'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.create_table('transaction_offers',
+ sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
+ sa.Column('customer_id', sa.String(length=50), nullable=False),
+ sa.Column('transaction_id', sa.String(length=50), nullable=False),
+ sa.Column('offer_id', sa.String(length=20), nullable=False),
+ sa.Column('product_id', sa.String(length=20), nullable=True),
+ sa.Column('min_amount', sa.Float(), nullable=False),
+ sa.Column('max_amount', sa.Float(), nullable=False),
+ sa.Column('eligible_amount', sa.Float(), nullable=True),
+ sa.Column('tenor', sa.Integer(), 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('transaction_offers')
+ # ### end Alembic commands ###
diff --git a/migrations/versions/89759cebb9c6_migration_on_sat_apr_26_12_50_46_utc_.py b/migrations/versions/89759cebb9c6_migration_on_sat_apr_26_12_50_46_utc_.py
new file mode 100644
index 0000000..3c33c55
--- /dev/null
+++ b/migrations/versions/89759cebb9c6_migration_on_sat_apr_26_12_50_46_utc_.py
@@ -0,0 +1,38 @@
+"""Migration on Sat Apr 26 12:50:46 UTC 2025
+
+Revision ID: 89759cebb9c6
+Revises: 2a45dd99c9cb
+Create Date: 2025-04-26 12:50:49.771355
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '89759cebb9c6'
+down_revision = '2a45dd99c9cb'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('offers', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('interest_rate', sa.Float(), nullable=True))
+ batch_op.add_column(sa.Column('management_rate', sa.Float(), nullable=True))
+ batch_op.add_column(sa.Column('insurance_rate', sa.Float(), nullable=True))
+ batch_op.add_column(sa.Column('vat_rate', sa.Float(), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('offers', schema=None) as batch_op:
+ batch_op.drop_column('vat_rate')
+ batch_op.drop_column('insurance_rate')
+ batch_op.drop_column('management_rate')
+ batch_op.drop_column('interest_rate')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/95a52be203c4_migration_on_sat_may_3_21_53_29_utc_2025.py b/migrations/versions/95a52be203c4_migration_on_sat_may_3_21_53_29_utc_2025.py
new file mode 100644
index 0000000..7a03ceb
--- /dev/null
+++ b/migrations/versions/95a52be203c4_migration_on_sat_may_3_21_53_29_utc_2025.py
@@ -0,0 +1,32 @@
+"""Migration on Sat May 3 21:53:29 UTC 2025
+
+Revision ID: 95a52be203c4
+Revises: 38acee611d55
+Create Date: 2025-05-03 21:53:32.154029
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '95a52be203c4'
+down_revision = '38acee611d55'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('eligible_amount', sa.Float(), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.drop_column('eligible_amount')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/9bb0367eb486_migration_on_fri_apr_11_12_48_01_utc_.py b/migrations/versions/9bb0367eb486_migration_on_fri_apr_11_12_48_01_utc_.py
new file mode 100644
index 0000000..be5e457
--- /dev/null
+++ b/migrations/versions/9bb0367eb486_migration_on_fri_apr_11_12_48_01_utc_.py
@@ -0,0 +1,40 @@
+"""Migration on Fri Apr 11 12:48:01 UTC 2025
+
+Revision ID: 9bb0367eb486
+Revises: fd447d78b161
+Create Date: 2025-04-11 12:48:36.145311
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '9bb0367eb486'
+down_revision = 'fd447d78b161'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('product_id', sa.String(length=20), nullable=True))
+ batch_op.add_column(sa.Column('current_loan_amount', sa.Float(), nullable=True))
+ batch_op.add_column(sa.Column('default_penalty_fee', sa.Float(), nullable=True))
+ batch_op.add_column(sa.Column('continuous_fee', sa.Float(), nullable=True))
+ batch_op.add_column(sa.Column('due_date', sa.DateTime(), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.drop_column('due_date')
+ batch_op.drop_column('continuous_fee')
+ batch_op.drop_column('default_penalty_fee')
+ batch_op.drop_column('current_loan_amount')
+ batch_op.drop_column('product_id')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/a4847b997191_migration_on_wed_apr_16_17_42_49_utc_.py b/migrations/versions/a4847b997191_migration_on_wed_apr_16_17_42_49_utc_.py
new file mode 100644
index 0000000..a41dc5c
--- /dev/null
+++ b/migrations/versions/a4847b997191_migration_on_wed_apr_16_17_42_49_utc_.py
@@ -0,0 +1,57 @@
+"""Migration on Wed Apr 16 17:42:49 UTC 2025
+
+Revision ID: a4847b997191
+Revises: 783a023a477f
+Create Date: 2025-04-16 17:43:22.509659
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'a4847b997191'
+down_revision = '783a023a477f'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.create_table('loan_charges',
+ sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
+ sa.Column('loan_id', sa.Integer(), nullable=False),
+ sa.Column('transaction_id', sa.String(length=50), nullable=True),
+ sa.Column('code', sa.String(length=50), nullable=False),
+ sa.Column('amount', sa.Float(), nullable=True),
+ sa.Column('percent', sa.Float(), nullable=True),
+ sa.Column('description', sa.Text(), nullable=True),
+ sa.Column('due', sa.Integer(), nullable=False),
+ sa.Column('created_at', sa.DateTime(), nullable=True),
+ sa.Column('updated_at', sa.DateTime(), nullable=True),
+ sa.PrimaryKeyConstraint('id')
+ )
+ op.create_table('offers',
+ sa.Column('id', sa.String(), nullable=False),
+ sa.Column('product_id', sa.String(), nullable=False),
+ sa.Column('min_amount', sa.Float(), nullable=False),
+ sa.Column('max_amount', sa.Float(), nullable=False),
+ sa.Column('tenor', sa.Integer(), nullable=False),
+ sa.Column('created_at', sa.DateTime(), nullable=True),
+ sa.Column('updated_at', sa.DateTime(), nullable=True),
+ sa.PrimaryKeyConstraint('id')
+ )
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('product_id', sa.String(length=20), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.drop_column('product_id')
+
+ op.drop_table('offers')
+ op.drop_table('loan_charges')
+ # ### end Alembic commands ###
diff --git a/migrations/versions/b3a5e10bc77e_.py b/migrations/versions/b3a5e10bc77e_.py
new file mode 100644
index 0000000..8a8205a
--- /dev/null
+++ b/migrations/versions/b3a5e10bc77e_.py
@@ -0,0 +1,32 @@
+"""empty message
+
+Revision ID: b3a5e10bc77e
+Revises: e8dd9b841ad7
+Create Date: 2025-05-27 01:52:48.538333
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'b3a5e10bc77e'
+down_revision = 'e8dd9b841ad7'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('reference', sa.String(length=50), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.drop_column('reference')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/b54422fb31e0_.py b/migrations/versions/b54422fb31e0_.py
new file mode 100644
index 0000000..dd26721
--- /dev/null
+++ b/migrations/versions/b54422fb31e0_.py
@@ -0,0 +1,46 @@
+"""empty message
+
+Revision ID: b54422fb31e0
+Revises: 0acd553309a1
+Create Date: 2025-06-16 12:24:09.159498
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'b54422fb31e0'
+down_revision = '0acd553309a1'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('repayments_data', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('fbn_transaction_id', sa.String(length=50), nullable=True))
+ batch_op.add_column(sa.Column('customer_id', sa.String(length=50), nullable=True))
+ batch_op.add_column(sa.Column('account_id', sa.String(length=50), nullable=True))
+ batch_op.add_column(sa.Column('repayment_amount', sa.Float(), nullable=True))
+ batch_op.add_column(sa.Column('amount_collected', sa.Float(), nullable=True))
+
+ with op.batch_alter_table('transactions', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('phone_number', 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('phone_number')
+
+ with op.batch_alter_table('repayments_data', schema=None) as batch_op:
+ batch_op.drop_column('amount_collected')
+ batch_op.drop_column('repayment_amount')
+ batch_op.drop_column('account_id')
+ batch_op.drop_column('customer_id')
+ batch_op.drop_column('fbn_transaction_id')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/b8f6fd76ead8_migration_on_thu_apr_10_16_21_45_utc_.py b/migrations/versions/b8f6fd76ead8_migration_on_thu_apr_10_16_21_45_utc_.py
new file mode 100644
index 0000000..69d16e7
--- /dev/null
+++ b/migrations/versions/b8f6fd76ead8_migration_on_thu_apr_10_16_21_45_utc_.py
@@ -0,0 +1,86 @@
+"""Migration on Thu Apr 10 16:21:45 UTC 2025
+
+Revision ID: b8f6fd76ead8
+Revises:
+Create Date: 2025-04-10 16:22:15.946157
+
+"""
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects import postgresql
+
+# revision identifiers, used by Alembic.
+revision = 'b8f6fd76ead8'
+down_revision = None
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.create_table('repayments',
+ sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
+ sa.Column('loan_id', sa.String(length=50), nullable=False),
+ sa.Column('customer_id', sa.String(length=50), nullable=False),
+ sa.Column('product_id', sa.String(length=20), nullable=True),
+ sa.Column('created_at', sa.DateTime(), nullable=True),
+ sa.Column('updated_at', sa.DateTime(), nullable=True),
+ sa.PrimaryKeyConstraint('id')
+ )
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.alter_column('id',
+ existing_type=sa.VARCHAR(length=50),
+ type_=sa.Integer(),
+ existing_nullable=False,
+ autoincrement=True,
+ existing_server_default=sa.text("nextval('loan_id_seq'::regclass)"))
+
+ with op.batch_alter_table('transactions', schema=None) as batch_op:
+ batch_op.alter_column('channel',
+ existing_type=sa.VARCHAR(length=8),
+ type_=sa.String(length=50),
+ existing_nullable=False)
+ batch_op.alter_column('created_at',
+ existing_type=postgresql.TIMESTAMP(timezone=True),
+ type_=sa.DateTime(),
+ existing_nullable=True,
+ existing_server_default=sa.text('now()'))
+ batch_op.alter_column('updated_at',
+ existing_type=postgresql.TIMESTAMP(timezone=True),
+ type_=sa.DateTime(),
+ existing_nullable=True,
+ existing_server_default=sa.text('now()'))
+ batch_op.drop_constraint('transactions_id_key', type_='unique')
+
+ # ### 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.create_unique_constraint('transactions_id_key', ['id'])
+ batch_op.alter_column('updated_at',
+ existing_type=sa.DateTime(),
+ type_=postgresql.TIMESTAMP(timezone=True),
+ existing_nullable=True,
+ existing_server_default=sa.text('now()'))
+ batch_op.alter_column('created_at',
+ existing_type=sa.DateTime(),
+ type_=postgresql.TIMESTAMP(timezone=True),
+ existing_nullable=True,
+ existing_server_default=sa.text('now()'))
+ batch_op.alter_column('channel',
+ existing_type=sa.String(length=50),
+ type_=sa.VARCHAR(length=8),
+ existing_nullable=False)
+
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.alter_column('id',
+ existing_type=sa.Integer(),
+ type_=sa.VARCHAR(length=50),
+ existing_nullable=False,
+ autoincrement=True,
+ existing_server_default=sa.text("nextval('loan_id_seq'::regclass)"))
+
+ op.drop_table('repayments')
+ # ### end Alembic commands ###
diff --git a/migrations/versions/de9ad96ba34e_migration_on_thu_apr_17_14_15_36_utc_.py b/migrations/versions/de9ad96ba34e_migration_on_thu_apr_17_14_15_36_utc_.py
new file mode 100644
index 0000000..a4f4276
--- /dev/null
+++ b/migrations/versions/de9ad96ba34e_migration_on_thu_apr_17_14_15_36_utc_.py
@@ -0,0 +1,38 @@
+"""Migration on Thu Apr 17 14:15:36 UTC 2025
+
+Revision ID: de9ad96ba34e
+Revises: ec8d97f9b584
+Create Date: 2025-04-17 14:16:16.537466
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'de9ad96ba34e'
+down_revision = 'ec8d97f9b584'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.create_table('charges',
+ sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
+ sa.Column('offer_id', sa.String(length=50), nullable=False),
+ sa.Column('code', sa.String(length=50), nullable=False),
+ sa.Column('percent', sa.Float(), nullable=True),
+ sa.Column('description', sa.Text(), nullable=True),
+ sa.Column('due', sa.Integer(), nullable=False),
+ 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('charges')
+ # ### end Alembic commands ###
diff --git a/migrations/versions/e8dd9b841ad7_.py b/migrations/versions/e8dd9b841ad7_.py
new file mode 100644
index 0000000..22a3b68
--- /dev/null
+++ b/migrations/versions/e8dd9b841ad7_.py
@@ -0,0 +1,36 @@
+"""empty message
+
+Revision ID: e8dd9b841ad7
+Revises: 2eee4157505f
+Create Date: 2025-05-19 11:46:19.204637
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'e8dd9b841ad7'
+down_revision = '2eee4157505f'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('offers', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('max_daily_loans', sa.Integer(), nullable=True))
+ batch_op.add_column(sa.Column('max_active_loans', sa.Integer(), nullable=True))
+ batch_op.add_column(sa.Column('max_life_loans', sa.Integer(), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('offers', schema=None) as batch_op:
+ batch_op.drop_column('max_life_loans')
+ batch_op.drop_column('max_active_loans')
+ batch_op.drop_column('max_daily_loans')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/eb99c7fb9e09_migration_on_sat_apr_26_19_02_17_utc_.py b/migrations/versions/eb99c7fb9e09_migration_on_sat_apr_26_19_02_17_utc_.py
new file mode 100644
index 0000000..c77223e
--- /dev/null
+++ b/migrations/versions/eb99c7fb9e09_migration_on_sat_apr_26_19_02_17_utc_.py
@@ -0,0 +1,32 @@
+"""Migration on Sat Apr 26 19:02:17 UTC 2025
+
+Revision ID: eb99c7fb9e09
+Revises: 89759cebb9c6
+Create Date: 2025-04-26 19:02:20.443678
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'eb99c7fb9e09'
+down_revision = '89759cebb9c6'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('original_transaction', sa.String(length=50), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.drop_column('original_transaction')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/ec8d97f9b584_migration_on_thu_apr_17_10_40_05_utc_.py b/migrations/versions/ec8d97f9b584_migration_on_thu_apr_17_10_40_05_utc_.py
new file mode 100644
index 0000000..1cf6d46
--- /dev/null
+++ b/migrations/versions/ec8d97f9b584_migration_on_thu_apr_17_10_40_05_utc_.py
@@ -0,0 +1,34 @@
+"""Migration on Thu Apr 17 10:40:05 UTC 2025
+
+Revision ID: ec8d97f9b584
+Revises: 287ecb02d3d7
+Create Date: 2025-04-17 10:40:34.751272
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'ec8d97f9b584'
+down_revision = '287ecb02d3d7'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loan_charges', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('transaction_id', sa.String(length=50), nullable=True))
+ batch_op.add_column(sa.Column('due_date', sa.DateTime(), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loan_charges', schema=None) as batch_op:
+ batch_op.drop_column('due_date')
+ batch_op.drop_column('transaction_id')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/f1e83a993034_migration_on_tue_apr_29_20_43_35_utc_.py b/migrations/versions/f1e83a993034_migration_on_tue_apr_29_20_43_35_utc_.py
new file mode 100644
index 0000000..8fd4163
--- /dev/null
+++ b/migrations/versions/f1e83a993034_migration_on_tue_apr_29_20_43_35_utc_.py
@@ -0,0 +1,32 @@
+"""Migration on Tue Apr 29 20:43:35 UTC 2025
+
+Revision ID: f1e83a993034
+Revises: 86e701febdda
+Create Date: 2025-04-29 20:43:38.595543
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'f1e83a993034'
+down_revision = '86e701febdda'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loan_repayment_schedules', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('transaction_id', sa.String(length=50), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loan_repayment_schedules', schema=None) as batch_op:
+ batch_op.drop_column('transaction_id')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/f6cd1bfc8832_migration_on_fri_apr_11_14_34_36_utc_.py b/migrations/versions/f6cd1bfc8832_migration_on_fri_apr_11_14_34_36_utc_.py
new file mode 100644
index 0000000..498ede0
--- /dev/null
+++ b/migrations/versions/f6cd1bfc8832_migration_on_fri_apr_11_14_34_36_utc_.py
@@ -0,0 +1,34 @@
+"""Migration on Fri Apr 11 14:34:36 UTC 2025
+
+Revision ID: f6cd1bfc8832
+Revises: 610b7e9d15a6
+Create Date: 2025-04-11 14:35:07.093967
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'f6cd1bfc8832'
+down_revision = '610b7e9d15a6'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('collection_type', sa.String(length=20), nullable=True))
+ batch_op.drop_column('product_id')
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('loans', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('product_id', sa.VARCHAR(length=20), autoincrement=False, nullable=True))
+ batch_op.drop_column('collection_type')
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/fd447d78b161_migration_on_fri_apr_11_12_02_45_utc_.py b/migrations/versions/fd447d78b161_migration_on_fri_apr_11_12_02_45_utc_.py
new file mode 100644
index 0000000..eff663e
--- /dev/null
+++ b/migrations/versions/fd447d78b161_migration_on_fri_apr_11_12_02_45_utc_.py
@@ -0,0 +1,38 @@
+"""Migration on Fri Apr 11 12:02:45 UTC 2025
+
+Revision ID: fd447d78b161
+Revises: 1340e7e578b9
+Create Date: 2025-04-11 12:03:28.346671
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'fd447d78b161'
+down_revision = '1340e7e578b9'
+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.alter_column('account_id',
+ existing_type=sa.VARCHAR(length=50),
+ nullable=True)
+ batch_op.drop_column('ref_model')
+
+ # ### 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.add_column(sa.Column('ref_model', sa.VARCHAR(length=50), autoincrement=False, nullable=True))
+ batch_op.alter_column('account_id',
+ existing_type=sa.VARCHAR(length=50),
+ nullable=False)
+
+ # ### end Alembic commands ###
diff --git a/requirements.txt b/requirements.txt
index 7289956..820a23d 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -30,12 +30,12 @@ httpx
# JWT
flask-jwt-extended
-pyjwt
+
# Kafka
confluent-kafka==1.9.2
-werkzeug
+
python-dateutil