Sha256: e9726ae5a9c022dcaab936c0305d20de2894f0752b674c1f5e9aaf617d8d80b8

Contents?: true

Size: 701 Bytes

Versions: 4

Compression:

Stored size: 701 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
          [format_instalment_text(installment_number, amount), 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

4 entries across 4 versions & 1 rubygems

Version Path
catarse_pagarme-0.1.1 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-0.1.0 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-0.0.2 app/helpers/catarse_pagarme/application_helper.rb
catarse_pagarme-0.0.1 app/helpers/catarse_pagarme/application_helper.rb