from pydantic import BaseModel


class InsertBuildTypes(BaseModel):
    function_code: str
    type_code: str
    lang: str
    type_name: str


def init_api_enums_build_types(db_session):
    from Schemas import BuildTypes, ApiEnumDropdown

    insert_types = [
        {
            "function_code": "EVYOS",
            "type_code": "APT_KZN",
            "type_name": "Apartman Kazan Dairesi",
            "lang": "TR",
        },
        {
            "function_code": "EVYOS",
            "type_code": "APT_GRJ",
            "type_name": "Apartman Garaj",
            "lang": "TR",
        },
        {
            "function_code": "EVYOS",
            "type_code": "APT_DP",
            "type_name": "Apartman Depo",
            "lang": "TR",
        },
        {
            "function_code": "EVYOS",
            "type_code": "DAIRE",
            "type_name": "Apartman Dairesi",
            "lang": "TR",
        },
        {
            "function_code": "EVYOS",
            "type_code": "APT",
            "type_name": "Apartman Binası",
            "lang": "TR",
        },
        {
            "function_code": "EVYOS",
            "type_code": "APT_YNT",
            "type_name": "Apartman Yönetimi",
            "lang": "TR",
        },
        {
            "function_code": "EVYOS",
            "type_code": "APT_PRK",
            "type_name": "Apartman Açık Park Alanı",
            "lang": "TR",
        },
        {
            "function_code": "EVYOS",
            "type_code": "APT_YSL",
            "type_name": "Apartman Yeşil Alan",
            "lang": "TR",
        },
        {
            "function_code": "EVYOS",
            "type_code": "APT_YOL",
            "type_name": "Apartman Ara Yol",
            "lang": "TR",
        },
    ]
    for insert_type in insert_types:
        build_types = InsertBuildTypes(
            function_code="EVYOS",
            lang=insert_type["lang"],
            type_code=str(insert_type["type_code"]).upper(),
            type_name=insert_type["type_name"],
        )
        created_build_type = BuildTypes.find_or_create(
            **build_types.model_dump(), is_confirmed=True, db=db_session
        )
        created_build_type.save(db=db_session)

    insert_enums = [
        {"enum_class": "BuildDuesTypes", "type_code": "BDT-D", "type_name": "Debit"},
        {
            "enum_class": "BuildDuesTypes",
            "type_code": "BDT-A",
            "type_name": "Add Debit",
        },
        {
            "enum_class": "BuildDuesTypes",
            "type_code": "BDT-R",
            "type_name": "Renovation",
        },
        {
            "enum_class": "BuildDuesTypes",
            "type_code": "BDT-L",
            "type_name": "Lawyer expence",
        },
        {
            "enum_class": "BuildDuesTypes",
            "type_code": "BDT-S",
            "type_name": "Service fee",
        },
        {
            "enum_class": "BuildDuesTypes",
            "type_code": "BDT-I",
            "type_name": "Information",
        },
        {
            "enum_class": "AccountingReceiptTypes",
            "type_code": "ART-A",
            "type_name": "Kasa Tahsil Fişi",
        },
        {
            "enum_class": "AccountingReceiptTypes",
            "type_code": "ART-E",
            "type_name": "Kasa Tediye Fişi",
        },
        {
            "enum_class": "AccountingReceiptTypes",
            "type_code": "ART-M",
            "type_name": "Mahsup Fişi",
        },
        {
            "enum_class": "AccountingReceiptTypes",
            "type_code": "ART-O",
            "type_name": "Açılış Fişi",
        },
        {
            "enum_class": "AccountingReceiptTypes",
            "type_code": "ART-C",
            "type_name": "Kapanış Fişi",
        },
        {"enum_class": "IbanBudgetType", "type_code": "IBT-I", "type_name": "Iban"},
        {"enum_class": "IbanBudgetType", "type_code": "IBT-B", "type_name": "Budget"},
        {
            "enum_class": "IbanBudgetType",
            "type_code": "IBT-TR",
            "type_name": "Transaction records",
        },
        {"enum_class": "ProjectTypes", "type_code": "R", "type_name": "Tadilat"},
        {
            "enum_class": "ProjectTypes",
            "type_code": "PT-C",
            "type_name": "Mahkeme süreçleri",
        },
        {
            "enum_class": "ProjectTypes",
            "type_code": "PT-Z",
            "type_name": "Sıfır Bakiye",
        },
        {
            "enum_class": "EdmBudgetType",
            "type_code": "PT-B",
            "type_name": "Banka records",
        },
        {
            "enum_class": "EdmBudgetType",
            "type_code": "PT-S",
            "type_name": "Sistem kaydı",
        },
        {
            "enum_class": "EdmBudgetType",
            "type_code": "EBT-C",
            "type_name": "Build, Flat or Site records",
        },
        {"enum_class": "ExpireType", "type_code": "1", "type_name": "daily"},
        {"enum_class": "ExpireType", "type_code": "7", "type_name": "weekly"},
        {"enum_class": "ExpireType", "type_code": "30", "type_name": "monthly"},
        {"enum_class": "ExpireType", "type_code": "90", "type_name": "quarter"},
        {"enum_class": "ExpireType", "type_code": "180", "type_name": "six_month"},
        {"enum_class": "ExpireType", "type_code": "365", "type_name": "yearly"},
        {"enum_class": "PhoneType", "type_code": "M", "type_name": "cep tel"},
        {"enum_class": "PhoneType", "type_code": "L", "type_name": "sabit telefon"},
        {"enum_class": "PhoneType", "type_code": "F", "type_name": "fax"},
        {"enum_class": "PhoneType", "type_code": "C", "type_name": "santral"},
        {
            "enum_class": "PhoneType",
            "type_code": "G",
            "type_name": "ülke genelindeki hatlar 444",
        },
        {"enum_class": "PerComType", "type_code": "1", "type_name": "Person"},
        {"enum_class": "PerComType", "type_code": "2", "type_name": "Company"},
        {"enum_class": "Directions", "type_code": "NN", "type_name": "North"},
        {"enum_class": "Directions", "type_code": "EE", "type_name": "East"},
        {"enum_class": "Directions", "type_code": "SS", "type_name": "South"},
        {"enum_class": "Directions", "type_code": "WW", "type_name": "West"},
        {"enum_class": "Directions", "type_code": "NE", "type_name": "North East"},
        {"enum_class": "Directions", "type_code": "NW", "type_name": "North West"},
        {"enum_class": "Directions", "type_code": "SE", "type_name": "South East"},
        {"enum_class": "Directions", "type_code": "SW", "type_name": "South West"},
        {
            "enum_class": "MeetingTypes",
            "type_code": "MT-RBM",
            "type_name": "Regular Building Meeting",
        },
        {
            "enum_class": "MeetingTypes",
            "type_code": "MT-DBM",
            "type_name": "Disaster Building Meeting",
        },
        {
            "enum_class": "MeetingTypes",
            "type_code": "MT-EBM",
            "type_name": "Emergency Building Meeting",
        },
        {
            "enum_class": "DebitTypes",
            "type_code": "DT-D",
            "type_name": "Debit Sender",
        },
        {
            "enum_class": "DebitTypes",
            "type_code": "DT-R",
            "type_name": "Credit Receiver",
        },
        {
            "enum_class": "DebitTypes",
            "type_code": "DT-Z",
            "type_name": "Zero Balance",
        },
        {
            "enum_class": "TimePeriod",
            "type_code": "TP-W",
            "type_name": "Weekly",
        },
        {
            "enum_class": "TimePeriod",
            "type_code": "TP-M",
            "type_name": "Monthly",
        },
        {
            "enum_class": "TimePeriod",
            "type_code": "TP-Q",
            "type_name": "Quarterly",
        },
        {
            "enum_class": "TimePeriod",
            "type_code": "TP-Y",
            "type_name": "Yearly",
        },
    ]

    for insert_enum in insert_enums:
        created_api_enum = ApiEnumDropdown.find_or_create(
            enum_class=insert_enum["enum_class"],
            value=insert_enum["type_name"],
            key=str(insert_enum["type_code"]).upper(),
            description=insert_enum["type_name"],
            is_confirmed=True,
            db=db_session,
        )
        created_api_enum.save(db=db_session)
