Sha256: 599f4315380390aa11dac428bdfe0c3a4ce57e97a69aece1bacfaf8445034da0

Contents?: true

Size: 958 Bytes

Versions: 55

Compression:

Stored size: 958 Bytes

Contents

module CatarsePagarme
  module ApplicationHelper

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

      collection = installments.map do |installment|
        installment_number = installment[0].to_i
        if installment_number <= (project.try(:total_installments) || 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

55 entries across 55 versions & 1 rubygems

Version Path
catarse_pagarme-3.0.1 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-3.0.0 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.16.3 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.16.2 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.16.1 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.16.0 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.15.0 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.14.14 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.14.13 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.14.12 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.14.11 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.14.10 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.14.9 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.14.8 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.14.7 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.14.6 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.14.5 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.14.4 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.14.3 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-2.14.2 app/helpers/catarse_pagarme/application_helper.rb