adherent 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/adherent/icones/imputation-delete.png +0 -0
  3. data/app/assets/images/adherent/icones/imputation-edit.png +0 -0
  4. data/app/assets/images/images/Sorting icons.psd +0 -0
  5. data/app/assets/images/images/back_disabled.png +0 -0
  6. data/app/assets/images/images/back_enabled.png +0 -0
  7. data/app/assets/images/images/back_enabled_hover.png +0 -0
  8. data/app/assets/images/images/favicon.ico +0 -0
  9. data/app/assets/images/images/forward_disabled.png +0 -0
  10. data/app/assets/images/images/forward_enabled.png +0 -0
  11. data/app/assets/images/images/forward_enabled_hover.png +0 -0
  12. data/app/assets/images/images/sort_asc.png +0 -0
  13. data/app/assets/images/images/sort_asc_disabled.png +0 -0
  14. data/app/assets/images/images/sort_both.png +0 -0
  15. data/app/assets/images/images/sort_desc.png +0 -0
  16. data/app/assets/images/images/sort_desc_disabled.png +0 -0
  17. data/app/assets/javascripts/adherent/allpayments.js +7 -0
  18. data/app/assets/javascripts/adherent/jquery.dataTables.min.js +157 -0
  19. data/app/assets/javascripts/adherent/members.js +116 -0
  20. data/app/assets/stylesheets/adherent/allpayments.css +4 -0
  21. data/app/assets/stylesheets/adherent/demo_table.css +577 -0
  22. data/app/controllers/adherent/allpayments_controller.rb +9 -0
  23. data/app/controllers/adherent/payments_controller.rb +41 -4
  24. data/app/controllers/adherent/reglements_controller.rb +24 -0
  25. data/app/helpers/adherent/allpayments_helper.rb +5 -0
  26. data/app/helpers/adherent/application_helper.rb +24 -9
  27. data/app/helpers/adherent/payments_helper.rb +1 -10
  28. data/app/models/adherent/adhesion.rb +10 -6
  29. data/app/models/adherent/member.rb +2 -2
  30. data/app/models/adherent/payment.rb +27 -6
  31. data/app/views/adherent/allpayments/_payment.html.haml +14 -0
  32. data/app/views/adherent/allpayments/index.html.haml +22 -0
  33. data/app/views/adherent/members/index.html.erb +6 -5
  34. data/app/views/adherent/payments/_payment.html.haml +11 -0
  35. data/app/views/adherent/payments/edit.html.erb +13 -0
  36. data/app/views/adherent/payments/index.html.haml +1 -12
  37. data/app/views/adherent/payments/new.html.erb +1 -1
  38. data/app/views/adherent/payments/show.html.haml +33 -0
  39. data/app/views/adherent/reglements/show.html.haml +31 -0
  40. data/config/initializers/validators.rb +12 -0
  41. data/config/locales/fr.yml +1 -1
  42. data/config/routes.rb +3 -0
  43. data/lib/adherent/version.rb +1 -1
  44. data/test/dummy/app/models/organism.rb +1 -0
  45. data/test/dummy/log/development.log +14434 -0
  46. data/test/dummy/log/test.log +62947 -0
  47. data/test/dummy/tmp/cache/assets/BF0/070/sprockets%2F42b486109907c85c344e3428f5615140 +0 -0
  48. data/test/dummy/tmp/cache/assets/C2F/180/sprockets%2F24383c007af706866f9a978498308d01 +0 -0
  49. data/test/dummy/tmp/cache/assets/C44/670/sprockets%2Fe128312dd259094d00196a3f02f41819 +0 -0
  50. data/test/dummy/tmp/cache/assets/C4D/C10/sprockets%2Fe52bf847776498593423b635698c989c +0 -0
  51. data/test/dummy/tmp/cache/assets/C50/1E0/sprockets%2Fd687f61462083316a5947ccd9211605a +0 -0
  52. data/test/dummy/tmp/cache/assets/C53/BA0/sprockets%2F0701319e027b68d87b4d5727aa571973 +0 -0
  53. data/test/dummy/tmp/cache/assets/C7C/2A0/sprockets%2F451d3616d07ff0801851aecc85940392 +0 -0
  54. data/test/dummy/tmp/cache/assets/C8B/B50/sprockets%2F1bf0946089435ce76a87bd41668373c2 +0 -0
  55. data/test/dummy/tmp/cache/assets/C8C/C00/sprockets%2F25d88d6c610820a36668853eea17e359 +0 -0
  56. data/test/dummy/tmp/cache/assets/C91/5E0/sprockets%2F28a1436ca683918e98c79266d19d430e +0 -0
  57. data/test/dummy/tmp/cache/assets/CA4/6A0/sprockets%2F49b5803aaa253c1ffa5214311973e684 +0 -0
  58. data/test/dummy/tmp/cache/assets/CA6/0A0/sprockets%2F63a72244bdf73521f399e501b341d16d +0 -0
  59. data/test/dummy/tmp/cache/assets/CAA/020/sprockets%2Fa2032410860d92e63293c996d5fa3ac6 +0 -0
  60. data/test/dummy/tmp/cache/assets/CAA/DA0/sprockets%2Fc1d5b8783261726af51242f75d0034ef +0 -0
  61. data/test/dummy/tmp/cache/assets/CAD/BF0/sprockets%2Fd27d4e6bd84d0108fc54a21959181335 +0 -0
  62. data/test/dummy/tmp/cache/assets/CB3/3E0/sprockets%2Ff03d611409c3b2c45d75f97158197ee0 +0 -0
  63. data/test/dummy/tmp/cache/assets/CB7/310/sprockets%2F9d00a7c05c5990e797170e06dd5641d9 +0 -0
  64. data/test/dummy/tmp/cache/assets/CC5/430/sprockets%2F887b61f7cb339b94a85b7e721295493c +0 -0
  65. data/test/dummy/tmp/cache/assets/CC6/700/sprockets%2Fda996593aa3789391cab3d7762f13687 +0 -0
  66. data/test/dummy/tmp/cache/assets/CC7/410/sprockets%2Fc39062f6a04c41168a923ea22d701a5a +0 -0
  67. data/test/dummy/tmp/cache/assets/CCB/400/sprockets%2Fb211324ce679335840009b6a2aa45cfc +0 -0
  68. data/test/dummy/tmp/cache/assets/CD6/8A0/sprockets%2Fcb476833cd1a806e251da407a58d9520 +0 -0
  69. data/test/dummy/tmp/cache/assets/CDC/0B0/sprockets%2Ffef07c3c165353f861564ede180350a4 +0 -0
  70. data/test/dummy/tmp/cache/assets/CDD/EB0/sprockets%2F0e17703d917f6560e5c3b46ae85c09a2 +0 -0
  71. data/test/dummy/tmp/cache/assets/CE0/B90/sprockets%2F7baa8d092b9d409d47643521a8b55e62 +0 -0
  72. data/test/dummy/tmp/cache/assets/CE1/EB0/sprockets%2Fe2d34e55c19309ae4d1b8628d38514c6 +0 -0
  73. data/test/dummy/tmp/cache/assets/CE4/B80/sprockets%2Fdc146f8d1ff283ff045000f8349e3942 +0 -0
  74. data/test/dummy/tmp/cache/assets/CE8/950/sprockets%2Fd68548f1d6d12fe519aea39909520b36 +0 -0
  75. data/test/dummy/tmp/cache/assets/CEA/B70/sprockets%2F2cdb1061009b0d4430f4d073562b2cbc +0 -0
  76. data/test/dummy/tmp/cache/assets/CF6/590/sprockets%2F4904f8e3b4e2397b86f64f3549e3d63c +0 -0
  77. data/test/dummy/tmp/cache/assets/CF8/560/sprockets%2F7e8587b418f3496ca670f76e8b7423ea +0 -0
  78. data/test/dummy/tmp/cache/assets/CFA/700/sprockets%2Ff51725f304c66b6ed8ab01120cb1a593 +0 -0
  79. data/test/dummy/tmp/cache/assets/CFD/F60/sprockets%2Faac72c81c4f00133234e7d1bb46d7925 +0 -0
  80. data/test/dummy/tmp/cache/assets/CFE/380/sprockets%2F25b295cad423d26a3a334e3864cab085 +0 -0
  81. data/test/dummy/tmp/cache/assets/D04/640/sprockets%2F93cc6f780004fd5b09d1774c3bb0b802 +0 -0
  82. data/test/dummy/tmp/cache/assets/D0B/520/sprockets%2Fa659c61ab2078241e32ebaf671f87e41 +0 -0
  83. data/test/dummy/tmp/cache/assets/D0D/CC0/sprockets%2F90fc5652fe6161075680fcd4cd0c45d2 +0 -0
  84. data/test/dummy/tmp/cache/assets/D14/210/sprockets%2Fb5db5427cdef8d152ae598d461178026 +0 -0
  85. data/test/dummy/tmp/cache/assets/D15/960/sprockets%2F557c56f5b8b86ba772e07281f1f3a0c7 +0 -0
  86. data/test/dummy/tmp/cache/assets/D16/870/sprockets%2F3f2a439772fcd9cd0f434f723837ae51 +0 -0
  87. data/test/dummy/tmp/cache/assets/D16/D00/sprockets%2F52e940c5c1d8089bcdf984d4d27c5520 +0 -0
  88. data/test/dummy/tmp/cache/assets/D1A/390/sprockets%2F1d08a6978a059fa2494e078ec1ac7e93 +0 -0
  89. data/test/dummy/tmp/cache/assets/D1A/820/sprockets%2F20a218b05c2726d14bd025c36ba31ddd +0 -0
  90. data/test/dummy/tmp/cache/assets/D1A/D90/sprockets%2F6c459fd8844374d4aa166c64f544fae0 +0 -0
  91. data/test/dummy/tmp/cache/assets/D20/590/sprockets%2F22948c5cb4a59a4c252888f75cdf387a +0 -0
  92. data/test/dummy/tmp/cache/assets/D25/100/sprockets%2F4b9f1fdc6f9b86cc0624a7951766d926 +0 -0
  93. data/test/dummy/tmp/cache/assets/D26/A70/sprockets%2Fbb35e749193d15ad00bf0d04513a3bd6 +0 -0
  94. data/test/dummy/tmp/cache/assets/D27/980/sprockets%2F65718e7a65fd89199b02b7cd38b90be9 +0 -0
  95. data/test/dummy/tmp/cache/assets/D2A/220/sprockets%2Fb0d6ff4608e402650ca685bc013d5d0a +0 -0
  96. data/test/dummy/tmp/cache/assets/D2B/FA0/sprockets%2F32aa9ce8b2315cc01f8a2c27374215ce +0 -0
  97. data/test/dummy/tmp/cache/assets/D32/5D0/sprockets%2F3acc8697202c55974ff0122bcf20fa2b +0 -0
  98. data/test/dummy/tmp/cache/assets/D34/630/sprockets%2Fa259c79ff690848e93962f587da8f2ac +0 -0
  99. data/test/dummy/tmp/cache/assets/D34/E20/sprockets%2F3c0dfd7a47fb35af6a3ad88310713543 +0 -0
  100. data/test/dummy/tmp/cache/assets/D3E/7A0/sprockets%2Ff9a1dbe464c536a11de32284fbc89192 +0 -0
  101. data/test/dummy/tmp/cache/assets/D3F/640/sprockets%2F9b448668c4c3a12d6aaa017b94e69ed2 +0 -0
  102. data/test/dummy/tmp/cache/assets/D42/040/sprockets%2F3def97f4406db752008fa340f74a6e3f +0 -0
  103. data/test/dummy/tmp/cache/assets/D42/C40/sprockets%2F224cf987cad00c39ae3d39b971f8109b +0 -0
  104. data/test/dummy/tmp/cache/assets/D44/860/sprockets%2F9157a652853bd3cea861bd767fed0b08 +0 -0
  105. data/test/dummy/tmp/cache/assets/D44/BF0/sprockets%2Fcf34626c45538b36718fd50fa9bcb2e6 +0 -0
  106. data/test/dummy/tmp/cache/assets/D45/2A0/sprockets%2F9c55f3eca763e68ded31023b7f66543a +0 -0
  107. data/test/dummy/tmp/cache/assets/D46/650/sprockets%2F6ee2abb1888774ab7c549f15b50d615f +0 -0
  108. data/test/dummy/tmp/cache/assets/D48/B20/sprockets%2F5768e2da329c68c958acde5d26124de0 +0 -0
  109. data/test/dummy/tmp/cache/assets/D48/FD0/sprockets%2F4403ce85c7fe84fe60d426553aa99b1f +0 -0
  110. data/test/dummy/tmp/cache/assets/D49/2D0/sprockets%2F59e843295151ccde25afb2f9f6e7a605 +0 -0
  111. data/test/dummy/tmp/cache/assets/D4B/710/sprockets%2F41e4ac5488184198d7e33e18b7aece4f +0 -0
  112. data/test/dummy/tmp/cache/assets/D4B/C40/sprockets%2F2428f6c76bb4a5efb583e158681fb73d +0 -0
  113. data/test/dummy/tmp/cache/assets/D51/560/sprockets%2Ff6c8347aff37a4784ea82069ba176f5f +0 -0
  114. data/test/dummy/tmp/cache/assets/D52/250/sprockets%2F967f6481dd795af37e3a49be042f8e1b +0 -0
  115. data/test/dummy/tmp/cache/assets/D56/090/sprockets%2F4af17d268e2ffe72af8a78b78811f666 +0 -0
  116. data/test/dummy/tmp/cache/assets/D57/2C0/sprockets%2F57e8e5954196bd14468ff5db3ae99cd0 +0 -0
  117. data/test/dummy/tmp/cache/assets/D5F/600/sprockets%2F9c4623e57da4d15adb71bd1b04188b1d +0 -0
  118. data/test/dummy/tmp/cache/assets/D63/7A0/sprockets%2Fa0d549181d4ba25b5ed57b841efc2d14 +0 -0
  119. data/test/dummy/tmp/cache/assets/D65/0C0/sprockets%2F409bdde508f6197117fe0ab1344ca3de +0 -0
  120. data/test/dummy/tmp/cache/assets/D65/900/sprockets%2F4dd3fce32a54a0f8fb029c30f41d3487 +0 -0
  121. data/test/dummy/tmp/cache/assets/D68/100/sprockets%2F7d7522df5cd3ba1f22c81c653dd5d651 +0 -0
  122. data/test/dummy/tmp/cache/assets/D6A/5C0/sprockets%2F9b410af44867a4979d1aea0ab84ed24b +0 -0
  123. data/test/dummy/tmp/cache/assets/D6B/970/sprockets%2F214e29a7345faee9672bca1756e4aaf1 +0 -0
  124. data/test/dummy/tmp/cache/assets/D6B/D20/sprockets%2Fee6531726dfe6592fa84b42a420b6acd +0 -0
  125. data/test/dummy/tmp/cache/assets/D71/AF0/sprockets%2Fb289e7b3562dcfd42bd0957f27a2f52a +0 -0
  126. data/test/dummy/tmp/cache/assets/D73/0F0/sprockets%2F5ba6d2f108d33e64b84fc4dd91960d6e +0 -0
  127. data/test/dummy/tmp/cache/assets/D73/8B0/sprockets%2Fac0e6a1f5b87c2966f07864c89c0acc3 +0 -0
  128. data/test/dummy/tmp/cache/assets/D7A/3E0/sprockets%2F3dfc09dcfefff43d4680267d832149c3 +0 -0
  129. data/test/dummy/tmp/cache/assets/D7B/800/sprockets%2F850d92cf676cc2c2c662ee8dc328f82c +0 -0
  130. data/test/dummy/tmp/cache/assets/D7D/950/sprockets%2F8259f3fc885403b4eea8dd12964c2ffc +0 -0
  131. data/test/dummy/tmp/cache/assets/D7F/140/sprockets%2Fb6961cbff5838a917c93f2cb6185d6ae +0 -0
  132. data/test/dummy/tmp/cache/assets/D92/430/sprockets%2Fc55e2bbc3d3c5566893be021ec1c4ab7 +0 -0
  133. data/test/dummy/tmp/cache/assets/D9A/810/sprockets%2F53a9bd5325fcfa4148c273e3deb2d19d +0 -0
  134. data/test/dummy/tmp/cache/assets/D9D/BA0/sprockets%2Fa3a3f78f8e854339e32a5ab0638abbbf +0 -0
  135. data/test/dummy/tmp/cache/assets/DA7/930/sprockets%2F06db55d1b7d0c96a4ff1657e169e6ece +0 -0
  136. data/test/dummy/tmp/cache/assets/DA8/0D0/sprockets%2F74dcf71bbdf4ad56a3b4338b93d9866c +0 -0
  137. data/test/dummy/tmp/cache/assets/DAD/8E0/sprockets%2F498547cbaefbf040cfff05e9c6e53386 +0 -0
  138. data/test/dummy/tmp/cache/assets/DB0/A80/sprockets%2F9fdb8e951f975dae3836c2ccf0f65a34 +0 -0
  139. data/test/dummy/tmp/cache/assets/DBC/890/sprockets%2Fa6a1ac17a4326ab9f49d1a74de70f3aa +0 -0
  140. data/test/dummy/tmp/cache/assets/DC1/9E0/sprockets%2F4fdc113ba37308cc3d7d2dbbe1e9d625 +0 -0
  141. data/test/dummy/tmp/cache/assets/DCC/170/sprockets%2Fa2b9a6a717a82fc483c94abbe71aa95f +0 -0
  142. data/test/dummy/tmp/cache/assets/DCD/870/sprockets%2F26f53f256948ecabba69abf1e1dea282 +0 -0
  143. data/test/dummy/tmp/cache/assets/DD3/F60/sprockets%2Fde4fdc4d1f700596d5f2ce7077fbc32e +0 -0
  144. data/test/dummy/tmp/cache/assets/DD4/980/sprockets%2Fed1289bfd5270a38bd9adfcb8d0627c8 +0 -0
  145. data/test/dummy/tmp/cache/assets/DD7/110/sprockets%2Fa7626606dec6ffd4a8a4b76abb7f6a94 +0 -0
  146. data/test/dummy/tmp/cache/assets/DD7/2D0/sprockets%2F9f68c831ccc33f95a6b0a5d7aaf76d8a +0 -0
  147. data/test/dummy/tmp/cache/assets/DED/9A0/sprockets%2F1e96fab65eff8789cd8c76ffadf40814 +0 -0
  148. data/test/dummy/tmp/cache/assets/E12/820/sprockets%2Ff8ced48d293d9ae81be776bac3d3de86 +0 -0
  149. data/test/dummy/tmp/cache/assets/E2A/410/sprockets%2F73874a0edbd48f62ca7cad3c4a9e6aca +0 -0
  150. data/test/dummy/tmp/cache/assets/E3B/7A0/sprockets%2F3c7ac679f8c2cf31dec4ed6ee8064ece +0 -0
  151. data/test/dummy/tmp/cache/assets/E5A/2A0/sprockets%2Fed33dc2e47cddca2a7f3b9d850f01fef +0 -0
  152. data/test/dummy/tmp/cache/assets/E8E/C80/sprockets%2Fbcfe97b68b37db0b902decd4ea5ae8ea +0 -0
  153. data/test/dummy/tmp/pids/server.pid +1 -1
  154. metadata +78 -2
@@ -14,20 +14,35 @@ module Adherent
14
14
  end
15
15
 
16
16
  # Pour transformer un montant selon le format numérique français avec deux décimales
17
- def virgule(montant)
17
+ def two_decimals(montant)
18
18
  ActionController::Base.helpers.number_with_precision(montant, precision:2) rescue '0,00'
19
19
  end
20
20
 
21
- # affiche un nombre avec deux décimales
22
- # utilisé dans les vues qui demandent un montant
23
- def two_decimals(montant)
24
- sprintf('%0.02f',montant)
25
- rescue
26
- '0.00'
27
- end
28
-
21
+
29
22
  def icon_to_users
30
23
  icon_to 'users.png', members_path, title:'Liste des membres'
31
24
  end
25
+
26
+ def list_imputations(payment)
27
+
28
+ content_tag(:ul) do
29
+ payment.reglements.map do |r|
30
+ content_tag(:li) do
31
+ imputation_with_actions(payment, r)
32
+ end
33
+ end.join.html_safe
34
+ end
35
+ end
36
+
37
+ def imputation_with_actions(pay, reglt)
38
+ html = ''
39
+ html << "Adhésion #{reglt.adhesion.member.to_s} pour #{number_to_currency(reglt.amount, locale: :fr)}"
40
+ html << "&nbsp;&nbsp;"
41
+ html << "#{icon_to 'detail.png', payment_reglement_path(pay, reglt)}"
42
+ # html << "#{icon_to 'imputation-edit.png', edit_payment_reglement_path(pay, reglt), title:'Modifier l\'imputation'}"
43
+ # html << "#{icon_to 'imputation-delete.png', payment_reglement_path(pay, reglt), title:'Supprimer l\'imputation'}"
44
+ html.html_safe
45
+ end
46
+
32
47
  end
33
48
  end
@@ -1,14 +1,5 @@
1
1
  module Adherent
2
2
  module PaymentsHelper
3
- def list_imputations(payment)
4
-
5
- content_tag(:ul) do
6
- payment.reglements.map do |r|
7
- content_tag(:li) do
8
- "Adhésion #{r.adhesion.member.to_s} pour #{number_to_currency(r.amount, locale: :fr)}"
9
- end
10
- end.join.html_safe
11
- end
12
- end
3
+
13
4
  end
14
5
  end
@@ -32,12 +32,15 @@ module Adherent
32
32
  }
33
33
  end
34
34
 
35
- # liste toutes les adhésions qui ne sont pas payées
36
- # TODO voir pour faire une requête SQL ou un scope qui serait surment moins
37
- # consommatrice de mémoire
38
- def self.unpaid
39
- all.reject {|adh| adh.is_paid?}
40
- end
35
+ # liste toutes les adhésions qui ne sont pas payées.
36
+ # pour rappel un where ne fonctionne pas avec un aggrégat obligeant à utiliser la clause having
37
+ # reglements_amount.to_i donne le montant des règlements enregistrés
38
+ # to_i est nécessaire car le retour fait par Rails est un string
39
+ scope :unpaid, select('adherent_adhesions.*, sum(adherent_reglements.amount) as reglements_amount').
40
+ joins('left join adherent_reglements on adherent_reglements.adhesion_id = adherent_adhesions.id').
41
+ group('adherent_adhesions.id').
42
+ having('adherent_adhesions.amount > 0 AND (adherent_adhesions.amount > sum(adherent_reglements.amount) OR sum(adherent_reglements.amount) IS NULL)')
43
+
41
44
 
42
45
  # méthode mise en place pour assurer une mise en forme lisible
43
46
  # dans la sélection des imputations
@@ -67,6 +70,7 @@ module Adherent
67
70
  imputation = [montant, due].min
68
71
  r = reglements.new(amount:imputation)
69
72
  r.payment_id = payment_id
73
+ puts r.errors.messages unless r.valid?
70
74
  r.save!
71
75
  r
72
76
 
@@ -12,9 +12,9 @@ module Adherent
12
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
+ # arel des adhésions impayées par ordre de date
16
16
  def unpaid_adhesions
17
- adhesions.order(:to_date).reject {|adh| adh.is_paid? }
17
+ adhesions.order(:to_date).unpaid
18
18
  end
19
19
 
20
20
  # indique s'il y a des adhésions impayées pour ce membre
@@ -1,5 +1,21 @@
1
1
  module Adherent
2
- class Payment < ActiveRecord::Base
2
+
3
+ # La classe Payment permet d'enregistrer les payments effectués par les adhérents
4
+ #
5
+ # Un callback after_create tente d'imputer le réglement sur une adhésion qui soit due.
6
+ #
7
+ # Comme il est possible qu'un adhérent fasse un réglement pour plusieurs personnes (les
8
+ # membres de sa famille par exemple), il est possible d'éclater des payments sur
9
+ # différents réglements. Un payment a donc plusieurs réglements.
10
+ #
11
+ # Des méthodes non_impute et imputation_on_adh(adhesion) permettent de savoir
12
+ # si la totalité du payment a été affectée à un réglement et d'imputer le montant
13
+ # sur une adhésion spécifiée.
14
+ #
15
+ # Un validator spécifique est mis en place pour interdire de diminuer le payment
16
+ # en dessous des montants déja imputés.
17
+ #
18
+ class Payment < ActiveRecord::Base
3
19
 
4
20
  has_many :reglements, :dependent=>:destroy
5
21
  belongs_to :member
@@ -7,11 +23,12 @@ module Adherent
7
23
  attr_accessible :amount, :date, :mode
8
24
 
9
25
  validates :amount, :date, :mode, :member_id, presence:true
26
+ validates :amount, :over_imputations=>true
10
27
 
11
- pick_date_for :date
28
+ pick_date_for :date
12
29
 
13
- # le montant ne peut être que positif
14
- validates_numericality_of :amount, greater_than: 0
30
+
31
+ validates_numericality_of :amount
15
32
  # le mode doit être dans les MODES
16
33
  validates_inclusion_of :mode, in: Adherent::MODES
17
34
 
@@ -29,7 +46,11 @@ module Adherent
29
46
  # calcule le montant du paiement qui n'a pas été imputé, donc qui
30
47
  # ne correspond pas à des réglements
31
48
  def non_impute
32
- amount - reglements(true).sum(:amount)
49
+ amount - impute
50
+ end
51
+
52
+ def impute
53
+ reglements(true).sum(:amount)
33
54
  end
34
55
 
35
56
 
@@ -50,7 +71,7 @@ module Adherent
50
71
  # on crée un réglement du montant dû dans la limité du montant du paiement.
51
72
  a_imputer = amount
52
73
  member.unpaid_adhesions.each do |adh|
53
- if a_imputer > 0
74
+ if a_imputer > 0
54
75
  reglemt = adh.add_reglement(id, a_imputer)
55
76
  a_imputer -= reglemt.amount
56
77
  end
@@ -0,0 +1,14 @@
1
+ %tr
2
+ %td
3
+ = payment.member.to_s
4
+ = icon_to 'payment.png', member_payments_path(payment.member), title:'Liste des paiements de cet adhérent'
5
+ %td= payment.date
6
+ %td.numeric= two_decimals payment.amount
7
+ %td= payment.mode
8
+ %td= list_imputations(payment)
9
+ %td.numeric= two_decimals payment.non_impute
10
+
11
+ %td
12
+ - if (payment.non_impute != 0.0)
13
+ = icon_to 'imputation.png', new_payment_reglement_path(payment), title: 'Imputer le solde sur une adhésion'
14
+ = icon_to 'detail.png', member_payment_path(payment.member, payment)
@@ -0,0 +1,22 @@
1
+ = content_for :menu do
2
+ = icon_to_users
3
+
4
+
5
+
6
+ .champ
7
+ %h3 Table de tous les paiements
8
+
9
+ %table.table.display.table-striped.table-bordered.table-condensed#allpayments(cellpadding="0" cellspacing="0" border="0")
10
+ %thead
11
+ %tr
12
+ %th De
13
+ %th.date-euro Le
14
+ %th Montant (€)
15
+ %th Par
16
+ %th Imputé sur
17
+ %th Reste à imputer (€)
18
+ %th Actions
19
+ %tbody
20
+ = render partial:'adherent/allpayments/payment', collection:@payments
21
+
22
+
@@ -1,6 +1,7 @@
1
1
  <%= content_for :menu do %>
2
- <%= icon_to 'home.png', main_app.root_path %>
3
- <%= icon_to 'user-plus.png', new_member_path %>
2
+
3
+ <%= icon_to 'nouveau.png', new_member_path, title:'Ajouter un membre' %>
4
+ <%= icon_to 'payment.png', payments_path, title:'Table des paiements' %>
4
5
  <% end -%>
5
6
 
6
7
 
@@ -8,7 +9,7 @@
8
9
 
9
10
 
10
11
  <h3>Liste des <%= I18n::t('members') %></h3>
11
- <table class="table table-striped table-bordered table-condensed" cellpadding="0" cellspacing="0" border="0">
12
+ <table class="table display table-striped table-bordered table-condensed" id='members' cellpadding="0" cellspacing="0" border="0">
12
13
  <thead>
13
14
  <tr>
14
15
 
@@ -18,12 +19,12 @@
18
19
 
19
20
  <th><%= I18n::t('forname') %></th>
20
21
 
21
- <th><%= I18n::t('birthdate') %></th>
22
+ <th class='date-euro'><%= I18n::t('birthdate') %></th>
22
23
 
23
24
  <th><%= I18n::t('mail') %></th>
24
25
  <th><%= I18n::t('tel') %></th>
25
26
 
26
- <th>Actions</th>
27
+ <th class='actions'>Actions</th>
27
28
 
28
29
  </tr>
29
30
  </thead>
@@ -0,0 +1,11 @@
1
+ %tr
2
+ %td= payment.date
3
+ %td.numeric= number_to_currency(payment.amount, locale: :fr)
4
+ %td= payment.mode
5
+ %td= list_imputations(payment)
6
+ %td.numeric= number_to_currency payment.non_impute, locale: :fr
7
+
8
+ %td
9
+ - if (payment.non_impute != 0.0)
10
+ = icon_to 'imputation.png', new_payment_reglement_path(payment), title: 'Imputer le solde sur une adhésion'
11
+ = icon_to 'detail.png', member_payment_path(payment.member, payment)
@@ -0,0 +1,13 @@
1
+ <%= content_for :menu do %>
2
+
3
+ <%= icon_to 'payment.png', member_payments_path(@member) %>
4
+ <% end -%>
5
+
6
+ <div class="champ">
7
+ <h3>Enregistrement d'un paiement de <%= @member.to_s %></h3>
8
+ </div>
9
+ <div class="row-fluid inner-champ">
10
+
11
+ <%= render 'form' %>
12
+ </div>
13
+
@@ -16,15 +16,4 @@
16
16
  %th Reste à imputer
17
17
  %th Actions
18
18
  %tbody
19
- - @payments.each do |payment|
20
- %tr
21
- %td= payment.date
22
- %td= number_to_currency(payment.amount, locale: :fr)
23
- %td= payment.mode
24
- %td= list_imputations(payment)
25
- %td= number_to_currency payment.non_impute, locale: :fr
26
-
27
- %td
28
- - if (payment.non_impute != 0.0)
29
- = icon_to 'imputation.png', new_payment_reglement_path(payment), title: 'Imputer le solde sur une autre adhésion'
30
- = icon_to 'supprimer.png', [@member,payment], method: :delete, confirm: 'Etes vous sûr ?'
19
+ = render @payments
@@ -4,7 +4,7 @@
4
4
  <% end -%>
5
5
 
6
6
  <div class="champ">
7
- <h3>Enregistrement d'un paiement de <%= @member.to_s %></h3>
7
+ <h3>Enregistrement d'un paiement de <%= @member.to_s %></h3>
8
8
  </div>
9
9
  <div class="row-fluid inner-champ">
10
10
 
@@ -0,0 +1,33 @@
1
+ = content_for :menu do
2
+ = icon_to 'payment.png', member_payments_path(@member), title:"Liste des paiements de #{@member.to_s}"
3
+ = icon_to 'money-plus.png', new_member_payment_path(@member), title:'Nouveau paiement'
4
+ - if (@payment.non_impute != 0.0)
5
+ = icon_to 'imputation.png', new_payment_reglement_path(@payment), title: 'Imputer le solde sur une autre adhésion'
6
+ = icon_to 'modifier.png', edit_member_payment_path(@payment.member, @payment)
7
+ = icon_to 'supprimer.png', [@member,@payment], method: :delete, confirm: 'Etes vous sûr ?'
8
+
9
+
10
+ .champ
11
+ %h3 Détail d'un paiement
12
+
13
+ .inner-champ
14
+ %p
15
+ %b Effectué par :
16
+ = @member.to_s
17
+ %p
18
+ %b Le :
19
+ = @payment.date
20
+ %p
21
+ %b Montant :
22
+ = number_to_currency(@payment.amount, locale: :fr)
23
+ %p
24
+ %b Par :
25
+ = @payment.mode
26
+ %p
27
+ %b Imputé sur :
28
+ = list_imputations(@payment)
29
+ %p
30
+ %b Reste à imputer :
31
+ = number_to_currency @payment.non_impute, locale: :fr
32
+
33
+
@@ -0,0 +1,31 @@
1
+ = content_for :menu do
2
+ = icon_to 'supprimer.png', [@payment, @reglement], method: :delete, confirm: 'Etes vous sûr ?'
3
+ = icon_to 'retour.png', :back
4
+
5
+
6
+
7
+ .champ
8
+ %h3 Détail d'un réglement
9
+
10
+ .inner-champ
11
+ %p
12
+ %b Imputé sur un payment effectué par :
13
+ = @payment.member.to_s
14
+ %p
15
+ %b Le :
16
+ = @payment.date
17
+ %p
18
+ %b d'un montant total de :
19
+ = number_to_currency(@payment.amount, locale: :fr)
20
+ %p
21
+ %b dont sur ce réglement :
22
+ = number_to_currency(@reglement.amount, locale: :fr)
23
+ %p
24
+ %b enregistré le :
25
+ = l @reglement.created_at
26
+ - if @reglement.created_at != @reglement.updated_at
27
+ %p
28
+ %b modifié le :
29
+ = l @reglement.updated_at
30
+
31
+
@@ -0,0 +1,12 @@
1
+ # ce validator est utilisé par Payment pour s'assurer que
2
+ # le montant du Payment est effectivement supérieur aux réglements
3
+ # qui ont déjà été imputés sur ce paiement.
4
+ #
5
+ class OverImputationsValidator < ActiveModel::EachValidator
6
+
7
+ def validate_each(record, attribute, value)
8
+ if (record.reglements.any? && value < record.impute)
9
+ record.errors.add(attribute, :under_imputations)
10
+ end
11
+ end
12
+ end
@@ -210,7 +210,7 @@ fr:
210
210
  too_long: Trop long
211
211
  greater_than_or_equal_to: Valeur trop basse
212
212
  greater_than: Valeur trop faible
213
-
213
+ under_imputations: Montant inférieur aux montants déjà imputés
214
214
 
215
215
 
216
216
  coord: coordonnée
data/config/routes.rb CHANGED
@@ -5,7 +5,10 @@ Adherent::Engine.routes.draw do
5
5
 
6
6
 
7
7
 
8
+ get "allpayments/index"
9
+
8
10
  resources :coords
11
+ resources :payments, :controller=>:allpayments
9
12
 
10
13
 
11
14
  resources :members do
@@ -1,3 +1,3 @@
1
1
  module Adherent
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -2,4 +2,5 @@ class Organism < ActiveRecord::Base
2
2
  attr_accessible :status, :title
3
3
 
4
4
  has_many :members, class_name:'Adherent::Member'
5
+ has_many :payments, :through=>:members, class_name:'Adherent::Payment'
5
6
  end