Sha256: 9fa0ad656900fc681a929980a23ae8f596393e4757f4c6be8c92b0c07c52ab90

Contents?: true

Size: 888 Bytes

Versions: 37

Compression:

Stored size: 888 Bytes

Contents

module CatarsePagarme
  module ApplicationHelper

    def installments_for_select(payment)
      installments = payment.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

37 entries across 37 versions & 1 rubygems

Version Path
catarse_pagarme-2.8.8 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.8.7 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.8.6 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.8.5 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.8.4 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.8.3 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.8.2 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.8.1 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.8.0 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.7.15 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.7.14 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.7.13 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.7.12 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.7.11 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.7.10 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.7.9 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.7.8 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.7.7 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.7.6 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.7.5 app/helpers/catarse_pagarme/application_helper.rb