class Family::Accounting::Students::MatricesController < Family::Controller
  def show
    render_success :ok, json: matrices.build_all(student).map { |m| matrix_props(m) }
  end

  private
    def matrices
      student.accounting_student_matrices
    end

    def subcategories
      current_school.accounting_subcategories.includes(subcategory: :category)
    end

    def matrix_props(matrix)
      {
        id: matrix.id,
        student_id: matrix.student_id,
        subcategory_id: matrix.subcategory_id,
        name: matrix.subcategory.decorate.title,
        primary: matrix.decorate.primary_percentage,
        secondary: matrix.decorate.secondary_percentage,
        viewable: matrix.viewable
      }
    end
end
