Sha256: 204bdd1b43ce9b810c2f0d4b20a456d2966fa9aae2bf90994a1003167c0edf28

Contents?: true

Size: 898 Bytes

Versions: 29

Compression:

Stored size: 898 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.to_i
          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

29 entries across 29 versions & 1 rubygems

Version Path
catarse_pagarme-2.5.1 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.5.0 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.4.10 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.4.9 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.4.8 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.4.7 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.4.6 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.4.5 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.4.4 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.4.3 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.4.2 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-1.5.3 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-1.5.2 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.4.1 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-1.5.1 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-1.5.0 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.4.0 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.3.10 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-1.4.9 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.3.9 app/helpers/catarse_pagarme/application_helper.rb