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: catalog_item.rb
    path of file: ./repos/ekylibre/app/models
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

# = Informations
#
# == License
#
# Ekylibre - Simple agricultural ERP
# Copyright (C) 2008-2009
    
  def unit_amount_in_target_unit(target_unit)
    unit_amount_with_indicator = { unit_amount: 0.0, indicator: nil, unit: nil }
    o_target_unit = Unit.find_by(reference_name: target_unit.to_s)

    if unit && o_target_unit.dimension == unit.dimension
      converted_amount = UnitComputation.convert_amount(pretax_amount, unit, o_target_unit)
      unit_amount_with_indicator[:unit_amount] = converted_amount.to_d.round(2)
      unit_amount_with_indicator[:indicator] = Unit::STOCK_INDICATOR_PER_DIMENSION[unit.dimension.to_sym]
      unit_amount_with_indicator[:unit] = target_unit
    elsif variant.nature.population_counting == 'decimal'
      o_variant_unit = Onoma::Unit[variant.default_unit.reference_name.to_sym]
      if variant.default_quantity.to_f > 0.0 && o_variant_unit.dimension == o_target_unit.dimension
        coefficient = Measure.new(variant.default_quantity, variant.default_unit.reference_name.to_sym).convert(target_unit.to_sym).to_f
        unit_amount_with_indicator[:unit_amount] = (pretax_amount / coefficient).round(2)
        unit_amount_with_indicator[:indicator] = Unit::STOCK_INDICATOR_PER_DIMENSION[o_variant_unit.dimension.to_sym]
        unit_amount_with_indicator[:unit] = target_unit
      end