from enum import Enum from typing import Optional, List class AccountTypeEnum(str, Enum): BALANCE = 'B' CREDIT = 'C' SAVING = 'S' INVESTMENT = 'I' CRYPTOCURRENCY = 'CRYPT' OTHER = 'O' @staticmethod def get_account_type_from_str( string :str, from_sheet: bool = False ) -> Optional['AccountTypeEnum']: if from_sheet: inside_paranthesis = string[string.find('(')+1:string.find(')')] for type in AccountTypeEnum: if type.value == inside_paranthesis: return type return None else: for type in AccountTypeEnum: if type.name == string: return type return None @staticmethod def get_all_account_types() -> List[str]: return [type.value for type in AccountTypeEnum] @staticmethod def is_income(account_type: 'AccountTypeEnum') -> bool: return account_type in ( AccountTypeEnum.BALANCE, AccountTypeEnum.SAVING, AccountTypeEnum.INVESTMENT, AccountTypeEnum.CRYPTOCURRENCY ) @staticmethod def is_expense(account_type: 'AccountTypeEnum') -> bool: if account_type == AccountTypeEnum.OTHER: return False return not AccountTypeEnum.is_income(account_type=account_type) class BusinessTypeEnum(str, Enum): AUTO = 'Auto & Transport' UTILS = 'Bills & Utlities' BUSINESS_SERVICES = 'Business Services' EDUCATION = 'Education' ENTERTAINMENT = 'Entertainment' FEES = 'Fees & Charges' FINANCIAL = 'Financial' FOOD = 'Food' GIFTS = 'Gift & Donations' HEALTH = 'Health & Fitness' HOME = 'Home' INCOME = 'Income' INVESTMENTS = 'Investments' KIDS = 'Kids' LOANS = 'Loans' MISC = 'Misc Expenses' PERSONAL_CARE = 'Personal Care' PETS = 'Pets' SHOPPING = 'Shopping' TRAVEL = 'Travel' DINING = 'Dining' @staticmethod def get_business_type_from_str( string :str ) -> Optional['BusinessTypeEnum']: for type in BusinessTypeEnum: if type.value == string: return type return None @staticmethod def get_all_business_types() -> List[str]: return [type.value for type in BusinessTypeEnum]