Module: Adherent::PaymentsHelper

Defined in:
app/helpers/adherent/payments_helper.rb

Instance Method Summary collapse

Instance Method Details

#max_dateObject



7
8
9
# File 'app/helpers/adherent/payments_helper.rb', line 7

def max_date
  @member.organism.range_date.last
end

#min_dateObject



3
4
5
# File 'app/helpers/adherent/payments_helper.rb', line 3

def min_date 
  @member.organism.range_date.first
end

#recu_cotisation(payment, member) ⇒ Object

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



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/helpers/adherent/payments_helper.rb', line 15

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