diff --git a/app/models/__init__.py b/app/models/__init__.py index af5353a..a4f3b4f 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -1,7 +1,5 @@ from .customer import Customer -from .account import Account from .loan import Loan from .transaction import Transaction -from .repayment import Repayment -__all__ = ['Customer', 'Account', 'Loan', 'Transaction', 'Repayment'] \ No newline at end of file +__all__ = ['Customer', 'Loan', 'Transaction'] \ No newline at end of file diff --git a/app/models/account.py b/app/models/account.py deleted file mode 100644 index e8a90ce..0000000 --- a/app/models/account.py +++ /dev/null @@ -1,49 +0,0 @@ -from datetime import datetime, timezone -from sqlalchemy.orm import relationship -from app.extensions import db -from sqlalchemy.exc import IntegrityError - -class Account(db.Model): - __tablename__ = 'accounts' - - id = db.Column(db.String(50), primary_key=True) - customer_id = db.Column(db.String(50), nullable=False) - account_type = db.Column(db.String(50)) - status = db.Column(db.String(20), default='active') - lien_amount = db.Column(db.Float, default=0.0) - created_at = db.Column(db.DateTime, default=datetime.now(timezone.utc)) - updated_at = db.Column(db.DateTime, default=datetime.now(timezone.utc), onupdate=datetime.now(timezone.utc)) - - customer = relationship( - "Customer", - primaryjoin="Customer.id == Account.customer_id", - foreign_keys=[customer_id], - back_populates="accounts", - ) - - @classmethod - def create_account(cls, id, customer_id, account_type, status='active'): - account = cls( - id=id, - customer_id=customer_id, - account_type=account_type - ) - - try: - db.session.add(account) - except IntegrityError as err: - raise ValueError(f"Database integrity error: {err}") - return account - - @classmethod - def is_valid_account(cls, account_id, customer_id): - account = cls.query.filter_by(id=account_id, customer_id=customer_id).first() - if not account: - return False - if account.lien_amount > 0: - return False - return True - - def __repr__(self): - return f'' - \ No newline at end of file