Sha256: 8159eb1dd37b410e98fca8f53d23cd6f79db971197e4faf74cab17a7a31beb58

Contents?: true

Size: 1.44 KB

Versions: 21

Compression:

Stored size: 1.44 KB

Contents

module Adherent
  module PaymentsHelper
    def min_date 
      @member.organism.range_date.first
    end
    
    def max_date
      @member.organism.range_date.last
    end
    
    # cas de figure : le payment correspond précisément à l'adhésion du membre
    # on fait une édition simple : pour votre cotisation du .... au ...
    # Le payment reprend plusieurs règlements 
    # TODO A voir, il peut y avoir des paiements partiels ou total
    def recu_cotisation(payment, member)
      rs = payment.reglements.includes(:adhesion=>:member).to_a
      if rs.size == 1 && rs.first.adhesion.member == member
        adh = rs.first.adhesion
        "votre adhésion pour la période #{du_au(adh.from_date, adh.to_date)}"
        
      elsif rs.size == 1
        # une seule adhésion mais pas pour lui
        adh = rs.first.adhesion
        m = adh.member
        "l'adhésion de #{m.forname} #{m.name} pour la période #{du_au(adh.from_date, adh.to_date)}"    
      else  
        # plusieurs adhésions
        str  = "les adhésions de <ul>"
        rs.each do |r| 
          str+='<li>'
          adh = r.adhesion
          m = adh.member
          str += "#{m.forname} #{m.name} pour la période #{du_au(adh.from_date, adh.to_date)}"
          str += '</li>'
        end
        str += '</ul>'
        str.html_safe
      end
      
    end
    
    protected 
    
    def du_au(from_date, to_date)
      "du #{from_date} au #{to_date}"
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
adherent-0.3.4 app/helpers/adherent/payments_helper.rb
adherent-0.3.3 app/helpers/adherent/payments_helper.rb
adherent-0.3.2 app/helpers/adherent/payments_helper.rb
adherent-0.3.1 app/helpers/adherent/payments_helper.rb
adherent-0.3.0 app/helpers/adherent/payments_helper.rb
adherent-0.2.9 app/helpers/adherent/payments_helper.rb
adherent-0.2.8 app/helpers/adherent/payments_helper.rb
adherent-0.2.7 app/helpers/adherent/payments_helper.rb
adherent-0.2.6 app/helpers/adherent/payments_helper.rb
adherent-0.2.5 app/helpers/adherent/payments_helper.rb
adherent-0.2.4 app/helpers/adherent/payments_helper.rb
adherent-0.2.3 app/helpers/adherent/payments_helper.rb
adherent-0.2.2.4 app/helpers/adherent/payments_helper.rb
adherent-0.2.2.3 app/helpers/adherent/payments_helper.rb
adherent-0.2.2.2 app/helpers/adherent/payments_helper.rb
adherent-0.2.2.1 app/helpers/adherent/payments_helper.rb
adherent-0.2.2 app/helpers/adherent/payments_helper.rb
adherent-0.2.1 app/helpers/adherent/payments_helper.rb
adherent-0.2.0 app/helpers/adherent/payments_helper.rb
adherent-0.1.10 app/helpers/adherent/payments_helper.rb