From 63e1f9cab761b1ddfc332b42b2e021d578604c7e Mon Sep 17 00:00:00 2001 From: Nargis Sultani Date: Wed, 29 Nov 2023 01:19:13 -0500 Subject: [PATCH] Updated the financial_institutions table. --- src/entities/models/dao.py | 50 ++++++++++++++++++++++++++++++++++++-- src/entities/models/dto.py | 30 ++++++++++++++++++++++- 2 files changed, 77 insertions(+), 3 deletions(-) diff --git a/src/entities/models/dao.py b/src/entities/models/dao.py index 3599188..8926118 100644 --- a/src/entities/models/dao.py +++ b/src/entities/models/dao.py @@ -1,6 +1,6 @@ from datetime import datetime from typing import List -from sqlalchemy import ForeignKey, func +from sqlalchemy import ForeignKey, String, func from sqlalchemy.orm import Mapped, mapped_column, relationship from sqlalchemy.orm import DeclarativeBase from sqlalchemy.ext.asyncio import AsyncAttrs @@ -17,10 +17,32 @@ class AuditMixin(object): class FinancialInstitutionDao(AuditMixin, Base): __tablename__ = "financial_institutions" lei: Mapped[str] = mapped_column(unique=True, index=True, primary_key=True) - name: Mapped[str] = mapped_column(index=True) + legal_name: Mapped[str] = mapped_column(index=True) domains: Mapped[List["FinancialInstitutionDomainDao"]] = relationship( "FinancialInstitutionDomainDao", back_populates="fi" ) + tax_id: Mapped[str] = mapped_column(unique=True) + rssd_id: Mapped[int] = mapped_column(unique=True) + primary_federal_regulator_id: Mapped[str] = mapped_column( + ForeignKey("federal_regulator.id"), index=True, primary_key=True + ) + hmda_institution_type_id: Mapped[str] = mapped_column( + ForeignKey("hmda_institution_type.id"), index=True, primary_key=True + ) + sbl_institution_type_id: Mapped[str] = mapped_column( + ForeignKey("sbl_institution_type.id"), index=True, primary_key=True + ) + hq_address_street_1: Mapped[str] = mapped_column(nullable=False) + hq_address_street_2: Mapped[str] + hq_address_city: Mapped[str] + hq_address_state: Mapped[str] = mapped_column(ForeignKey("address_state.code"), index=True, primary_key=True) + hq_address_zip: Mapped[str] = mapped_column(String(5), nullable=False) + parent_lei: Mapped[str] = mapped_column(String(20)) + parent_legal_name: Mapped[str] + parent_rssd_id: Mapped[int] + top_holder_lei: Mapped[str] = mapped_column(String(20)) + top_holder_legal_name: Mapped[str] + top_holder_rssd_id: Mapped[int] class FinancialInstitutionDomainDao(AuditMixin, Base): @@ -33,3 +55,27 @@ class FinancialInstitutionDomainDao(AuditMixin, Base): class DeniedDomainDao(AuditMixin, Base): __tablename__ = "denied_domains" domain: Mapped[str] = mapped_column(index=True, primary_key=True) + + +class FederalRegulatorDao(AuditMixin, Base): + __tablename__ = "federal_regulator" + id: Mapped[str] = mapped_column(String(4), index=True, primary_key=True) + name: Mapped[str] = mapped_column(unique=True, nullable=False) + + +class HMDAInstitutionTypeDao(AuditMixin, Base): + __tablename__ = "hmda_institution_type" + id: Mapped[str] = mapped_column(index=True, primary_key=True) + name: Mapped[str] = mapped_column(unique=True) + + +class SBLInstitutionTypeDao(AuditMixin, Base): + __tablename__ = "sbl_institution_type" + id: Mapped[str] = mapped_column(index=True, primary_key=True) + name: Mapped[str] = mapped_column(unique=True, nullable=False) + + +class AddressStateDao(AuditMixin, Base): + __tablename__ = "address_state" + code: Mapped[str] = mapped_column(String(2), primary_key=True) + name: Mapped[str] = mapped_column(unique=True, nullable=False) diff --git a/src/entities/models/dto.py b/src/entities/models/dto.py index a09062b..a7ae988 100644 --- a/src/entities/models/dto.py +++ b/src/entities/models/dto.py @@ -19,7 +19,7 @@ class Config: class FinancialInstitutionBase(BaseModel): - name: str + legal_name: str class FinancialInstitutionDto(FinancialInstitutionBase): @@ -40,6 +40,34 @@ class Config: from_attributes = True +class FederalRegulatorDto(BaseModel): + id: str + + class Config: + from_attributes = True + + +class HMDAInstitutionTypeDto(BaseModel): + id: str + + class Config: + from_attributes = True + + +class SBLInstitutionTypeDto(BaseModel): + id: str + + class Config: + from_attributes = True + + +class AddressStateDto(BaseModel): + code: str + + class Config: + from_attributes = True + + class UserProfile(BaseModel): first_name: str last_name: str