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: per_item.rb
    path of file: ./repos/openfoodnetwork/app/models/calculator
    
    the code of the file until where you have to start completion: # frozen_string_literal: false
    
    def compute(object = nil)
      return 0 if object.nil?

      number_of_line_items = line_items_for(object).reduce(0) do |sum, line_item|
        value_to_add = line_item.quantity
        sum + value_to_add
      end
      preferred_amount * number_of_line_items
    end