Sha256: 4500c9d73cbf22ab4dfc1f8b33a9bec72322a220bb9c8c27359845747a6a415d

Contents?: true

Size: 1.24 KB

Versions: 11

Compression:

Stored size: 1.24 KB

Contents

module Kaui
  module AccountHelper

    def pretty_account_identifier
      return nil if @account.nil?
      @account.name.presence || @account.email.presence || truncate_uuid(@account.external_key)
    end

    def email_notifications_plugin_available?
      Kenui::EmailNotificationService.email_notification_plugin_available?(Kaui.current_tenant_user_options(current_user, session)).first
    rescue
      return false
    end

    def account_closed?
      return false if @account.nil?
      blocking_states = @account.blocking_states('ACCOUNT','account-service','NONE', Kaui.current_tenant_user_options(current_user, session))

      is_account_closed = false
      blocking_states.each do |blocking_state|
        if blocking_state.state_name.eql?('CLOSE_ACCOUNT')
          is_account_closed = true
          break
        end
      end
      is_account_closed
    end

    def billing_info_margin
      style = ''
      unless can?(:trigger, Kaui::Payment) && can?(:credit, Kaui::Account) && can?(:charge, Kaui::Account)
        style = "#{style}margin-top:15px;"
      end

      unless can? :trigger, Kaui::Invoice
        style = "#{style}margin-bottom:15px;"
      end

      style = "style='#{style}'" unless style.empty?
      style
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
kaui-2.0.4 app/helpers/kaui/account_helper.rb
kaui-2.0.3 app/helpers/kaui/account_helper.rb
kaui-2.0.2 app/helpers/kaui/account_helper.rb
kaui-2.0.1 app/helpers/kaui/account_helper.rb
kaui-2.0.0 app/helpers/kaui/account_helper.rb
kaui-1.4.1 app/helpers/kaui/account_helper.rb
kaui-1.4.0 app/helpers/kaui/account_helper.rb
kaui-1.3.0 app/helpers/kaui/account_helper.rb
kaui-1.2.0 app/helpers/kaui/account_helper.rb
kaui-1.1.0 app/helpers/kaui/account_helper.rb
kaui-1.0.0 app/helpers/kaui/account_helper.rb