resources :forms, controller: 'forms/' do
  scope module: :forms do
    resources :entries, only: [:index, :update]
    resources :fields
  end
end

namespace :accounting do
  resource :cafeteria, only: [:show, :update]

  resources :allocations, only: :index
  resources :categories, except: [:edit, :new]
  resources :charges, only: :create
  resources :credits, only: :create
  resources :subcategories, except: [:index, :edit, :new]
  resources :tags, except: [:new, :edit]
  resources :transfers, only: :create

  namespace :invoices do
    resource :config, only: :update
  end

  resources :invoices, except: [:edit, :new],
    concerns: [:batch_create, :batch_update, :batch_delete] do
    post :attach, on: :member
    delete :detach, on: :member
    get :pdf, on: :collection

    scope module: :invoices do
      resources :charges, only: :index
    end
  end

  namespace :paya do
    resource :config, only: :show

    resources :forms, only: [] do
      get :payform, on: :collection
      get :accountform, on: :collection
    end
  end

  resources :payments, only: [:index, :create] do
    get :receipt, on: :member

    scope module: :payments do
      resource :details, only: :show
    end
  end

  resources :transactions, except: [:edit, :create, :new] do
    get :distribution, on: :collection
    get :aging, on: :collection
    get :report, on: :collection
    get :balance_summary, on: :collection
    post :batch_destroy, on: :collection
    patch :void, on: :member

    scope module: :transactions do
      resources :logs, only: :index
    end
  end

  namespace :transactions do
    resources :tags, only: [], concerns: [:batch_create, :batch_delete]
  end

  scope :accounts do
    resources :families, only: [:index, :show] do
      get :statement, on: :collection
      get :balance_report, on: :collection

      scope module: :families do
        resources :payment_methods, only: [:index, :show, :destroy]
      end
    end

    resources :students, only: [:index, :show] do
      get :statement, on: :member

      scope module: :students do
        resource :matrices, only: [:show, :update]

        namespace :billing do
          resource :templates, only: :create, path: '/templates/:id/attach'
          resources :transactions, except: [:show, :new, :edit]
        end
      end
    end
  end

  namespace :billing do
    resources :scheduled, only: :index, concerns: :batch_create

    resources :templates, except: [:new, :edit] do
      post :attach, on: :member
      delete :detach, on: :member

      scope module: :templates do
        resources :transactions, except: [:show, :new, :edit]
      end
    end
  end
end

namespace :administration do
  resource :attendance, only: [:show, :update], controller: :attendance
  resource :grades, only: [:show, :update]
  resources :edfi_grades, only: :index
  resources :school_periods, except: [:new, :edit]

  resources :school_years do
    scope module: :school_years do
      resources :school_days, concerns: :batch_update
      resources :sessions, only: [:index, :create]
    end
  end
end

namespace :admissions do
  resource :config, only: [:show, :update]
  resource :contact_revision_fields, only: [:show, :update]
  resource :family_access, only: [:show, :update], controller: :family_access
  resource :family_additional_fields, only: [:show, :update]
  resource :family_revision_fields, only: [:show, :update]
  resource :medical_revision_fields, only: [:show, :update]
  resource :registration_fields, only: [:show, :update]
  resource :statistics, only: [] do
    get :applicants_by_grade, on: :collection
    get :applicants_by_state, on: :collection
    get :applicants_by_enrollment, on: :collection
    get :applicants_by_entrance, on: :collection
    get :pre_applicants_count, on: :collection
    get :report, on: :collection
  end

  resources :agreements, except: [:new, :edit]
  resources :attachments, except: [:new, :edit]
  resources :checkboxes, except: [:new, :edit]
  resources :documents, except: [:new, :edit]
  resources :enrollment_classrooms, only: :index
  resources :essays, except: [:new, :edit]
  resources :statuses, except: [:new, :edit]
  resources :students, only: :index
  resources :tags, except: [:new, :edit]

  resources :applicants, except: [:new, :create, :edit], concerns: :batch_update do
    post :submit, on: :member
    patch :approve, on: :member
    patch :batch_approve, on: :collection
    patch :batch_enroll, on: :collection
    patch :state, on: :collection
    get :export, on: :collection
    get :agreements_pdf, on: :collection
    get :essays_pdf, on: :collection
    get :download_application, on: :collection
    get :applicant_list, on: :collection
    get :payment_export, on: :collection

    scope module: :applicants do
      resource :medical, only: [:show, :update]
      resource :application, only: :show

      resources :agreements, only: [:index, :show, :destroy]
      resources :checkboxes, only: [:index, :show, :update]
      resources :documents, only: [:index, :update, :destroy]
      resources :essays, only: [:index, :show, :destroy]
      resources :additional_values, only: [:index, :destroy] do
        patch :update, on: :collection
      end

      resource :student, only: [:show, :update] do
        scope module: :student do
          resource :medical, only: [:show, :update]

          resources :enrollment_classrooms, only: :index, concerns: :batch_update

          resources :additional_values, only: :index do
            patch :update, on: :collection
            get :fields, on: :collection
          end
        end
      end
    end
  end

  namespace :applicants do
    resources :tags, only: [], concerns: [:batch_create, :batch_update, :batch_delete]
  end

  resources :applications, except: [:new, :edit] do
    post :copy, on: :collection
    get :available_grades, on: :collection

    scope module: :applications do
      resource :additional_fields, only: [:show, :update]
      resource :grades, only: :show
      resource :profile_fields, only: [:show, :update]

      resources :agreements, except: [:show, :edit]
      resources :attachments, except: [:show, :edit]
      resources :checkboxes, except: [:show, :edit]
      resources :documents, except: [:show, :edit]
      resources :essays, except: [:show, :edit]
    end
  end

  resources :families, except: [:create, :destroy] do
    patch :apply, on: :collection
    get :export, on: :collection
    get :payment_export, on: :collection
    post :invite, on: :member
    post :batch_invite, on: :collection

    scope module: :families do
      resource :additional_fields, only: [:show, :update]
      resource :medical_revisions, only: [:show, :update]
      resource :revisions, only: [:show, :update]
      resource :payment, only: [:show, :update]

      resources :applicant_payments, only: [:index, :update]
      resources :contact_revisions, only: [:index, :show, :new, :create, :update]
      resources :students, only: :index

      resources :additional_values, only: :index do
        patch :update, on: :collection
        get :fields, on: :collection
      end

      namespace :current do
        resource :medical, only: [:show, :update]

        resources :contacts, except: [:create, :destroy]

        resources :additional_values, only: :index do
          patch :update, on: :collection
        end
      end
    end
  end

  namespace :families do
    resources :tags, only: [], concerns: [:batch_create, :batch_update, :batch_delete]
  end

  resources :students, only: :index do
    post :create_applicant, on: :member
    patch :enroll, on: :member
    post :batch_create_applicants, on: :collection
    patch :batch_enroll, on: :collection
    get :list_pdf, on: :collection
  end
end

namespace :communication do
  resources :contacts, only: :index
  resources :employees, only: :index
  resources :students, only: :index

  resources :batch_emails do
    get :recipients, on: :member
    post :send_email, on: :member
  end

  namespace :smtp do
    resource :config, only: [:show, :update]
    resource :mailer, only: :create
  end

  namespace :sparkpost do
    resource :bounce_domain, only: [:show, :create, :update]
    resource :sending_domain, only: [:show, :create, :update]
    resource :tracking_domain, only: [:show, :create, :update]
  end
end

namespace :course do
  resources :classrooms, concerns: :batch_update
  resources :property_entry, only: :index, concerns: :batch_update, controller: :property_entry
  resources :states, only: :index

  resources :courses do
    scope module: :courses do
      resources :classrooms, only: :index do
        post :attach, on: :collection
        delete :detach, on: :collection
      end
    end
  end
end

namespace :covid do
  resource :config, only: [:show, :update]

  resources :classrooms, only: :index

  resources :employee_screenings, only: [:index, :new, :create, :destroy] do
    get :employee_count, on: :collection
    get :employee_search, on: :collection
    get :export, on: :collection
    get :google_export, on: :collection
  end

  resources :employee_temperatures, only: [:index, :destroy], concerns: :batch_create do
    get :employee_count, on: :collection
    get :employee_search, on: :collection
    get :export, on: :collection
    get :google_export, on: :collection
  end

  resources :screenings, only: [:index, :new, :create, :destroy] do
    get :student_count, on: :collection
    get :student_search, on: :collection
    get :export, on: :collection
    get :google_export, on: :collection
  end

  resources :temperatures, only: [:index, :destroy], concerns: :batch_create do
    get :student_count, on: :collection
    get :student_search, on: :collection
    get :export, on: :collection
    get :google_export, on: :collection
  end

  namespace :form do
    resources :options, only: :destroy

    resources :sections, except: :edit, concerns: :batch_update do
      resources :displays, except: :edit
      resources :fields, only: :index, concerns: :batch_update
      resources :questions, except: :edit
    end
  end
end

namespace :financial_aid do
  resource :config, only: [:show, :update]

  resources :answers, only: :index, concerns: :batch_update
  resources :waivers, only: [:index, :destroy], concerns: :batch_create

  resources :applications, only: [:index, :show, :update] do
    resources :contacts, only: :index
  end

  namespace :stripe do
    resource :payment, only: :show
  end
end

namespace :google do
  resource :config, only: [:show, :update] do
    get :refresh_domains, on: :collection
  end
end

scope module: :legacy do
  resources :classrooms, only: :index
  resources :families, only: [:index, :show, :update]
  resources :requirement_labels, only: :index

  resources :students, only: [:index, :show, :update] do
    get :available_codes, on: :member
    post :create_user, on: :member

    scope module: :students do
      resources :school_years, only: :index
    end
  end

  namespace :discipline do
    resource :config, only: [:show, :update]

    resources :groups, except: :edit
    resources :logs, only: [:index, :update, :destroy], concerns: :batch_create
    resources :violations, except: :edit

    resources :detentions, only: :index, concerns: :batch_create do
      get :pending, on: :collection
    end

    resources :students, only: :index do
      scope module: :students do
        resources :logs, only: [:index, :show]
        resources :detentions, only: [:index, :show]
      end
    end
  end

  namespace :calendar do
    resources :events, only: [:index, :show]
  end

  resources :employees, only: [] do
    scope module: :employees do
      resources :classrooms, only: :index
    end
  end

  namespace :facility do
    resources :activities, only: :index
    resources :buildings, except: [:new, :edit]
    resources :locations, except: [:new, :edit]
    resources :planners, only: :index
    resources :rooms, except: [:new, :edit]
  end

  namespace :human_resources do
    resources :category_groups, except: [:new, :edit]
    resources :categories, except: [:new, :edit]
    resources :positions, except: [:new, :edit]
    resources :property_entry, only: :index, concerns: :batch_update, controller: :property_entry
    resources :types, except: [:new, :edit]

    resources :additional_fields, except: [:new, :edit] do
      patch :order, on: :collection
      delete :destroy_additional_values, on: :member
    end
    resources :additional_groups, except: [:new, :edit] do
      patch :order, on: :collection
    end

    resources :reports, only: [] do
      get :dynamic_report, on: :collection
    end

    namespace :employees do
      resources :categories, only: [:index], concerns: [:batch_create, :batch_update, :batch_delete]
    end

    resources :employees, except: :create do
      patch :password_update, on: :member

      scope module: :employees do
        resource :lunch_period, controller: :lunch_period, except: [:create]
        resource :state_id, only: :show

        resources :audits, only: [:index, :show]
        resources :classrooms, only: :index
        resources :departments, only: :index, concerns: :batch_update
        resources :notes, except: [:new, :edit]

        resources :positions, except: [:new, :edit] do
          delete :delete_employee, on: :member
        end

        resources :additional_ids, except: [:new, :edit] do
          get :available, on: :collection
        end

        resources :additional_values, only: :index do
          patch :update, on: :collection
        end

        resources :addresses, except: [:new, :edit] do
          get :available, on: :collection
        end

        namespace :indiana do
          resources :identities, only: [:index, :show, :create] do
            get :missing_information, on: :collection
            get :processing_status, on: :collection
          end
        end

        resources :email_addresses, only: [:create, :update, :destroy] do
          patch :remove_suppression, on: :member
        end

        resources :names, except: [:new, :edit] do
          get :available, on: :collection
        end

        resources :phones, except: [:new, :edit] do
          get :available, on: :collection
        end
      end
    end
  end

  namespace :family do
    resources :additional_groups
    resources :additional_fields

    resources :families, only: [] do
      scope module: :families do
        resource :medical, only: [:show, :update]

        resources :contacts, only: :index
      end
    end
  end

  namespace :nursing do
    resources :complaints, except: [:new, :edit]
    resources :medications, except: [:new, :edit]
    resources :prescription_distributions, except: [:new, :edit]
    resources :vaccines, except: [:show, :new, :edit]

    resources :logs, except: [:new, :edit] do
      get :report, on: :collection
    end

    resources :students, only: [:index, :show] do
      get :allergies, on: :collection
      get :emergency_info, on: :collection
      get :exempt, on: :collection
      get :immunizations, on: :collection
      get :medical_alerts, on: :collection
      get :missing_vaccinations, on: :collection
      get :vaccination_export, on: :collection
      get :screening_export, on: :collection
      get :vaccine_summary, on: :collection
      get :logs, on: :collection

      scope module: :students do
        resource :medicals, only: [:show, :update]

        resources :contacts, only: :index
        resources :medications, except: [:new, :edit]
        resources :prescriptions, except: [:new, :edit]
        resources :screenings, only: [:index, :show, :new, :create, :update, :destroy]
        resources :vaccines, except: [:new, :edit]
      end
    end
  end

  namespace :service do
    resource :requirements, only: [:show, :update]
    resource :settings, only: [:show, :update]

    resources :groups, except: [:new, :edit]
    resources :opportunities, except: [:index, :new, :edit]

    resources :family_logs, only: [:index, :show],
      concerns: [:batch_create, :batch_update, :batch_delete]

    resources :student_logs, only: :index,
      concerns: [:batch_create, :batch_update, :batch_delete] do
      get :export, on: :collection
    end

    namespace :reports do
      get :summary
    end

    resources :families, only: :index do
      get :statistics, on: :member

      scope module: :families do
        resources :logs, only: [:show, :update, :destroy]
      end
    end

    resources :students, only: :index do
      get :export, on: :collection
      get :statistics, on: :member

      scope module: :students do
        resources :history, except: [:new, :edit]
        resources :logs, except: [:new, :edit]
      end
    end

    namespace :reports do
      get :family_totals
      get :family_records
      get :student_records
      get :student_totals
      get :log_export
      get :opportunity_detail
      get :opportunity_summary
    end

    namespace :students do
      resource :statistics, only: [] do
        get :pending_count, on: :collection
      end
    end
  end

  namespace :student do
    resources :activities
    resources :activity_students, concerns: [:batch_create, :batch_delete]
    resources :categories
    resources :category_groups
    resources :property_entry, only: :index, concerns: :batch_update, controller: :property_entry
    resources :types

    resources :additional_fields do
      patch :order, on: :collection
      delete :destroy_additional_values, on: :member
    end

    resources :additional_groups do
      patch :order, on: :collection
    end

    resources :additional_values, only: :index, concerns: :batch_update do
      get :fields, on: :collection
    end

    resources :students, only: [] do
      scope module: :students do
        resource :categories, only: [:show, :update]
        resource :details, only: [:show, :update]
        resource :medicals, only: :show
        resource :origins, only: [:show, :update]
        resource :races, only: [:show, :update]
        resource :requirement_label, except: [:index, :new, :edit]
        resource :state_id, only: :show

        resources :accommodations
        resources :audits, only: [:index, :show]
        resources :documents, only: [:index, :destroy]
        resources :school_years, only: [:index, :show, :update]
        resources :graduation_plans, except: [:show]

        resources :additional_ids, except: [:new, :edit] do
          get :available, on: :collection
        end

        resources :additional_values, only: :index do
          patch :update, on: :collection
        end

        resources :email_addresses, only: [:create, :update, :destroy] do
          patch :remove_suppression, on: :member
        end

        namespace :indiana do
          resources :summer_release, only: [:index, :create]
          resources :summer_graduates, only: :create
          resources :choices, only: [:index, :show, :destroy]
          resources :enrollments, only: [:index, :show, :destroy]
          resources :rosters, only: [:show, :destroy, :update]
          resources :transcripts, only: [:index, :show, :destroy]

          resources :identities, only: [:index, :show, :create] do
            get :missing_information, on: :collection
            get :processing_status, on: :collection
          end
        end

        resources :names, except: [:new, :edit] do
          get :available, on: :collection
        end

        resources :state_programs do
          get :available_program_types, on: :collection
        end

        namespace :wisconsin do
          resource :digital_equity, only: [:show, :update]

          resources :identities, only: [:index, :show, :create] do
            get :missing_information, on: :collection
          end
        end
      end
    end

    resources :school_years, only: [] do
      scope module: :school_years do
        resources :exit_reasons, only: :index
      end
    end
  end
end

namespace :library do
  resources :bibs, except: [:new, :edit]
  resources :catalogs, only: :index
  resources :contributors, only: [:index, :show, :create]
  resources :holdings, only: :create
  resources :locations, except: [:new, :edit]
  resources :publishers, only: [:index, :show, :create]

  namespace :items do
    resources :conditions, except: [:new, :edit]
    resources :types, except: [:new, :edit]
  end
end

namespace :oauth do
  resources :applications, except: [:new, :edit]
end

namespace :payjunction do
  resource :credentials, only: [:show, :update, :destroy]

  resources :accounts, only: [:index, :update]
  resources :terminals, only: [:index, :update]
end

namespace :school do
  resource :primary_email_addresses, only: :show

  resources :additional_ids, except: [:new, :edit] do
    get :available, on: :collection
  end
end

namespace :settings do
  resource :module, only: [:show, :update]
  resource :schools, only: [:show, :update]
  resource :school_branding, only: [:show, :update]
  resource :school_configs, only: [:show, :update]
  resource :state_reporting, only: [:show, :update], controller: :state_reporting

  resource :tep_integration, only: [:show, :update], controller: :tep_integration do
    get :export, on: :collection
  end

  resources :states, only: :index

  resource :apple_manager, only: [:show, :update] do
    get :export, on: :collection
  end

  resources :permissions, only: [:show, :update] do
    get :export, on: :collection
  end
end

namespace :state_reporting do
  resource :dashboard, only: :show, controller: :dashboard do
    post :sync_attendance, on: :collection
    post :sync_calendars, on: :collection
    post :sync_course_offerings, on: :collection
    post :sync_course_section_rosters, on: :collection
    post :sync_master_schedule, on: :collection
    post :sync_parents, on: :collection
    post :sync_staff, on: :collection
    post :sync_student_education, on: :collection
    post :sync_student_programs, on: :collection
    post :sync_student_transcripts, on: :collection
    post :sync_students, on: :collection
    post :sync_graduates, on: :collection
    post :sync_student_accommodations, on: :collection
    post :sync_student_graduation_plans, on: :collection
    get :staff_report, on: :collection
    get :students_report, on: :collection
    get :transcript_report, on: :collection
    get :programs_report, on: :collection
    get :attendance_report, on: :collection
    get :courses_report, on: :collection
    get :accommodations_report, on: :collection
    get :graduate_report, on: :collection
    get :graduation_plans_report, on: :collection
  end

  resources :calendar_event_descriptors, only: :index
  resources :calendar_type_descriptors, only: :index
  resources :configs, only: [:index, :show, :create, :update]

  resources :error_logs, only: :index do
    get :counts, on: :collection
  end

  resources :transcript_error_logs, only: :index do
    get :counts, on: :collection
  end

  resources :school_years, only: [] do
    scope module: :school_years do
      resources :school_days, only: :index, concerns: :batch_update
    end
  end
end

namespace :threoze do
  resource :billing, only: [:show, :update]
  resources :payments, only: :create do
    get :receipt, on: :member
  end

  resources :invoices, only: [:show, :index] do
    get :pdf, on: :member
  end

  namespace :payjunction do
    resource :vault, except: :index
  end
end

namespace :time_card do
  resource :config, only: [:show, :update]

  resources :cycles
  resources :entries
  resources :requests, except: :create
  resources :tasks
end
