"""Vendor Model.""" from sqlalchemy import Boolean from sqlalchemy import Column from sqlalchemy import Enum from sqlalchemy import Integer from sqlalchemy import Numeric from sqlalchemy import String from sqlalchemy.engine import Row from moneyhub.config import Config from moneyhub.models.snowflake_base import BaseModel class Vendor(BaseModel): """Vendor DB Model.""" __tablename__ = 'vendor' if Config.ENVIRONMENT != Config.TEST_ENVIRONMENT: __table_args__ = {'schema': 'ORCHARD_APP_REPORTING_V2.ART_RELATIONS_PROD_ART_RELATIONS'} vendor_id = Column(Integer, nullable=False, primary_key=True) is_distributor = Column(Enum('Y', 'N'), default='N', nullable=False) migrated_to_abacus = Column(Boolean, default=False, nullable=False) name = Column(String(256), nullable=False) is_owned = Column(String(3), default='No', nullable=False) sap_vendor_id = Column(String(20), nullable=True) first_statement_period = Column(Numeric(38, 0), nullable=False) @classmethod def get_by_account_id(cls, account_id: int) -> Row: """GET vendor for a specified account ID. Args: account_id (int): the id of an abacus account Returns: Row: vendor row """ return cls.query.filter(cls.vendor_id == account_id).first()