Sha256: 0789273a5a699785826dd9c6222754aef2c818e4f097e28781a8b4e49f81d260

Contents?: true

Size: 893 Bytes

Versions: 30

Compression:

Stored size: 893 Bytes

Contents

module CatarsePagarme
  module ApplicationHelper

    def installments_for_select(contribution)
      installments = contribution.pagarme_delegator.get_installments['installments']

      collection = installments.map do |installment|
        installment_number = installment[0].to_i
        if installment_number <= CatarsePagarme.configuration.max_installments
          amount = installment[1]['installment_amount'] / 100.0

          optional_text = nil
          if installment_number != 1
            optional_text = I18n.t('projects.contributions.edit.installment_with_tax')
          end

          ["#{format_instalment_text(installment_number, amount)} #{optional_text}", installment_number]
        end
      end

      collection.compact
    end

    def format_instalment_text(number, amount)
      [number, number_to_currency(amount, precision: 2)].join("x ")
    end

  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
catarse_pagarme-2.3.7 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.3.6 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.3.5 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.3.4 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.3.3 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.3.1 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-1.4.0 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.3.0 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.2.1 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-1.3.1 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.2.0 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-1.3.0 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.1.1 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.1.0 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-1.2.0 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.0.3 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.0.2 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.0.1 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-1.1.0 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.0.0 app/helpers/catarse_pagarme/application_helper.rb