diff --git a/app/eco/models/account.py b/app/eco/models/account.py new file mode 100644 index 0000000..98cebc5 --- /dev/null +++ b/app/eco/models/account.py @@ -0,0 +1,17 @@ +from sqlalchemy import Column, String, Date, Boolean, Integer +from app.extensions import db + +class Account(db.Model): + __tablename__ = 'accounts' + __bind_key__ = 'eco' + + id = Column(Integer, primary_key=True) + affiliate_code = Column(String(3), nullable=False) + customer_id = Column(String(9), nullable=False) + account_id = Column(String(10), unique=True, nullable=False) + registration_date = Column(Date, nullable=False) + account_currency_code = Column(String(3), nullable=False) + plastic_card_attached = Column(Boolean, default=False) + + def __repr__(self): + return f"" \ No newline at end of file diff --git a/app/eco/models/customer.py b/app/eco/models/customer.py new file mode 100644 index 0000000..7c3dc42 --- /dev/null +++ b/app/eco/models/customer.py @@ -0,0 +1,18 @@ +from sqlalchemy import Column, String, Date, Integer +from sqlalchemy.orm import relationship +from app.extensions import db + + +class Customer(db.Model): + __tablename__ = 'customers' + __bind_key__ = 'eco' + + id = Column(Integer, primary_key=True) + affiliate_code = Column(String(3), nullable=False) + customer_id = Column(String(9), unique=True, nullable=False) + msisdn = Column(String(15), nullable=True) + created_at = Column(Date, nullable=False) + + + def __repr__(self): + return f"" \ No newline at end of file diff --git a/app/eco/models/installment.py b/app/eco/models/installment.py new file mode 100644 index 0000000..b44ea36 --- /dev/null +++ b/app/eco/models/installment.py @@ -0,0 +1,21 @@ +from app.eco.enums.installment_status import InstallmentStatus +from sqlalchemy import Column, String, Date, Numeric, ForeignKey, Enum, Integer, DateTime +from app.extensions import db +import enum + +class Installment(db.Model): + __tablename__ = 'installments' + __bind_key__ = 'eco' + + + id = Column(Integer, primary_key=True) + loan_id = Column(Integer, nullable=False) + installment_number = Column(Integer, nullable=False) + due_date = Column(Date, nullable=False) + amount = Column(Numeric(12, 2), nullable=False) + paid_amount = Column(Numeric(12, 2), default=0.00) + status = Column(Enum(InstallmentStatus), default=InstallmentStatus.PENDING) + penalty_amount = Column(Numeric(12, 2), default=0.00) + + def __repr__(self): + return f"" \ No newline at end of file diff --git a/app/eco/models/loan.py b/app/eco/models/loan.py new file mode 100644 index 0000000..096e9bf --- /dev/null +++ b/app/eco/models/loan.py @@ -0,0 +1,26 @@ +from app.eco.enums.loan_status import LoanStatus +from sqlalchemy import Column, String, Date, Numeric, Enum +from app.extensions import db +import enum + +class Loan(db.Model): + __tablename__ = 'loans' + __bind_key__ = 'eco' + + id = Column(Integer, primary_key=True) + request_id = Column(String(50), unique=True, nullable=False) + affiliate_code = Column(String(3), nullable=False) + customer_id = Column(String(9), nullable=False) + account_id = Column(String(10), nullable=False) + product_id = Column(String(4), nullable=False) + debt_id = Column(String(20), unique=True, nullable=False) + initial_credit_amount = Column(Numeric(12, 2), nullable=False) + current_balance = Column(Numeric(12, 2), nullable=False) + interest_rate = Column(Numeric(5, 2), nullable=False) + status = Column(Enum(LoanStatus), default=LoanStatus.PENDING) + disbursement_date = Column(Date, nullable=False) + due_date = Column(Date, nullable=False) + lien_amount = Column(Numeric(12, 2), default=0.00) + + def __repr__(self): + return f"" \ No newline at end of file diff --git a/app/eco/models/offer.py b/app/eco/models/offer.py new file mode 100644 index 0000000..7214148 --- /dev/null +++ b/app/eco/models/offer.py @@ -0,0 +1,22 @@ +from sqlalchemy import Column, String, Numeric, Date, Integer +from app.extensions import db + +class Offer(db.Model): + __tablename__ = 'offers' + __bind_key__ = 'eco' + + id = Column(Integer, primary_key=True) + offer_id = Column(String(50), unique=True, nullable=False) + session_id = Column(String(50), nullable=False) + customer_id = Column(String(9), nullable=False) + product_id = Column(String(4), nullable=False) + amount = Column(Numeric(12, 2), nullable=False) + upfront_payment = Column(Numeric(12, 2), nullable=False) + interest_rate = Column(Numeric(5, 2), nullable=False) + installment_amount = Column(Numeric(12, 2), nullable=False) + total_repayment_amount = Column(Numeric(12, 2), nullable=False) + expiration_date = Column(Date, nullable=False) + status = Column(String(20), default='AVAILABLE') + + def __repr__(self): + return f"" \ No newline at end of file diff --git a/app/eco/models/session.py b/app/eco/models/session.py new file mode 100644 index 0000000..8d59343 --- /dev/null +++ b/app/eco/models/session.py @@ -0,0 +1,18 @@ +from sqlalchemy import Column, String, DateTime, Integer +from app.extensions import db + +class Session(db.Model): + __tablename__ = 'sessions' + __bind_key__ = 'eco' + + id = Column(Integer, primary_key=True) + session_id = Column(String(50), unique=True, nullable=False) + customer_id = Column(String(9), nullable=True) + account_id = Column(String(10), nullable=True) + msisdn = Column(String(15), nullable=False) + channel = Column(String(10), nullable=False) + expires_at = Column(DateTime, nullable=False) + status = Column(String(20), default='ACTIVE') + + def __repr__(self): + return f"" \ No newline at end of file