You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: by_article_controller.rb
    path of file: ./repos/hitobito/app/controllers/invoices
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

#  Copyright (c) 2023, Schweizer Wanderwege. This file is part of
#  hitobito and licensed under the Affero General Public License version 3
#  or later. See the COPYING file at the top-level directory or at
#  https://github.com/hitobito/hitobito.

class Invoices::ByArticleController < ListController
  self.nesting = Group

  def self.model_class
    Invoice
  end

  helper_method :from
    
  def invoice_ids
    collection = Payments::Collection.new
                                     .in_layer(group.id)
                                     .from(from_date)
                                     .to(to_date)
                                     .excluding_cancelled_invoices

    collection = case params[:type]&.to_sym
                 when :deficit
                   collection.of_non_fully_paid_invoices
                 when :excess
                   collection.of_overpaid_invoices
                 else
                   collection.having_invoice_item(params[:name],
                                                  params[:account],
                                                  params[:cost_center])
                 end