adherent 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/adherent/icones/address-book-open.png +0 -0
  3. data/app/assets/images/adherent/icones/bandaid.png +0 -0
  4. data/app/assets/images/adherent/icones/card-address.png +0 -0
  5. data/app/assets/images/adherent/icones/home.png +0 -0
  6. data/app/assets/images/adherent/icones/user-plus.png +0 -0
  7. data/app/assets/images/adherent/icones/users.png +0 -0
  8. data/app/controllers/adherent/adhesions_controller.rb +2 -6
  9. data/app/controllers/adherent/coords_controller.rb +2 -22
  10. data/app/controllers/adherent/payments_controller.rb +2 -8
  11. data/app/controllers/adherent/reglements_controller.rb +1 -0
  12. data/app/helpers/adherent/application_helper.rb +4 -0
  13. data/app/models/adherent/adhesion.rb +16 -14
  14. data/app/models/adherent/coord.rb +4 -0
  15. data/app/models/adherent/member.rb +19 -7
  16. data/app/models/adherent/payment.rb +23 -20
  17. data/app/models/adherent/reglement.rb +3 -0
  18. data/app/views/adherent/adhesions/edit.html.erb +1 -1
  19. data/app/views/adherent/adhesions/index.html.haml +1 -1
  20. data/app/views/adherent/adhesions/new.html.erb +1 -1
  21. data/app/views/adherent/coords/edit.html.erb +1 -3
  22. data/app/views/adherent/coords/new.html.erb +1 -1
  23. data/app/views/adherent/coords/show.html.erb +2 -2
  24. data/app/views/adherent/members/edit.html.erb +2 -3
  25. data/app/views/adherent/members/index.html.erb +8 -8
  26. data/app/views/adherent/members/new.html.erb +1 -1
  27. data/app/views/adherent/members/show.html.erb +4 -3
  28. data/app/views/adherent/payments/index.html.haml +1 -1
  29. data/app/views/adherent/payments/new.html.erb +1 -1
  30. data/app/views/adherent/reglements/new.html.erb +1 -1
  31. data/config/initializers/pick_date_extension.rb +12 -4
  32. data/config/locales/fr.yml +3 -1
  33. data/lib/adherent/engine.rb +5 -0
  34. data/lib/adherent/version.rb +1 -1
  35. data/test/dummy/app/controllers/application_controller.rb +1 -1
  36. data/test/dummy/log/development.log +24686 -0
  37. data/test/dummy/log/test.log +76446 -0
  38. data/test/dummy/tmp/cache/assets/BF0/070/sprockets%2F42b486109907c85c344e3428f5615140 +0 -0
  39. data/test/dummy/tmp/cache/assets/C44/670/sprockets%2Fe128312dd259094d00196a3f02f41819 +0 -0
  40. data/test/dummy/tmp/cache/assets/C4D/C10/sprockets%2Fe52bf847776498593423b635698c989c +0 -0
  41. data/test/dummy/tmp/cache/assets/C50/1E0/sprockets%2Fd687f61462083316a5947ccd9211605a +0 -0
  42. data/test/dummy/tmp/cache/assets/C53/BA0/sprockets%2F0701319e027b68d87b4d5727aa571973 +0 -0
  43. data/test/dummy/tmp/cache/assets/C8B/B50/sprockets%2F1bf0946089435ce76a87bd41668373c2 +0 -0
  44. data/test/dummy/tmp/cache/assets/C90/510/sprockets%2Ff5920073f4480657faac32986b1f8587 +0 -0
  45. data/test/dummy/tmp/cache/assets/C91/5E0/sprockets%2F28a1436ca683918e98c79266d19d430e +0 -0
  46. data/test/dummy/tmp/cache/assets/CA4/930/sprockets%2F72a29d61339a55b21d1ac7ec59153244 +0 -0
  47. data/test/dummy/tmp/cache/assets/CA6/0A0/sprockets%2F63a72244bdf73521f399e501b341d16d +0 -0
  48. data/test/dummy/tmp/cache/assets/CAD/BF0/sprockets%2Fd27d4e6bd84d0108fc54a21959181335 +0 -0
  49. data/test/dummy/tmp/cache/assets/CB3/3E0/sprockets%2Ff03d611409c3b2c45d75f97158197ee0 +0 -0
  50. data/test/dummy/tmp/cache/assets/CC6/700/sprockets%2Fda996593aa3789391cab3d7762f13687 +0 -0
  51. data/test/dummy/tmp/cache/assets/CC7/410/sprockets%2Fc39062f6a04c41168a923ea22d701a5a +0 -0
  52. data/test/dummy/tmp/cache/assets/CCB/400/sprockets%2Fb211324ce679335840009b6a2aa45cfc +0 -0
  53. data/test/dummy/tmp/cache/assets/CD6/8A0/sprockets%2Fcb476833cd1a806e251da407a58d9520 +0 -0
  54. data/test/dummy/tmp/cache/assets/CDC/0B0/sprockets%2Ffef07c3c165353f861564ede180350a4 +0 -0
  55. data/test/dummy/tmp/cache/assets/CDD/EB0/sprockets%2F0e17703d917f6560e5c3b46ae85c09a2 +0 -0
  56. data/test/dummy/tmp/cache/assets/CE0/B90/sprockets%2F7baa8d092b9d409d47643521a8b55e62 +0 -0
  57. data/test/dummy/tmp/cache/assets/CE1/EB0/sprockets%2Fe2d34e55c19309ae4d1b8628d38514c6 +0 -0
  58. data/test/dummy/tmp/cache/assets/CE4/B80/sprockets%2Fdc146f8d1ff283ff045000f8349e3942 +0 -0
  59. data/test/dummy/tmp/cache/assets/CFA/700/sprockets%2Ff51725f304c66b6ed8ab01120cb1a593 +0 -0
  60. data/test/dummy/tmp/cache/assets/CFD/F60/sprockets%2Faac72c81c4f00133234e7d1bb46d7925 +0 -0
  61. data/test/dummy/tmp/cache/assets/D0B/520/sprockets%2Fa659c61ab2078241e32ebaf671f87e41 +0 -0
  62. data/test/dummy/tmp/cache/assets/D0D/CC0/sprockets%2F90fc5652fe6161075680fcd4cd0c45d2 +0 -0
  63. data/test/dummy/tmp/cache/assets/D14/210/sprockets%2Fb5db5427cdef8d152ae598d461178026 +0 -0
  64. data/test/dummy/tmp/cache/assets/D15/960/sprockets%2F557c56f5b8b86ba772e07281f1f3a0c7 +0 -0
  65. data/test/dummy/tmp/cache/assets/D16/870/sprockets%2F3f2a439772fcd9cd0f434f723837ae51 +0 -0
  66. data/test/dummy/tmp/cache/assets/D16/D00/sprockets%2F52e940c5c1d8089bcdf984d4d27c5520 +0 -0
  67. data/test/dummy/tmp/cache/assets/D1A/390/sprockets%2F1d08a6978a059fa2494e078ec1ac7e93 +0 -0
  68. data/test/dummy/tmp/cache/assets/D1A/820/sprockets%2F20a218b05c2726d14bd025c36ba31ddd +0 -0
  69. data/test/dummy/tmp/cache/assets/D1A/D90/sprockets%2F6c459fd8844374d4aa166c64f544fae0 +0 -0
  70. data/test/dummy/tmp/cache/assets/D20/590/sprockets%2F22948c5cb4a59a4c252888f75cdf387a +0 -0
  71. data/test/dummy/tmp/cache/assets/D25/100/sprockets%2F4b9f1fdc6f9b86cc0624a7951766d926 +0 -0
  72. data/test/dummy/tmp/cache/assets/D26/A70/sprockets%2Fbb35e749193d15ad00bf0d04513a3bd6 +0 -0
  73. data/test/dummy/tmp/cache/assets/D27/980/sprockets%2F65718e7a65fd89199b02b7cd38b90be9 +0 -0
  74. data/test/dummy/tmp/cache/assets/D2A/220/sprockets%2Fb0d6ff4608e402650ca685bc013d5d0a +0 -0
  75. data/test/dummy/tmp/cache/assets/D2B/FA0/sprockets%2F32aa9ce8b2315cc01f8a2c27374215ce +0 -0
  76. data/test/dummy/tmp/cache/assets/D32/5D0/sprockets%2F3acc8697202c55974ff0122bcf20fa2b +0 -0
  77. data/test/dummy/tmp/cache/assets/D3E/7A0/sprockets%2Ff9a1dbe464c536a11de32284fbc89192 +0 -0
  78. data/test/dummy/tmp/cache/assets/D3F/640/sprockets%2F9b448668c4c3a12d6aaa017b94e69ed2 +0 -0
  79. data/test/dummy/tmp/cache/assets/D42/040/sprockets%2F3def97f4406db752008fa340f74a6e3f +0 -0
  80. data/test/dummy/tmp/cache/assets/D44/860/sprockets%2F9157a652853bd3cea861bd767fed0b08 +0 -0
  81. data/test/dummy/tmp/cache/assets/D44/BF0/sprockets%2Fcf34626c45538b36718fd50fa9bcb2e6 +0 -0
  82. data/test/dummy/tmp/cache/assets/D45/2A0/sprockets%2F9c55f3eca763e68ded31023b7f66543a +0 -0
  83. data/test/dummy/tmp/cache/assets/D48/B20/sprockets%2F5768e2da329c68c958acde5d26124de0 +0 -0
  84. data/test/dummy/tmp/cache/assets/D48/FD0/sprockets%2F4403ce85c7fe84fe60d426553aa99b1f +0 -0
  85. data/test/dummy/tmp/cache/assets/D4B/710/sprockets%2F41e4ac5488184198d7e33e18b7aece4f +0 -0
  86. data/test/dummy/tmp/cache/assets/D4B/C40/sprockets%2F2428f6c76bb4a5efb583e158681fb73d +0 -0
  87. data/test/dummy/tmp/cache/assets/D51/560/sprockets%2Ff6c8347aff37a4784ea82069ba176f5f +0 -0
  88. data/test/dummy/tmp/cache/assets/D56/090/sprockets%2F4af17d268e2ffe72af8a78b78811f666 +0 -0
  89. data/test/dummy/tmp/cache/assets/D57/2C0/sprockets%2F57e8e5954196bd14468ff5db3ae99cd0 +0 -0
  90. data/test/dummy/tmp/cache/assets/D5F/600/sprockets%2F9c4623e57da4d15adb71bd1b04188b1d +0 -0
  91. data/test/dummy/tmp/cache/assets/D63/7A0/sprockets%2Fa0d549181d4ba25b5ed57b841efc2d14 +0 -0
  92. data/test/dummy/tmp/cache/assets/D68/100/sprockets%2F7d7522df5cd3ba1f22c81c653dd5d651 +0 -0
  93. data/test/dummy/tmp/cache/assets/D6A/5C0/sprockets%2F9b410af44867a4979d1aea0ab84ed24b +0 -0
  94. data/test/dummy/tmp/cache/assets/D6B/970/sprockets%2F214e29a7345faee9672bca1756e4aaf1 +0 -0
  95. data/test/dummy/tmp/cache/assets/D6B/D20/sprockets%2Fee6531726dfe6592fa84b42a420b6acd +0 -0
  96. data/test/dummy/tmp/cache/assets/D70/650/sprockets%2Fe9a55b9e2e492638448a622c2fc0bfab +0 -0
  97. data/test/dummy/tmp/cache/assets/D71/AF0/sprockets%2Fb289e7b3562dcfd42bd0957f27a2f52a +0 -0
  98. data/test/dummy/tmp/cache/assets/D73/0F0/sprockets%2F5ba6d2f108d33e64b84fc4dd91960d6e +0 -0
  99. data/test/dummy/tmp/cache/assets/D73/8B0/sprockets%2Fac0e6a1f5b87c2966f07864c89c0acc3 +0 -0
  100. data/test/dummy/tmp/cache/assets/D7B/800/sprockets%2F850d92cf676cc2c2c662ee8dc328f82c +0 -0
  101. data/test/dummy/tmp/cache/assets/D7D/950/sprockets%2F8259f3fc885403b4eea8dd12964c2ffc +0 -0
  102. data/test/dummy/tmp/cache/assets/D92/430/sprockets%2Fc55e2bbc3d3c5566893be021ec1c4ab7 +0 -0
  103. data/test/dummy/tmp/cache/assets/D9A/810/sprockets%2F53a9bd5325fcfa4148c273e3deb2d19d +0 -0
  104. data/test/dummy/tmp/cache/assets/D9D/BA0/sprockets%2Fa3a3f78f8e854339e32a5ab0638abbbf +0 -0
  105. data/test/dummy/tmp/cache/assets/DA7/930/sprockets%2F06db55d1b7d0c96a4ff1657e169e6ece +0 -0
  106. data/test/dummy/tmp/cache/assets/DA8/0D0/sprockets%2F74dcf71bbdf4ad56a3b4338b93d9866c +0 -0
  107. data/test/dummy/tmp/cache/assets/DAD/860/sprockets%2F11e875f5b7f7f5efbad0f6b5f880e244 +0 -0
  108. data/test/dummy/tmp/cache/assets/DAD/8E0/sprockets%2F498547cbaefbf040cfff05e9c6e53386 +0 -0
  109. data/test/dummy/tmp/cache/assets/DB0/A80/sprockets%2F9fdb8e951f975dae3836c2ccf0f65a34 +0 -0
  110. data/test/dummy/tmp/cache/assets/DBC/890/sprockets%2Fa6a1ac17a4326ab9f49d1a74de70f3aa +0 -0
  111. data/test/dummy/tmp/cache/assets/DC1/9E0/sprockets%2F4fdc113ba37308cc3d7d2dbbe1e9d625 +0 -0
  112. data/test/dummy/tmp/cache/assets/DCC/170/sprockets%2Fa2b9a6a717a82fc483c94abbe71aa95f +0 -0
  113. data/test/dummy/tmp/cache/assets/DCD/870/sprockets%2F26f53f256948ecabba69abf1e1dea282 +0 -0
  114. data/test/dummy/tmp/cache/assets/DD4/980/sprockets%2Fed1289bfd5270a38bd9adfcb8d0627c8 +0 -0
  115. data/test/dummy/tmp/cache/assets/DD7/110/sprockets%2Fa7626606dec6ffd4a8a4b76abb7f6a94 +0 -0
  116. data/test/dummy/tmp/cache/assets/DD7/2D0/sprockets%2F9f68c831ccc33f95a6b0a5d7aaf76d8a +0 -0
  117. data/test/dummy/tmp/cache/assets/E12/820/sprockets%2Ff8ced48d293d9ae81be776bac3d3de86 +0 -0
  118. data/test/dummy/tmp/cache/assets/E2A/410/sprockets%2F73874a0edbd48f62ca7cad3c4a9e6aca +0 -0
  119. data/test/dummy/tmp/cache/assets/E3B/7A0/sprockets%2F3c7ac679f8c2cf31dec4ed6ee8064ece +0 -0
  120. data/test/dummy/tmp/cache/assets/E5A/2A0/sprockets%2Fed33dc2e47cddca2a7f3b9d850f01fef +0 -0
  121. data/test/dummy/tmp/cache/assets/E8E/C80/sprockets%2Fbcfe97b68b37db0b902decd4ea5ae8ea +0 -0
  122. data/test/dummy/tmp/capybara/capybara-201308230842396609518899.html +2 -0
  123. data/test/dummy/tmp/capybara/capybara-201308231131452286985805.html +2 -0
  124. data/test/dummy/tmp/capybara/capybara-201308231134102302539877.html +80 -0
  125. data/test/dummy/tmp/capybara/capybara-201308231250391236128298.html +80 -0
  126. data/test/dummy/tmp/capybara/capybara-201308231253582766291529.html +171 -0
  127. data/test/dummy/tmp/capybara/capybara-201308240659049618867125.html +171 -0
  128. data/test/dummy/tmp/capybara/capybara-201308240700213116620673.html +171 -0
  129. data/test/dummy/tmp/pids/server.pid +1 -0
  130. metadata +86 -54
  131. data/app/views/adherent/adhesions/show.html.erb +0 -2
  132. data/app/views/adherent/coords/index.html.erb +0 -55
  133. data/app/views/adherent/payments/edit.html.erb +0 -2
  134. data/app/views/adherent/payments/show.html.erb +0 -2
  135. data/app/views/adherent/reglements/index.html.erb +0 -2
  136. data/app/views/adherent/reglements/show.html.erb +0 -2
  137. data/test/adherent_test.rb +0 -7
  138. data/test/fixtures/adherent/adhesions.yml +0 -13
  139. data/test/fixtures/adherent/coords.yml +0 -21
  140. data/test/fixtures/adherent/members.yml +0 -13
  141. data/test/fixtures/adherent/payments.yml +0 -19
  142. data/test/fixtures/adherent/reglements.yml +0 -11
  143. data/test/functional/adherent/adhesions_controller_test.rb +0 -32
  144. data/test/functional/adherent/coords_controller_test.rb +0 -53
  145. data/test/functional/adherent/members_controller_test.rb +0 -55
  146. data/test/functional/adherent/payments_controller_test.rb +0 -32
  147. data/test/functional/adherent/reglements_controller_test.rb +0 -25
  148. data/test/integration/navigation_test.rb +0 -10
  149. data/test/test_helper.rb +0 -27
  150. data/test/unit/adherent/adhesion_test.rb +0 -36
  151. data/test/unit/adherent/coord_test.rb +0 -9
  152. data/test/unit/adherent/member_test.rb +0 -17
  153. data/test/unit/adherent/payment_test.rb +0 -24
  154. data/test/unit/adherent/reglement_test.rb +0 -9
  155. data/test/unit/helpers/adherent/adhesion_helper_test.rb +0 -6
  156. data/test/unit/helpers/adherent/coords_helper_test.rb +0 -6
  157. data/test/unit/helpers/adherent/members_helper_test.rb +0 -6
  158. data/test/unit/helpers/adherent/payments_helper_test.rb +0 -6
  159. data/test/unit/helpers/adherent/reglements_helper_test.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f46b619c95046614d77348c16f1722c1c0685689
4
- data.tar.gz: 53af5fc158eeefd2ff4de7aa9accb91fc8a6f58e
3
+ metadata.gz: cc38f0e8374b387fb78018d2256a35d72eaa42a0
4
+ data.tar.gz: 6da830b9cba2dfb5172b2187667515a232e913c4
5
5
  SHA512:
6
- metadata.gz: 5d92233c98a0957408105cc3f7dd0aad60a1a93b0c26211c42085192b2a43b0940797164cb2eae3d80659d56e1824107534efb6bab193049461d78b1f6cee8ac
7
- data.tar.gz: a1f744d115859f1993c9bdb6afd62c11fc9f0d10b9d410edd02ab85b83dbb21e64ec26816a56fadd8e5efcfd529dafee12f7a7fa452eecf2cef791ed778a047c
6
+ metadata.gz: 8929f5da67a218679c1cb133780e9c64e1643c2eb638f9d4d19e5aefcdfc7f3d972fe1809fa7b8a6350eb98480dc05e92dc98ec916ef2e8ecaff7967e4b8c787
7
+ data.tar.gz: 050ca3b73234556f4b891a1e9827f68478ce33386d2622970e479bfdd59e281f3fb285200ea4bc8e47da2e8d6c1a1570bd6f7e4776495572704c9711935696af
@@ -21,7 +21,7 @@ module Adherent
21
21
  # PUT /adhesions/1
22
22
  # PUT /adhesions/1.json
23
23
  def update
24
- @adhesion = Adhesion.find(params[:id])
24
+ @adhesion = @member.adhesions.find(params[:id])
25
25
 
26
26
  respond_to do |format|
27
27
  if @adhesion.update_attributes(params[:adhesion])
@@ -57,11 +57,7 @@ module Adherent
57
57
  end
58
58
  end
59
59
 
60
- def show
61
-
62
- @adhesion= @member.adhesions.find(params[:id])
63
-
64
- end
60
+
65
61
 
66
62
  # DELETE /adhesion/1
67
63
  # DELETE /coords/1.json
@@ -6,17 +6,7 @@ module Adherent
6
6
  class CoordsController < ApplicationController
7
7
 
8
8
  before_filter :find_member, :except=>[:index]
9
- # GET /coords
10
- # GET /coords.json
11
- def index
12
- @coords = @organism.members.collect {|m| m.coord }
13
-
14
- respond_to do |format|
15
- format.html # index.html.erb
16
- format.json { render json: @coords }
17
- end
18
- end
19
-
9
+
20
10
  # GET /coords/1
21
11
  # GET /coords/1.json
22
12
  def show
@@ -79,17 +69,7 @@ module Adherent
79
69
  end
80
70
  end
81
71
 
82
- # DELETE /coords/1
83
- # DELETE /coords/1.json
84
- def destroy
85
- @coord = Coord.find(params[:id])
86
- @coord.destroy
87
-
88
- respond_to do |format|
89
- format.html { redirect_to coords_url }
90
- format.json { head :no_content }
91
- end
92
- end
72
+
93
73
 
94
74
  protected
95
75
 
@@ -24,14 +24,8 @@ module Adherent
24
24
  render 'new'
25
25
  end
26
26
  end
27
-
28
- def edit
29
- @payment = @member.payments.find(params[:id])
30
- end
31
-
32
- def show
33
- @payment = @member.payments.find(params[:id])
34
- end
27
+
28
+
35
29
 
36
30
  # DELETE /payment/1
37
31
  # DELETE /coords/1.json
@@ -14,6 +14,7 @@ module Adherent
14
14
  @unpaid_adhesions = Adhesion.unpaid
15
15
  end
16
16
 
17
+ # TODO voir pour faire les deux approches (succès et échec)
17
18
  def create
18
19
  @payment = Payment.find(params[:payment_id])
19
20
  @payment.imputation_on_adh(params[:reglement][:adhesion_id])
@@ -17,5 +17,9 @@ module Adherent
17
17
  def virgule(montant)
18
18
  ActionController::Base.helpers.number_with_precision(montant, precision:2) rescue '0,00'
19
19
  end
20
+
21
+ def icon_to_users
22
+ icon_to 'users.png', members_path, title:'Liste des membres'
23
+ end
20
24
  end
21
25
  end
@@ -3,7 +3,7 @@
3
3
  module Adherent
4
4
  class Adhesion < ActiveRecord::Base
5
5
 
6
- attr_accessible :from_date, :member, :to_date, :amount
6
+ attr_accessible :from_date, :to_date, :amount
7
7
 
8
8
  belongs_to :member
9
9
  has_many :reglements
@@ -15,23 +15,25 @@ module Adherent
15
15
  pick_date_for :from_date, :to_date
16
16
 
17
17
  # partant d'une adhésion, retourne un hash avec les attributs correspondants à
18
- # un renouvellement d'adhésion
19
- def self.next_adh_values(adh = nil)
20
- if adh
21
- {:from_date =>I18n.l(adh.read_attribute(:to_date)+1),
22
- :to_date=>I18n.l(adh.read_attribute(:to_date).years_since(1)),
23
- amount: adh.amount
18
+ # un renouvellement d'adhésion.
19
+ # S'il n'y pas d'adhésion, fonctionne avec des valeurs par défaut
20
+ def self.next_adh_values(montant = 0)
21
+ {:from_date =>I18n.l(Date.today),
22
+ :to_date=>I18n.l(Date.today.years_since(1) -1 ),
23
+ amount: montant
24
+ }
25
+ end
26
+
27
+ def next_adh_values(montant = 0)
28
+ montant = amount if montant == 0
29
+ {:from_date =>I18n.l(read_attribute(:to_date)+1),
30
+ :to_date=>I18n.l(read_attribute(:to_date).years_since(1)),
31
+ amount: montant
24
32
  }
25
- else
26
- {:from_date=>I18n.l(Date.today),
27
- :to_date=>I18n.l(Date.today.years_since(1) - 1),
28
- amount:0
29
- }
30
- end
31
33
  end
32
34
 
33
35
  # liste toutes les adhésions qui ne sont pas payées
34
- # TODO voir pour faire une requête SQL qui serait surment moins
36
+ # TODO voir pour faire une requête SQL ou un scope qui serait surment moins
35
37
  # consommatrice de mémoire
36
38
  def self.unpaid
37
39
  all.reject {|adh| adh.is_paid?}
@@ -3,5 +3,9 @@ module Adherent
3
3
  belongs_to :member
4
4
 
5
5
  attr_accessible :address, :city, :gsm, :mail, :office, :references, :tel, :zip
6
+
7
+ validates :member_id, :presence=>true
8
+
9
+
6
10
  end
7
11
  end
@@ -5,33 +5,45 @@ module Adherent
5
5
  pick_date_for :birthdate
6
6
 
7
7
  belongs_to :organism, class_name: 'Organism'
8
- has_one :coord
8
+ has_one :coord, dependent: :destroy
9
9
  has_many :adhesions
10
10
  has_many :payments
11
11
 
12
- validates :number, :name, :forname , :presence=>true
12
+ validates :number, :name, :forname , :organism_id, :presence=>true
13
13
  validates_uniqueness_of :number, :scope=>:organism_id
14
14
 
15
+ # array des adhésions impayées par ordre de date
15
16
  def unpaid_adhesions
16
- adhesions.reject {|adh| adh.is_paid? }
17
+ adhesions.order(:to_date).reject {|adh| adh.is_paid? }
17
18
  end
18
19
 
20
+ # indique s'il y a des adhésions impayées pour ce membre
19
21
  def unpaid_adhesions?
20
22
  unpaid_adhesions.any?
21
23
  end
22
24
 
25
+ # donne le montant total des adhésions impayées
23
26
  def unpaid_amount
24
27
  unpaid_adhesions.sum(&:due)
25
28
  end
26
29
 
30
+ # renvoie le prenom NOM
27
31
  def to_s
28
- [forname, name.capitalize].join(' ')
32
+ [forname, name.upcase].join(' ')
29
33
  end
30
34
 
31
- def next_adhesion
35
+ # renvoie une nouvelle adhésion préremplie avec les éléments issus de la
36
+ # dernière adhésion.
37
+ # il est possible d'imposer le montant si nécessaire
38
+ def next_adhesion(amount = nil)
39
+ amount ||= 0
32
40
  adh = adhesions(true).order('to_date').last
33
- n_ad = Adhesion.next_adh_values(adh)
34
- adhesions.new(n_ad)
41
+ if adh
42
+ vals = adh.next_adh_values(amount)
43
+ else
44
+ vals = Adhesion::next_adh_values(amount)
45
+ end
46
+ adhesions.new(vals)
35
47
  end
36
48
 
37
49
  end
@@ -6,7 +6,7 @@ module Adherent
6
6
 
7
7
  attr_accessible :amount, :date, :mode
8
8
 
9
- validates :amount, :date, :mode, presence:true
9
+ validates :amount, :date, :mode, :member_id, presence:true
10
10
 
11
11
  pick_date_for :date
12
12
 
@@ -17,44 +17,47 @@ module Adherent
17
17
 
18
18
  after_create :imputation
19
19
 
20
+ # Pour faire une imputation sur une adhesion dont l'id est transmise en argument.
21
+ # Utile lorsque le payment est fait par un membre pour payer l'adhésion d'un tiers
22
+ # (par exemple un membre de sa famille).
23
+ # TODO faire que la valeur de retour soit true ou false pour
24
+ # que la méthode créate du controller puisse tester et rediriger en conséquence
25
+ def imputation_on_adh(adh_id)
26
+ Adhesion.find(adh_id).add_reglement(id, non_impute)
27
+ end
28
+
29
+ # calcule le montant du paiement qui n'a pas été imputé, donc qui
30
+ # ne correspond pas à des réglements
31
+ def non_impute
32
+ amount - reglements(true).sum(:amount)
33
+ end
34
+
20
35
 
36
+ protected
21
37
  # quand on reçoit un paiement, il faut en réaliser l'imputation,
22
38
  # plusieurs cas de figure sont à envisager.
23
39
  #
24
- # Le cas le plus simple est lorsque le montant est inférieur ou égal ou
40
+ # Le cas le plus simple est lorsque le montant est inférieur ou égal aux
25
41
  # montant dus par le membre pour les adhésions en cours.
26
42
  #
27
- # Donc on impute sur les adhésions du membre non soldées et on regarde s'il reste
28
- # quelque chose.
29
- #
43
+ # Donc on impute sur les adhésions du membre non soldées en commençant par les
44
+ # plus anciennes.
30
45
  #
31
46
  #
32
47
  def imputation
33
48
  # liste les adhésions non soldées et le montant total dû
34
49
  # pour chaque adhésion non soldée (prise dans l'ordre chrono)
35
50
  # on crée un réglement du montant dû dans la limité du montant du paiement.
36
- un_paid_adhs = member.adhesions.order(:to_date).reject {|adh| adh.is_paid?}
37
51
  a_imputer = amount
38
- un_paid_adhs.each do |adh|
52
+ member.unpaid_adhesions.each do |adh|
39
53
  if a_imputer > 0
40
- impute = adh.add_reglement(id, a_imputer)
41
- a_imputer -= impute
54
+ reglemt = adh.add_reglement(id, a_imputer)
55
+ a_imputer -= reglemt.amount
42
56
  end
43
57
  end
44
58
  end
45
59
 
46
- # pour faire une imputation sur une adhesion dont l'id est transmise en argument
47
- # TODO faire que la valeur de retour soit true ou false pour
48
- # que la méthode créate du controller puisse tester et rediriger en conséquence
49
- def imputation_on_adh(adh_id)
50
- Adhesion.find(adh_id).add_reglement(id, amount)
51
- end
52
60
 
53
- # calcule le montant du paiement qui n'a pas été imputé, donc qui
54
- # ne correspond pas à des réglements
55
- def non_impute
56
- amount - reglements(true).sum(:amount)
57
- end
58
61
 
59
62
  end
60
63
  end
@@ -3,5 +3,8 @@ module Adherent
3
3
  belongs_to :adhesion
4
4
  belongs_to :payment
5
5
  attr_accessible :amount
6
+
7
+ validates :adhesion_id, :payment_id, :amount, presence:true
8
+ validates_numericality_of :amount, greater_than:0.0
6
9
  end
7
10
  end
@@ -1,6 +1,6 @@
1
1
  <%= content_for :menu do %>
2
2
 
3
- <%= icon_to 'navigation90.png', member_adhesions_path(@member) %>
3
+ <%= icon_to 'bandaid.png', member_adhesions_path(@member) %>
4
4
  <% end -%>
5
5
 
6
6
  <div class="champ">
@@ -1,5 +1,5 @@
1
1
  = content_for :menu do
2
- = icon_to 'navigation90.png', members_path, title:'Liste des membres'
2
+ = icon_to_users
3
3
  = icon_to 'nouveau.png', new_member_adhesion_path(@member), title:'Nouvelle adhésion ou renouvellement'
4
4
 
5
5
 
@@ -1,6 +1,6 @@
1
1
  <%= content_for :menu do %>
2
2
 
3
- <%= icon_to 'navigation90.png', member_adhesions_path(@member) %>
3
+ <%= icon_to_users %>
4
4
  <% end -%>
5
5
 
6
6
  <div class="champ">
@@ -1,8 +1,6 @@
1
1
  <%= content_for :menu do %>
2
+ <%= icon_to_users %>
2
3
 
3
- <%= icon_to 'nouveau.png', new_coord_path %>
4
- <%= icon_to 'detail.png', @coord %>
5
- <%= icon_to 'retour.png', :back %>
6
4
  <% end -%>
7
5
 
8
6
  <div class="champ">
@@ -1,6 +1,6 @@
1
1
  <%= content_for :menu do %>
2
2
 
3
- <%= icon_to 'navigation90.png', members_path %>
3
+ <%= icon_to_users %>
4
4
  <% end -%>
5
5
 
6
6
  <div class="champ">
@@ -1,12 +1,12 @@
1
1
 
2
2
  <%= content_for :menu do %>
3
- <%= icon_to 'navigation90.png', members_path %>
3
+ <%= icon_to_users %>
4
4
  <%= icon_to 'modifier.png', edit_member_coord_path(@member) %>
5
5
 
6
6
  <% end -%>
7
7
 
8
8
  <div class="champ">
9
- <h3>Fiche <%= I18n::t('coord').pluralize %> <%= "#{@member.forname} #{@member.name}" %> </h3>
9
+ <h3>Fiche <%= I18n::t('coord').pluralize %> <%= "#{@member.to_s}" %></h3>
10
10
  </div>
11
11
  <div class="row-fluid inner-champ">
12
12
 
@@ -1,8 +1,7 @@
1
1
  <%= content_for :menu do %>
2
+ <%= icon_to 'users.png', members_path, title:'Liste des membres' %>
3
+ <%= icon_to 'card-address.png', member_coord_path(@member), title:'Coordonnées' %>
2
4
 
3
- <%= icon_to 'nouveau.png', new_member_path %>
4
- <%= icon_to 'detail.png', @member %>
5
- <%= icon_to 'retour.png', :back %>
6
5
  <% end -%>
7
6
 
8
7
  <div class="champ">
@@ -1,13 +1,13 @@
1
1
  <%= content_for :menu do %>
2
- <%= icon_to 'navigation90.png', main_app.root_path %>
3
- <%= icon_to 'nouveau.png', new_member_path %>
2
+ <%= icon_to 'home.png', main_app.root_path %>
3
+ <%= icon_to 'user-plus.png', new_member_path %>
4
4
  <% end -%>
5
5
 
6
6
 
7
7
  <div class="champ">
8
8
 
9
9
 
10
- <h3> Liste des <%= I18n::t('members') %></h3>
10
+ <h3>Liste des <%= I18n::t('members') %></h3>
11
11
  <table class="table table-striped table-bordered table-condensed" cellpadding="0" cellspacing="0" border="0">
12
12
  <thead>
13
13
  <tr>
@@ -36,12 +36,12 @@
36
36
  <td><%= member.birthdate %></td>
37
37
  <td><%= member.coord ? member.coord.mail : '' %>
38
38
  <td><%= member.coord ? member.coord.tel : '' %>
39
- <td><%= icon_to 'detail.png', member_coord_path(member), title:'Coordonnées' %>
40
- <%= icon_to 'afficher.png', member_adhesions_path(member), title:'Liste des adhésions' %>
39
+ <td><%= icon_to 'card-address.png', member_coord_path(member), title:'Coordonnées', id:"coord_member_#{member.id}" %>
40
+ <%= icon_to 'bandaid.png', member_adhesions_path(member), title:'Liste des adhésions', id:"adhesion_member_#{member.id}"%>
41
41
 
42
- <%= icon_to 'payment.png', member_payments_path(member), title: 'Liste des paiements' %>
43
- <%= icon_to 'modifier.png', edit_member_path(member) %>
44
- <%= icon_to 'supprimer.png', member, :confirm => 'Etes vous sur ?', :method => :delete %></td>
42
+ <%= icon_to 'payment.png', member_payments_path(member), title: 'Liste des paiements' , id:"payment_member_#{member.id}"%>
43
+ <%= icon_to 'modifier.png', edit_member_path(member) , id:"edit_member_#{member.id}" %>
44
+ <%= icon_to 'supprimer.png', member, id:"delete_member_#{member.id}", :confirm => 'Etes vous sur ?', :method => :delete %></td>
45
45
  </tr>
46
46
  <% end %>
47
47
  </tbody>
@@ -1,6 +1,6 @@
1
1
  <%= content_for :menu do %>
2
2
 
3
- <%= icon_to 'navigation90.png', members_path %>
3
+ <%= icon_to 'users.png', members_path %>
4
4
  <% end -%>
5
5
 
6
6
  <div class="champ">
@@ -1,9 +1,10 @@
1
1
 
2
2
  <%= content_for :menu do %>
3
-
3
+ <%= icon_to 'users.png', members_path, title:'Liste des membres' %>
4
+ <%= icon_to 'card-address.png', member_coord_path(@member) , title:'Coordonées' %>
4
5
  <%= icon_to 'modifier.png', edit_member_path(@member) %>
5
- <%= icon_to 'detail.png', member_coord_path(@member) %>
6
- <%= icon_to 'navigation90.png', members_path %>
6
+
7
+
7
8
  <% end -%>
8
9
 
9
10
  <div class="champ">