def create_modules_and_services_and_actions(db_session):
    from Schemas import (
        Duty,
        OccupantTypes,
        Modules,
        Services,
    )

    erp_module = Modules.find_or_create(
        **{
            "module_name": "EVYOS ERP",
            "module_description": "EVYOS Enterprise Resource Planning",
            "module_code": "EVYOS-ERP",
            "module_layer": 1,
            "is_default_module": False,
            "is_confirmed": True,
        },
        db=db_session,
    )
    erp_module.save(db=db_session)

    build_module = Modules.find_or_create(
        **{
            "module_name": "Bina Yönetim Modülü",
            "module_description": "Building Management Module",
            "module_code": "BLD-MNG",
            "module_layer": 1,
            "is_default_module": False,
            "is_confirmed": True,
        },
        db=db_session,
    )
    build_module.save(db=db_session)

    user_module = Modules.find_or_create(
        **{
            "module_name": "Kullancı Modülü",
            "module_description": "Kullanıcı Genel Modülü",
            "module_code": "USR-PUB",
            "module_layer": 1,
            "is_default_module": True,
            "is_confirmed": True,
        },
        db=db_session,
    )
    user_module.save(db=db_session)

    erp_module_module_dict = dict(
        module_id=erp_module.id,
        module_uu_id=str(erp_module.uu_id),
    )
    build_module_module_dict = dict(
        module_id=build_module.id,
        module_uu_id=str(build_module.uu_id),
    )
    duty_objects = Duty.filter_all(
        Duty.duty_code.notin_(["BULK", "OCCUPANT", "BM0001"]),
        db=db_session,
    ).data
    for duty_object in duty_objects:
        created_service = Services.find_or_create(
            **erp_module_module_dict,
            service_name=duty_object.duty_name,
            service_description=duty_object.duty_description,
            service_code=f"SRE-{duty_object.duty_code}",
            related_responsibility=duty_object.duty_code,
            is_confirmed=True,
            db=db_session,
        )
        created_service.save(db=db_session)

    occupant_types = OccupantTypes.filter_all(db=db_session).data
    for occupant_type in occupant_types:
        created_service = Services.find_or_create(
            **build_module_module_dict,
            service_name=occupant_type.occupant_type,
            service_description=occupant_type.occupant_description,
            service_code=f"SRO-{occupant_type.occupant_code}",
            related_responsibility=occupant_type.occupant_code,
            is_confirmed=True,
            db=db_session,
        )
        created_service.save(db=db_session)
