Sha256: 6cc1b38270e87dfe2b43a466719a73afefea1f8c2f3bf9359f0fc28ba19f4dc1

Contents?: true

Size: 1.22 KB

Versions: 8

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module Decidim
  module Budgets
    # A helper to render order and budgets actions
    module ProjectsHelper
      # Render a budget as a currency
      #
      # budget - A integer to represent a budget
      def budget_to_currency(budget)
        number_to_currency budget, unit: Decidim.currency_unit, precision: 0
      end

      # Return a percentage of the current order budget from the total budget
      def current_order_budget_percent
        current_order&.budget_percent.to_f.floor
      end

      # Return the minimum percentage of the current order budget from the total budget
      def current_order_budget_percent_minimum
        return 0 if current_order.minimum_projects_rule?

        component_settings.vote_threshold_percent
      end

      def budget_confirm_disabled_attr
        return if current_order_can_be_checked_out?

        %( disabled="disabled" ).html_safe
      end

      # Return true if the current order is checked out
      delegate :checked_out?, to: :current_order, prefix: true, allow_nil: true

      # Return true if the user can continue to the checkout process
      def current_order_can_be_checked_out?
        current_order&.can_checkout?
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
decidim-budgets-0.23.6 app/helpers/decidim/budgets/projects_helper.rb
decidim-budgets-0.23.5 app/helpers/decidim/budgets/projects_helper.rb
decidim-budgets-0.23.4 app/helpers/decidim/budgets/projects_helper.rb
decidim-budgets-0.23.3 app/helpers/decidim/budgets/projects_helper.rb
decidim-budgets-0.23.2 app/helpers/decidim/budgets/projects_helper.rb
decidim-budgets-0.23.1 app/helpers/decidim/budgets/projects_helper.rb
decidim-budgets-0.23.1.rc1 app/helpers/decidim/budgets/projects_helper.rb
decidim-budgets-0.23.0 app/helpers/decidim/budgets/projects_helper.rb