app/models/row_to_ni_duty_calculator.rb
def options
    options = uk_options.each_with_object(default_options) do |uk_option, acc|
      category = uk_option.category

      next unless Api::MeasureType.supported_option_category?(category)

      option = if category == DutyOptions::ThirdCountryTariff::CATEGORY
                 DutyOptions::Chooser.new(
                   uk_option,
                   xi_options.third_country_tariff_option,
                   user_session.total_amount,
                 ).call
               else
                 cheapest_xi_option = xi_options.public_send("cheapest_#{category}_option")
                 xi_option = cheapest_xi_option || xi_options.third_country_tariff_option

                 option = DutyOptions::Chooser.new(
                   uk_option,
                   xi_option,
                   user_session.total_amount,
                 ).call

                 uk_only = cheapest_xi_option.nil?

                 footnote_suffix = I18n.t("row_to_ni_measure_type_footnotes_suffixes.#{category}.uk_only.#{option.source}_html", uk_only_text: uk_only_text_for(category, option, uk_option)) if uk_only

                 option
               end

      next if option.blank?

      footnote_suffix ||= I18n.t("row_to_ni_measure_type_footnotes_suffixes.#{option.category}.#{option.source}_html")

      option.footnote_suffix = footnote_suffix.html_safe

      acc << option
    end

    options = options.uniq(&:measure_sid)
    options = handle_duplicate_mfn_option(options)
    options.sort_by(&:priority)
  end
# 1. Encapsulate OptionResult with a footnote
1. Encapsulate OptionResult with a footnote
1 . Encapsulate OptionResult with a footnote
def options
    options = uk_options.each_with_object(default_options) do |uk_option, acc|
      category = uk_option.category
      next unless Api::MeasureType.supported_option_category?(category)
      option = if category == DutyOptions::ThirdCountryTariff::CATEGORY
                 DutyOptions::Chooser.new(
                   uk_option,
                   xi_options.third_country_tariff_option,
                   user_session.total_amount,
                 ).call
               else
                 cheapest_xi_option = xi_options.public_send("cheapest_#{category}_option")
                 xi_option = cheapest_xi_option || xi_options.third_country_tariff_option
                 option = DutyOptions::Chooser.new(
                   uk_option,
                   xi_option,
                   user_session.total_amount,
                 ).call
                 uk_only = cheapest_xi_option.nil?
                 footnote_suffix = I18n.t("row_to_ni_measure_type_footnotes_suffixes.#{category}.uk_only.#{option.source}_html", uk_only_text: uk_only_text_for(category, option, uk_option)) if uk_only
                 option
               end
      next if option.blank?
      footnote_suffix ||= I18n.t("row_to_ni_measure_type_footnotes_suffixes.#{option.category}.#{option.source}_html")
      option.footnote_suffix = footnote_suffix.html_safe
      acc << option
    end
    options = options.uniq(&:measure_sid)
    options = handle_duplicate_mfn_option(options)
    options.sort_by(&:priority)
  end
def options options = uk_options . each_with_object ( default_options ) do | uk_option , acc | category = uk_option . category next unless Api :: MeasureType . supported_option_category? ( category ) option = if category == DutyOptions :: ThirdCountryTariff :: CATEGORY DutyOptions :: Chooser . new ( uk_option , xi_options . third_country_tariff_option , user_session . total_amount , ) . call else cheapest_xi_option = xi_options . public_send ( "cheapest_#{category}_option" ) xi_option = cheapest_xi_option || xi_options . third_country_tariff_option option = DutyOptions :: Chooser . new ( uk_option , xi_option , user_session . total_amount , ) . call uk_only = cheapest_xi_option . nil? footnote_suffix = I18n . t ( "row_to_ni_measure_type_footnotes_suffixes.#{category}.uk_only.#{option.source}_html" , uk_only_text : uk_only_text_for ( category , option , uk_option ) ) if uk_only option end next if option . blank? footnote_suffix ||= I18n . t ( "row_to_ni_measure_type_footnotes_suffixes.#{option.category}.#{option.source}_html" ) option . footnote_suffix = footnote_suffix . html_safe acc << option end options = options . uniq ( & :measure_sid ) options = handle_duplicate_mfn_option ( options ) options . sort_by ( & :priority ) end
1.
1 .